HHH-6073 : test fix up
This commit is contained in:
parent
5e8e49d3ae
commit
bd5c483b67
|
@ -35,8 +35,12 @@ import java.sql.SQLException;
|
||||||
@SuppressWarnings( {"UnnecessaryBoxing"})
|
@SuppressWarnings( {"UnnecessaryBoxing"})
|
||||||
public class Mocks {
|
public class Mocks {
|
||||||
|
|
||||||
public static Connection createConnection(String dbName, int version) {
|
public static Connection createConnection(String databaseName, int majorVersion) {
|
||||||
DatabaseMetaDataHandler metadataHandler = new DatabaseMetaDataHandler( dbName, version );
|
return createConnection( databaseName, majorVersion, -9999 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Connection createConnection(String databaseName, int majorVersion, int minorVersion) {
|
||||||
|
DatabaseMetaDataHandler metadataHandler = new DatabaseMetaDataHandler( databaseName, majorVersion, minorVersion );
|
||||||
ConnectionHandler connectionHandler = new ConnectionHandler();
|
ConnectionHandler connectionHandler = new ConnectionHandler();
|
||||||
|
|
||||||
DatabaseMetaData metadataProxy = ( DatabaseMetaData ) Proxy.newProxyInstance(
|
DatabaseMetaData metadataProxy = ( DatabaseMetaData ) Proxy.newProxyInstance(
|
||||||
|
@ -90,6 +94,7 @@ public class Mocks {
|
||||||
private static class DatabaseMetaDataHandler implements InvocationHandler {
|
private static class DatabaseMetaDataHandler implements InvocationHandler {
|
||||||
private final String databaseName;
|
private final String databaseName;
|
||||||
private final int majorVersion;
|
private final int majorVersion;
|
||||||
|
private final int minorVersion;
|
||||||
|
|
||||||
private Connection connectionProxy;
|
private Connection connectionProxy;
|
||||||
|
|
||||||
|
@ -98,8 +103,13 @@ public class Mocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
private DatabaseMetaDataHandler(String databaseName, int majorVersion) {
|
private DatabaseMetaDataHandler(String databaseName, int majorVersion) {
|
||||||
|
this( databaseName, majorVersion, -9999 );
|
||||||
|
}
|
||||||
|
|
||||||
|
private DatabaseMetaDataHandler(String databaseName, int majorVersion, int minorVersion) {
|
||||||
this.databaseName = databaseName;
|
this.databaseName = databaseName;
|
||||||
this.majorVersion = majorVersion;
|
this.majorVersion = majorVersion;
|
||||||
|
this.minorVersion = minorVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
|
|
|
@ -33,6 +33,8 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.DerbyDialect;
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
import org.hibernate.dialect.DerbyTenFiveDialect;
|
||||||
|
import org.hibernate.dialect.DerbyTenSixDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.dialect.InformixDialect;
|
import org.hibernate.dialect.InformixDialect;
|
||||||
|
@ -123,7 +125,10 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
||||||
testDetermination( "H2", H2Dialect.class, resolver );
|
testDetermination( "H2", H2Dialect.class, resolver );
|
||||||
testDetermination( "MySQL", MySQLDialect.class, resolver );
|
testDetermination( "MySQL", MySQLDialect.class, resolver );
|
||||||
testDetermination( "PostgreSQL", PostgreSQLDialect.class, resolver );
|
testDetermination( "PostgreSQL", PostgreSQLDialect.class, resolver );
|
||||||
testDetermination( "Apache Derby", DerbyDialect.class, resolver );
|
testDetermination( "Apache Derby", 10, 4, DerbyDialect.class, resolver );
|
||||||
|
testDetermination( "Apache Derby", 10, 5, DerbyTenFiveDialect.class, resolver );
|
||||||
|
testDetermination( "Apache Derby", 10, 6, DerbyTenSixDialect.class, resolver );
|
||||||
|
testDetermination( "Apache Derby", 11, 5, DerbyTenSixDialect.class, resolver );
|
||||||
testDetermination( "Ingres", IngresDialect.class, resolver );
|
testDetermination( "Ingres", IngresDialect.class, resolver );
|
||||||
testDetermination( "ingres", IngresDialect.class, resolver );
|
testDetermination( "ingres", IngresDialect.class, resolver );
|
||||||
testDetermination( "INGRES", IngresDialect.class, resolver );
|
testDetermination( "INGRES", IngresDialect.class, resolver );
|
||||||
|
@ -197,9 +202,14 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testDetermination(String databaseName, int databaseMajorVersion, Class clazz, DialectResolver resolver) {
|
private void testDetermination(String databaseName, int databaseMajorVersion, Class clazz, DialectResolver resolver) {
|
||||||
|
testDetermination( databaseName, databaseMajorVersion, -9999, clazz, resolver );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testDetermination(String databaseName, int majorVersion, int minorVersion, Class clazz, DialectResolver resolver) {
|
||||||
dialectFactory.setDialectResolver( resolver );
|
dialectFactory.setDialectResolver( resolver );
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
Connection conn = Mocks.createConnection( databaseName, databaseMajorVersion );
|
Connection conn = Mocks.createConnection( databaseName, majorVersion, minorVersion );
|
||||||
assertEquals( clazz, dialectFactory.buildDialect( properties, conn ).getClass() );
|
assertEquals( clazz, dialectFactory.buildDialect( properties, conn ).getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue