db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1492652 - in /db/derby/code/branches/10.10: ./ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/suites/ java/testing/org/apache/derbyTesting/functionTests/tests/i18n/ java/testin...
Date Thu, 13 Jun 2013 12:52:24 GMT
Author: kmarsden
Date: Thu Jun 13 12:52:23 2013
New Revision: 1492652

URL: http://svn.apache.org/r1492652
Log:
DERBY-4035 i18n tests fail with Lexical error on z/os
merge from trunk ...
DERBY-6244
convert i18n/caseI_tr_TR.sql to JUnit
1489924

DERBY-6246 convert i18n/urlLocale.sql  to JUnit
1490716 
1491364 

DERBY-6255 convert i18n/messageLocale.sql to JUnit
1491542 
1491590
1492088

convert ieptestsnegative_ES and I18NImportExport
1492393


Added:
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/CaseI_tr_TRTest.java
      - copied unchanged from r1489924, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/CaseI_tr_TRTest.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/I18NImportExport.java
      - copied unchanged from r1492393, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/I18NImportExport.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/ImportExportProcedureESTest.java
      - copied unchanged from r1492393, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/ImportExportProcedureESTest.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java
      - copied, changed from r1490716, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java
Removed:
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/master/caseI_tr_TR.out
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/master/iepnegativetests_ES.out
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/master/messageLocale.out
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/master/urlLocale.out
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/suites/i18nTest.runall
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/I18NImportExport_app.properties
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/caseI_tr_TR.sql
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/caseI_tr_TR_app.properties
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/iepnegativetests_ES.sql
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/iepnegativetests_ES_app.properties
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/iepnegativetests_ES_sed.properties
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/messageLocale.sql
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/messageLocale_app.properties
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/urlLocale.sql
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/urlLocale_app.properties
Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.properties
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/_Suite.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/Decorator.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1489924,1490716,1491005,1491364,1491542,1491590,1492088,1492393

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.properties
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.properties?rev=1492652&r1=1492651&r2=1492652&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.properties
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/suites/derbyall.properties
Thu Jun 13 12:52:23 2013
@@ -13,6 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-suites=derbylang storeall xa derbytools jdbc20 derbynetclientmats encryptionAll simpledemo
unit i18nTest
+suites=derbylang storeall xa derbytools jdbc20 derbynetclientmats encryptionAll simpledemo
unit 
 derby.debug.true=enableBtreeConsistencyCheck
 derby.stream.error.logSeverityLevel=0

Copied: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java
(from r1490716, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java?p2=db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java&r1=1490716&r2=1492652&rev=1492652&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/UrlLocaleTest.java
Thu Jun 13 12:52:23 2013
@@ -24,13 +24,16 @@ import java.net.MalformedURLException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.sql.SQLWarning;
 import java.sql.Statement;
+import java.util.Locale;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.LocaleTestSetup;
 import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -68,8 +71,7 @@ public class UrlLocaleTest extends BaseJ
         s.executeUpdate("call checkRDefaultLoc()");
         
             // create a swiss database
-        String url = TestConfiguration.getCurrent().
-                getJDBCUrl(SupportFilesSetup.getReadWrite("swissdb").getPath());
+        String url = getReadWriteJDBCURL("swissdb");
         url += ";create=true;territory=fr_CH";
         Connection locConn = DriverManager.getConnection(url);
         createLocaleProcedures(locConn);
@@ -80,8 +82,7 @@ public class UrlLocaleTest extends BaseJ
         
         //-- create a Hindi in India database (hi_IN)
         
-        url = TestConfiguration.getCurrent().getJDBCUrl(
-                SupportFilesSetup.getReadWrite("hindi").getPath());
+        url = getReadWriteJDBCURL("hindi");
         url += ";create=true;territory=hi_IN";
         locConn = DriverManager.getConnection(url);
         createLocaleProcedures(locConn);
@@ -91,8 +92,7 @@ public class UrlLocaleTest extends BaseJ
         locConn.close();
        //- now try one with a variant
        // -- create a English in Israel database for JavaOS en_IL_JavaOS
-        url = TestConfiguration.getCurrent().
-                getJDBCUrl(SupportFilesSetup.getReadWrite("Israel").getPath());
+        url = getReadWriteJDBCURL("Israel");
         url += ";create=true;territory=en_IL_JavaOS";
         locConn = DriverManager.getConnection(url);
         createLocaleProcedures(locConn);
@@ -103,8 +103,7 @@ public class UrlLocaleTest extends BaseJ
         
         // now try with just a language - we support this
         // as some vms do.
-        url = TestConfiguration.getCurrent().
-                getJDBCUrl(SupportFilesSetup.getReadWrite("bacon").getPath());
+        url = getReadWriteJDBCURL("bacon");
         url += ";create=true;territory=da";
         locConn = DriverManager.getConnection(url);
         createLocaleProcedures(locConn);
@@ -122,29 +121,154 @@ public class UrlLocaleTest extends BaseJ
      */
     public void testUrlLocaleNegative() throws SQLException {
         //Connection without territory specified in territory attribute        
-        String url = TestConfiguration.getCurrent().getJDBCUrl("../extinout/fail1");
+        String url = getReadWriteJDBCURL("fail1");
         url += ";create=true;territory=";
-        testInvalidTerritoryFormat(url);
+        checkInvalidTerritoryFormat(url);
         //- database will not have been created so this connection will fail
-        url = TestConfiguration.getCurrent().getJDBCUrl("../extinout/fail1");
+        url = getReadWriteJDBCURL("fail1");
         try {
-            Connection locConn = DriverManager.getConnection(url);
+            DriverManager.getConnection(url);
             fail("Database connect " + url + " should fail because db does not exist");
         }    catch (SQLException se ) {   
             assertSQLState("XJ004", se);
           }
         //Invalid territory specification
-        testInvalidTerritoryFormat("en_");
-        testInvalidTerritoryFormat("en_d");
-        testInvalidTerritoryFormat("en-US");
+        checkInvalidTerritoryFormat("en_");
+        checkInvalidTerritoryFormat("en_d");
+        checkInvalidTerritoryFormat("en-US");
         
     }
 
-    private void testInvalidTerritoryFormat(String territory) {
+    /**
+     * Test valid message resolution for an unknown Locale.
+     * converted from i18n/messageLocale.sql
+     *
+     * This test case must run in a decorator that sets the locale to one
+     * that is not recognized by Derby.
+     */
+    public void messageLocale_unknown() throws SQLException {
+        String url = getReadWriteJDBCURL("rrTTdb");
+        url += ";create=true";
+        Connection locConn = DriverManager.getConnection(url);
+        Statement s = locConn.createStatement();
+        createLocaleProcedures(locConn);
+        // check this current database was created with the default locale rr_TT
+        s.executeUpdate("call checkDefaultLoc()");
+        // check database Locale
+        s.executeUpdate("call checkDatabaseLoc('rr_TT')");
+        // Expect an error in English because rr_TT has no translated messages.
+        // Language is determined by choosing a random word (that we hope 
+        // won't change) in the current 
+        try {
+            s.executeUpdate("create table t1 oops (i int)");
+        } catch (SQLException se) {
+            assertSQLState("42X01", se);
+            assertTrue("Expected English Message with \"Encountered\" " ,
+                      (se.getMessage().indexOf("Encountered") != -1));
+            
+        }
+        // Setup for warning
+        s.executeUpdate("create table t2 (i int)");
+        s.executeUpdate("create index i2_a on t2(i)");
+
+        // Expect WARNING to also be English. Index is a duplicate
+        s.executeUpdate("create index i2_b on t2(i)");
+        SQLWarning sqlw = s.getWarnings();
+        assertSQLState("01504", sqlw);
+        assertTrue("Expected English warning", 
+                sqlw.getMessage().indexOf("duplicate") != -1);
+        
+        s.close();
+        locConn.close();
+    }
+      
+    /**
+     * Test valid message resolution for German Locale.
+     * converted from i18n/messageLocale.sql
+     *
+     * This test case must run in a decorator that sets the default locale
+     * to Locale.GERMANY.
+     */
+    public void messageLocale_Germany() throws SQLException {
+        //create a database with a locale that has a small
+        // number of messages. Missing ones will default to
+        // the locale of the default locale: German;
+        String url = getReadWriteJDBCURL("qqPPdb");
+        url += ";create=true;territory=qq_PP_testOnly";
+        Connection locConn = DriverManager.getConnection(url);
+        Statement s = locConn.createStatement();
+        s.executeUpdate("create table t2 (i int)");
+        s.executeUpdate("create index i2_a on t2(i)");
+        // Error that is in qq_PP messages
         try {
-            String url = TestConfiguration.getCurrent().getJDBCUrl("../extinout/fail3");
+            s.executeUpdate("create table t1 oops (i int)");
+        } catch (SQLException se) {
+            assertSQLState("42X01", se);
+            assertTrue("Expected qq_PP Message with \"Encountered\" " ,
+                      (se.getMessage().indexOf("Encountered") != -1));
+            
+        }
+        
+        // Expect WARNING to be in German (default) because there is no 
+        //qq_PP message. Index is a duplicate
+        s.executeUpdate("create index i2_b on t2(i)");
+        SQLWarning sqlw = s.getWarnings();
+        assertSQLState("01504", sqlw);
+        assertTrue("Expected German warning with Duplikat", 
+                sqlw.getMessage().indexOf(" Duplikat") != -1);
+        
+        // Error from default German Locale as it does not exist in qq_PP
+        // from default locale (German);
+        try {
+            s.executeUpdate("drop table t3");
+        } catch (SQLException se) {
+            assertSQLState("42Y55", se);
+            assertTrue("Expected German Message with vorhanden"  ,
+                      (se.getMessage().indexOf("vorhanden") != -1));
+            
+        }
+        
+        //Now all English messages
+        url =  getReadWriteJDBCURL("enUSdb");
+        url += ";create=true;territory=en_US";
+        locConn = DriverManager.getConnection(url);
+        s = locConn.createStatement();
+        s.executeUpdate("create table t2 (i int)");
+        s.executeUpdate("create index i2_a on t2(i)");
+
+        try {
+            s.executeUpdate("create table t1 oops (i int)");
+        } catch (SQLException se) {
+            assertSQLState("42X01", se);
+            assertTrue("Expected English message with \"Encountered\" " ,
+                      (se.getMessage().indexOf("Encountered") != -1));
+            
+        }
+        
+        // Expect WARNING to be in English because it is English db
+        // Even though German default Locale still
+        s.executeUpdate("create index i2_b on t2(i)");
+         sqlw = s.getWarnings();
+        assertSQLState("01504", sqlw);
+        assertTrue("Expected English warning with duplicate", 
+                sqlw.getMessage().indexOf("duplicate") != -1);
+ 
+        try {
+            s.executeUpdate("drop table t3");
+        } catch (SQLException se) {
+            assertSQLState("42Y55", se);
+            assertTrue("Expected English Message with performed"  ,
+                      (se.getMessage().indexOf("performed") != -1));
+            
+        }
+        
+    }
+  
+    private void checkInvalidTerritoryFormat(String territory) {
+        try {
+            String url = getReadWriteJDBCURL("fail3");
             url += ";create=true;territory=" + territory;
-            Connection locConn = DriverManager.getConnection(url);
+            DriverManager.getConnection(url);
             fail("connection without territory: " + url + "should have failed");
         } catch (SQLException se ) {
           assertSQLState("XJ041", se);
@@ -152,6 +276,16 @@ public class UrlLocaleTest extends BaseJ
         }
     }
     
+    /**
+     * Get JDBC URL for database to be accessed in the read-write directory
+     * @param dbname short database name to be created 
+     * @return the JDBC URL for the database
+     */
+    private static String getReadWriteJDBCURL(String dbname)
+   {
+        return TestConfiguration.getCurrent().
+        getJDBCUrl(SupportFilesSetup.getReadWriteFileName(dbname));
+    }
     
     /**
      * Create procedures to test current territory value
@@ -167,12 +301,22 @@ public class UrlLocaleTest extends BaseJ
                     "style java language java external name " +
                     "'org.apache.derbyTesting.functionTests.tests.i18n." +
                     "DefaultLocale.checkRDefaultLocale'");
-
+        s.executeUpdate("create procedure checkDefaultLoc() parameter " +
+                "style java language java external name " +
+                "'org.apache.derbyTesting.functionTests.tests.i18n." +
+                "DefaultLocale.checkDefaultLocale'");
     }
     
     public static Test suite() {
         TestSuite suite = new TestSuite();
         suite.addTestSuite(UrlLocaleTest.class);
+        suite.addTest(new LocaleTestSetup(
+                new UrlLocaleTest("messageLocale_unknown"),
+                new Locale("rr", "TT")));
+        suite.addTest(new LocaleTestSetup(
+                new UrlLocaleTest("messageLocale_Germany"),
+                Locale.GERMANY));
+
         Test tsuite =  new CleanDatabaseTestSetup(suite) {
             /**
              * Creates the table used in the test cases.

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/_Suite.java?rev=1492652&r1=1492651&r2=1492652&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/_Suite.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/i18n/_Suite.java
Thu Jun 13 12:52:23 2013
@@ -57,7 +57,10 @@ public class _Suite extends BaseTestCase
         suite.addTest(LocalizedAttributeScriptTest.suite());
         suite.addTest(LocalizedDisplayScriptTest.suite());
         suite.addTest(JapanCodeConversionTest.suite());
-
+        suite.addTest(CaseI_tr_TRTest.suite());
+        suite.addTest(UrlLocaleTest.suite());
+        suite.addTest(I18NImportExport.suite());
+        suite.addTest(ImportExportProcedureESTest.suite());
         return suite;
 	}
 }

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java?rev=1492652&r1=1492651&r2=1492652&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
Thu Jun 13 12:52:23 2013
@@ -70,6 +70,7 @@ public class DriverTest extends BaseJDBC
         "testcreatedb1", 
         "testcreatedb2",
         "testcreatedb3",
+        "trailblank",
         "'wombat'"
     };
     
@@ -530,6 +531,22 @@ public class DriverTest extends BaseJDBC
         
         assertConnect(false, url, null);
         shutdownDB(shuturl, null);
+        
+        // Test trailing spaces - Beetle 4653. Moved from urlLocale.sql
+        url = TestConfiguration.getCurrent().getJDBCUrl("trailblank");
+        url += ";create=true";
+        assertConnect(false,url,null);
+        
+        // regular connection with trailing spaces
+        url = TestConfiguration.getCurrent().
+                getJDBCUrl("trailblank     ");
+        assertConnect(true, url, null);
+        
+        // shutdown with trailing spaces
+        url = TestConfiguration.getCurrent().
+                getJDBCUrl("trailblank     ");
+        url += ";shutdown=true";
+        shutdownDB(url,null);
     }
     
     /**

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java?rev=1492652&r1=1492651&r2=1492652&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportProcedureTest.java
Thu Jun 13 12:52:23 2013
@@ -42,7 +42,7 @@ import junit.framework.TestSuite;
  * Converted from ieptests.sql
  *
  */
-public final class ImportExportProcedureTest extends BaseJDBCTestCase {
+public class ImportExportProcedureTest extends BaseJDBCTestCase {
 
     /**
      * Public constructor required for running test as standalone JUnit.

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/Decorator.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/Decorator.java?rev=1492652&r1=1492651&r2=1492652&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/Decorator.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/Decorator.java
Thu Jun 13 12:52:23 2013
@@ -213,7 +213,7 @@ public class Decorator {
      * @param test Test to decorate
      * @return Decorated test
      */
-    private static Test attributesDatabase(
+    public static Test attributesDatabase(
             final Properties attributes, Test test)
     {
         test = new ChangeConfigurationSetup(test) {

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java?rev=1492652&r1=1492651&r2=1492652&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/junit/SupportFilesSetup.java
Thu Jun 13 12:52:23 2013
@@ -29,6 +29,8 @@ import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 
+import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
+
 import junit.extensions.TestSetup;
 import junit.framework.Assert;
 import junit.framework.Test;
@@ -251,6 +253,17 @@ public class SupportFilesSetup extends T
         } 
     }
     /**
+     * Get the full name of the file.
+     * @param name short name of file
+     * @return absolute path of file in EXTINOUT
+     */
+    public static String getReadWriteFileName(final String name)
+    {
+        return 
+                PrivilegedFileOpsForTests.getAbsolutePath(getReadWrite(name));
+    }
+    
+    /**
      * Obtain a File for the local copy of a read-write resource.
      * @param name Base name for the resouce.
      */



Mime
View raw message