Merge branch 'master' of github.com:hibernate/hibernate-orm
This commit is contained in:
commit
c46c04631d
|
@ -54,7 +54,7 @@ class DatabaseAllocator {
|
|||
"postgresql82", "postgresql83", "postgresql84", "postgresql91",
|
||||
"mysql50", "mysql51","mysql55",
|
||||
"db2-91", "db2-97",
|
||||
"mssql2005", "mssql2008R1", "mssql2008R2",
|
||||
"mssql2005", "mssql2008R1", "mssql2008R2", "mssql2012",
|
||||
"sybase155", "sybase157"
|
||||
];
|
||||
|
||||
|
@ -97,4 +97,4 @@ class DatabaseAllocator {
|
|||
}
|
||||
return (DatabaseAllocator) project.rootProject.properties[ DB_ALLOCATOR_KEY ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<key-property name="key1" type="string"/>
|
||||
<key-property name="key2" type="string"/>
|
||||
</composite-id>
|
||||
<discriminator column="TYPE" type="string" length="10"/>
|
||||
<discriminator column="`TYPE`" type="string" length="10"/>
|
||||
<property name="name" type="string"/>
|
||||
</class>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
@Entity
|
||||
@Table( name = "char_property" )
|
||||
|
@ -11,6 +12,7 @@ public class CharProperty implements Property {
|
|||
|
||||
private String name;
|
||||
|
||||
@Column(name = "`value`")
|
||||
private Character value;
|
||||
|
||||
public CharProperty() {
|
||||
|
|
|
@ -3,12 +3,14 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
@Entity
|
||||
@Table(name="int_property")
|
||||
public class IntegerProperty implements Property {
|
||||
private Integer id;
|
||||
private String name;
|
||||
@Column(name = "`value`")
|
||||
private Integer value;
|
||||
|
||||
public IntegerProperty() {
|
||||
|
|
|
@ -3,6 +3,7 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
@Entity
|
||||
@Table(name = "long_property")
|
||||
|
@ -10,7 +11,7 @@ public class LongProperty implements Property {
|
|||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(name = "`value`")
|
||||
private Long value;
|
||||
|
||||
public LongProperty() {
|
||||
|
|
|
@ -3,12 +3,14 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
@Entity
|
||||
@Table(name="string_property")
|
||||
public class StringProperty implements Property {
|
||||
private Integer id;
|
||||
private String name;
|
||||
@Column(name = "`value`")
|
||||
private String value;
|
||||
|
||||
public StringProperty() {
|
||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.test.annotations.beanvalidation;
|
|||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Column;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
|
@ -41,6 +42,7 @@ public class MinMax {
|
|||
|
||||
@Max(10)
|
||||
@Min(2)
|
||||
@Column(name = "`value`")
|
||||
private Integer value;
|
||||
|
||||
private MinMax() {
|
||||
|
|
|
@ -1,86 +1,88 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.test.annotations.beanvalidation;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Future;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
@Entity
|
||||
public class Tv {
|
||||
|
||||
@Id
|
||||
@Size(max = 2)
|
||||
public String serial;
|
||||
|
||||
@Length(max = 5)
|
||||
public String model;
|
||||
|
||||
public int size;
|
||||
|
||||
@Size(max = 2)
|
||||
public String name;
|
||||
|
||||
@Future
|
||||
public Date expDate;
|
||||
|
||||
@Size(min = 0)
|
||||
public String description;
|
||||
|
||||
@Min(1000)
|
||||
public BigInteger lifetime;
|
||||
|
||||
@NotNull
|
||||
@Valid
|
||||
public Tuner tuner;
|
||||
|
||||
@Valid
|
||||
public Recorder recorder;
|
||||
|
||||
@Embeddable
|
||||
public static class Tuner {
|
||||
@NotNull
|
||||
public String frequency;
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
public static class Recorder {
|
||||
@NotNull
|
||||
public BigDecimal time;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @author tags or express
|
||||
* copyright attribution statements applied by the authors. All
|
||||
* third-party contributions are distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package org.hibernate.test.annotations.beanvalidation;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Column;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.Future;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
@Entity
|
||||
public class Tv {
|
||||
|
||||
@Id
|
||||
@Size(max = 2)
|
||||
public String serial;
|
||||
|
||||
@Length(max = 5)
|
||||
public String model;
|
||||
|
||||
public int size;
|
||||
|
||||
@Size(max = 2)
|
||||
public String name;
|
||||
|
||||
@Future
|
||||
public Date expDate;
|
||||
|
||||
@Size(min = 0)
|
||||
public String description;
|
||||
|
||||
@Min(1000)
|
||||
public BigInteger lifetime;
|
||||
|
||||
@NotNull
|
||||
@Valid
|
||||
public Tuner tuner;
|
||||
|
||||
@Valid
|
||||
public Recorder recorder;
|
||||
|
||||
@Embeddable
|
||||
public static class Tuner {
|
||||
@NotNull
|
||||
public String frequency;
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
public static class Recorder {
|
||||
@NotNull
|
||||
@Column(name = "`time`")
|
||||
public BigDecimal time;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -14,6 +15,7 @@ public class Tooth {
|
|||
@Id
|
||||
@GeneratedValue
|
||||
public Integer id;
|
||||
@Column(name = "`type`")
|
||||
public String type;
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
public Tooth leftNeighbour;
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.cid;
|
||||
import java.util.Date;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.AssociationOverrides;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "id.channel", joinColumns = @JoinColumn(name = "chan_id", nullable = false)),
|
||||
@AssociationOverride(name = "id.presenter", joinColumns = @JoinColumn(name = "presenter_name", nullable = false))})
|
||||
public class TvMagazin {
|
||||
@EmbeddedId
|
||||
public TvMagazinPk id;
|
||||
@Temporal(TemporalType.TIME)
|
||||
Date time;
|
||||
}
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.cid;
|
||||
import java.util.Date;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.AssociationOverrides;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "id.channel", joinColumns = @JoinColumn(name = "chan_id", nullable = false)),
|
||||
@AssociationOverride(name = "id.presenter", joinColumns = @JoinColumn(name = "presenter_name", nullable = false))})
|
||||
public class TvMagazin {
|
||||
@EmbeddedId
|
||||
public TvMagazinPk id;
|
||||
@Temporal(TemporalType.TIME)
|
||||
@Column(name="`time`")
|
||||
Date time;
|
||||
}
|
||||
|
|
|
@ -1,36 +1,37 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.cid;
|
||||
import java.util.Date;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.AssociationOverrides;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
/**
|
||||
* @author Chandra Patni
|
||||
*/
|
||||
@Entity
|
||||
@SecondaryTable( name = "TV_PROGRAM_EXT", pkJoinColumns = {
|
||||
@PrimaryKeyJoinColumn( name = "CHANNEL_ID" ),
|
||||
@PrimaryKeyJoinColumn( name = "PRESENTER_NAME" )
|
||||
} )
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "id.channel", joinColumns = @JoinColumn(name = "chan_id", nullable = false)),
|
||||
@AssociationOverride(name = "id.presenter", joinColumns = @JoinColumn(name = "presenter_name", nullable = false))})
|
||||
public class TvProgram {
|
||||
@EmbeddedId
|
||||
public TvMagazinPk id;
|
||||
|
||||
@Temporal( TemporalType.TIME )
|
||||
Date time;
|
||||
|
||||
@Column( name = "TXT", table = "TV_PROGRAM_EXT" )
|
||||
public String text;
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.cid;
|
||||
import java.util.Date;
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.AssociationOverrides;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
/**
|
||||
* @author Chandra Patni
|
||||
*/
|
||||
@Entity
|
||||
@SecondaryTable( name = "TV_PROGRAM_EXT", pkJoinColumns = {
|
||||
@PrimaryKeyJoinColumn( name = "CHANNEL_ID" ),
|
||||
@PrimaryKeyJoinColumn( name = "PRESENTER_NAME" )
|
||||
} )
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "id.channel", joinColumns = @JoinColumn(name = "chan_id", nullable = false)),
|
||||
@AssociationOverride(name = "id.presenter", joinColumns = @JoinColumn(name = "presenter_name", nullable = false))})
|
||||
public class TvProgram {
|
||||
@EmbeddedId
|
||||
public TvMagazinPk id;
|
||||
|
||||
@Temporal( TemporalType.TIME )
|
||||
@Column(name="`time`")
|
||||
Date time;
|
||||
|
||||
@Column( name = "TXT", table = "TV_PROGRAM_EXT" )
|
||||
public String text;
|
||||
|
||||
}
|
|
@ -1,36 +1,37 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.cid;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@SecondaryTable( name = "TV_PROGRAM_IDCLASS", pkJoinColumns =
|
||||
{
|
||||
@PrimaryKeyJoinColumn( name = "CHANNEL_ID" ),
|
||||
@PrimaryKeyJoinColumn( name = "PRESENTER_NAME" )
|
||||
} )
|
||||
@IdClass( TvMagazinPk.class )
|
||||
public class TvProgramIdClass {
|
||||
@Id
|
||||
@JoinColumn(nullable=false)
|
||||
public Channel channel;
|
||||
@Id
|
||||
@JoinColumn(nullable=false)
|
||||
public Presenter presenter;
|
||||
|
||||
@Temporal( TemporalType.TIME )
|
||||
Date time;
|
||||
|
||||
@Column( name = "TXT", table = "TV_PROGRAM_IDCLASS" )
|
||||
public String text;
|
||||
}
|
||||
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.cid;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.IdClass;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.SecondaryTable;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
@Entity
|
||||
@SecondaryTable( name = "TV_PROGRAM_IDCLASS", pkJoinColumns =
|
||||
{
|
||||
@PrimaryKeyJoinColumn( name = "CHANNEL_ID" ),
|
||||
@PrimaryKeyJoinColumn( name = "PRESENTER_NAME" )
|
||||
} )
|
||||
@IdClass( TvMagazinPk.class )
|
||||
public class TvProgramIdClass {
|
||||
@Id
|
||||
@JoinColumn(nullable=false)
|
||||
public Channel channel;
|
||||
@Id
|
||||
@JoinColumn(nullable=false)
|
||||
public Presenter presenter;
|
||||
|
||||
@Temporal( TemporalType.TIME )
|
||||
@Column(name="`time`")
|
||||
Date time;
|
||||
|
||||
@Column( name = "TXT", table = "TV_PROGRAM_IDCLASS" )
|
||||
public String text;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,72 +1,74 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.collectionelement.embeddables.withcustomenumdef;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Embeddable
|
||||
public class Location {
|
||||
public static enum Type {
|
||||
POSTAL_CODE,
|
||||
COMMUNE,
|
||||
REGION,
|
||||
PROVINCE,
|
||||
COUNTY
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
// @Column(columnDefinition = "VARCHAR(32)")
|
||||
private Type type;
|
||||
|
||||
public Location() {
|
||||
}
|
||||
|
||||
public Location(String name, Type type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.collectionelement.embeddables.withcustomenumdef;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Embeddable
|
||||
public class Location {
|
||||
public static enum Type {
|
||||
POSTAL_CODE,
|
||||
COMMUNE,
|
||||
REGION,
|
||||
PROVINCE,
|
||||
COUNTY
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
// @Column(columnDefinition = "VARCHAR(32)")
|
||||
@Column(name = "`type`")
|
||||
private Type type;
|
||||
|
||||
public Location() {
|
||||
}
|
||||
|
||||
public Location(String name, Type type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
|
@ -38,6 +39,7 @@ import org.hibernate.annotations.GenericGenerator;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="`Query`")
|
||||
public class Query {
|
||||
@Id
|
||||
@GeneratedValue( generator = "increment" )
|
||||
|
|
|
@ -1,63 +1,64 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.embeddables;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
/**
|
||||
* @author Chris Pheby
|
||||
*/
|
||||
@Embeddable
|
||||
public class Investment {
|
||||
|
||||
private DollarValue amount;
|
||||
private String description;
|
||||
private MyDate date;
|
||||
|
||||
public DollarValue getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(DollarValue amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Column(length = 500)
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public MyDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(MyDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.test.annotations.embeddables;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
/**
|
||||
* @author Chris Pheby
|
||||
*/
|
||||
@Embeddable
|
||||
public class Investment {
|
||||
|
||||
private DollarValue amount;
|
||||
private String description;
|
||||
@Column(name = "`date`")
|
||||
private MyDate date;
|
||||
|
||||
public DollarValue getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(DollarValue amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Column(length = 500)
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public MyDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(MyDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,32 +1,34 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class CorpType {
|
||||
private Integer id;
|
||||
private String type;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
//$Id$
|
||||
package org.hibernate.test.annotations.embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
public class CorpType {
|
||||
private Integer id;
|
||||
@Column(name = "`type`")
|
||||
private String type;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,43 @@
|
|||
package org.hibernate.test.annotations.join;
|
||||
import java.util.Collection;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity( name = "sys_user" )
|
||||
@Table( name = "SYS_USER" )
|
||||
public class SysUserOrm {
|
||||
|
||||
private long userid;
|
||||
|
||||
private Collection<SysGroupsOrm> groups;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column( name = "`auid`" )
|
||||
public long getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid( long userid ) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
@ManyToMany( fetch = FetchType.LAZY )
|
||||
@JoinTable( name = "SYS_GROUPS_USERS",
|
||||
joinColumns = @JoinColumn( name = "USERID", referencedColumnName = "`auid`" ),
|
||||
inverseJoinColumns = @JoinColumn( name = "GROUPID", referencedColumnName = "GROUPID" ) )
|
||||
public Collection<SysGroupsOrm> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups( Collection<SysGroupsOrm> groups ) {
|
||||
this.groups = groups;
|
||||
}
|
||||
}
|
||||
package org.hibernate.test.annotations.join;
|
||||
import java.util.Collection;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity( name = "sys_user" )
|
||||
@Table( name = "`SYS_USER`" )
|
||||
public class SysUserOrm {
|
||||
|
||||
private long userid;
|
||||
|
||||
private Collection<SysGroupsOrm> groups;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@Column( name = "`auid`" )
|
||||
public long getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid( long userid ) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
@ManyToMany( fetch = FetchType.LAZY )
|
||||
@JoinTable( name = "SYS_GROUPS_USERS",
|
||||
joinColumns = @JoinColumn( name = "USERID", referencedColumnName = "`auid`" ),
|
||||
inverseJoinColumns = @JoinColumn( name = "GROUPID", referencedColumnName = "GROUPID" ) )
|
||||
public Collection<SysGroupsOrm> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups( Collection<SysGroupsOrm> groups ) {
|
||||
this.groups = groups;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@ import javax.persistence.Column;
|
|||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="`Zone`")
|
||||
public class Zone {
|
||||
private Integer id;
|
||||
|
||||
|
|
|
@ -30,11 +30,13 @@ import java.io.Serializable;
|
|||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author Sharath Reddy
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="`Language`")
|
||||
public class Language implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
package org.hibernate.test.annotations.onetoone;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Column;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -35,6 +36,7 @@ public class SerialNumber {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name="`value`")
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import javax.persistence.SqlResultSetMapping;
|
|||
@FieldResult(name = "name", column = "name"),
|
||||
@FieldResult(name = "editor", column = "editor")
|
||||
},
|
||||
discriminatorColumn = "type"
|
||||
discriminatorColumn = "`type`"
|
||||
)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
<id name="id" type="long"><generator class="native"/></id>
|
||||
|
||||
<property name="data" type="string" not-null="true"/>
|
||||
<property name="data" column="`data`" type="string" not-null="true"/>
|
||||
|
||||
<!--
|
||||
Associations
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
<id name="id" type="long"><generator class="native"/></id>
|
||||
|
||||
<property name="data" type="string" not-null="true"/>
|
||||
<property name="data" column="`data`" type="string" not-null="true"/>
|
||||
|
||||
<!--
|
||||
Associations
|
||||
|
@ -47,7 +47,7 @@
|
|||
|
||||
<id name="id" type="long"><generator class="native"/></id>
|
||||
|
||||
<property name="data" type="string" not-null="true"/>
|
||||
<property name="data" column="`data`" type="string" not-null="true"/>
|
||||
|
||||
<!--
|
||||
Associations
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.criteria">
|
||||
<class name="TestObject" table="test">
|
||||
<class name="TestObject" table="`test`">
|
||||
<id name="id">
|
||||
<column name="ID" />
|
||||
<generator class="native" />
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<generator class="assigned"/>
|
||||
</id>
|
||||
|
||||
<discriminator column="TYPE" type="character"/>
|
||||
<discriminator column="`TYPE`" type="character"/>
|
||||
|
||||
<property name="name"
|
||||
not-null="true"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<id name="id" access="field" type="long">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<discriminator column="TYPE" type="string" />
|
||||
<discriminator column="`TYPE`" type="string" />
|
||||
<property name="vin" type="string"/>
|
||||
<property name="owner" type="string"/>
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
</fetch-profile>
|
||||
</class>
|
||||
|
||||
<class name="CourseOffering" table="SECTION">
|
||||
<class name="CourseOffering" table="`SECTION`">
|
||||
<id name="id" type="long">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</set>
|
||||
<map name="addresses" table="addresses">
|
||||
<key column="human"/>
|
||||
<map-key type="string" column="type"/>
|
||||
<map-key type="string" column="`type`"/>
|
||||
<composite-element class="Address">
|
||||
<property name="street"/>
|
||||
<property name="city"/>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="version asc"
|
||||
mutable="false" cascade="all" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="true" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
</id>
|
||||
<version name="version" column="VERS" type="long" />
|
||||
<property name="customerName" not-null="true"/>
|
||||
<property name="type" not-null="true"/>
|
||||
<property name="type" column="`type`" not-null="true"/>
|
||||
<bag name="variations" inverse="false" order-by="id asc"
|
||||
mutable="true" cascade="all-delete-orphan" fetch="join">
|
||||
<key column="contract"/>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<id name="id" column="ID" type="long">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<discriminator column="TYPE" />
|
||||
<discriminator column="`TYPE`" />
|
||||
<property name="name" type="string"/>
|
||||
<many-to-one name="other" class="MyEntity" />
|
||||
<subclass name="MySubclassEntity" discriminator-value="S">
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.hibernate.LobHelper;
|
|||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -40,6 +42,7 @@ import org.junit.Test;
|
|||
* @author Brett Meyer
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-7698" )
|
||||
@RequiresDialect( value = H2Dialect.class, jiraKey = "HHH-7724" )
|
||||
public class JpaLargeBlobTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,17 +10,17 @@
|
|||
|
||||
<sql-query name="simpleScalar" callable="true">
|
||||
<return-scalar column="name" type="string"/>
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
{ call simpleScalar(:number) }
|
||||
</sql-query>
|
||||
<sql-query name="paramhandling" callable="true">
|
||||
<return-scalar column="value" type="long" />
|
||||
<return-scalar column="`value`" type="long" />
|
||||
<return-scalar column="value2" type="long" />
|
||||
{ call testParamHandling(?,?) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling_mixed" callable="true">
|
||||
<return-scalar column="value" type="long" />
|
||||
<return-scalar column="`value`" type="long" />
|
||||
<return-scalar column="value2" type="long" />
|
||||
{ call testParamHandling(?,:second) }
|
||||
</sql-query>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<return-property name="regionCode" column="REGIONCODE"/>
|
||||
<return-property name="employmentId" column="EMPID"/>
|
||||
<return-property name="salary">
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return>
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<property name="endDate" column="ENDDATE" insert="false"/>
|
||||
<property name="regionCode" column="REGIONCODE" update="false"/>
|
||||
<property name="salary" type="org.hibernate.test.sql.hand.MonetaryAmountUserType">
|
||||
<column name="VALUE" sql-type="float"/>
|
||||
<column name="`VALUE`" sql-type="float"/>
|
||||
<column name="CURRENCY"/>
|
||||
</property>
|
||||
<loader query-ref="employment"/>
|
||||
|
@ -162,7 +162,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
<!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
|
||||
|
@ -179,18 +179,18 @@
|
|||
|
||||
<sql-query name="simpleScalar" callable="true">
|
||||
<return-scalar column="name" type="string"/>
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
{ call simpleScalar(:number) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling" callable="true">
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
<return-scalar column="value2" type="long"/>
|
||||
{ call paramHandling(?,?) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling_mixed" callable="true">
|
||||
<return-scalar column="value" type="long" />
|
||||
<return-scalar column="`value`" type="long" />
|
||||
<return-scalar column="value2" type="long" />
|
||||
{ call paramHandling(?,:second) }
|
||||
</sql-query>
|
||||
|
@ -206,7 +206,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<property name="endDate" insert="false"/>
|
||||
<property name="regionCode" update="false"/>
|
||||
<property name="salary" type="org.hibernate.test.sql.hand.MonetaryAmountUserType">
|
||||
<column name="VALUE" sql-type="float"/>
|
||||
<column name="`VALUE`" sql-type="float"/>
|
||||
<column name="CURRENCY"/>
|
||||
</property>
|
||||
<loader query-ref="employment"/>
|
||||
|
@ -160,7 +160,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
<!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
|
||||
|
@ -177,18 +177,18 @@
|
|||
|
||||
<sql-query name="simpleScalar" callable="true">
|
||||
<return-scalar column="name" type="string"/>
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
{ call simpleScalar(:number) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling" callable="true">
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
<return-scalar column="value2" type="long"/>
|
||||
{ call paramHandling(?,?) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling_mixed" callable="true">
|
||||
<return-scalar column="value" type="long" />
|
||||
<return-scalar column="`value`" type="long" />
|
||||
<return-scalar column="value2" type="long" />
|
||||
{ call paramHandling(?,:second) }
|
||||
</sql-query>
|
||||
|
@ -204,7 +204,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<property name="endDate" insert="false"/>
|
||||
<property name="regionCode" update="false"/>
|
||||
<property name="salary" type="org.hibernate.test.sql.hand.MonetaryAmountUserType">
|
||||
<column name="VALUE" sql-type="float"/>
|
||||
<column name="`VALUE`" sql-type="float"/>
|
||||
<column name="CURRENCY"/>
|
||||
</property>
|
||||
<loader query-ref="employment"/>
|
||||
|
@ -154,7 +154,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
<!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
|
||||
<sql-query name="simpleScalar" callable="true">
|
||||
<return-scalar column="name" type="string"/>
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
{ ? = call simpleScalar(:number) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling" callable="true">
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
<return-scalar column="value2" type="long"/>
|
||||
{ ? = call testParamHandling(?,?) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling_mixed" callable="true">
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
<return-scalar column="value2" type="long"/>
|
||||
{ ? = call testParamHandling(?,:second) }
|
||||
</sql-query>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<return-property name="regionCode" column="REGIONCODE"/>
|
||||
<return-property name="employmentId" column="EMPID"/>
|
||||
<return-property name="salary">
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return>
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
<!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
|
||||
|
@ -178,18 +178,18 @@
|
|||
|
||||
<sql-query name="simpleScalar" callable="true">
|
||||
<return-scalar column="name" type="string"/>
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
{ call simpleScalar(:number) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling" callable="true">
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
<return-scalar column="value2" type="long"/>
|
||||
{ call paramHandling(?,?) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling_mixed" callable="true">
|
||||
<return-scalar column="value" type="long" />
|
||||
<return-scalar column="`value`" type="long" />
|
||||
<return-scalar column="value2" type="long" />
|
||||
{ call paramHandling(?,:second) }
|
||||
</sql-query>
|
||||
|
@ -205,7 +205,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return>
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<property name="endDate" column="ENDDATE" insert="false"/>
|
||||
<property name="regionCode" column="REGIONCODE" update="false"/>
|
||||
<property name="salary" type="org.hibernate.test.sql.hand.MonetaryAmountUserType">
|
||||
<column name="VALUE" sql-type="float"/>
|
||||
<column name="`VALUE`" sql-type="float"/>
|
||||
<column name="CURRENCY"/>
|
||||
</property>
|
||||
<loader query-ref="employment"/>
|
||||
|
@ -161,7 +161,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
<!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
|
||||
|
@ -178,18 +178,18 @@
|
|||
|
||||
<sql-query name="simpleScalar" callable="true">
|
||||
<return-scalar column="name" type="string"/>
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
{ call simpleScalar(:number) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling" callable="true">
|
||||
<return-scalar column="value" type="long"/>
|
||||
<return-scalar column="`value`" type="long"/>
|
||||
<return-scalar column="value2" type="long"/>
|
||||
{ call paramHandling(?,?) }
|
||||
</sql-query>
|
||||
|
||||
<sql-query name="paramhandling_mixed" callable="true">
|
||||
<return-scalar column="value" type="long" />
|
||||
<return-scalar column="`value`" type="long" />
|
||||
<return-scalar column="value2" type="long" />
|
||||
{ call paramHandling(?,:second) }
|
||||
</sql-query>
|
||||
|
@ -205,7 +205,7 @@
|
|||
<return-property name="salary">
|
||||
<!-- as multi column properties are not supported via the
|
||||
{}-syntax, we need to provide an explicit column list for salary via <return-property> -->
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return>
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<property name="endDate" column="ENDDATE" insert="false"/>
|
||||
<property name="regionCode" column="REGIONCODE" update="false"/>
|
||||
<property name="salary" type="org.hibernate.test.sql.hand.MonetaryAmountUserType">
|
||||
<column name="VALUE" sql-type="float"/>
|
||||
<column name="`VALUE`" sql-type="float"/>
|
||||
<column name="CURRENCY"/>
|
||||
</property>
|
||||
</class>
|
||||
|
@ -246,7 +246,7 @@
|
|||
<return-property name="element.regionCode" column="REGIONCODE"/>
|
||||
<return-property name="element.employmentId" column="EMPID"/>
|
||||
<return-property name="element.salary">
|
||||
<return-column name="VALUE"/>
|
||||
<return-column name="`VALUE`"/>
|
||||
<return-column name="CURRENCY"/>
|
||||
</return-property>
|
||||
</return-join>
|
||||
|
|
|
@ -94,7 +94,7 @@ public class CreditCard implements java.io.Serializable {
|
|||
number = v;
|
||||
}
|
||||
|
||||
@Column(name = "TYPE")
|
||||
@Column(name = "`TYPE`")
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<column name="NAME" length="20" not-null="true"/>
|
||||
</property>
|
||||
<property name="value" type="string">
|
||||
<column name="VALUE" length="1948"/>
|
||||
<column name="`VALUE`" length="1948"/>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ test {
|
|||
systemProperties['jgroups.udp.enable_bundling'] = false
|
||||
systemProperties['jgroups.bind_addr'] = 'localhost'
|
||||
// Use Infinispan's test JGroups stack that uses TEST_PING
|
||||
systemProperties['hibernate.cache.infinispan.jgroups_cfg'] = 'stacks/tcp.xml'
|
||||
// systemProperties['log4j.configuration'] = 'file:/log4j/log4j-infinispan.xml'
|
||||
systemProperties['hibernate.cache.infinispan.jgroups_cfg'] = '2lc-test-tcp.xml'
|
||||
// systemProperties['log4j.configuration'] = 'file:/log4j/log4j-infinispan.xml'
|
||||
enabled = true
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.hibernate.cache.infinispan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
|
@ -16,14 +17,18 @@ import org.hibernate.cache.infinispan.timestamp.ClusteredTimestampsRegionImpl;
|
|||
import org.hibernate.cache.infinispan.util.Caches;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.commands.module.ModuleCommandFactory;
|
||||
import org.infinispan.config.Configuration;
|
||||
import org.infinispan.configuration.cache.CacheMode;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
import org.infinispan.configuration.cache.ConfigurationBuilder;
|
||||
import org.infinispan.factories.GlobalComponentRegistry;
|
||||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.infinispan.transaction.TransactionMode;
|
||||
import org.infinispan.transaction.lookup.GenericTransactionManagerLookup;
|
||||
import org.infinispan.util.concurrent.IsolationLevel;
|
||||
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
|
||||
import org.infinispan.configuration.parsing.ParserRegistry;
|
||||
import org.infinispan.util.FileLookupFactory;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
||||
|
@ -314,7 +319,7 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
dissectProperty(prefixLoc, key, properties);
|
||||
}
|
||||
}
|
||||
defineGenericDataTypeCacheConfigurations(settings, properties);
|
||||
defineGenericDataTypeCacheConfigurations(properties);
|
||||
definePendingPutsCache();
|
||||
} catch (CacheException ce) {
|
||||
throw ce;
|
||||
|
@ -381,19 +386,32 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
|
||||
protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
|
||||
try {
|
||||
String configLoc = ConfigurationHelper.getString(INFINISPAN_CONFIG_RESOURCE_PROP, properties, DEF_INFINISPAN_CONFIG_RESOURCE);
|
||||
EmbeddedCacheManager manager = new DefaultCacheManager(configLoc, false);
|
||||
String globalStats = extractProperty(INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
|
||||
if (globalStats != null) {
|
||||
manager.getGlobalConfiguration().setExposeGlobalJmxStatistics(Boolean.parseBoolean(globalStats));
|
||||
}
|
||||
manager.start();
|
||||
return manager;
|
||||
String configLoc = ConfigurationHelper.getString(
|
||||
INFINISPAN_CONFIG_RESOURCE_PROP, properties, DEF_INFINISPAN_CONFIG_RESOURCE);
|
||||
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
InputStream is = FileLookupFactory.newInstance().lookupFileStrict(
|
||||
configLoc, ctxClassLoader);
|
||||
ParserRegistry parserRegistry = new ParserRegistry(ctxClassLoader);
|
||||
ConfigurationBuilderHolder holder = parserRegistry.parse(is);
|
||||
|
||||
// Override global jmx statistics exposure
|
||||
String globalStats = extractProperty(
|
||||
INFINISPAN_GLOBAL_STATISTICS_PROP, properties);
|
||||
if (globalStats != null)
|
||||
holder.getGlobalConfigurationBuilder().globalJmxStatistics()
|
||||
.enabled(Boolean.parseBoolean(globalStats));
|
||||
|
||||
return createCacheManager(holder);
|
||||
} catch (IOException e) {
|
||||
throw new CacheException("Unable to create default cache manager", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected EmbeddedCacheManager createCacheManager(
|
||||
ConfigurationBuilderHolder holder) {
|
||||
return new DefaultCacheManager(holder, true);
|
||||
}
|
||||
|
||||
private void startRegion(BaseRegion region, String regionName) {
|
||||
regionNames.add(regionName);
|
||||
getCacheCommandFactory(region.getCache()).addRegion(regionName, region);
|
||||
|
@ -458,45 +476,59 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
return cfgOverride;
|
||||
}
|
||||
|
||||
private void defineGenericDataTypeCacheConfigurations(Settings settings, Properties properties) throws CacheException {
|
||||
private void defineGenericDataTypeCacheConfigurations(Properties properties) {
|
||||
String[] defaultGenericDataTypes = new String[]{ENTITY_KEY, COLLECTION_KEY, TIMESTAMPS_KEY, QUERY_KEY};
|
||||
for (String type : defaultGenericDataTypes) {
|
||||
TypeOverrides override = overrideStatisticsIfPresent(typeOverrides.get(type), properties);
|
||||
String cacheName = override.getCacheName();
|
||||
Configuration newCacheCfg = override.createInfinispanConfiguration();
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
// Read base configuration
|
||||
applyConfiguration(cacheName, builder);
|
||||
|
||||
// Apply overrides
|
||||
Configuration cacheConfig = manager.defineConfiguration(cacheName, cacheName, newCacheCfg);
|
||||
override.applyTo(builder);
|
||||
// Configure transaction manager
|
||||
cacheConfig = configureTransactionManager(cacheConfig, cacheName, properties);
|
||||
manager.defineConfiguration(cacheName, cacheName, cacheConfig);
|
||||
configureTransactionManager(builder, cacheName, properties);
|
||||
// Define configuration, validate and then apply
|
||||
Configuration cfg = builder.build();
|
||||
override.validateInfinispanConfiguration(cfg);
|
||||
manager.defineConfiguration(cacheName, cfg);
|
||||
definedConfigurations.add(cacheName);
|
||||
override.validateInfinispanConfiguration(cacheConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private AdvancedCache getCache(String regionName, String typeKey, Properties properties) {
|
||||
TypeOverrides regionOverride = typeOverrides.get(regionName);
|
||||
if (!definedConfigurations.contains(regionName)) {
|
||||
String templateCacheName = null;
|
||||
Configuration regionCacheCfg = null;
|
||||
String templateCacheName;
|
||||
Configuration regionCacheCfg;
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
if (regionOverride != null) {
|
||||
if (log.isDebugEnabled()) log.debug("Cache region specific configuration exists: " + regionOverride);
|
||||
regionOverride = overrideStatisticsIfPresent(regionOverride, properties);
|
||||
regionCacheCfg = regionOverride.createInfinispanConfiguration();
|
||||
String cacheName = regionOverride.getCacheName();
|
||||
if (cacheName != null) // Region specific override with a given cache name
|
||||
templateCacheName = cacheName;
|
||||
templateCacheName = cacheName;
|
||||
else // Region specific override without cache name, so template cache name is generic for data type.
|
||||
templateCacheName = typeOverrides.get(typeKey).getCacheName();
|
||||
templateCacheName = typeOverrides.get(typeKey).getCacheName();
|
||||
|
||||
// Read template configuration
|
||||
applyConfiguration(templateCacheName, builder);
|
||||
|
||||
regionOverride = overrideStatisticsIfPresent(regionOverride, properties);
|
||||
regionOverride.applyTo(builder);
|
||||
|
||||
} else {
|
||||
// No region specific overrides, template cache name is generic for data type.
|
||||
templateCacheName = typeOverrides.get(typeKey).getCacheName();
|
||||
regionCacheCfg = typeOverrides.get(typeKey).createInfinispanConfiguration();
|
||||
// Read template configuration
|
||||
builder.read(manager.getCacheConfiguration(templateCacheName));
|
||||
// Apply overrides
|
||||
typeOverrides.get(typeKey).applyTo(builder);
|
||||
}
|
||||
// Configure transaction manager
|
||||
regionCacheCfg = configureTransactionManager(regionCacheCfg, templateCacheName, properties);
|
||||
// Apply overrides
|
||||
manager.defineConfiguration(regionName, templateCacheName, regionCacheCfg);
|
||||
configureTransactionManager(builder, templateCacheName, properties);
|
||||
// Define configuration
|
||||
manager.defineConfiguration(regionName, builder.build());
|
||||
definedConfigurations.add(regionName);
|
||||
}
|
||||
AdvancedCache cache = manager.getCache(regionName).getAdvancedCache();
|
||||
|
@ -506,6 +538,12 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
return createCacheWrapper(cache);
|
||||
}
|
||||
|
||||
private void applyConfiguration(String cacheName, ConfigurationBuilder builder) {
|
||||
Configuration cfg = manager.getCacheConfiguration(cacheName);
|
||||
if (cfg != null)
|
||||
builder.read(cfg);
|
||||
}
|
||||
|
||||
private CacheCommandFactory getCacheCommandFactory(AdvancedCache cache) {
|
||||
GlobalComponentRegistry globalCr = cache.getComponentRegistry()
|
||||
.getGlobalComponentRegistry();
|
||||
|
@ -532,25 +570,30 @@ public class InfinispanRegionFactory implements RegionFactory {
|
|||
return cache;
|
||||
}
|
||||
|
||||
private Configuration configureTransactionManager(Configuration regionOverrides, String templateCacheName, Properties properties) {
|
||||
private void configureTransactionManager(ConfigurationBuilder builder,
|
||||
String cacheName, Properties properties) {
|
||||
// Get existing configuration to verify whether a tm was configured or not.
|
||||
Configuration templateConfig = manager.defineConfiguration(templateCacheName, new Configuration());
|
||||
if (templateConfig.isTransactionalCache()) {
|
||||
String ispnTmLookupClassName = templateConfig.getTransactionManagerLookupClass();
|
||||
Configuration baseCfg = manager.getCacheConfiguration(cacheName);
|
||||
if (baseCfg != null && baseCfg.transaction().transactionMode().isTransactional()) {
|
||||
String ispnTmLookupClassName = baseCfg.transaction().transactionManagerLookup().getClass().getName();
|
||||
String hbTmLookupClassName = org.hibernate.cache.infinispan.tm.HibernateTransactionManagerLookup.class.getName();
|
||||
if (ispnTmLookupClassName != null && !ispnTmLookupClassName.equals(hbTmLookupClassName)) {
|
||||
if (GenericTransactionManagerLookup.class.getName().equals(ispnTmLookupClassName)) {
|
||||
log.debug("Using default Infinispan transaction manager lookup " +
|
||||
"instance (GenericTransactionManagerLookup), overriding it " +
|
||||
"with Hibernate transaction manager lookup");
|
||||
builder.transaction().transactionManagerLookup(transactionManagerlookup);
|
||||
} else if (ispnTmLookupClassName != null && !ispnTmLookupClassName.equals(hbTmLookupClassName)) {
|
||||
log.debug("Infinispan is configured [" + ispnTmLookupClassName + "] with a different transaction manager lookup " +
|
||||
"class than Hibernate [" + hbTmLookupClassName + "]");
|
||||
} else {
|
||||
regionOverrides.setTransactionManagerLookup(transactionManagerlookup);
|
||||
// Infinispan TM lookup class null, so apply Hibernate one directly
|
||||
builder.transaction().transactionManagerLookup(transactionManagerlookup);
|
||||
}
|
||||
|
||||
String useSyncProp = extractProperty(INFINISPAN_USE_SYNCHRONIZATION_PROP, properties);
|
||||
boolean useSync = useSyncProp == null ? DEF_USE_SYNCHRONIZATION : Boolean.parseBoolean(useSyncProp);
|
||||
regionOverrides.fluent().transaction().useSynchronization(useSync);
|
||||
builder.transaction().useSynchronization(useSync);
|
||||
}
|
||||
|
||||
return regionOverrides;
|
||||
}
|
||||
|
||||
private TypeOverrides overrideStatisticsIfPresent(TypeOverrides override, Properties properties) {
|
||||
|
|
|
@ -25,7 +25,8 @@ import java.util.HashSet;
|
|||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.infinispan.config.Configuration;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
import org.infinispan.configuration.cache.ConfigurationBuilder;
|
||||
import org.infinispan.eviction.EvictionStrategy;
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
|
@ -118,25 +119,23 @@ public class TypeOverrides {
|
|||
this.isExposeStatistics = isExposeStatistics;
|
||||
}
|
||||
|
||||
public Configuration createInfinispanConfiguration() {
|
||||
Configuration cacheCfg = new Configuration();
|
||||
public void applyTo(ConfigurationBuilder builder) {
|
||||
if (overridden.contains("evictionStrategy"))
|
||||
cacheCfg.fluent().eviction().strategy(evictionStrategy);
|
||||
builder.eviction().strategy(evictionStrategy);
|
||||
if (overridden.contains("evictionWakeUpInterval"))
|
||||
cacheCfg.fluent().expiration().wakeUpInterval(evictionWakeUpInterval);
|
||||
builder.expiration().wakeUpInterval(evictionWakeUpInterval);
|
||||
if (overridden.contains("evictionMaxEntries"))
|
||||
cacheCfg.fluent().eviction().maxEntries(evictionMaxEntries);
|
||||
builder.eviction().maxEntries(evictionMaxEntries);
|
||||
if (overridden.contains("expirationLifespan"))
|
||||
cacheCfg.fluent().expiration().lifespan(expirationLifespan);
|
||||
builder.expiration().lifespan(expirationLifespan);
|
||||
if (overridden.contains("expirationMaxIdle"))
|
||||
cacheCfg.fluent().expiration().maxIdle(expirationMaxIdle);
|
||||
builder.expiration().maxIdle(expirationMaxIdle);
|
||||
if (overridden.contains("isExposeStatistics") && isExposeStatistics)
|
||||
cacheCfg.fluent().jmxStatistics();
|
||||
return cacheCfg;
|
||||
builder.jmxStatistics().enable();
|
||||
}
|
||||
|
||||
public void validateInfinispanConfiguration(Configuration configuration) throws CacheException {
|
||||
// no-op
|
||||
public void validateInfinispanConfiguration(Configuration cfg) throws CacheException {
|
||||
// no-op, method overriden
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
*/
|
||||
package org.hibernate.cache.infinispan.timestamp;
|
||||
|
||||
import org.infinispan.config.Configuration;
|
||||
import org.infinispan.config.Configuration.CacheMode;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
import org.infinispan.eviction.EvictionStrategy;
|
||||
|
||||
import org.hibernate.cache.CacheException;
|
||||
|
@ -35,15 +34,16 @@ import org.hibernate.cache.infinispan.TypeOverrides;
|
|||
* @since 3.5
|
||||
*/
|
||||
public class TimestampTypeOverrides extends TypeOverrides {
|
||||
|
||||
@Override
|
||||
public void validateInfinispanConfiguration(Configuration configuration) throws CacheException {
|
||||
CacheMode cacheMode = configuration.getCacheMode();
|
||||
if (cacheMode.equals(CacheMode.INVALIDATION_ASYNC) || cacheMode.equals(CacheMode.INVALIDATION_SYNC)) {
|
||||
public void validateInfinispanConfiguration(Configuration cfg) throws CacheException {
|
||||
if (cfg.clustering().cacheMode().isInvalidation()) {
|
||||
throw new CacheException("Timestamp cache cannot be configured with invalidation");
|
||||
}
|
||||
EvictionStrategy strategy = configuration.getEvictionStrategy();
|
||||
EvictionStrategy strategy = cfg.eviction().strategy();
|
||||
if (!strategy.equals(EvictionStrategy.NONE)) {
|
||||
throw new CacheException("Timestamp cache cannot be configured with eviction");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<properties>
|
||||
<!--<property name="configurationFile" value="jgroups-tcp.xml"/>-->
|
||||
<property name="configurationFile"
|
||||
value="${hibernate.cache.infinispan.jgroups_cfg:tcp.xml}"/>
|
||||
value="${hibernate.cache.infinispan.jgroups_cfg:jgroups-tcp.xml}"/>
|
||||
</properties>
|
||||
<!-- See the JGroupsTransport javadocs for more flags -->
|
||||
</transport>
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class AbstractNonFunctionalTestCase extends org.hibernate.testin
|
|||
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
|
||||
System.setProperty(PREFER_IPV4STACK, "true");
|
||||
jgroupsCfgFile = System.getProperty(JGROUPS_CFG_FILE);
|
||||
System.setProperty(JGROUPS_CFG_FILE, "stacks/tcp.xml");
|
||||
System.setProperty(JGROUPS_CFG_FILE, "2lc-test-tcp.xml");
|
||||
|
||||
testSupport.setUp();
|
||||
}
|
||||
|
|
|
@ -24,9 +24,11 @@ package org.hibernate.test.cache.infinispan;
|
|||
import java.util.Properties;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.config.Configuration;
|
||||
import org.infinispan.config.Configuration.CacheMode;
|
||||
import org.infinispan.configuration.cache.CacheMode;
|
||||
import org.infinispan.configuration.cache.Configuration;
|
||||
import org.infinispan.configuration.cache.ConfigurationBuilder;
|
||||
import org.infinispan.eviction.EvictionStrategy;
|
||||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
|
@ -58,6 +60,7 @@ import static org.junit.Assert.fail;
|
|||
* @since 3.5
|
||||
*/
|
||||
public class InfinispanRegionFactoryTestCase {
|
||||
|
||||
@Test
|
||||
public void testConfigurationProcessing() {
|
||||
final String person = "com.acme.Person";
|
||||
|
@ -73,31 +76,35 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.lifespan", "120000");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.max_idle", "60000");
|
||||
p.setProperty("hibernate.cache.infinispan.query.cfg", "my-query-cache");
|
||||
p.setProperty("hibernate.cache.infinispan.query.eviction.strategy", "FIFO");
|
||||
p.setProperty("hibernate.cache.infinispan.query.eviction.strategy", "LIRS");
|
||||
p.setProperty("hibernate.cache.infinispan.query.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.query.eviction.max_entries", "10000");
|
||||
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
|
||||
assertEquals("entity", factory.getTypeOverrides().get("entity").getCacheName());
|
||||
assertEquals("entity", factory.getTypeOverrides().get("collection").getCacheName());
|
||||
assertEquals("timestamps", factory.getTypeOverrides().get("timestamps").getCacheName());
|
||||
try {
|
||||
assertEquals("entity", factory.getTypeOverrides().get("entity").getCacheName());
|
||||
assertEquals("entity", factory.getTypeOverrides().get("collection").getCacheName());
|
||||
assertEquals("timestamps", factory.getTypeOverrides().get("timestamps").getCacheName());
|
||||
|
||||
assertEquals("person-cache", factory.getTypeOverrides().get(person).getCacheName());
|
||||
assertEquals(EvictionStrategy.LRU, factory.getTypeOverrides().get(person).getEvictionStrategy());
|
||||
assertEquals(2000, factory.getTypeOverrides().get(person).getEvictionWakeUpInterval());
|
||||
assertEquals(5000, factory.getTypeOverrides().get(person).getEvictionMaxEntries());
|
||||
assertEquals(60000, factory.getTypeOverrides().get(person).getExpirationLifespan());
|
||||
assertEquals(30000, factory.getTypeOverrides().get(person).getExpirationMaxIdle());
|
||||
assertEquals("person-cache", factory.getTypeOverrides().get(person).getCacheName());
|
||||
assertEquals(EvictionStrategy.LRU, factory.getTypeOverrides().get(person).getEvictionStrategy());
|
||||
assertEquals(2000, factory.getTypeOverrides().get(person).getEvictionWakeUpInterval());
|
||||
assertEquals(5000, factory.getTypeOverrides().get(person).getEvictionMaxEntries());
|
||||
assertEquals(60000, factory.getTypeOverrides().get(person).getExpirationLifespan());
|
||||
assertEquals(30000, factory.getTypeOverrides().get(person).getExpirationMaxIdle());
|
||||
|
||||
assertEquals("person-addresses-cache", factory.getTypeOverrides().get(addresses).getCacheName());
|
||||
assertEquals(120000, factory.getTypeOverrides().get(addresses).getExpirationLifespan());
|
||||
assertEquals(60000, factory.getTypeOverrides().get(addresses).getExpirationMaxIdle());
|
||||
assertEquals("person-addresses-cache", factory.getTypeOverrides().get(addresses).getCacheName());
|
||||
assertEquals(120000, factory.getTypeOverrides().get(addresses).getExpirationLifespan());
|
||||
assertEquals(60000, factory.getTypeOverrides().get(addresses).getExpirationMaxIdle());
|
||||
|
||||
assertEquals("my-query-cache", factory.getTypeOverrides().get("query").getCacheName());
|
||||
assertEquals(EvictionStrategy.FIFO, factory.getTypeOverrides().get("query").getEvictionStrategy());
|
||||
assertEquals(3000, factory.getTypeOverrides().get("query").getEvictionWakeUpInterval());
|
||||
assertEquals(10000, factory.getTypeOverrides().get("query").getEvictionMaxEntries());
|
||||
assertEquals("my-query-cache", factory.getTypeOverrides().get("query").getCacheName());
|
||||
assertEquals(EvictionStrategy.LIRS, factory.getTypeOverrides().get("query").getEvictionStrategy());
|
||||
assertEquals(3000, factory.getTypeOverrides().get("query").getEvictionWakeUpInterval());
|
||||
assertEquals(10000, factory.getTypeOverrides().get("query").getEvictionMaxEntries());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -116,11 +123,11 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.lifespan", "60000");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "LIRS");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "20000");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.cfg", "addresses-cache");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.strategy", "FIFO");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.strategy", "LIRS");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.wake_up_interval", "2500");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.eviction.max_entries", "5500");
|
||||
p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.lifespan", "65000");
|
||||
|
@ -130,9 +137,10 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
|
||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "25000");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
try {
|
||||
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
assertFalse(manager.getCacheManagerConfiguration()
|
||||
.globalJmxStatistics().enabled());
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertFalse(factory.getDefinedConfigurations().contains(person));
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
|
@ -144,70 +152,71 @@ public class InfinispanRegionFactoryTestCase {
|
|||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(address));
|
||||
cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(2000, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(5000, cacheCfg.getEvictionMaxEntries());
|
||||
assertEquals(60000, cacheCfg.getExpirationLifespan());
|
||||
assertEquals(30000, cacheCfg.getExpirationMaxIdle());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
|
||||
assertEquals(2000, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(5000, cacheCfg.eviction().maxEntries());
|
||||
assertEquals(60000, cacheCfg.expiration().lifespan());
|
||||
assertEquals(30000, cacheCfg.expiration().maxIdle());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion(address, p, null);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(address));
|
||||
cache = region.getCache();
|
||||
cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(20000, cacheCfg.getEvictionMaxEntries());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
|
||||
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(20000, cacheCfg.eviction().maxEntries());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion(car, p, null);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(address));
|
||||
cache = region.getCache();
|
||||
cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(20000, cacheCfg.getEvictionMaxEntries());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
|
||||
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(20000, cacheCfg.eviction().maxEntries());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(addresses, p, null);
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion(addresses, p, null);
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
assertNull(factory.getTypeOverrides().get(parts));
|
||||
cache = collectionRegion .getCache();
|
||||
cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(2500, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(5500, cacheCfg.getEvictionMaxEntries());
|
||||
assertEquals(65000, cacheCfg.getExpirationLifespan());
|
||||
assertEquals(35000, cacheCfg.getExpirationMaxIdle());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
|
||||
assertEquals(2500, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(5500, cacheCfg.eviction().maxEntries());
|
||||
assertEquals(65000, cacheCfg.expiration().lifespan());
|
||||
assertEquals(35000, cacheCfg.expiration().maxIdle());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(addresses));
|
||||
assertNull(factory.getTypeOverrides().get(parts));
|
||||
cache = collectionRegion.getCache();
|
||||
cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(25000, cacheCfg.getEvictionMaxEntries());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
|
||||
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(25000, cacheCfg.eviction().maxEntries());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
|
||||
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
|
||||
assertNotNull(factory.getTypeOverrides().get(addresses));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(addresses));
|
||||
assertNull(factory.getTypeOverrides().get(parts));
|
||||
cache = collectionRegion.getCache();
|
||||
cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(25000, cacheCfg.getEvictionMaxEntries());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
|
||||
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(25000, cacheCfg.eviction().maxEntries());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
|
@ -217,32 +226,34 @@ public class InfinispanRegionFactoryTestCase {
|
|||
public void testBuildEntityCollectionRegionOverridesOnly() {
|
||||
AdvancedCache cache;
|
||||
Properties p = new Properties();
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "LIRS");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "30000");
|
||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
|
||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
|
||||
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "35000");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
factory.getCacheManager();
|
||||
try {
|
||||
factory.getCacheManager();
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
|
||||
assertNull(factory.getTypeOverrides().get("com.acme.Address"));
|
||||
cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(30000, cacheCfg.getEvictionMaxEntries());
|
||||
assertEquals(100000, cacheCfg.getExpirationMaxIdle());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
|
||||
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(30000, cacheCfg.eviction().maxEntries());
|
||||
// Max idle value comes from base XML configuration
|
||||
assertEquals(100000, cacheCfg.expiration().maxIdle());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
assertNull(factory.getTypeOverrides().get("com.acme.Person.addresses"));
|
||||
cache = collectionRegion.getCache();
|
||||
cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(35000, cacheCfg.getEvictionMaxEntries());
|
||||
assertEquals(100000, cacheCfg.getExpirationMaxIdle());
|
||||
cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
|
||||
assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(35000, cacheCfg.eviction().maxEntries());
|
||||
assertEquals(100000, cacheCfg.expiration().maxIdle());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
|
@ -260,87 +271,89 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
try {
|
||||
factory.getCacheManager();
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertFalse(factory.getDefinedConfigurations().contains(person));
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, null);
|
||||
assertNotNull(factory.getTypeOverrides().get(person));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(person));
|
||||
AdvancedCache cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(10000, cacheCfg.getEvictionMaxEntries());
|
||||
assertEquals(60000, cacheCfg.getExpirationLifespan());
|
||||
assertEquals(30000, cacheCfg.getExpirationMaxIdle());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
|
||||
assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(10000, cacheCfg.eviction().maxEntries());
|
||||
assertEquals(60000, cacheCfg.expiration().lifespan());
|
||||
assertEquals(30000, cacheCfg.expiration().maxIdle());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimestampValidation() {
|
||||
Properties p = new Properties();
|
||||
final DefaultCacheManager manager = new DefaultCacheManager();
|
||||
InfinispanRegionFactory factory = createRegionFactory(manager, p);
|
||||
Configuration config = new Configuration();
|
||||
config.setCacheMode(CacheMode.INVALIDATION_SYNC);
|
||||
manager.defineConfiguration("timestamps", config);
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
|
||||
manager.defineConfiguration("timestamps", builder.build());
|
||||
try {
|
||||
factory.start(null, p);
|
||||
fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
|
||||
} catch(CacheException ce) {
|
||||
}
|
||||
}
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testBuildDefaultTimestampsRegion() {
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
Properties p = new Properties();
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
try {
|
||||
assertTrue(factory.getDefinedConfigurations().contains("timestamps"));
|
||||
assertTrue(factory.getTypeOverrides().get("timestamps").getCacheName().equals("timestamps"));
|
||||
Configuration config = new Configuration();
|
||||
config.setFetchInMemoryState(false);
|
||||
manager.defineConfiguration("timestamps", config);
|
||||
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
|
||||
assertTrue(factory.getTypeOverrides().get("timestamps")
|
||||
.getCacheName().equals("timestamps"));
|
||||
TimestampsRegionImpl region = (TimestampsRegionImpl)
|
||||
factory.buildTimestampsRegion(timestamps, p);
|
||||
AdvancedCache cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.NONE, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(CacheMode.REPL_ASYNC, cacheCfg.getCacheMode());
|
||||
assertTrue(cacheCfg.isUseLazyDeserialization());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
|
||||
assertEquals(CacheMode.REPL_ASYNC, cacheCfg.clustering().cacheMode());
|
||||
assertTrue(cacheCfg.storeAsBinary().enabled());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildDiffCacheNameTimestampsRegion() {
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
Properties p = new Properties();
|
||||
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "unrecommended-timestamps");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
try {
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
assertFalse(factory.getDefinedConfigurations().contains("timestamp"));
|
||||
assertTrue(factory.getDefinedConfigurations().contains("unrecommended-timestamps"));
|
||||
assertTrue(factory.getTypeOverrides().get("timestamps").getCacheName().equals("unrecommended-timestamps"));
|
||||
Configuration config = new Configuration();
|
||||
config.setFetchInMemoryState(false);
|
||||
config.setCacheMode(CacheMode.REPL_SYNC);
|
||||
manager.defineConfiguration("unrecommended-timestamps", config);
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
builder.clustering().stateTransfer().fetchInMemoryState(true);
|
||||
builder.clustering().cacheMode(CacheMode.REPL_SYNC);
|
||||
manager.defineConfiguration("unrecommended-timestamps", builder.build());
|
||||
TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
|
||||
AdvancedCache cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.NONE, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(CacheMode.REPL_SYNC, cacheCfg.getCacheMode());
|
||||
assertFalse(cacheCfg.isUseLazyDeserialization());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
|
||||
assertEquals(CacheMode.REPL_SYNC, cacheCfg.clustering().cacheMode());
|
||||
assertFalse(cacheCfg.storeAsBinary().enabled());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildTimestamRegionWithCacheNameOverride() {
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
|
@ -354,6 +367,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildTimestamRegionWithFifoEvictionOverride() {
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
|
@ -373,6 +387,7 @@ public class InfinispanRegionFactoryTestCase {
|
|||
if (factory != null) factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildTimestamRegionWithNoneEvictionOverride() {
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
|
@ -380,10 +395,8 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.timestamps.cfg", "timestamps-none-eviction");
|
||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "NONE");
|
||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "10000");
|
||||
p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "0");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
manager.getGlobalConfiguration().setTransportClass(null);
|
||||
try {
|
||||
factory.buildTimestampsRegion(timestamps, p);
|
||||
assertTrue(factory.getDefinedConfigurations().contains("timestamps-none-eviction"));
|
||||
|
@ -391,45 +404,43 @@ public class InfinispanRegionFactoryTestCase {
|
|||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildQueryRegion() {
|
||||
final String query = "org.hibernate.cache.internal.StandardQueryCache";
|
||||
Properties p = new Properties();
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
manager.getGlobalConfiguration().setTransportClass(null);
|
||||
try {
|
||||
assertTrue(factory.getDefinedConfigurations().contains("local-query"));
|
||||
QueryResultsRegionImpl region = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
|
||||
AdvancedCache cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(CacheMode.LOCAL, cacheCfg.getCacheMode());
|
||||
assertFalse(cacheCfg.isExposeJmxStatistics());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(CacheMode.LOCAL, cacheCfg.clustering().cacheMode());
|
||||
assertFalse(cacheCfg.jmxStatistics().enabled());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildQueryRegionWithCustomRegionName() {
|
||||
final String queryRegionName = "myquery";
|
||||
Properties p = new Properties();
|
||||
p.setProperty("hibernate.cache.infinispan.myquery.cfg", "timestamps-none-eviction");
|
||||
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "FIFO");
|
||||
p.setProperty("hibernate.cache.infinispan.myquery.eviction.strategy", "LIRS");
|
||||
p.setProperty("hibernate.cache.infinispan.myquery.eviction.wake_up_interval", "2222");
|
||||
p.setProperty("hibernate.cache.infinispan.myquery.eviction.max_entries", "11111");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
manager.getGlobalConfiguration().setTransportClass(null);
|
||||
try {
|
||||
assertTrue(factory.getDefinedConfigurations().contains("local-query"));
|
||||
QueryResultsRegionImpl region = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(queryRegionName, p);
|
||||
assertNotNull(factory.getTypeOverrides().get(queryRegionName));
|
||||
assertTrue(factory.getDefinedConfigurations().contains(queryRegionName));
|
||||
AdvancedCache cache = region.getCache();
|
||||
Configuration cacheCfg = cache.getConfiguration();
|
||||
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
|
||||
assertEquals(2222, cacheCfg.getEvictionWakeUpInterval());
|
||||
assertEquals(11111, cacheCfg.getEvictionMaxEntries());
|
||||
Configuration cacheCfg = cache.getCacheConfiguration();
|
||||
assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
|
||||
assertEquals(2222, cacheCfg.expiration().wakeUpInterval());
|
||||
assertEquals(11111, cacheCfg.eviction().maxEntries());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
|
@ -445,42 +456,46 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
try {
|
||||
assertTrue(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
assertTrue(manager.getCacheManagerConfiguration().globalJmxStatistics().enabled());
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
|
||||
AdvancedCache cache = region.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("entity").isExposeStatistics());
|
||||
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
|
||||
cache = region.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
|
||||
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
final String query = "org.hibernate.cache.internal.StandardQueryCache";
|
||||
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
|
||||
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl)
|
||||
factory.buildQueryResultsRegion(query, p);
|
||||
cache = queryRegion.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("query").isExposeStatistics());
|
||||
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
Configuration config = new Configuration();
|
||||
config.setFetchInMemoryState(false);
|
||||
manager.defineConfiguration("timestamps", config);
|
||||
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
builder.clustering().stateTransfer().fetchInMemoryState(true);
|
||||
manager.defineConfiguration("timestamps", builder.build());
|
||||
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl)
|
||||
factory.buildTimestampsRegion(timestamps, p);
|
||||
cache = timestampsRegion.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
|
||||
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
cache = collectionRegion.getCache();
|
||||
assertTrue(factory.getTypeOverrides().get("collection").isExposeStatistics());
|
||||
assertTrue(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisableStatistics() {
|
||||
Properties p = new Properties();
|
||||
|
@ -492,38 +507,38 @@ public class InfinispanRegionFactoryTestCase {
|
|||
p.setProperty("hibernate.cache.infinispan.entity.eviction.wake_up_interval", "3000");
|
||||
p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
|
||||
InfinispanRegionFactory factory = createRegionFactory(p);
|
||||
EmbeddedCacheManager manager = factory.getCacheManager();
|
||||
try {
|
||||
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
|
||||
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, null);
|
||||
AdvancedCache cache = region.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("entity").isExposeStatistics());
|
||||
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
|
||||
cache = region.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
|
||||
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
final String query = "org.hibernate.cache.internal.StandardQueryCache";
|
||||
QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
|
||||
cache = queryRegion.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("query").isExposeStatistics());
|
||||
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
|
||||
Configuration config = new Configuration();
|
||||
config.setFetchInMemoryState(false);
|
||||
manager.defineConfiguration("timestamps", config);
|
||||
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
|
||||
ConfigurationBuilder builder = new ConfigurationBuilder();
|
||||
builder.clustering().stateTransfer().fetchInMemoryState(true);
|
||||
factory.getCacheManager().defineConfiguration("timestamps", builder.build());
|
||||
TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl)
|
||||
factory.buildTimestampsRegion(timestamps, p);
|
||||
cache = timestampsRegion.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
|
||||
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
|
||||
factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
|
||||
cache = collectionRegion.getCache();
|
||||
assertFalse(factory.getTypeOverrides().get("collection").isExposeStatistics());
|
||||
assertFalse(cache.getConfiguration().isExposeJmxStatistics());
|
||||
assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
|
||||
} finally {
|
||||
factory.stop();
|
||||
}
|
||||
|
@ -534,7 +549,8 @@ public class InfinispanRegionFactoryTestCase {
|
|||
}
|
||||
|
||||
private InfinispanRegionFactory createRegionFactory(final EmbeddedCacheManager manager, Properties p) {
|
||||
final InfinispanRegionFactory factory = new InfinispanRegionFactory() {
|
||||
final InfinispanRegionFactory factory = new SingleNodeTestCase.TestInfinispanRegionFactory() {
|
||||
|
||||
@Override
|
||||
protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(Settings settings, Properties properties) {
|
||||
return new HibernateTransactionManagerLookup(null, null) {
|
||||
|
@ -554,7 +570,9 @@ public class InfinispanRegionFactoryTestCase {
|
|||
else
|
||||
return super.createCacheManager(properties);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
factory.start(null, p);
|
||||
return factory;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.infinispan.test.CacheManagerCallable;
|
||||
import org.infinispan.test.fwk.TestCacheManagerFactory;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -42,6 +46,7 @@ import org.junit.Test;
|
|||
import org.hibernate.cache.infinispan.access.PutFromLoadValidator;
|
||||
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl;
|
||||
|
||||
import static org.infinispan.test.TestingUtil.withCacheManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -56,6 +61,10 @@ import static org.junit.Assert.fail;
|
|||
* @version $Revision: $
|
||||
*/
|
||||
public class PutFromLoadValidatorUnitTestCase {
|
||||
|
||||
private static final Log log = LogFactory.getLog(
|
||||
PutFromLoadValidatorUnitTestCase.class);
|
||||
|
||||
private Object KEY1 = "KEY1";
|
||||
|
||||
private TransactionManager tm;
|
||||
|
@ -85,22 +94,32 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
nakedPutTest(true);
|
||||
}
|
||||
|
||||
private void nakedPutTest(boolean transactional) throws Exception {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(
|
||||
new DefaultCacheManager(), transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
private void nakedPutTest(final boolean transactional) throws Exception {
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
try {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
|
||||
transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Test
|
||||
public void testRegisteredPut() throws Exception {
|
||||
|
@ -111,23 +130,34 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
registeredPutTest(true);
|
||||
}
|
||||
|
||||
private void registeredPutTest(boolean transactional) throws Exception {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
|
||||
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
private void registeredPutTest(final boolean transactional) throws Exception {
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
|
||||
transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
try {
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Test
|
||||
public void testNakedPutAfterKeyRemoval() throws Exception {
|
||||
|
@ -146,28 +176,40 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
nakedPutAfterRemovalTest(true, true);
|
||||
}
|
||||
|
||||
private void nakedPutAfterRemovalTest(boolean transactional, boolean removeRegion)
|
||||
throws Exception {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
|
||||
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
private void nakedPutAfterRemovalTest(final boolean transactional,
|
||||
final boolean removeRegion) throws Exception {
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
|
||||
transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
try {
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertFalse(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertFalse(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testRegisteredPutAfterKeyRemoval() throws Exception {
|
||||
|
@ -186,29 +228,41 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
registeredPutAfterRemovalTest(true, true);
|
||||
}
|
||||
|
||||
private void registeredPutAfterRemovalTest(boolean transactional, boolean removeRegion)
|
||||
throws Exception {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
|
||||
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
private void registeredPutAfterRemovalTest(final boolean transactional,
|
||||
final boolean removeRegion) throws Exception {
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
|
||||
transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
try {
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testRegisteredPutWithInterveningKeyRemoval() throws Exception {
|
||||
|
@ -227,29 +281,41 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
registeredPutWithInterveningRemovalTest(true, true);
|
||||
}
|
||||
|
||||
private void registeredPutWithInterveningRemovalTest(boolean transactional, boolean removeRegion)
|
||||
private void registeredPutWithInterveningRemovalTest(
|
||||
final boolean transactional, final boolean removeRegion)
|
||||
throws Exception {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(new DefaultCacheManager(),
|
||||
transactional ? tm : null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
PutFromLoadValidator testee = new PutFromLoadValidator(cm,
|
||||
transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
try {
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertFalse(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertFalse(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Test
|
||||
public void testDelayedNakedPutAfterKeyRemoval() throws Exception {
|
||||
|
@ -268,87 +334,114 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
delayedNakedPutAfterRemovalTest(true, true);
|
||||
}
|
||||
|
||||
private void delayedNakedPutAfterRemovalTest(boolean transactional, boolean removeRegion)
|
||||
private void delayedNakedPutAfterRemovalTest(
|
||||
final boolean transactional, final boolean removeRegion)
|
||||
throws Exception {
|
||||
PutFromLoadValidator testee = new TestValidator(transactional ? tm : null, 100);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
Thread.sleep(110);
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
PutFromLoadValidator testee = new TestValidator(cm,
|
||||
transactional ? tm : null, 100);
|
||||
if (removeRegion) {
|
||||
testee.invalidateRegion();
|
||||
} else {
|
||||
testee.invalidateKey(KEY1);
|
||||
}
|
||||
try {
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
Thread.sleep(110);
|
||||
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
boolean lockable = testee.acquirePutFromLoadLock(KEY1);
|
||||
try {
|
||||
assertTrue(lockable);
|
||||
}
|
||||
finally {
|
||||
if (lockable) {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleRegistrations() throws Exception {
|
||||
multipleRegistrationtest(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleRegistrationsTransactional() throws Exception {
|
||||
multipleRegistrationtest(true);
|
||||
}
|
||||
|
||||
private void multipleRegistrationtest(final boolean transactional) throws Exception {
|
||||
final PutFromLoadValidator testee = new PutFromLoadValidator(
|
||||
new DefaultCacheManager(), transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
final PutFromLoadValidator testee = new PutFromLoadValidator(cm,
|
||||
transactional ? tm : null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
|
||||
final CountDownLatch registeredLatch = new CountDownLatch(3);
|
||||
final CountDownLatch finishedLatch = new CountDownLatch(3);
|
||||
final AtomicInteger success = new AtomicInteger();
|
||||
final CountDownLatch registeredLatch = new CountDownLatch(3);
|
||||
final CountDownLatch finishedLatch = new CountDownLatch(3);
|
||||
final AtomicInteger success = new AtomicInteger();
|
||||
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
registeredLatch.countDown();
|
||||
registeredLatch.await(5, TimeUnit.SECONDS);
|
||||
if (testee.acquirePutFromLoadLock(KEY1)) {
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
success.incrementAndGet();
|
||||
if (transactional) {
|
||||
tm.begin();
|
||||
}
|
||||
testee.registerPendingPut(KEY1);
|
||||
registeredLatch.countDown();
|
||||
registeredLatch.await(5, TimeUnit.SECONDS);
|
||||
if (testee.acquirePutFromLoadLock(KEY1)) {
|
||||
try {
|
||||
log.trace("Put from load lock acquired for key = " + KEY1);
|
||||
success.incrementAndGet();
|
||||
}
|
||||
finally {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
} else {
|
||||
log.trace("Unable to acquired putFromLoad lock for key = " + KEY1);
|
||||
}
|
||||
finishedLatch.countDown();
|
||||
}
|
||||
finally {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
finishedLatch.countDown();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
};
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(3);
|
||||
|
||||
// Start with a removal so the "isPutValid" calls will fail if
|
||||
// any of the concurrent activity isn't handled properly
|
||||
|
||||
testee.invalidateRegion();
|
||||
|
||||
// Do the registration + isPutValid calls
|
||||
executor.execute(r);
|
||||
executor.execute(r);
|
||||
executor.execute(r);
|
||||
|
||||
try {
|
||||
finishedLatch.await(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
assertEquals("All threads succeeded", 3, success.get());
|
||||
}
|
||||
};
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(3);
|
||||
|
||||
// Start with a removal so the "isPutValid" calls will fail if
|
||||
// any of the concurrent activity isn't handled properly
|
||||
|
||||
testee.invalidateRegion();
|
||||
|
||||
// Do the registration + isPutValid calls
|
||||
executor.execute(r);
|
||||
executor.execute(r);
|
||||
executor.execute(r);
|
||||
|
||||
finishedLatch.await(5, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals("All threads succeeded", 3, success.get());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,17 +452,23 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
*/
|
||||
@Test
|
||||
public void testRemovalCleanup() throws Exception {
|
||||
TestValidator testee = new TestValidator(null, 200);
|
||||
testee.invalidateKey("KEY1");
|
||||
testee.invalidateKey("KEY2");
|
||||
expectRemovalLenth(2, testee, 60000l);
|
||||
assertEquals(2, testee.getRemovalQueueLength());
|
||||
expectRemovalLenth(2, testee, 60000l);
|
||||
assertEquals(2, testee.getRemovalQueueLength());
|
||||
expectRemovalLenth( 2, testee, 60000l );
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
TestValidator testee = new TestValidator(cm, null, 200);
|
||||
testee.invalidateKey("KEY1");
|
||||
testee.invalidateKey("KEY2");
|
||||
expectRemovalLenth(2, testee, 60000l);
|
||||
assertEquals(2, testee.getRemovalQueueLength());
|
||||
expectRemovalLenth(2, testee, 60000l);
|
||||
assertEquals(2, testee.getRemovalQueueLength());
|
||||
expectRemovalLenth(2, testee, 60000l);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void expectRemovalLenth(int expectedLength, TestValidator testee, long timeout) throws InterruptedException {
|
||||
private void expectRemovalLenth(int expectedLength, TestValidator testee, long timeout) {
|
||||
long timeoutMilestone = System.currentTimeMillis() + timeout;
|
||||
while ( true ) {
|
||||
int queueLength = testee.getRemovalQueueLength();
|
||||
|
@ -381,7 +480,11 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
if ( System.currentTimeMillis() > timeoutMilestone ) {
|
||||
fail( "condition not reached after " + timeout + " milliseconds. giving up!" );
|
||||
}
|
||||
Thread.sleep(20);
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,74 +500,81 @@ public class PutFromLoadValidatorUnitTestCase {
|
|||
}
|
||||
|
||||
private void invalidationBlocksForInProgressPutTest(final boolean keyOnly) throws Exception {
|
||||
final PutFromLoadValidator testee = new PutFromLoadValidator(
|
||||
new DefaultCacheManager(), null,
|
||||
PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
final CountDownLatch removeLatch = new CountDownLatch(1);
|
||||
final CountDownLatch pferLatch = new CountDownLatch(1);
|
||||
final AtomicReference<Object> cache = new AtomicReference<Object>("INITIAL");
|
||||
withCacheManager(new CacheManagerCallable(
|
||||
TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
final PutFromLoadValidator testee = new PutFromLoadValidator(
|
||||
cm, null, PutFromLoadValidator.NAKED_PUT_INVALIDATION_PERIOD);
|
||||
final CountDownLatch removeLatch = new CountDownLatch(1);
|
||||
final CountDownLatch pferLatch = new CountDownLatch(1);
|
||||
final AtomicReference<Object> cache = new AtomicReference<Object>("INITIAL");
|
||||
|
||||
Callable<Boolean> pferCallable = new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
testee.registerPendingPut(KEY1);
|
||||
if (testee.acquirePutFromLoadLock(KEY1)) {
|
||||
Callable<Boolean> pferCallable = new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
testee.registerPendingPut(KEY1);
|
||||
if (testee.acquirePutFromLoadLock(KEY1)) {
|
||||
try {
|
||||
removeLatch.countDown();
|
||||
pferLatch.await();
|
||||
cache.set("PFER");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
finally {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
Callable<Void> invalidateCallable = new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
removeLatch.await();
|
||||
if (keyOnly) {
|
||||
testee.invalidateKey(KEY1);
|
||||
} else {
|
||||
testee.invalidateRegion();
|
||||
}
|
||||
cache.set(null);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
Future<Boolean> pferFuture = executorService.submit(pferCallable);
|
||||
Future<Void> invalidateFuture = executorService.submit(invalidateCallable);
|
||||
|
||||
try {
|
||||
try {
|
||||
removeLatch.countDown();
|
||||
pferLatch.await();
|
||||
cache.set("PFER");
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
finally {
|
||||
testee.releasePutFromLoadLock(KEY1);
|
||||
invalidateFuture.get(1, TimeUnit.SECONDS);
|
||||
fail("invalidateFuture did not block");
|
||||
}
|
||||
catch (TimeoutException good) {}
|
||||
|
||||
pferLatch.countDown();
|
||||
|
||||
assertTrue(pferFuture.get(5, TimeUnit.SECONDS));
|
||||
invalidateFuture.get(5, TimeUnit.SECONDS);
|
||||
|
||||
assertNull(cache.get());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
Callable<Void> invalidateCallable = new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
removeLatch.await();
|
||||
if (keyOnly) {
|
||||
testee.invalidateKey(KEY1);
|
||||
} else {
|
||||
testee.invalidateRegion();
|
||||
}
|
||||
cache.set(null);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
Future<Boolean> pferFuture = executorService.submit(pferCallable);
|
||||
Future<Void> invalidateFuture = executorService.submit(invalidateCallable);
|
||||
|
||||
try {
|
||||
invalidateFuture.get(1, TimeUnit.SECONDS);
|
||||
fail("invalidateFuture did not block");
|
||||
}
|
||||
catch (TimeoutException good) {}
|
||||
|
||||
pferLatch.countDown();
|
||||
|
||||
assertTrue(pferFuture.get(5, TimeUnit.SECONDS));
|
||||
invalidateFuture.get(5, TimeUnit.SECONDS);
|
||||
|
||||
assertNull(cache.get());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private static class TestValidator extends PutFromLoadValidator {
|
||||
|
||||
protected TestValidator(TransactionManager transactionManager,
|
||||
long nakedPutInvalidationPeriod) {
|
||||
super(new DefaultCacheManager(),
|
||||
transactionManager, nakedPutInvalidationPeriod);
|
||||
protected TestValidator(EmbeddedCacheManager cm,
|
||||
TransactionManager transactionManager,
|
||||
long nakedPutInvalidationPeriod) {
|
||||
super(cm, transactionManager, nakedPutInvalidationPeriod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemovalQueueLength() {
|
||||
// TODO Auto-generated method stub
|
||||
return super.getRemovalQueueLength();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ import javax.transaction.TransactionManager;
|
|||
|
||||
import junit.framework.AssertionFailedError;
|
||||
import org.hibernate.cache.infinispan.util.Caches;
|
||||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.test.CacheManagerCallable;
|
||||
import org.infinispan.test.fwk.TestCacheManagerFactory;
|
||||
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.junit.After;
|
||||
|
@ -54,6 +55,7 @@ import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
|
|||
import org.hibernate.test.cache.infinispan.NodeEnvironment;
|
||||
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
||||
|
||||
import static org.infinispan.test.TestingUtil.withCacheManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -162,61 +164,70 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
|
|||
final CountDownLatch pferLatch = new CountDownLatch( 1 );
|
||||
final CountDownLatch removeLatch = new CountDownLatch( 1 );
|
||||
final TransactionManager remoteTm = remoteCollectionRegion.getTransactionManager();
|
||||
PutFromLoadValidator validator = new PutFromLoadValidator(
|
||||
new DefaultCacheManager(), remoteTm, 20000) {
|
||||
@Override
|
||||
public boolean acquirePutFromLoadLock(Object key) {
|
||||
boolean acquired = super.acquirePutFromLoadLock( key );
|
||||
try {
|
||||
removeLatch.countDown();
|
||||
pferLatch.await( 2, TimeUnit.SECONDS );
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
log.debug( "Interrupted" );
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error( "Error", e );
|
||||
throw new RuntimeException( "Error", e );
|
||||
}
|
||||
return acquired;
|
||||
}
|
||||
};
|
||||
|
||||
final TransactionalAccessDelegate delegate =
|
||||
new TransactionalAccessDelegate(localCollectionRegion, validator);
|
||||
final TransactionManager localTm = localCollectionRegion.getTransactionManager();
|
||||
|
||||
Callable<Void> pferCallable = new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
delegate.putFromLoad( "k1", "v1", 0, null );
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Callable<Void> removeCallable = new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
removeLatch.await();
|
||||
Caches.withinTx(localTm, new Callable<Void>() {
|
||||
withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createLocalCacheManager(false)) {
|
||||
@Override
|
||||
public void call() {
|
||||
PutFromLoadValidator validator = new PutFromLoadValidator(cm,
|
||||
remoteTm, 20000) {
|
||||
@Override
|
||||
public boolean acquirePutFromLoadLock(Object key) {
|
||||
boolean acquired = super.acquirePutFromLoadLock( key );
|
||||
try {
|
||||
removeLatch.countDown();
|
||||
pferLatch.await( 2, TimeUnit.SECONDS );
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
log.debug( "Interrupted" );
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error( "Error", e );
|
||||
throw new RuntimeException( "Error", e );
|
||||
}
|
||||
return acquired;
|
||||
}
|
||||
};
|
||||
|
||||
final TransactionalAccessDelegate delegate =
|
||||
new TransactionalAccessDelegate(localCollectionRegion, validator);
|
||||
final TransactionManager localTm = localCollectionRegion.getTransactionManager();
|
||||
|
||||
Callable<Void> pferCallable = new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
delegate.remove("k1");
|
||||
delegate.putFromLoad( "k1", "v1", 0, null );
|
||||
return null;
|
||||
}
|
||||
});
|
||||
pferLatch.countDown();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
Future<Void> pferFuture = executorService.submit( pferCallable );
|
||||
Future<Void> removeFuture = executorService.submit( removeCallable );
|
||||
Callable<Void> removeCallable = new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
removeLatch.await();
|
||||
Caches.withinTx(localTm, new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
delegate.remove("k1");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
pferLatch.countDown();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
pferFuture.get();
|
||||
removeFuture.get();
|
||||
ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
Future<Void> pferFuture = executorService.submit( pferCallable );
|
||||
Future<Void> removeFuture = executorService.submit( removeCallable );
|
||||
|
||||
assertFalse(localCollectionRegion.getCache().containsKey("k1"));
|
||||
try {
|
||||
pferFuture.get();
|
||||
removeFuture.get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
assertFalse(localCollectionRegion.getCache().containsKey("k1"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -44,8 +44,6 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
|
@ -104,11 +102,6 @@ public class ConcurrentWriteTest extends SingleNodeTestCase {
|
|||
return DualNodeJtaTransactionManagerImpl.getInstance( DualNodeTestCase.LOCAL );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends RegionFactory> getCacheRegionFactory() {
|
||||
return InfinispanRegionFactory.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ConnectionProvider> getConnectionProviderClass() {
|
||||
return DualNodeConnectionProviderImpl.class;
|
||||
|
|
|
@ -26,6 +26,9 @@ package org.hibernate.test.cache.infinispan.functional;
|
|||
import javax.transaction.Status;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.infinispan.configuration.parsing.ConfigurationBuilderHolder;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.infinispan.test.fwk.TestCacheManagerFactory;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
|
@ -86,7 +89,7 @@ public abstract class SingleNodeTestCase extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
protected Class<? extends RegionFactory> getCacheRegionFactory() {
|
||||
return InfinispanRegionFactory.class;
|
||||
return TestInfinispanRegionFactory.class;
|
||||
}
|
||||
|
||||
protected Class<? extends TransactionFactory> getTransactionFactoryClass() {
|
||||
|
@ -148,4 +151,17 @@ public abstract class SingleNodeTestCase extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public static class TestInfinispanRegionFactory extends InfinispanRegionFactory {
|
||||
|
||||
public TestInfinispanRegionFactory() {
|
||||
super(); // For reflection-based instantiation
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EmbeddedCacheManager createCacheManager(ConfigurationBuilderHolder holder) {
|
||||
return TestCacheManagerFactory.createClusteredCacheManager(holder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -27,11 +27,11 @@ import java.util.Set;
|
|||
import javax.transaction.Status;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
@ -73,7 +73,7 @@ public class BulkOperationsTestCase extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
protected Class<? extends RegionFactory> getCacheRegionFactory() {
|
||||
return InfinispanRegionFactory.class;
|
||||
return SingleNodeTestCase.TestInfinispanRegionFactory.class;
|
||||
}
|
||||
|
||||
protected Class<? extends TransactionFactory> getTransactionFactoryClass() {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
|||
|
||||
private static ClassLoader originalTCCL;
|
||||
|
||||
private static ClassLoader visibleClassesCl;
|
||||
// private static ClassLoader visibleClassesCl;
|
||||
|
||||
@BeforeClass
|
||||
public static void prepareClassLoader() {
|
||||
|
@ -200,12 +200,10 @@ public class IsolatedClassLoaderTest extends DualNodeTestCase {
|
|||
if ( useNamedRegion ) {
|
||||
cacheName = "AccountRegion"; // As defined by ClassLoaderTestDAO via calls to query.setCacheRegion
|
||||
// Define cache configurations for region early to avoid ending up with local caches for this region
|
||||
localManager.defineConfiguration(
|
||||
cacheName, "replicated-query", new org.infinispan.config.Configuration()
|
||||
);
|
||||
remoteManager.defineConfiguration(
|
||||
cacheName, "replicated-query", new org.infinispan.config.Configuration()
|
||||
);
|
||||
localManager.defineConfiguration(cacheName,
|
||||
localManager.getCacheConfiguration("replicated-query"));
|
||||
remoteManager.defineConfiguration(cacheName,
|
||||
remoteManager.getCacheConfiguration("replicated-query"));
|
||||
}
|
||||
else {
|
||||
cacheName = "replicated-query";
|
||||
|
|
|
@ -24,6 +24,7 @@ package org.hibernate.test.cache.infinispan.functional.cluster;
|
|||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
@ -51,7 +52,8 @@ public class ClusterAwareRegionFactory implements RegionFactory {
|
|||
private static final Log log = LogFactory.getLog(ClusterAwareRegionFactory.class);
|
||||
private static final Hashtable<String, EmbeddedCacheManager> cacheManagers = new Hashtable<String, EmbeddedCacheManager>();
|
||||
|
||||
private final InfinispanRegionFactory delegate = new InfinispanRegionFactory();
|
||||
private final InfinispanRegionFactory delegate =
|
||||
new SingleNodeTestCase.TestInfinispanRegionFactory();
|
||||
private String cacheManagerName;
|
||||
private boolean locallyAdded;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ package org.hibernate.test.cache.infinispan.timestamp;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
|
||||
import org.infinispan.AdvancedCache;
|
||||
import org.infinispan.context.Flag;
|
||||
import org.infinispan.notifications.Listener;
|
||||
|
@ -124,15 +125,11 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
|
|||
return CacheTestUtil.buildConfiguration("test", MockInfinispanRegionFactory.class, false, true);
|
||||
}
|
||||
|
||||
public static class MockInfinispanRegionFactory extends InfinispanRegionFactory {
|
||||
public static class MockInfinispanRegionFactory extends SingleNodeTestCase.TestInfinispanRegionFactory {
|
||||
|
||||
public MockInfinispanRegionFactory() {
|
||||
}
|
||||
|
||||
public MockInfinispanRegionFactory(Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected TimestampsRegionImpl createTimestampsRegion(CacheAdapter cacheAdapter, String regionName) {
|
||||
// return new MockTimestampsRegionImpl(cacheAdapter, regionName, getTransactionManager(), this);
|
||||
|
@ -148,20 +145,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
|
|||
};
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
|
||||
// try {
|
||||
// EmbeddedCacheManager manager = new DefaultCacheManager(InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE);
|
||||
// org.infinispan.config.Configuration ispnCfg = new org.infinispan.config.Configuration();
|
||||
// ispnCfg.setCacheMode(org.infinispan.config.Configuration.CacheMode.REPL_SYNC);
|
||||
// manager.defineConfiguration("timestamps", ispnCfg);
|
||||
// return manager;
|
||||
// } catch (IOException e) {
|
||||
// throw new CacheException("Unable to create default cache manager", e);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Listener
|
||||
@Listener
|
||||
public static class MockClassLoaderAwareListener extends ClassLoaderAwareCache.ClassLoaderAwareListener {
|
||||
MockClassLoaderAwareListener(Object listener, ClassLoaderAwareCache cache) {
|
||||
super(listener, cache);
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.test.cache.infinispan.tm;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import javax.naming.Context;
|
||||
|
@ -34,10 +32,9 @@ import javax.naming.NameNotFoundException;
|
|||
import javax.naming.Reference;
|
||||
import javax.naming.StringRefAddr;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.TransactionManager;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.enhydra.jdbc.standard.StandardXADataSource;
|
||||
import org.infinispan.configuration.cache.ConfigurationBuilder;
|
||||
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
|
||||
import org.infinispan.util.logging.Log;
|
||||
import org.infinispan.util.logging.LogFactory;
|
||||
|
@ -62,8 +59,6 @@ import org.hibernate.stat.Statistics;
|
|||
import org.hibernate.test.cache.infinispan.functional.Item;
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl;
|
||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
@ -90,7 +85,7 @@ public class JBossStandaloneJtaExampleTest {
|
|||
jndiServer = startJndiServer();
|
||||
ctx = createJndiContext();
|
||||
// Inject configuration to initialise transaction manager from config classloader
|
||||
lookup.init( new org.infinispan.config.Configuration() );
|
||||
lookup.init(new ConfigurationBuilder().build());
|
||||
bindTransactionManager();
|
||||
bindUserTransaction();
|
||||
}
|
||||
|
@ -98,6 +93,8 @@ public class JBossStandaloneJtaExampleTest {
|
|||
@After
|
||||
public void tearDown() throws Exception {
|
||||
try {
|
||||
unbind("UserTransaction", ctx);
|
||||
unbind("java:/TransactionManager", ctx);
|
||||
ctx.close();
|
||||
jndiServer.stop();
|
||||
}
|
||||
|
@ -255,7 +252,8 @@ public class JBossStandaloneJtaExampleTest {
|
|||
cfg.setProperty(Environment.RELEASE_CONNECTIONS, "auto");
|
||||
cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
|
||||
cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
|
||||
cfg.setProperty(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.infinispan.InfinispanRegionFactory");
|
||||
cfg.setProperty(Environment.CACHE_REGION_FACTORY,
|
||||
"org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase$TestInfinispanRegionFactory");
|
||||
|
||||
Properties envProps = Environment.getProperties();
|
||||
envProps.put(AvailableSettings.JTA_PLATFORM, new JBossStandAloneJtaPlatform());
|
||||
|
|
|
@ -64,7 +64,6 @@ public class CacheTestSupport {
|
|||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
|
||||
// Try to ensure we use IPv4; otherwise cluster formation is very slow
|
||||
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
|
||||
System.setProperty(PREFER_IPV4STACK, "true");
|
||||
|
@ -74,7 +73,6 @@ public class CacheTestSupport {
|
|||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
|
||||
if (preferIPv4Stack == null)
|
||||
System.clearProperty(PREFER_IPV4STACK);
|
||||
else
|
||||
|
|
|
@ -23,14 +23,7 @@
|
|||
*/
|
||||
package org.hibernate.test.cache.infinispan.util;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
@ -38,6 +31,7 @@ import org.hibernate.cfg.Configuration;
|
|||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.Settings;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.test.cache.infinispan.functional.SingleNodeTestCase;
|
||||
|
||||
/**
|
||||
* Utilities for cache testing.
|
||||
|
@ -46,7 +40,8 @@ import org.hibernate.service.ServiceRegistry;
|
|||
*/
|
||||
public class CacheTestUtil {
|
||||
|
||||
public static Configuration buildConfiguration(String regionPrefix, Class regionFactory, boolean use2ndLevel, boolean useQueries) {
|
||||
public static Configuration buildConfiguration(String regionPrefix,
|
||||
Class regionFactory, boolean use2ndLevel, boolean useQueries) {
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.setProperty(Environment.GENERATE_STATISTICS, "true");
|
||||
cfg.setProperty(Environment.USE_STRUCTURED_CACHE, "true");
|
||||
|
@ -60,85 +55,47 @@ public class CacheTestUtil {
|
|||
return cfg;
|
||||
}
|
||||
|
||||
public static Configuration buildLocalOnlyConfiguration(String regionPrefix, boolean use2ndLevel, boolean useQueries) {
|
||||
Configuration cfg = buildConfiguration(regionPrefix, InfinispanRegionFactory.class, use2ndLevel, useQueries);
|
||||
cfg.setProperty(InfinispanRegionFactory.INFINISPAN_CONFIG_RESOURCE_PROP,
|
||||
InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public static Configuration buildCustomQueryCacheConfiguration(String regionPrefix, String queryCacheName) {
|
||||
Configuration cfg = buildConfiguration(regionPrefix, InfinispanRegionFactory.class, true, true);
|
||||
cfg.setProperty(InfinispanRegionFactory.QUERY_CACHE_RESOURCE_PROP, queryCacheName);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public static InfinispanRegionFactory startRegionFactory(
|
||||
ServiceRegistry serviceRegistry,
|
||||
Configuration cfg) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
public static InfinispanRegionFactory startRegionFactory(ServiceRegistry reg,
|
||||
Configuration cfg){
|
||||
try {
|
||||
Settings settings = cfg.buildSettings(reg);
|
||||
Properties properties = cfg.getProperties();
|
||||
|
||||
Settings settings = cfg.buildSettings( serviceRegistry );
|
||||
Properties properties = cfg.getProperties();
|
||||
|
||||
String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
|
||||
Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryType);
|
||||
InfinispanRegionFactory regionFactory = (InfinispanRegionFactory) factoryClass.newInstance();
|
||||
regionFactory.start(settings, properties);
|
||||
return regionFactory;
|
||||
String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
|
||||
Class clazz = Thread.currentThread()
|
||||
.getContextClassLoader().loadClass(factoryType);
|
||||
InfinispanRegionFactory regionFactory;
|
||||
if (clazz == InfinispanRegionFactory.class) {
|
||||
regionFactory = new SingleNodeTestCase.TestInfinispanRegionFactory();
|
||||
} else {
|
||||
regionFactory = (InfinispanRegionFactory) clazz.newInstance();
|
||||
}
|
||||
regionFactory.start(settings, properties);
|
||||
return regionFactory;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static InfinispanRegionFactory startRegionFactory(
|
||||
ServiceRegistry serviceRegistry,
|
||||
Configuration cfg,
|
||||
CacheTestSupport testSupport) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
InfinispanRegionFactory factory = startRegionFactory( serviceRegistry, cfg );
|
||||
public static InfinispanRegionFactory startRegionFactory(ServiceRegistry reg,
|
||||
Configuration cfg, CacheTestSupport testSupport) {
|
||||
InfinispanRegionFactory factory = startRegionFactory(reg, cfg);
|
||||
testSupport.registerFactory(factory);
|
||||
return factory;
|
||||
}
|
||||
|
||||
public static void stopRegionFactory(InfinispanRegionFactory factory, CacheTestSupport testSupport) {
|
||||
public static void stopRegionFactory(InfinispanRegionFactory factory,
|
||||
CacheTestSupport testSupport) {
|
||||
factory.stop();
|
||||
testSupport.unregisterFactory(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports easy creation of a TestSuite where a subclass' "FailureExpected" version of a base
|
||||
* test is included in the suite, while the base test is excluded. E.g. test class FooTestCase
|
||||
* includes method testBar(), while test class SubFooTestCase extends FooTestCase includes method
|
||||
* testBarFailureExcluded(). Passing SubFooTestCase.class to this method will return a suite that
|
||||
* does not include testBar().
|
||||
*
|
||||
* FIXME Move this to UnitTestCase
|
||||
*/
|
||||
public static TestSuite createFailureExpectedSuite(Class testClass) {
|
||||
|
||||
TestSuite allTests = new TestSuite(testClass);
|
||||
Set failureExpected = new HashSet();
|
||||
Enumeration tests = allTests.tests();
|
||||
while (tests.hasMoreElements()) {
|
||||
Test t = (Test) tests.nextElement();
|
||||
if (t instanceof TestCase) {
|
||||
String name = ((TestCase) t).getName();
|
||||
if (name.endsWith("FailureExpected"))
|
||||
failureExpected.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
TestSuite result = new TestSuite();
|
||||
tests = allTests.tests();
|
||||
while (tests.hasMoreElements()) {
|
||||
Test t = (Test) tests.nextElement();
|
||||
if (t instanceof TestCase) {
|
||||
String name = ((TestCase) t).getName();
|
||||
if (!failureExpected.contains(name + "FailureExpected")) {
|
||||
result.addTest(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent instantiation.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<!--
|
||||
~ JBoss, Home of Professional Open Source
|
||||
~ Copyright 2012 Red Hat Inc. and/or its affiliates and other
|
||||
~ contributors as indicated by the @author tags. All rights reserved.
|
||||
~ See the copyright.txt in the distribution for a full listing of
|
||||
~ individual contributors.
|
||||
~
|
||||
~ This is free software; you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Lesser General Public License as
|
||||
~ published by the Free Software Foundation; either version 2.1 of
|
||||
~ the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
~ Lesser General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public
|
||||
~ License along with this software; if not, write to the Free
|
||||
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
-->
|
||||
<config xmlns="urn:org:jgroups"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="urn:org:jgroups file:schema/JGroups-3.2.xsd">
|
||||
<TCP bind_port="7800"
|
||||
loopback="true"
|
||||
port_range="30"
|
||||
recv_buf_size="20000000"
|
||||
send_buf_size="640000"
|
||||
max_bundle_size="64000"
|
||||
max_bundle_timeout="30"
|
||||
enable_bundling="true"
|
||||
use_send_queues="true"
|
||||
sock_conn_timeout="300"
|
||||
enable_diagnostics="false"
|
||||
bundler_type="old"
|
||||
send_queue_size="0"
|
||||
|
||||
thread_pool.enabled="true"
|
||||
thread_pool.min_threads="1"
|
||||
thread_pool.max_threads="8"
|
||||
thread_pool.keep_alive_time="5000"
|
||||
thread_pool.queue_enabled="false"
|
||||
thread_pool.queue_max_size="100"
|
||||
thread_pool.rejection_policy="Run"
|
||||
|
||||
oob_thread_pool.enabled="true"
|
||||
oob_thread_pool.min_threads="1"
|
||||
oob_thread_pool.max_threads="8"
|
||||
oob_thread_pool.keep_alive_time="5000"
|
||||
oob_thread_pool.queue_enabled="false"
|
||||
oob_thread_pool.queue_max_size="100"
|
||||
oob_thread_pool.rejection_policy="Run"/>
|
||||
|
||||
<org.infinispan.test.fwk.TEST_PING ergonomics="false" testName=""/>
|
||||
|
||||
<MERGE2 max_interval="10000"
|
||||
min_interval="3000"/>
|
||||
<FD_SOCK/>
|
||||
<!--
|
||||
Note that this is an atypically short timeout and a small number of retries
|
||||
configured this way to speed up unit testing, since we know all nodes run in the same JVM
|
||||
and hence failure detections will be very quick.
|
||||
-->
|
||||
<FD timeout="3000" max_tries="3"/>
|
||||
<VERIFY_SUSPECT timeout="1500"/>
|
||||
<pbcast.NAKACK2
|
||||
use_mcast_xmit="false"
|
||||
xmit_interval="1000"
|
||||
xmit_table_num_rows="100"
|
||||
xmit_table_msgs_per_row="10000"
|
||||
xmit_table_max_compaction_time="10000"
|
||||
max_msg_batch_size="100"
|
||||
become_server_queue_size="0"/>
|
||||
|
||||
<UNICAST2
|
||||
max_bytes="20M"
|
||||
xmit_table_num_rows="20"
|
||||
xmit_table_msgs_per_row="10000"
|
||||
xmit_table_max_compaction_time="10000"
|
||||
max_msg_batch_size="100"/>
|
||||
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="5000"
|
||||
max_bytes="400000"/>
|
||||
<pbcast.GMS print_local_addr="false" join_timeout="7000" view_bundling="true"/>
|
||||
<FC max_credits="2000000"
|
||||
min_threshold="0.10"/>
|
||||
<FRAG2 frag_size="60000"/>
|
||||
|
||||
</config>
|
|
@ -1,5 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ JBoss, Home of Professional Open Source
|
||||
~ Copyright 2012 Red Hat Inc. and/or its affiliates and other
|
||||
~ contributors as indicated by the @author tags. All rights reserved.
|
||||
~ See the copyright.txt in the distribution for a full listing of
|
||||
~ individual contributors.
|
||||
~
|
||||
~ This is free software; you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU Lesser General Public License as
|
||||
~ published by the Free Software Foundation; either version 2.1 of
|
||||
~ the License, or (at your option) any later version.
|
||||
~
|
||||
~ This software is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
~ Lesser General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU Lesser General Public
|
||||
~ License along with this software; if not, write to the Free
|
||||
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
-->
|
||||
|
||||
<!-- Infinispan configuration based on the AS7 standalone, single node, set up -->
|
||||
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="urn:infinispan:config:5.1"
|
||||
|
|
|
@ -31,7 +31,7 @@ ext {
|
|||
junitVersion = '4.10'
|
||||
h2Version = '1.2.145'
|
||||
bytemanVersion = '1.5.2'
|
||||
infinispanVersion = '5.1.6.FINAL'
|
||||
infinispanVersion = '5.2.0.Beta2'
|
||||
jnpVersion = '5.0.6.CR1'
|
||||
|
||||
libraries = [
|
||||
|
|
Loading…
Reference in New Issue