From bd5c483b67ac6d7873a0b2c9b8549930a1e40c00 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Tue, 5 Apr 2011 16:08:59 -0500 Subject: [PATCH] HHH-6073 : test fix up --- .../src/test/java/org/hibernate/dialect/Mocks.java | 14 ++++++++++++-- .../dialect/resolver/DialectFactoryTest.java | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/Mocks.java b/hibernate-core/src/test/java/org/hibernate/dialect/Mocks.java index e20357b321..7eee5abfc7 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/Mocks.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/Mocks.java @@ -35,8 +35,12 @@ import java.sql.SQLException; @SuppressWarnings( {"UnnecessaryBoxing"}) public class Mocks { - public static Connection createConnection(String dbName, int version) { - DatabaseMetaDataHandler metadataHandler = new DatabaseMetaDataHandler( dbName, version ); + public static Connection createConnection(String databaseName, int majorVersion) { + 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(); DatabaseMetaData metadataProxy = ( DatabaseMetaData ) Proxy.newProxyInstance( @@ -90,6 +94,7 @@ public class Mocks { private static class DatabaseMetaDataHandler implements InvocationHandler { private final String databaseName; private final int majorVersion; + private final int minorVersion; private Connection connectionProxy; @@ -98,8 +103,13 @@ public class Mocks { } private DatabaseMetaDataHandler(String databaseName, int majorVersion) { + this( databaseName, majorVersion, -9999 ); + } + + private DatabaseMetaDataHandler(String databaseName, int majorVersion, int minorVersion) { this.databaseName = databaseName; this.majorVersion = majorVersion; + this.minorVersion = minorVersion; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java index aae0a88109..a10de842fa 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/resolver/DialectFactoryTest.java @@ -33,6 +33,8 @@ import org.hibernate.HibernateException; import org.hibernate.cfg.Environment; import org.hibernate.dialect.DB2Dialect; import org.hibernate.dialect.DerbyDialect; +import org.hibernate.dialect.DerbyTenFiveDialect; +import org.hibernate.dialect.DerbyTenSixDialect; import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.InformixDialect; @@ -123,7 +125,10 @@ public class DialectFactoryTest extends BaseUnitTestCase { testDetermination( "H2", H2Dialect.class, resolver ); testDetermination( "MySQL", MySQLDialect.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 ); @@ -197,9 +202,14 @@ public class DialectFactoryTest extends BaseUnitTestCase { } 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 ); Properties properties = new Properties(); - Connection conn = Mocks.createConnection( databaseName, databaseMajorVersion ); + Connection conn = Mocks.createConnection( databaseName, majorVersion, minorVersion ); assertEquals( clazz, dialectFactory.buildDialect( properties, conn ).getClass() ); } + }