diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EntityHierarchyBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EntityHierarchyBuilder.java index 0f7cbb1705..3b7b6b556d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EntityHierarchyBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EntityHierarchyBuilder.java @@ -412,6 +412,7 @@ public class EntityHierarchyBuilder { info, JPADotNames.INHERITANCE ); if ( inheritanceAnnotation != null ) { +// if ( inheritanceAnnotation != null && !inheritanceAnnotation.value( "strategy" ).asString().equals( inheritanceType.toString() ) ) { throw new AnnotationException( String.format( "The inheritance type for %s must be specified on the root entity %s", diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/NonNullableCircularDependencyCascadeTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/NonNullableCircularDependencyCascadeTest.java index af45af5906..ab03530fcb 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/NonNullableCircularDependencyCascadeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/NonNullableCircularDependencyCascadeTest.java @@ -40,9 +40,9 @@ import static org.junit.Assert.fail; * @author Gail Badner */ @SuppressWarnings("unchecked") +@FailureExpectedWithNewMetamodel public class NonNullableCircularDependencyCascadeTest extends BaseCoreFunctionalTestCase { @Test - @FailureExpectedWithNewMetamodel public void testIdClassInSuperclass() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java index 6cfe367c74..e2ef6c390a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java @@ -37,6 +37,7 @@ import static org.junit.Assert.fail; /** * @author Steve Ebersole */ +@FailureExpectedWithNewMetamodel public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase { public static final String CARD_ID = "cardId"; public static final String KEY_ID = "keyId"; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/bidirectional/OneToOneWithDerivedIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/bidirectional/OneToOneWithDerivedIdentityTest.java index 6183728f06..8757a16fd9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/bidirectional/OneToOneWithDerivedIdentityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/derivedidentities/bidirectional/OneToOneWithDerivedIdentityTest.java @@ -32,9 +32,9 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +@FailureExpected(jiraKey = "HHH-5695") public class OneToOneWithDerivedIdentityTest extends BaseCoreFunctionalTestCase { @Test - @FailureExpected(jiraKey = "HHH-5695") public void testInsertFooAndBarWithDerivedId() { Session s = openSession(); s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/loader/LoaderTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/loader/LoaderTest.java index 22a8e074ff..33a655d7d6 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/loader/LoaderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/loader/LoaderTest.java @@ -38,6 +38,7 @@ import static org.junit.Assert.assertEquals; /** * @author Emmanuel Bernard */ +@FailureExpectedWithNewMetamodel public class LoaderTest extends BaseCoreFunctionalTestCase { @Override protected String[] getXmlFiles() { @@ -55,7 +56,6 @@ public class LoaderTest extends BaseCoreFunctionalTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testBasic() throws Exception { Session s = openSession(); Transaction tx = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java index 96ab9bddc0..e340352b4e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/referencedcolumnname/ManyToOneReferencedColumnNameTest.java @@ -36,10 +36,10 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; /** * @author Emmanuel Bernard */ +@FailureExpectedWithNewMetamodel public class ManyToOneReferencedColumnNameTest extends BaseCoreFunctionalTestCase { @Test @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) - @FailureExpectedWithNewMetamodel public void testReoverableExceptionInFkOrdering() throws Exception { //SF should not blow up Vendor v = new Vendor(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java index c63131040e..9a25747f04 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/AggressiveReleaseTest.java @@ -20,11 +20,10 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.internal.util.SerializationHelper; - -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.jta.TestingJtaBootstrap; import org.hibernate.testing.jta.TestingJtaPlatformImpl; + import org.junit.Test; /** @@ -34,6 +33,7 @@ import org.junit.Test; */ @RequiresDialect(H2Dialect.class) public class AggressiveReleaseTest extends ConnectionManagementTestCase { + @Override public void configure(Configuration cfg) { super.configure( cfg ); @@ -66,7 +66,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase { // Some additional tests specifically for the aggressive-release functionality... @Test - @FailureExpectedWithNewMetamodel public void testSerializationOnAfterStatementAggressiveRelease() throws Throwable { prepare(); try { @@ -91,7 +90,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testSerializationFailsOnAfterStatementAggressiveReleaseWithOpenResources() throws Throwable { prepare(); Session s = getSessionUnderTest(); @@ -132,7 +130,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testQueryIteration() throws Throwable { prepare(); Session s = getSessionUnderTest(); @@ -165,7 +162,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testQueryScrolling() throws Throwable { prepare(); Session s = getSessionUnderTest(); @@ -198,7 +194,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testSuppliedConnection() throws Throwable { prepare(); @@ -223,7 +218,6 @@ public class AggressiveReleaseTest extends ConnectionManagementTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testConnectionMaintanenceDuringFlush() throws Throwable { prepare(); Session s = getSessionUnderTest(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java b/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java index ba3a685f27..e3622c3400 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/ConnectionManagementTestCase.java @@ -22,19 +22,18 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.test.connections; -import org.junit.Test; - -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.internal.util.SerializationHelper; - -import org.hibernate.testing.FailureExpectedWithNewMetamodel; -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.internal.util.SerializationHelper; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; + +import org.junit.Test; + /** * Common test cases relating to session management and how the sessions * manages its underlying jdbc connection across different config @@ -139,8 +138,7 @@ public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTes * be allowed to serialize. */ @Test - @FailureExpectedWithNewMetamodel - public final void testConnectedSerialization() throws Throwable { + public void testConnectedSerialization() throws Throwable { prepare(); Session sessionUnderTest = getSessionUnderTest(); @@ -166,7 +164,6 @@ public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTes * be allowed to serialize. */ @Test - @FailureExpectedWithNewMetamodel public final void testEnabledFilterSerialization() throws Throwable { prepare(); Session sessionUnderTest = getSessionUnderTest(); @@ -205,7 +202,6 @@ public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTes * to serialize. */ @Test - @FailureExpectedWithNewMetamodel public final void testManualDisconnectedSerialization() throws Throwable { prepare(); Session sessionUnderTest = getSessionUnderTest(); @@ -224,7 +220,6 @@ public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTes * expected in the given environment. */ @Test - @FailureExpectedWithNewMetamodel public final void testManualDisconnectChain() throws Throwable { prepare(); Session sessionUnderTest = getSessionUnderTest(); @@ -253,8 +248,7 @@ public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTes * prior to disconnecting. */ @Test - @FailureExpectedWithNewMetamodel - public final void testManualDisconnectWithOpenResources() throws Throwable { + public void testManualDisconnectWithOpenResources() throws Throwable { prepare(); Session sessionUnderTest = getSessionUnderTest(); @@ -323,7 +317,6 @@ public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTes * Test that session-closed protections work properly in all environments. */ @Test - @FailureExpectedWithNewMetamodel public void testSessionClosedProtections() throws Throwable { prepare(); Session s = getSessionUnderTest(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/HibernateCreateBlobFailedCase.java b/hibernate-core/src/test/java/org/hibernate/test/connections/HibernateCreateBlobFailedCase.java index f51c0f2276..4e1967f655 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/HibernateCreateBlobFailedCase.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/HibernateCreateBlobFailedCase.java @@ -33,7 +33,6 @@ import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertFalse; @@ -43,7 +42,6 @@ import static org.junit.Assert.assertFalse; * * @author Steve Ebersole */ -@FailureExpectedWithNewMetamodel public class HibernateCreateBlobFailedCase extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java index b329a6a0e3..fa8eaa8669 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/SuppliedConnectionTest.java @@ -37,9 +37,11 @@ import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.spi.Stoppable; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; +import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.env.ConnectionProviderBuilder; import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.junit.Test; /** * Implementation of SuppliedConnectionTest. @@ -68,6 +70,30 @@ public class SuppliedConnectionTest extends ConnectionManagementTestCase { } } + /** + * {@inheritDoc} + * + * @see org.hibernate.test.connections.ConnectionManagementTestCase#testConnectedSerialization() + */ + @Override + @Test + @FailureExpectedWithNewMetamodel + public void testConnectedSerialization() throws Throwable { + super.testConnectedSerialization(); + } + + /** + * {@inheritDoc} + * + * @see org.hibernate.test.connections.ConnectionManagementTestCase#testManualDisconnectWithOpenResources() + */ + @Override + @Test + @FailureExpectedWithNewMetamodel + public void testManualDisconnectWithOpenResources() throws Throwable { + super.testManualDisconnectWithOpenResources(); + } + @Override protected Session getSessionUnderTest() throws Throwable { connectionUnderTest = cp.getConnection(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java b/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java index cc7797b1bd..baeb37bd53 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/connections/ThreadLocalCurrentSessionTest.java @@ -33,7 +33,6 @@ import org.hibernate.context.internal.ThreadLocalSessionContext; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.transaction.spi.LocalStatus; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.RequiresDialect; import static org.junit.Assert.assertEquals; @@ -89,7 +88,6 @@ public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase } @Test - @FailureExpectedWithNewMetamodel public void testTransactionProtection() { Session session = sessionFactory().getCurrentSession(); try { @@ -102,7 +100,6 @@ public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase } @Test - @FailureExpectedWithNewMetamodel public void testContextCleanup() { Session session = sessionFactory().getCurrentSession(); session.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java index 83effc5916..d8c5d904c4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/ComplexJoinAliasTest.java @@ -94,7 +94,7 @@ import static org.junit.Assert.assertEquals; * @author Chris Wilson * @link https://hibernate.onjira.com/browse/HHH-4630 */ - +@FailureExpectedWithNewMetamodel public class ComplexJoinAliasTest extends BaseCoreFunctionalTestCase { @Override @@ -106,7 +106,6 @@ public class ComplexJoinAliasTest extends BaseCoreFunctionalTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testCriteriaThroughCompositeId() throws Exception { Session session = openSession(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java index 1db1514208..d4ec54bb37 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java @@ -88,6 +88,7 @@ import static org.junit.Assert.assertTrue; * * @author Gavin King */ +@FailureExpectedWithNewMetamodel public class HQLTest extends QueryTranslatorTestCase { @Override public boolean createSchema() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java index c824bcec51..f65de20a44 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java @@ -99,6 +99,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +@FailureExpectedWithNewMetamodel public class FooBarTest extends LegacyTestCase { private static final Logger log = Logger.getLogger( FooBarTest.class ); @@ -1556,7 +1557,7 @@ public class FooBarTest extends LegacyTestCase { } private boolean isOuterJoinFetchingDisabled() { - return new Integer(0).equals( ( (SessionFactoryImplementor) sessionFactory() ).getSettings().getMaximumFetchDepth() ); + return new Integer(0).equals( sessionFactory().getSettings().getMaximumFetchDepth() ); } @Test @@ -1719,7 +1720,7 @@ public class FooBarTest extends LegacyTestCase { GlarchProxy g = new Glarch(); Multiplicity m = new Multiplicity(); m.count = 12; - m.glarch = (Glarch) g; + m.glarch = g; g.setMultiple(m); Session s = openSession(); @@ -4905,8 +4906,8 @@ public class FooBarTest extends LegacyTestCase { g2.setStrings(set); Session s = openSession(); Transaction t = s.beginTransaction(); - Serializable gid = (Serializable) s.save(g); - Serializable g2id = (Serializable) s.save(g2); + Serializable gid = s.save(g); + Serializable g2id = s.save(g2); t.commit(); assertTrue( g.getVersion()==0 ); assertTrue( g2.getVersion()==0 ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java index c844132341..e2c87aae8d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java @@ -59,6 +59,7 @@ import static org.junit.Assert.assertTrue; @SuppressWarnings( {"UnnecessaryUnboxing", "UnnecessaryBoxing"}) +@FailureExpectedWithNewMetamodel public class SQLFunctionsTest extends LegacyTestCase { private static final Logger log = Logger.getLogger( SQLFunctionsTest.class ); @@ -72,7 +73,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testDialectSQLFunctions() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -144,7 +144,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testSetProperties() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -185,7 +184,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testSetPropertiesMap() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -219,7 +217,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testBroken() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -252,7 +249,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testNothinToUpdate() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -277,7 +273,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testCachedQuery() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -341,7 +336,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testCachedQueryRegion() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -396,7 +390,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testSQLFunctions() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -558,7 +551,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testBlobClob() throws Exception { // Sybase does not support ResultSet.getBlob(String) if ( getDialect() instanceof SybaseDialect || getDialect() instanceof Sybase11Dialect || getDialect() instanceof SybaseASE15Dialect || getDialect() instanceof SybaseAnywhereDialect ) { @@ -655,7 +647,6 @@ public class SQLFunctionsTest extends LegacyTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testCachedQueryOnInsert() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); diff --git a/hibernate-core/src/test/resources/org/hibernate/test/connections/Silly.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/test/connections/Silly.hbm.xml index 4ec5d50a74..71d9c8180d 100644 --- a/hibernate-core/src/test/resources/org/hibernate/test/connections/Silly.hbm.xml +++ b/hibernate-core/src/test/resources/org/hibernate/test/connections/Silly.hbm.xml @@ -5,6 +5,8 @@ + + @@ -20,6 +22,4 @@ - - \ No newline at end of file diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BeforeClassCallbackHandler.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BeforeClassCallbackHandler.java index cccb016f9e..88274c843e 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BeforeClassCallbackHandler.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BeforeClassCallbackHandler.java @@ -23,14 +23,14 @@ */ package org.hibernate.testing.junit4; -import org.jboss.logging.Logger; +import org.hibernate.testing.FailureExpected; +import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.junit.runners.model.Statement; /** * @author Steve Ebersole */ public class BeforeClassCallbackHandler extends Statement { - private static final Logger log = Logger.getLogger( BeforeClassCallbackHandler.class ); private final CustomRunner runner; private final Statement wrappedStatement; @@ -45,9 +45,13 @@ public class BeforeClassCallbackHandler extends Statement { try { runner.getTestClassMetadata().performBeforeClassCallbacks( runner.getTestInstance() ); } - catch (CallbackException e) { - // be nice to see the exception. but junit seems to be eating it... - log.error( "Before class callback error : " + e.getLocalizedMessage(), e ); + catch ( CallbackException error ) { + runner.setBeforeClassMethodFailed(); + if ( runner.getTestClass().getJavaClass().getAnnotation( FailureExpected.class ) == null && + ( !runner.useNewMetamodel() || + runner.getTestClass().getJavaClass().getAnnotation( FailureExpectedWithNewMetamodel.class ) == null ) ) { + throw error; + } } wrappedStatement.evaluate(); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java index c4c2f3e6ee..6714f7e56b 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java @@ -55,9 +55,32 @@ import org.hibernate.testing.SkipForDialect; * @author Steve Ebersole */ public class CustomRunner extends BlockJUnit4ClassRunner { + private static final Logger log = Logger.getLogger( CustomRunner.class ); + private static Dialect dialect = determineDialect(); + + private static Dialect determineDialect() { + try { + return Dialect.getDialect(); + } + catch( Exception e ) { + return new Dialect() { + }; + } + } + + private static class MatcherInstantiationException extends RuntimeException { + private MatcherInstantiationException(Class matcherClass, Throwable cause) { + super( "Unable to instantiate specified Matcher [" + matcherClass.getName(), cause ); + } + } private TestClassMetadata testClassMetadata; + private Boolean isAllTestsIgnored = null; + private Object testInstance; + private List computedTestMethods; + private Boolean useNewMetamodel; + private boolean beforeClassMethodFailed; public CustomRunner(Class clazz) throws InitializationError { super( clazz ); @@ -70,12 +93,18 @@ public class CustomRunner extends BlockJUnit4ClassRunner { testClassMetadata.validate( errors ); } + boolean beforeClassMethodFailed() { + return beforeClassMethodFailed; + } + + void setBeforeClassMethodFailed() { + beforeClassMethodFailed = true; + } + public TestClassMetadata getTestClassMetadata() { return testClassMetadata; } - private Boolean isAllTestsIgnored = null; - private boolean isAllTestsIgnored() { if ( isAllTestsIgnored == null ) { if ( computeTestMethods().isEmpty() ) { @@ -122,11 +151,9 @@ public class CustomRunner extends BlockJUnit4ClassRunner { protected Statement methodBlock(FrameworkMethod method) { final Statement originalMethodBlock = super.methodBlock( method ); final ExtendedFrameworkMethod extendedFrameworkMethod = (ExtendedFrameworkMethod) method; - return new FailureExpectedHandler( originalMethodBlock, testClassMetadata, extendedFrameworkMethod, testInstance ); + return new FailureExpectedHandler( this, originalMethodBlock, testClassMetadata, extendedFrameworkMethod, testInstance ); } - private Object testInstance; - protected Object getTestInstance() throws Exception { if ( testInstance == null ) { testInstance = super.createTest(); @@ -139,8 +166,6 @@ public class CustomRunner extends BlockJUnit4ClassRunner { return getTestInstance(); } - private List computedTestMethods; - @Override protected List computeTestMethods() { if ( computedTestMethods == null ) { @@ -169,9 +194,6 @@ public class CustomRunner extends BlockJUnit4ClassRunner { final boolean doValidation = Boolean.valueOf( System.getProperty( Helper.VALIDATE_FAILURE_EXPECTED, "true" ) ); - final boolean useNewMetamodel = Boolean.valueOf( - System.getProperty( BaseCoreFunctionalTestCase.USE_NEW_METADATA_MAPPINGS, "true" ) - ); int testCount = 0; Ignore virtualIgnore; @@ -179,7 +201,7 @@ public class CustomRunner extends BlockJUnit4ClassRunner { for ( FrameworkMethod frameworkMethod : methods ) { FailureExpected failureExpected = null; // Convert @FailureExpectedWithNewMetamodel annotations to @FailureExpected annotations - if ( useNewMetamodel ) { + if ( useNewMetamodel() ) { final FailureExpectedWithNewMetamodel failureExpectedWithNewMetamodel = Helper.locateAnnotation( FailureExpectedWithNewMetamodel.class, frameworkMethod, getTestClass() ); if ( failureExpectedWithNewMetamodel != null ) { @@ -219,35 +241,11 @@ public class CustomRunner extends BlockJUnit4ClassRunner { return result; } - @SuppressWarnings( {"ClassExplicitlyAnnotation"}) - public static class IgnoreImpl implements Ignore { - private final String value; - - public IgnoreImpl(String value) { - this.value = value; - } - - @Override - public String value() { - return value; - } - - @Override - public Class annotationType() { - return Ignore.class; - } - } - - private static Dialect dialect = determineDialect(); - - private static Dialect determineDialect() { - try { - return Dialect.getDialect(); - } - catch( Exception e ) { - return new Dialect() { - }; + boolean useNewMetamodel() { + if ( useNewMetamodel == null ) { + useNewMetamodel = Boolean.valueOf( System.getProperty( BaseCoreFunctionalTestCase.USE_NEW_METADATA_MAPPINGS, "true" ) ); } + return useNewMetamodel; } protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) { @@ -355,10 +353,22 @@ public class CustomRunner extends BlockJUnit4ClassRunner { } } - private static class MatcherInstantiationException extends RuntimeException { - private MatcherInstantiationException(Class matcherClass, Throwable cause) { - super( "Unable to instantiate specified Matcher [" + matcherClass.getName(), cause ); + @SuppressWarnings( {"ClassExplicitlyAnnotation"}) + public static class IgnoreImpl implements Ignore { + private final String value; + + public IgnoreImpl(String value) { + this.value = value; + } + + @Override + public String value() { + return value; + } + + @Override + public Class annotationType() { + return Ignore.class; } } - } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/FailureExpectedHandler.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/FailureExpectedHandler.java index 6dbb878e48..b00743c59a 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/FailureExpectedHandler.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/FailureExpectedHandler.java @@ -35,16 +35,19 @@ import org.hibernate.testing.FailureExpected; class FailureExpectedHandler extends Statement { private static final Logger log = Logger.getLogger( FailureExpectedHandler.class ); + private final CustomRunner runner; private final TestClassMetadata testClassMetadata; private final ExtendedFrameworkMethod extendedFrameworkMethod; private final Statement realInvoker; private final Object testInstance; public FailureExpectedHandler( + CustomRunner runner, Statement realInvoker, TestClassMetadata testClassMetadata, ExtendedFrameworkMethod extendedFrameworkMethod, Object testInstance) { + this.runner = runner; this.realInvoker = realInvoker; this.testClassMetadata = testClassMetadata; this.extendedFrameworkMethod = extendedFrameworkMethod; @@ -53,6 +56,9 @@ class FailureExpectedHandler extends Statement { @Override public void evaluate() throws Throwable { + if ( runner.beforeClassMethodFailed() ) { + return; + } final FailureExpected failureExpected = extendedFrameworkMethod.getFailureExpectedAnnotation(); try { realInvoker.evaluate();