HHH-11536 - Fix unit tests failing on Oracle

(cherry picked from commit e54ce7b266)

HHH-11536 - Fix unit tests failing on Oracle

(cherry picked from commit dd895c78b6)
(cherry picked from commit 2857189765)
This commit is contained in:
Andrea Boriero 2017-03-01 13:47:27 +00:00 committed by Gail Badner
parent 36d83f1e5e
commit a97a65be38
4 changed files with 29 additions and 7 deletions

View File

@ -10,6 +10,8 @@ import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@ -17,6 +19,7 @@ import static org.junit.Assert.assertNull;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@RequiresDialectFeature( value = DialectChecks.SupportsIdentityColumns.class)
public class NotFoundTest extends BaseCoreFunctionalTestCase { public class NotFoundTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testManyToOne() throws Exception { public void testManyToOne() throws Exception {

View File

@ -86,9 +86,18 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase {
catch ( SQLException e ) { catch ( SQLException e ) {
fail( "incorrect exception type : sqlexception" ); fail( "incorrect exception type : sqlexception" );
} }
finally {
try {
session.doWork( connection -> {
final Statement stmnt = connection.createStatement();
stmnt.execute( getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) );
} );
}
finally { finally {
session.close(); session.close();
} }
}
assertFalse( getResourceRegistry( jdbcCoord ).hasRegisteredResources() ); assertFalse( getResourceRegistry( jdbcCoord ).hasRegisteredResources() );
} }

View File

@ -15,7 +15,6 @@ import org.hibernate.ejb.AvailableSettings;
import org.hibernate.ejb.QueryHints; import org.hibernate.ejb.QueryHints;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.*;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.junit.Test; import org.junit.Test;
@ -28,6 +27,14 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.FutureTask; import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipForDialects;
import org.hibernate.testing.TestForIssue;
import static org.junit.Assert.*; import static org.junit.Assert.*;
/** /**
@ -98,9 +105,12 @@ public class LockTest extends BaseEntityManagerFunctionalTestCase {
fail( "Find with immediate timeout should have thrown LockTimeoutException." ); fail( "Find with immediate timeout should have thrown LockTimeoutException." );
} }
catch (PersistenceException pe) { catch (PersistenceException pe) {
log.info("EntityManager.find() for PESSIMISTIC_WRITE with timeout of 0 threw a PersistenceException.\n" + log.info(
"This is likely a consequence of " + getDialect().getClass().getName() + " not properly mapping SQL errors into the correct HibernateException subtypes.\n" + "EntityManager.find() for PESSIMISTIC_WRITE with timeout of 0 threw a PersistenceException.\n" +
"See HHH-7251 for an example of one such situation.", pe); "This is likely a consequence of " + getDialect().getClass()
.getName() + " not properly mapping SQL errors into the correct HibernateException subtypes.\n" +
"See HHH-7251 for an example of one such situation.", pe
);
fail( "EntityManager should be throwing LockTimeoutException." ); fail( "EntityManager should be throwing LockTimeoutException." );
} }
finally { finally {

View File

@ -38,7 +38,7 @@ public class MonotonicRevisionNumberTest extends BaseEnversFunctionalTestCase {
OrderedSequenceGenerator seqGenerator = (OrderedSequenceGenerator) generator; OrderedSequenceGenerator seqGenerator = (OrderedSequenceGenerator) generator;
Assert.assertTrue( Assert.assertTrue(
"Oracle sequence needs to be ordered in RAC environment.", "Oracle sequence needs to be ordered in RAC environment.",
seqGenerator.sqlCreateStrings( getDialect() )[0].endsWith( " order" ) seqGenerator.sqlCreateStrings( getDialect() )[0].toLowerCase().endsWith( " order" )
); );
} }
} }