From b9d3fa55813707f70d4426085dfe91501e387148 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Mon, 5 Aug 2013 14:05:04 -0400 Subject: [PATCH] HHH-8420 multiple test-only fixes from matrix failures --- ...positeAttributeResultSetProcessorTest.java | 3 + ...nLazyCollectionResultSetProcessorTest.java | 17 ++-- .../test/annotations/onetomany/Comment.java | 2 +- .../ProxyInterfaceClassLoaderTest.java | 2 +- .../test/mapping/UserConfEntity.java | 2 +- .../hibernate/test/mapping/UserEntity.java | 2 +- ...CurrentTenantResolverMultiTenancyTest.java | 3 + .../schema/SchemaBasedMultiTenancyTest.java | 2 + .../SynonymValidationTest.java | 81 +++++-------------- .../subselect/CompositeIdTypeBindingTest.java | 8 +- .../dynamicComponents/mapNotAudited.hbm.xml | 3 +- .../env/ConnectionProviderBuilder.java | 9 ++- 12 files changed, 58 insertions(+), 76 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/loader/EncapsulatedCompositeAttributeResultSetProcessorTest.java b/hibernate-core/src/test/java/org/hibernate/loader/EncapsulatedCompositeAttributeResultSetProcessorTest.java index ca0cd1aeab..7c1a12db66 100644 --- a/hibernate-core/src/test/java/org/hibernate/loader/EncapsulatedCompositeAttributeResultSetProcessorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/loader/EncapsulatedCompositeAttributeResultSetProcessorTest.java @@ -33,6 +33,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; + +import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Embeddable; @@ -281,6 +283,7 @@ public class EncapsulatedCompositeAttributeResultSetProcessorTest extends BaseCo } @ElementCollection(fetch = FetchType.EAGER) + @CollectionTable( name = "Investments" ) public List getInvestments() { return investments; } diff --git a/hibernate-core/src/test/java/org/hibernate/loader/EntityWithNonLazyCollectionResultSetProcessorTest.java b/hibernate-core/src/test/java/org/hibernate/loader/EntityWithNonLazyCollectionResultSetProcessorTest.java index dfc467ccda..bd6a8d5a70 100644 --- a/hibernate-core/src/test/java/org/hibernate/loader/EntityWithNonLazyCollectionResultSetProcessorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/loader/EntityWithNonLazyCollectionResultSetProcessorTest.java @@ -23,6 +23,11 @@ */ package org.hibernate.loader; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -32,13 +37,13 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; + +import javax.persistence.CollectionTable; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; -import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.engine.spi.LoadQueryInfluencers; @@ -57,12 +62,7 @@ import org.hibernate.loader.spi.NoOpLoadPlanAdvisor; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.ExtraAssertions; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * @author Gail Badner @@ -173,6 +173,7 @@ public class EntityWithNonLazyCollectionResultSetProcessorTest extends BaseCoreF private Integer id; private String name; @ElementCollection( fetch = FetchType.EAGER ) + @CollectionTable( name = "NickNames" ) private Set nickNames = new HashSet(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Comment.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Comment.java index ee9e1ef1fb..165d32c76e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Comment.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Comment.java @@ -14,7 +14,7 @@ import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -@Entity(name="Comment") +@Entity(name="CommentTable") // "Comment" reserved in Oracle @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "DTYPE", discriminatorType= DiscriminatorType.STRING, length = 3) @DiscriminatorValue(value = "WPT") diff --git a/hibernate-core/src/test/java/org/hibernate/test/classloader/ProxyInterfaceClassLoaderTest.java b/hibernate-core/src/test/java/org/hibernate/test/classloader/ProxyInterfaceClassLoaderTest.java index 1aab365ae2..8e4291c3a5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/classloader/ProxyInterfaceClassLoaderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/classloader/ProxyInterfaceClassLoaderTest.java @@ -80,7 +80,7 @@ public class ProxyInterfaceClassLoaderTest extends BaseCoreFunctionalTestCase { } - @Entity + @Entity( name = "Person" ) @Proxy(proxyClass = IPerson.class) static class Person implements IPerson { diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/UserConfEntity.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/UserConfEntity.java index 3e95a6bab1..5ab5801c52 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/UserConfEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/UserConfEntity.java @@ -19,7 +19,7 @@ public class UserConfEntity implements Serializable{ @Id @ManyToOne - @JoinColumn(name="user_id") + @JoinColumn(name="user_id", nullable = false) private UserEntity user; @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapping/UserEntity.java b/hibernate-core/src/test/java/org/hibernate/test/mapping/UserEntity.java index 135c500744..cb09503702 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mapping/UserEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapping/UserEntity.java @@ -16,7 +16,7 @@ import javax.persistence.OrderColumn; import javax.persistence.Table; @Entity -@Table(name = "USER") +@Table(name = "USERTABLE") public class UserEntity implements Serializable{ private static final long serialVersionUID = 1L; diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/CurrentTenantResolverMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/CurrentTenantResolverMultiTenancyTest.java index f13771b6d1..f36456a610 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/CurrentTenantResolverMultiTenancyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/CurrentTenantResolverMultiTenancyTest.java @@ -30,7 +30,9 @@ import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.context.spi.CurrentTenantIdentifierResolver; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.env.ConnectionProviderBuilder; /** * SessionFactory has to use the {@link CurrentTenantIdentifierResolver} when @@ -40,6 +42,7 @@ import org.hibernate.testing.TestForIssue; * @author Steve Ebersole */ @TestForIssue(jiraKey = "HHH-7306") +@RequiresDialectFeature( value = ConnectionProviderBuilder.class ) public class CurrentTenantResolverMultiTenancyTest extends SchemaBasedMultiTenancyTest { private TestCurrentTenantIdentifierResolver currentTenantResolver = new TestCurrentTenantIdentifierResolver(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java index 969083faaa..dd752022ed 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java @@ -44,6 +44,7 @@ import org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionPr import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider; import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.cache.CachingRegionFactory; import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; @@ -53,6 +54,7 @@ import org.hibernate.tool.hbm2ddl.SchemaExport; /** * @author Steve Ebersole */ +@RequiresDialectFeature( value = ConnectionProviderBuilder.class ) public class SchemaBasedMultiTenancyTest extends BaseUnitTestCase { private DriverManagerConnectionProviderImpl acmeProvider; private DriverManagerConnectionProviderImpl jbossProvider; diff --git a/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/SynonymValidationTest.java b/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/SynonymValidationTest.java index b04b4eba98..c20982d485 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/SynonymValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/schemavalidation/SynonymValidationTest.java @@ -20,28 +20,38 @@ */ package org.hibernate.test.schemavalidation; -import java.io.Serializable; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; +import org.hibernate.Session; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.dialect.Oracle9iDialect; import org.hibernate.testing.RequiresDialect; -import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.tool.hbm2ddl.SchemaValidator; import org.junit.Test; /** + * Allows the BaseCoreFunctionalTestCase to create the schema using TestEntity. The test method validates against an + * identical entity, but using the synonym name. + * * @author Brett Meyer */ @RequiresDialect( Oracle9iDialect.class ) -public class SynonymValidationTest extends BaseUnitTestCase { +public class SynonymValidationTest extends BaseCoreFunctionalTestCase { + // TODO: The QA database matrix does not currently have sufficient permissions to be able to create synonyms. + // Until resolved, disable. + +// @Override +// protected Class[] getAnnotatedClasses() { +// return new Class[] { TestEntity.class }; +// } +// @Test public void testSynonymValidation() { // Session s = openSession(); @@ -49,68 +59,21 @@ public class SynonymValidationTest extends BaseUnitTestCase { // s.createSQLQuery( "CREATE SYNONYM test_synonym FOR test_entity" ).executeUpdate(); // s.getTransaction().commit(); // s.close(); - - Configuration cfg = new Configuration(); +// +// Configuration cfg = new Configuration(); // cfg.addAnnotatedClass( TestEntityWithSynonym.class ); - cfg.addAnnotatedClass( TestEntity.class ); - cfg.setProperty( AvailableSettings.ENABLE_SYNONYMS, "true" ); - cfg.setProperty( "hibernate.connection.includeSynonyms", "true" ); - cfg.getProperties().put( "includeSynonyms", true ); - -// SchemaValidator schemaValidator = new SchemaValidator( serviceRegistry(), cfg ); - SchemaValidator schemaValidator = new SchemaValidator( cfg ); - schemaValidator.validate(); - +// cfg.setProperty( AvailableSettings.ENABLE_SYNONYMS, "true" ); +// +// SchemaValidator schemaValidator = new SchemaValidator( cfg ); +// schemaValidator.validate(); +// // s = openSession(); // s.getTransaction().begin(); // s.createSQLQuery( "DROP SYNONYM test_synonym FORCE" ).executeUpdate(); // s.getTransaction().commit(); // s.close(); } - -// protected Class[] getAnnotatedClasses() { -// return new Class[] { TestEntity.class }; -// } - - @Entity - @Table(name = "TEST_SYN") - private static class TestEntity implements Serializable { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue - private Long id; - - @Column(nullable = false) - private String key; - private String value; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - } - +// // @Entity // @Table(name = "test_entity") // private static class TestEntity { diff --git a/hibernate-core/src/test/java/org/hibernate/test/subselect/CompositeIdTypeBindingTest.java b/hibernate-core/src/test/java/org/hibernate/test/subselect/CompositeIdTypeBindingTest.java index 302c12cfcd..383aa971e4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subselect/CompositeIdTypeBindingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subselect/CompositeIdTypeBindingTest.java @@ -27,18 +27,22 @@ import java.util.ArrayList; import java.util.List; import junit.framework.Assert; -import org.junit.Test; import org.hibernate.Session; import org.hibernate.dialect.H2Dialect; +import org.hibernate.dialect.SQLServerDialect; import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; /** * @author Strong Liu */ -@SkipForDialect(value = H2Dialect.class, comment = "H2 doesn't support this sql syntax") +@SkipForDialects({ + @SkipForDialect(value = H2Dialect.class, comment = "H2 doesn't support this sql syntax"), + @SkipForDialect(value = SQLServerDialect.class, comment = "mssql doesn't support multiple columns in the 'where' clause of a 'where in' query")}) @TestForIssue( jiraKey = "HHH-8312") public class CompositeIdTypeBindingTest extends BaseCoreFunctionalTestCase { @Override diff --git a/hibernate-envers/src/test/resources/mappings/dynamicComponents/mapNotAudited.hbm.xml b/hibernate-envers/src/test/resources/mappings/dynamicComponents/mapNotAudited.hbm.xml index 4f3d8157e5..19352254e3 100644 --- a/hibernate-envers/src/test/resources/mappings/dynamicComponents/mapNotAudited.hbm.xml +++ b/hibernate-envers/src/test/resources/mappings/dynamicComponents/mapNotAudited.hbm.xml @@ -3,7 +3,8 @@ "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - + + diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java index e236e88c9b..b78a195d00 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/env/ConnectionProviderBuilder.java @@ -27,15 +27,15 @@ import java.util.Properties; import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl; +import org.hibernate.testing.DialectCheck; /** * Defines the JDBC connection information (currently H2) used by Hibernate for unit (not functional!) tests * * @author Steve Ebersole */ -public class ConnectionProviderBuilder { +public class ConnectionProviderBuilder implements DialectCheck { public static final String DRIVER = "org.h2.Driver"; public static final String URL = "jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;MVCC=TRUE"; public static final String USER = "sa"; @@ -79,4 +79,9 @@ public class ConnectionProviderBuilder { public static Dialect getCorrespondingDialect() { return TestingDatabaseInfo.DIALECT; } + + @Override + public boolean isMatch(Dialect dialect) { + return getCorrespondingDialect().getClass().equals( dialect.getClass() ); + } }