HHH-7569 Merging test changes to master that were made only in 4.1

branch
This commit is contained in:
brmeyer 2012-09-05 12:14:14 -04:00 committed by Steve Ebersole
parent 6a48cccd5d
commit 7b04acd4f4
28 changed files with 386 additions and 83 deletions

View File

@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.dom4j.Node; import org.dom4j.Node;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.MappingException; import org.hibernate.MappingException;
@ -43,12 +42,12 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.SerializationHelper; import org.hibernate.internal.util.SerializationHelper;
import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.DynamicParameterizedType;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class SerializableToBlobType extends AbstractLobType implements ParameterizedType { public class SerializableToBlobType extends AbstractLobType implements DynamicParameterizedType {
/** /**
* class name of the serialisable class * class name of the serialisable class
*/ */
@ -138,12 +137,14 @@ public class SerializableToBlobType extends AbstractLobType implements Parameter
} }
public void setParameterValues(Properties parameters) { public void setParameterValues(Properties parameters) {
if ( parameters != null ) { ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
if ( reader != null ) {
serializableClass = reader.getReturnedClass();
}
else {
String className = parameters.getProperty( CLASS_NAME ); String className = parameters.getProperty( CLASS_NAME );
if ( className == null ) { if ( className == null ) {
throw new MappingException( throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
"No class name defined for type: " + SerializableToBlobType.class.getName()
);
} }
try { try {
serializableClass = ReflectHelper.classForName( className ); serializableClass = ReflectHelper.classForName( className );

View File

@ -24,14 +24,20 @@
package org.hibernate.metamodel.source.annotations.entity; package org.hibernate.metamodel.source.annotations.entity;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import org.junit.Test;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.id.Assigned; import org.hibernate.id.Assigned;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.IdentityGenerator; import org.hibernate.id.IdentityGenerator;
@ -42,17 +48,13 @@ import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.binding.EntityBinding;
import org.hibernate.metamodel.binding.EntityIdentifier; import org.hibernate.metamodel.binding.EntityIdentifier;
import org.hibernate.metamodel.source.MappingException; import org.hibernate.metamodel.source.MappingException;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.testing.RequiresDialect;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
@RequiresDialect(H2Dialect.class)
public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase { public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase {
@Entity @Entity
class NoGenerationEntity { class NoGenerationEntity {

View File

@ -28,6 +28,7 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import java.util.HashSet; import java.util.HashSet;
@ -74,6 +75,7 @@ public class Person {
@ElementCollection @ElementCollection
@JoinColumn @JoinColumn
@JoinTable(name = "T_NICKNAMES_A")
@OrderBy @OrderBy
public Set<String> getNickNamesAscendingNaturalSort() { public Set<String> getNickNamesAscendingNaturalSort() {
return nickNamesAscendingNaturalSort; return nickNamesAscendingNaturalSort;
@ -85,6 +87,7 @@ public class Person {
@ElementCollection @ElementCollection
@JoinColumn @JoinColumn
@JoinTable(name = "T_NICKNAMES_D")
@OrderBy( "desc" ) @OrderBy( "desc" )
public Set<String> getNickNamesDescendingNaturalSort() { public Set<String> getNickNamesDescendingNaturalSort() {
return nickNamesDescendingNaturalSort; return nickNamesDescendingNaturalSort;
@ -98,6 +101,7 @@ public class Person {
@ElementCollection @ElementCollection
@JoinColumn @JoinColumn
@OrderBy @OrderBy
@JoinTable(name = "T_ADDRESS_A")
public Set<Address> getAddressesAscendingNaturalSort() { public Set<Address> getAddressesAscendingNaturalSort() {
return addressesAscendingNaturalSort; return addressesAscendingNaturalSort;
} }
@ -109,6 +113,7 @@ public class Person {
@ElementCollection @ElementCollection
@JoinColumn @JoinColumn
@OrderBy( "desc" ) @OrderBy( "desc" )
@JoinTable(name = "T_ADDRESS_D")
public Set<Address> getAddressesDescendingNaturalSort() { public Set<Address> getAddressesDescendingNaturalSort() {
return addressesDescendingNaturalSort; return addressesDescendingNaturalSort;
} }
@ -120,6 +125,7 @@ public class Person {
@ElementCollection @ElementCollection
@JoinColumn @JoinColumn
@OrderBy( "city" ) @OrderBy( "city" )
@JoinTable(name = "T_ADD_CITY_A")
public Set<Address> getAddressesCityAscendingSort() { public Set<Address> getAddressesCityAscendingSort() {
return addressesCityAscendingSort; return addressesCityAscendingSort;
} }
@ -131,6 +137,7 @@ public class Person {
@ElementCollection @ElementCollection
@JoinColumn @JoinColumn
@OrderBy( "city desc" ) @OrderBy( "city desc" )
@JoinTable(name = "T_ADD_CITY_D")
public Set<Address> getAddressesCityDescendingSort() { public Set<Address> getAddressesCityDescendingSort() {
return addressesCityDescendingSort; return addressesCityDescendingSort;
} }

View File

@ -23,6 +23,8 @@
*/ */
package org.hibernate.test.annotations.embeddables; package org.hibernate.test.annotations.embeddables;
import static org.junit.Assert.assertEquals;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -32,20 +34,19 @@ import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.exception.GenericJDBCException; import org.hibernate.exception.GenericJDBCException;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl; import org.hibernate.testing.RequiresDialect;
import org.junit.Test;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/** /**
* @author Chris Pheby * @author Chris Pheby
*/ */
@RequiresDialect(H2Dialect.class)
public class EmbeddableIntegratorTest extends BaseUnitTestCase { public class EmbeddableIntegratorTest extends BaseUnitTestCase {
/** /**

View File

@ -11,13 +11,14 @@ import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.ParamDef; import org.hibernate.annotations.ParamDef;
import org.hibernate.annotations.SqlFragmentAlias; import org.hibernate.annotations.SqlFragmentAlias;
import org.hibernate.annotations.Type;
@Entity @Entity
@Table(name="USER") @Table(name="T_USER")
@SecondaryTable(name="SECURITY_USER") @SecondaryTable(name="SECURITY_USER")
@FilterDef(name="ageFilter", parameters=@ParamDef(name="age", type="integer")) @FilterDef(name="ageFilter", parameters=@ParamDef(name="age", type="integer"))
@Filter(name="ageFilter", condition="{u}.AGE < :age AND {s}.LOCKED_OUT <> 1", @Filter(name="ageFilter", condition="{u}.AGE < :age AND {s}.LOCKED_OUT <> 1",
aliases={@SqlFragmentAlias(alias="u", table="USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")}) aliases={@SqlFragmentAlias(alias="u", table="T_USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")})
public class User { public class User {
@Id @Id
@ -31,13 +32,14 @@ public class User {
@Column(name="AGE") @Column(name="AGE")
private int age; private int age;
@Column(name="USERNAME", table="SECURITY_USER") @Column(name="SECURITY_USERNAME", table="SECURITY_USER")
private String username; private String username;
@Column(name="PASSWORD", table="SECURITY_USER") @Column(name="SECURITY_PASSWORD", table="SECURITY_USER")
private String password; private String password;
@Column(name="LOCKED_OUT", table="SECURITY_USER") @Column(name="LOCKED_OUT", table="SECURITY_USER")
@Type( type = "numeric_boolean")
private boolean lockedOut; private boolean lockedOut;
public int getId() { public int getId() {

View File

@ -6,6 +6,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.Type;
@Entity @Entity
@Table(name="ZOOLOGY_MAMMAL") @Table(name="ZOOLOGY_MAMMAL")
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
public class Mammal extends Animal{ public class Mammal extends Animal{
@Column(name="IS_PREGNANT") @Column(name="IS_PREGNANT")
@Type( type="numeric_boolean" )
private boolean isPregnant; private boolean isPregnant;
public boolean isPregnant() { public boolean isPregnant() {

View File

@ -6,6 +6,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.Type;
@Entity @Entity
@Table(name="ZOOLOGY_MAMMAL") @Table(name="ZOOLOGY_MAMMAL")
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
public class Mammal extends Animal{ public class Mammal extends Animal{
@Column(name="IS_PREGNANT") @Column(name="IS_PREGNANT")
@Type( type="numeric_boolean" )
private boolean isPregnant; private boolean isPregnant;
public boolean isPregnant() { public boolean isPregnant() {

View File

@ -6,6 +6,7 @@ import javax.persistence.Table;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.Type;
@Entity @Entity
@Table(name="ZOOLOGY_MAMMAL") @Table(name="ZOOLOGY_MAMMAL")
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
public class Mammal extends Animal{ public class Mammal extends Animal{
@Column(name="IS_PREGNANT") @Column(name="IS_PREGNANT")
@Type( type="numeric_boolean" )
private boolean isPregnant; private boolean isPregnant;
public boolean isPregnant() { public boolean isPregnant() {

View File

@ -7,11 +7,13 @@ import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.test.annotations.id.sequences.entities.HibernateSequenceEntity; import org.hibernate.test.annotations.id.sequences.entities.HibernateSequenceEntity;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -19,6 +21,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@TestForIssue(jiraKey = "HHH-6068") @TestForIssue(jiraKey = "HHH-6068")
@RequiresDialect( value = H2Dialect.class)
public class HibernateSequenceTest extends BaseCoreFunctionalTestCase { public class HibernateSequenceTest extends BaseCoreFunctionalTestCase {
private static final String SCHEMA_NAME = "OTHER_SCHEMA"; private static final String SCHEMA_NAME = "OTHER_SCHEMA";

View File

@ -0,0 +1,44 @@
package org.hibernate.test.annotations.lob;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
/**
* @author Janario Oliveira
*/
@Entity
@TypeDefs({ @TypeDef(typeClass = ImplicitSerializableType.class, defaultForType = ImplicitSerializable.class) })
public class EntitySerialize {
@Id
@GeneratedValue
long id;
@Lob
ExplicitSerializable explicitLob;
@Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType")
ExplicitSerializable explicit;
ImplicitSerializable implicit;
@Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType")
ImplicitSerializable explicitOverridingImplicit;
/**
* common in ExplicitSerializable and ImplicitSerializable to create same property in both
* This property will not persist it have a default value per type
*
* @author Janario Oliveira
*/
public interface CommonSerializable {
String getDefaultValue();
void setDefaultValue(String defaultValue);
}
}

View File

@ -0,0 +1,23 @@
package org.hibernate.test.annotations.lob;
import java.io.Serializable;
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
/**
* @author Janario Oliveira
*/
public class ExplicitSerializable implements Serializable, CommonSerializable {
String defaultValue;
String value;
@Override
public String getDefaultValue() {
return defaultValue;
}
@Override
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
}

View File

@ -0,0 +1,30 @@
package org.hibernate.test.annotations.lob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
import org.hibernate.type.SerializableToBlobType;
/**
* @author Janario Oliveira
*/
public class ExplicitSerializableType extends SerializableToBlobType {
@Override
public Object get(ResultSet rs, String name) throws SQLException {
CommonSerializable deserialize = (CommonSerializable) super.get( rs, name );
deserialize.setDefaultValue( "EXPLICIT" );
return deserialize;
}
@Override
public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
if ( value != null ) {
( (CommonSerializable) value ).setDefaultValue( null );
}
super.set( st, value, index, session );
}
}

View File

@ -0,0 +1,23 @@
package org.hibernate.test.annotations.lob;
import java.io.Serializable;
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
/**
* @author Janario Oliveira
*/
public class ImplicitSerializable implements Serializable, CommonSerializable {
String defaultValue;
String value;
@Override
public String getDefaultValue() {
return defaultValue;
}
@Override
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
}

View File

@ -0,0 +1,31 @@
package org.hibernate.test.annotations.lob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
import org.hibernate.type.SerializableToBlobType;
/**
* @author Janario Oliveira
*/
public class ImplicitSerializableType extends SerializableToBlobType {
@Override
public Object get(ResultSet rs, String name) throws SQLException {
CommonSerializable deserialize = (CommonSerializable) super.get( rs, name );
deserialize.setDefaultValue( "IMPLICIT" );
return deserialize;
}
@Override
public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
if ( value != null ) {
( (CommonSerializable) value ).setDefaultValue( null );
}
super.set( st, value, index, session );
}
}

View File

@ -0,0 +1,89 @@
package org.hibernate.test.annotations.lob;
import static org.junit.Assert.assertEquals;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.SerializableToBlobType;
import org.hibernate.type.Type;
import org.junit.Test;
/**
* Test type definition for SerializableToBlobType
*
* @author Janario Oliveira
*/
public class SerializableToBlobTypeTest extends BaseCoreFunctionalTestCase {
@Test
public void testTypeDefinition() {
Configuration cfg = configuration();
PersistentClass pc = cfg.getClassMapping( EntitySerialize.class.getName() );
// explicitLob of SerializableToBlobType
Type explicitLobType = pc.getProperty( "explicitLob" ).getType();
assertEquals( ExplicitSerializable.class, explicitLobType.getReturnedClass() );
assertEquals( SerializableToBlobType.class.getName(), explicitLobType.getName() );
// explicit of ExplicitSerializableType
Type explicitType = pc.getProperty( "explicit" ).getType();
assertEquals( ExplicitSerializable.class, explicitType.getReturnedClass() );
assertEquals( ExplicitSerializableType.class.getName(), explicitType.getName() );
// implicit of ImplicitSerializableType
Type implicitType = pc.getProperty( "implicit" ).getType();
assertEquals( ImplicitSerializable.class, implicitType.getReturnedClass() );
assertEquals( ImplicitSerializableType.class.getName(), implicitType.getName() );
// explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType
Type overrideType = pc.getProperty( "explicitOverridingImplicit" ).getType();
assertEquals( ImplicitSerializable.class, overrideType.getReturnedClass() );
assertEquals( ExplicitSerializableType.class.getName(), overrideType.getName() );
}
@Test
public void testPersist() {
EntitySerialize entitySerialize = new EntitySerialize();
entitySerialize.explicitLob = new ExplicitSerializable();
entitySerialize.explicitLob.value = "explicitLob";
entitySerialize.explicitLob.defaultValue = "defaultExplicitLob";
entitySerialize.explicit = new ExplicitSerializable();
entitySerialize.explicit.value = "explicit";
entitySerialize.implicit = new ImplicitSerializable();
entitySerialize.implicit.value = "implicit";
entitySerialize.explicitOverridingImplicit = new ImplicitSerializable();
entitySerialize.explicitOverridingImplicit.value = "explicitOverridingImplicit";
Session session = openSession();
session.getTransaction().begin();
session.persist( entitySerialize );
session.getTransaction().commit();
session.close();
session = openSession();
EntitySerialize persistedSerialize = (EntitySerialize) session.get( EntitySerialize.class, entitySerialize.id );
assertEquals( "explicitLob", persistedSerialize.explicitLob.value );
assertEquals( "explicit", persistedSerialize.explicit.value );
assertEquals( "implicit", persistedSerialize.implicit.value );
assertEquals( "explicitOverridingImplicit", persistedSerialize.explicitOverridingImplicit.value );
assertEquals( "defaultExplicitLob", persistedSerialize.explicitLob.defaultValue );
assertEquals( "EXPLICIT", persistedSerialize.explicit.defaultValue );
assertEquals( "IMPLICIT", persistedSerialize.implicit.defaultValue );
assertEquals( "EXPLICIT", persistedSerialize.explicitOverridingImplicit.defaultValue );
session.close();
}
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] { EntitySerialize.class };
}
}

View File

@ -1,34 +1,36 @@
// $Id: AggressiveReleaseTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $ // $Id: AggressiveReleaseTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
package org.hibernate.test.connections; package org.hibernate.test.connections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.Connection; import java.sql.Connection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.junit.Test;
import org.hibernate.ConnectionReleaseMode; import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.internal.util.SerializationHelper; import org.hibernate.internal.util.SerializationHelper;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.jta.TestingJtaPlatformImpl; import org.hibernate.testing.jta.TestingJtaPlatformImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/** /**
* Implementation of AggressiveReleaseTest. * Implementation of AggressiveReleaseTest.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class AggressiveReleaseTest extends ConnectionManagementTestCase { public class AggressiveReleaseTest extends ConnectionManagementTestCase {
@Override @Override
public void configure(Configuration cfg) { public void configure(Configuration cfg) {

View File

@ -27,12 +27,15 @@ import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.RequiresDialect;
/** /**
* Implementation of BasicConnectionProviderTest. * Implementation of BasicConnectionProviderTest.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class BasicConnectionProviderTest extends ConnectionManagementTestCase { public class BasicConnectionProviderTest extends ConnectionManagementTestCase {
@Override @Override
protected Session getSessionUnderTest() { protected Session getSessionUnderTest() {

View File

@ -26,7 +26,9 @@ import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.internal.util.SerializationHelper; import org.hibernate.internal.util.SerializationHelper;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -45,6 +47,7 @@ import static org.junit.Assert.fail;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTestCase { public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTestCase {
@Override @Override
public final String[] getMappings() { public final String[] getMappings() {

View File

@ -24,12 +24,15 @@
package org.hibernate.test.connections; package org.hibernate.test.connections;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.RequiresDialect;
/** /**
* Implementation of CurrentSessionConnectionTest. * Implementation of CurrentSessionConnectionTest.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class CurrentSessionConnectionTest extends AggressiveReleaseTest { public class CurrentSessionConnectionTest extends AggressiveReleaseTest {
@Override @Override
protected Session getSessionUnderTest() throws Throwable { protected Session getSessionUnderTest() throws Throwable {

View File

@ -31,11 +31,13 @@ import org.hibernate.ConnectionReleaseMode;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Stoppable; import org.hibernate.service.spi.Stoppable;
import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.AfterClassOnce;
import org.hibernate.testing.BeforeClassOnce; import org.hibernate.testing.BeforeClassOnce;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaExport;
@ -44,6 +46,7 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class SuppliedConnectionTest extends ConnectionManagementTestCase { public class SuppliedConnectionTest extends ConnectionManagementTestCase {
private ConnectionProvider cp = ConnectionProviderBuilder.buildConnectionProvider(); private ConnectionProvider cp = ConnectionProviderBuilder.buildConnectionProvider();
private Connection connectionUnderTest; private Connection connectionUnderTest;

View File

@ -30,8 +30,10 @@ import org.hibernate.Session;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.context.internal.ThreadLocalSessionContext; import org.hibernate.context.internal.ThreadLocalSessionContext;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.transaction.spi.LocalStatus; import org.hibernate.engine.transaction.spi.LocalStatus;
import org.hibernate.testing.RequiresDialect;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -41,6 +43,7 @@ import static org.junit.Assert.fail;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase { public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase {
@Override @Override
public void configure(Configuration cfg) { public void configure(Configuration cfg) {

View File

@ -26,7 +26,8 @@ package org.hibernate.test.fileimport;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor; import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor; import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
@ -35,6 +36,10 @@ import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@TestForIssue( jiraKey = "HHH-2403" ) @TestForIssue( jiraKey = "HHH-2403" )
@RequiresDialect(value = H2Dialect.class,
jiraKey = "HHH-6286",
comment = "Only running the tests against H2, because the sql statements in the import file are not generic. " +
"This test should actually not test directly against the db")
public class CommandExtractorServiceTest extends MultiLineImportFileTest { public class CommandExtractorServiceTest extends MultiLineImportFileTest {
@Override @Override
public void configure(Configuration cfg) { public void configure(Configuration cfg) {

View File

@ -23,20 +23,20 @@
*/ */
package org.hibernate.test.propertyref; package org.hibernate.test.propertyref;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.H2Dialect;
import org.junit.Test; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class DoesNotWorkTest extends BaseCoreFunctionalTestCase { public class DoesNotWorkTest extends BaseCoreFunctionalTestCase {
@Override @Override
protected Class<?>[] getAnnotatedClasses() { protected Class<?>[] getAnnotatedClasses() {

View File

@ -23,22 +23,23 @@
*/ */
package org.hibernate.test.propertyref; package org.hibernate.test.propertyref;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List; import java.util.List;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.H2Dialect;
import org.junit.Test; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class DoesNotWorkWithHbmTest extends BaseCoreFunctionalTestCase { public class DoesNotWorkWithHbmTest extends BaseCoreFunctionalTestCase {
@Override @Override

View File

@ -37,19 +37,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
*/ */
public class SchemaExportSuppliedConnectionTest extends SchemaExportTest { public class SchemaExportSuppliedConnectionTest extends SchemaExportTest {
private ServiceRegistry serviceRegistry;
@Before
public void setUp() {
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
}
@After
public void tearDown() {
ServiceRegistryBuilder.destroy( serviceRegistry );
serviceRegistry = null;
}
@Override @Override
protected SchemaExport createSchemaExport(Configuration cfg) { protected SchemaExport createSchemaExport(Configuration cfg) {
return new SchemaExport( serviceRegistry, cfg ); return new SchemaExport( serviceRegistry, cfg );

View File

@ -23,10 +23,15 @@
*/ */
package org.hibernate.test.schemaupdate; package org.hibernate.test.schemaupdate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.tool.hbm2ddl.SchemaExport; import org.hibernate.tool.hbm2ddl.SchemaExport;
@ -44,6 +49,22 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect() return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect()
.supportsIfExistsBeforeTableName(); .supportsIfExistsBeforeTableName();
} }
protected ServiceRegistry serviceRegistry;
@Before
public void setUp() {
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
Configuration cfg = new Configuration();
cfg.addResource( MAPPING );
SchemaExport schemaExport = createSchemaExport( cfg );
schemaExport.drop( true, true );
}
@After
public void tearDown() {
ServiceRegistryBuilder.destroy( serviceRegistry );
serviceRegistry = null;
}
@Test @Test
public void testCreateAndDropOnlyType() { public void testCreateAndDropOnlyType() {
@ -52,12 +73,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
SchemaExport schemaExport = createSchemaExport( cfg ); SchemaExport schemaExport = createSchemaExport( cfg );
// create w/o dropping first; (OK because tables don't exist yet // create w/o dropping first; (OK because tables don't exist yet
schemaExport.execute( false, true, false, true ); schemaExport.execute( false, true, false, true );
if ( doesDialectSupportDropTableIfExist() ) { // if ( doesDialectSupportDropTableIfExist() ) {
assertEquals( 0, schemaExport.getExceptions().size() ); assertEquals( 0, schemaExport.getExceptions().size() );
} // }
else { // else {
assertEquals( 2, schemaExport.getExceptions().size() ); // assertEquals( 2, schemaExport.getExceptions().size() );
} // }
// create w/o dropping again; should be an exception for each table // create w/o dropping again; should be an exception for each table
// (2 total) because the tables exist already // (2 total) because the tables exist already
// assertEquals( 0, schemaExport.getExceptions().size() ); // assertEquals( 0, schemaExport.getExceptions().size() );
@ -96,7 +117,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
SchemaExport schemaExport = createSchemaExport( cfg ); SchemaExport schemaExport = createSchemaExport( cfg );
// should drop before creating, but tables don't exist yet // should drop before creating, but tables don't exist yet
schemaExport.create( true, true ); schemaExport.create( true, true );
if ( doesDialectSupportDropTableIfExist() ) {
assertEquals( 0, schemaExport.getExceptions().size() ); assertEquals( 0, schemaExport.getExceptions().size() );
}
else {
assertEquals( 2, schemaExport.getExceptions().size() );
}
// call create again; it should drop tables before re-creating // call create again; it should drop tables before re-creating
schemaExport.create( true, true ); schemaExport.create( true, true );
assertEquals( 0, schemaExport.getExceptions().size() ); assertEquals( 0, schemaExport.getExceptions().size() );

View File

@ -23,27 +23,29 @@
*/ */
package org.hibernate.test.service; package org.hibernate.test.service;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Properties; import java.util.Properties;
import org.junit.Test;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.testing.env.ConnectionProviderBuilder;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect( H2Dialect.class )
public class ServiceBootstrappingTest extends BaseUnitTestCase { public class ServiceBootstrappingTest extends BaseUnitTestCase {
@Test @Test
public void testBasicBuild() { public void testBasicBuild() {

View File

@ -23,44 +23,47 @@
*/ */
package org.hibernate.test.transaction.jta; package org.hibernate.test.transaction.jta;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.transaction.TransactionManager;
import org.junit.After; import javax.transaction.TransactionManager;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.ConnectionReleaseMode; import org.hibernate.ConnectionReleaseMode;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor; import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.test.common.JournalingTransactionObserver; import org.hibernate.test.common.JournalingTransactionObserver;
import org.hibernate.test.common.TransactionContextImpl; import org.hibernate.test.common.TransactionContextImpl;
import org.hibernate.test.common.TransactionEnvironmentImpl; import org.hibernate.test.common.TransactionEnvironmentImpl;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaBootstrap;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.After;
import static org.junit.Assert.assertEquals; import org.junit.Before;
import static org.junit.Assert.assertFalse; import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/** /**
* Testing transaction facade handling when the transaction is being driven by something other than the facade. * Testing transaction facade handling when the transaction is being driven by something other than the facade.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect(H2Dialect.class)
public class ManagedDrivingTest extends BaseUnitTestCase { public class ManagedDrivingTest extends BaseUnitTestCase {
private StandardServiceRegistryImpl serviceRegistry; private StandardServiceRegistryImpl serviceRegistry;