openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1156340 - /openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
Date Wed, 10 Aug 2011 19:47:24 GMT
Author: mikedd
Date: Wed Aug 10 19:47:24 2011
New Revision: 1156340

URL: http://svn.apache.org/viewvc?rev=1156340&view=rev
Log:
OPENJPA-2038: Add tests for tablename including schema

Modified:
    openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java

Modified: openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java?rev=1156340&r1=1156339&r2=1156340&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestDBDictionaryGeneratedSQL.java
Wed Aug 10 19:47:24 2011
@@ -113,6 +113,64 @@ public class TestDBDictionaryGeneratedSQ
         assertEquals(1, sqls.length);
         assertTrue(sqls[0].contains("NameIsRight"));
         assertTrue(sqls[0].contains("IAmASchema"));
-    }    
+    }
+    
+    public void testOverrideProperty() {
+        final JDBCConfiguration mockConfiguration = mock(JDBCConfiguration.class);
+        final DBIdentifierUtilImpl idImpl = new DBIdentifierUtilImpl();
+        
+        checking(new Expectations() {
+            {
+                allowing(mockConfiguration).getIdentifierUtilInstance();
+                will(returnValue(idImpl)); 
 
+                allowing(mockConfiguration);
+            }
+        });
+        
+        DBDictionary dict = new DBDictionary();
+        dict.setConfiguration(mockConfiguration);
+        dict.tableLengthIncludesSchema=true;
+        dict.maxTableNameLength = 12;
+
+        Table table = new Table();
+        table.setIdentifier(DBIdentifier.newTable("NameIsTooLong"));
+        table.setSchemaIdentifier(DBIdentifier.newSchema("IAmASchema"));
+        
+        try {
+            dict.getCreateTableSQL(table);
+            fail("Expected a UserException");
+        } catch (UserException ue) {
+            // expected - check message in case a different UserException is thrown.
+            assertTrue(ue.getMessage().contains("Table name \"IAmASchema.NameIsTooLong\""));
+        } 
+    }
+    
+    public void testOverridePropertyShortName() {
+        final JDBCConfiguration mockConfiguration = mock(JDBCConfiguration.class);
+        final DBIdentifierUtilImpl idImpl = new DBIdentifierUtilImpl();
+        
+        checking(new Expectations() {
+            {
+                allowing(mockConfiguration).getIdentifierUtilInstance();
+                will(returnValue(idImpl)); 
+
+                allowing(mockConfiguration);
+            }
+        });
+        
+        DBDictionary dict = new DBDictionary();
+        dict.setConfiguration(mockConfiguration);
+        dict.tableLengthIncludesSchema=true;
+        dict.maxTableNameLength = 18;
+
+        Table table = new Table();
+        table.setIdentifier(DBIdentifier.newTable("NameIsRight"));
+        table.setSchemaIdentifier(DBIdentifier.newSchema("schema"));
+        
+        String[] sqls = dict.getCreateTableSQL(table);
+        assertEquals(1, sqls.length);
+        assertTrue(sqls[0].contains("NameIsRight"));
+        assertTrue(sqls[0].contains("schema"));
+    }
 }



Mime
View raw message