Methods Summary |
---|
public void | afterConfigurationBuilt(org.hibernate.cfg.Mappings mappings, org.hibernate.dialect.Dialect dialect)
|
public void | afterSessionFactoryBuilt(org.hibernate.engine.SessionFactoryImplementor sfi)
|
protected boolean | allowsPhysicalColumnNameInHaving(java.lang.String testDescription)Does the db/dialect support using a column's physical name in the having clause
even after it has been aliased in the select/group-by clause. This is not actually
required by the SQL spec, although virtually ever DB in the world supports this.
// I only *know* of this being a limitation on Derby, although I highly suspect
// it is a limitation on any IBM/DB2 variant
if ( DerbyDialect.class.isInstance( getDialect() ) ) {
// https://issues.apache.org/jira/browse/DERBY-1624
reportSkip( "Dialect does not support physical column name in having clause after it is aliased", testDescription );
return false;
}
return true;
|
protected boolean | allowsPhysicalColumnNameInOrderby(java.lang.String testDescription)Does the db/dialect support using a column's physical name in the order-by clause
even after it has been aliased in the select clause. This is not actually
required by the SQL spec, although virtually ever DB in the world supports this
(the most glaring omission here being IBM-variant DBs ala DB2 and Derby).
if ( DB2Dialect.class.isInstance( getDialect() ) ) {
// https://issues.apache.org/jira/browse/DERBY-1624
reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
return false;
}
return true;
|
public boolean | appliesTo(org.hibernate.dialect.Dialect dialect)Intended to indicate that this test class as a whole is intended for
a dialect or series of dialects. Skips here (appliesTo = false) therefore
simply indicate that the given tests target a particular feature of the
checked database and none of the tests on this class should be run for the
checked dialect.
return true;
|
protected void | assertAllDataRemoved()
if ( !createSchema() ) {
return; // no tables were created...
}
if ( !Boolean.getBoolean( "hibernate.test.validateDataCleanup" ) ) {
return;
}
Session tmpSession = getSessions().openSession();
try {
List list = tmpSession.createQuery( "select o from java.lang.Object o" ).list();
Map items = new HashMap();
if ( !list.isEmpty() ) {
for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
Object element = iter.next();
Integer l = ( Integer ) items.get( tmpSession.getEntityName( element ) );
if ( l == null ) {
l = new Integer( 0 );
}
l = new Integer( l.intValue() + 1 );
items.put( tmpSession.getEntityName( element ), l );
System.out.println( "Data left: " + element );
}
fail( "Data is left in the database: " + items.toString() );
}
}
finally {
try {
tmpSession.close();
}
catch( Throwable t ) {
// intentionally empty
}
}
|
protected void | cleanupTest()
|
public void | configure(org.hibernate.cfg.Configuration cfg)
|
public boolean | createSchema()
return true;
|
protected boolean | dialectIs(java.lang.Class dialectClass)
return dialectClass.isInstance( getDialect() );
|
protected boolean | dialectIsCaseSensitive(java.lang.String testDescription)Is the db/dialect sensitive in terms of string comparisons?
if ( ! getDialect().areStringComparisonsCaseInsensitive() ) {
reportSkip( "Dialect is case sensitive. ", testDescription );
return true;
}
return false;
|
protected boolean | dialectIsNot(java.lang.Class dialectClass)
return ! dialectIs( dialectClass );
|
protected boolean | dialectIsNot(java.lang.Class[] dialectClasses)
return ! dialectIsOneOf( dialectClasses );
|
protected boolean | dialectIsOneOf(java.lang.Class[] dialectClasses)
for ( int i = 0; i < dialectClasses.length; i++ ) {
if ( dialectClasses[i].isInstance( getDialect() ) ) {
return true;
}
}
return false;
|
protected boolean | dialectSupportsEmptyInList(java.lang.String testDescription)Does the db/dialect support empty lists in the IN operator?
For example, is "... a.b IN () ..." supported?
if ( ! getDialect().supportsEmptyInList() ) {
reportSkip( "Dialect does not support SQL empty in list : x in ()", testDescription );
return false;
}
return true;
|
public java.lang.String | getBaseForMappings()
return "org/hibernate/test/";
|
public java.lang.String | getCacheConcurrencyStrategy()
return "nonstrict-read-write";
|
protected org.hibernate.cfg.Configuration | getCfg()
return environment.getConfiguration();
|
protected org.hibernate.dialect.Dialect | getDialect()
return ExecutionEnvironment.DIALECT;
|
public ExecutionEnvironment | getEnvironment()
return environment;
|
protected org.hibernate.SessionFactory | getSessions()Get the factory for this test environment.
return environment.getSessionFactory();
|
public org.hibernate.classic.Session | openSession()
session = getSessions().openSession();
return session;
|
public org.hibernate.classic.Session | openSession(org.hibernate.Interceptor interceptor)
session = getSessions().openSession(interceptor);
return session;
|
public boolean | overrideCacheStrategy()
return true;
|
protected void | prepareTest()
|
protected boolean | readCommittedIsolationMaintained(java.lang.String scenario)Is connection at least read committed?
Not, that this skip check relies on the JDBC driver reporting
the true isolation level correctly. HSQLDB, for example, will
report whatever you specify as the isolation
(Connection.setTransationIsolation()), even though it only supports
read-uncommitted.
int isolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
Session testSession = null;
try {
testSession = openSession();
isolation = testSession.connection().getTransactionIsolation();
}
catch( Throwable ignore ) {
}
finally {
if ( testSession != null ) {
try {
testSession.close();
}
catch( Throwable ignore ) {
}
}
}
if ( isolation < java.sql.Connection.TRANSACTION_READ_COMMITTED ) {
reportSkip( "environment does not support at least read committed isolation", scenario );
return false;
}
else {
return true;
}
|
public boolean | recreateSchemaAfterFailure()
return true;
|
protected void | runTest()runTest is overridden in order to apply session closure assertions.
final boolean stats = sfi().getStatistics().isStatisticsEnabled();
try {
if ( stats ) {
sfi().getStatistics().clear();
}
super.runTest();
if ( stats ) {
sfi().getStatistics().logSummary();
}
if ( session != null && session.isOpen() ) {
if ( session.isConnected() ) {
session.connection().rollback();
}
session.close();
session = null;
fail( "unclosed session" );
}
else {
session = null;
}
assertAllDataRemoved();
}
catch ( Throwable e ) {
log.trace( "test run resulted in error; attempting to cleanup", e );
try {
if ( session != null && session.isOpen() ) {
if ( session.isConnected() ) {
session.connection().rollback();
}
session.close();
}
}
catch ( Exception ignore ) {
}
try {
if ( recreateSchemaAfterFailure() && environment != null ) {
environment.rebuild();
}
}
catch ( Exception ignore ) {
}
throw e;
}
|
public void | setEnvironment(ExecutionEnvironment environment)
this.environment = environment;
|
protected final void | setUp()Override {@link junit.framework.TestCase#setUp()} to check if we need
to build a locally managed execution environment.
if ( environment == null ) {
log.info( "Building locally managed execution env" );
isEnvironmentLocallyManaged = true;
environment = new ExecutionEnvironment( this );
environment.initialize();
}
prepareTest();
|
protected org.hibernate.engine.SessionFactoryImplementor | sfi()Get the factory for this test environment, casted to {@link org.hibernate.engine.SessionFactoryImplementor}.
Shorthand for ( {@link org.hibernate.engine.SessionFactoryImplementor} ) {@link #getSessions()}...
return ( SessionFactoryImplementor ) getSessions();
|
protected void | skipExpectedFailure(java.lang.Throwable error)
super.skipExpectedFailure( error );
try {
if ( recreateSchemaAfterFailure() && environment != null ) {
environment.rebuild();
}
}
catch ( Exception ignore ) {
}
|
protected boolean | supportsCircularCascadeDelete()
if ( ! getDialect().supportsCircularCascadeDeleteConstraints() ) {
reportSkip( "db/dialect does not support 'circular' cascade delete constraints", "cascade delete constraint support" );
return false;
}
return true;
|
protected boolean | supportsExpectedLobUsagePattern()Expected LOB usage pattern is such that I can perform an insert
via prepared statement with a parameter binding for a LOB value
without crazy casting to JDBC driver implementation-specific classes...
Part of the trickiness here is the fact that this is largely
driver dependent. For Oracle, which is notoriously bad with
LOB support in their drivers actually does a pretty good job with
LOB support as of the 10.2.x versions of their drivers...
if ( ! getDialect().supportsExpectedLobUsagePattern() ) {
reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
return false;
}
return true;
|
protected boolean | supportsLobValueChangePropogation()Does the current dialect support propogating changes to LOB
values back to the database? Talking about mutating the
underlying value as opposed to supplying a new
LOB instance...
if ( ! getDialect().supportsLobValueChangePropogation() ) {
reportSkip( "database/driver does not support propogating LOB value change back to database", "LOB support" );
return false;
}
return true;
|
protected boolean | supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
if ( ! getDialect().supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() ) {
reportSkip( "Driver does not support 'position query' methods on forward-only cursors", "query support" );
return false;
}
return true;
|
protected boolean | supportsRowValueConstructorSyntaxInInList()
if ( ! getDialect().supportsRowValueConstructorSyntaxInInList() ) {
reportSkip( "Dialect does not support 'tuple' syntax as part of an IN value list", "query support" );
return false;
}
return true;
|
protected boolean | supportsSubqueryOnMutatingTable()
if ( !getDialect().supportsSubqueryOnMutatingTable() ) {
reportSkip( "database/driver does not support referencing mutating table in subquery", "bulk DML support" );
return false;
}
return true;
|
protected boolean | supportsSubselectOnLeftSideIn()
if ( ! getDialect().supportsSubselectAsInPredicateLHS() ) {
reportSkip( "Database does not support (<subselect>) in ( ... ) ", "query support" );
return false;
}
return true;
|
protected boolean | supportsUnboundedLobLocatorMaterialization()Is it supported to materialize a LOB locator outside the transaction in
which it was created?
Again, part of the trickiness here is the fact that this is largely
driver dependent.
NOTE: all database I have tested which {@link #supportsExpectedLobUsagePattern()}
also support the ability to materialize a LOB outside the owning transaction...
if ( !getDialect().supportsUnboundedLobLocatorMaterialization() ) {
reportSkip( "database/driver does not support materializing a LOB locator outside the 'owning' transaction", "LOB support" );
return false;
}
return true;
|
protected final void | tearDown()Override {@link junit.framework.TestCase#tearDown()} to tear down
the execution environment if it is locally managed.
cleanupTest();
if ( isEnvironmentLocallyManaged ) {
log.info( "Destroying locally managed execution env" );
environment.complete();
environment = null;
}
|