HHH-7602: Modified CustomRunner, BeforeClassCallbackHandler, and FailureExpectedHandler to handle exceptions in class methods. Marked tests appropriately with @FailureExpectedInNewMetamodel where necessary.
This commit is contained in:
parent
3ae06719fd
commit
57e4f3a9ea
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ import static org.junit.Assert.assertTrue;
|
|||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class HQLTest extends QueryTranslatorTestCase {
|
||||
@Override
|
||||
public boolean createSchema() {
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
<hibernate-mapping package="org.hibernate.test.connections">
|
||||
|
||||
<filter-def name="nameIsNull" condition="name is null" />
|
||||
|
||||
<class name="Silly">
|
||||
<id name="id" type="long">
|
||||
<generator class="increment"/>
|
||||
|
@ -20,6 +22,4 @@
|
|||
<property name="name"/>
|
||||
</class>
|
||||
|
||||
<filter-def name="nameIsNull" condition="name is null" />
|
||||
|
||||
</hibernate-mapping>
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<? extends Skip.Matcher> matcherClass, Throwable cause) {
|
||||
super( "Unable to instantiate specified Matcher [" + matcherClass.getName(), cause );
|
||||
}
|
||||
}
|
||||
|
||||
private TestClassMetadata testClassMetadata;
|
||||
private Boolean isAllTestsIgnored = null;
|
||||
private Object testInstance;
|
||||
private List<FrameworkMethod> 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<FrameworkMethod> computedTestMethods;
|
||||
|
||||
@Override
|
||||
protected List<FrameworkMethod> 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<? extends Annotation> 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<? extends Skip.Matcher> 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<? extends Annotation> annotationType() {
|
||||
return Ignore.class;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue