You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2008/02/05 02:44:02 UTC

svn commit: r618507 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/tests/lang/ testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/ testing/org/apache/derbyTesting/junit/ tools/org/apache/derby/iapi/tools/i18n/

Author: myrnavl
Date: Mon Feb  4 17:44:01 2008
New Revision: 618507

URL: http://svn.apache.org/viewvc?rev=618507&view=rev
Log:
DERBY-3224 - modifications to enable running with phoneME advanced platform;
  changes are as follows:
  - org/apache/derby/iapi/tools/i18n/LocalizedInput.java - 
    Performance of ij tests improved by using a BufferedReader on top of the 
    InputStreamReader when ij read from its scriptfiles. 
    The reason is the use of some buffers when doing character conversion. 
    Every time the buffer is full, an exception object would be created, thrown and caught; for instance, during LangScripts test, when ij read 1 char at a time from the InputStream, this would happen 1.5 million times. Using the BufferedReader reduced the number of exceptions to 92, and made the test run a lot faster on this platform. 
  - GrantRevokeTest - clean up code was added (on phoneME advanced tests run in opposite order. )
  - CollationTest.java and CollationTest2.java - Added code to not run the tests for non-english locales if the locales are not supported
  - ForBitDataTest.java - clean up code was added
  - ScrollCursors1Test.java - clean up code was added
  - ForUpdateTest.java - Moved code from a test to general setup as it was needed by more than one test and thus fixtures were not independent of order.
  - UpdateCursorTest.java - clean up code was added
  - upgradeTests/_Suite.java - added code to prevent upgrade from 10.3.1.4
    because 10.3.1.4 doesn't boot on this platform (DERBY-3176).
  - BaseJDBCTestCase - added method to compare Time objects
patch contributed by Vermund Ostgaard 


Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateCursorTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
    db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java Mon Feb  4 17:44:01 2008
@@ -28,6 +28,8 @@
 import java.sql.Statement;
 import java.sql.Types;
 
+import java.text.Collator;
+import java.util.Locale;
 import javax.sql.DataSource;
 
 import junit.framework.Test;
@@ -1247,9 +1249,33 @@
         suite.addTest(new CleanDatabaseTestSetup(
                 new CollationTest("testDefaultCollation")));
         suite.addTest(collatedSuite("en", "testEnglishCollation"));
-        suite.addTest(collatedSuite("no", "testNorwayCollation"));
-        suite.addTest(collatedSuite("pl", "testPolishCollation"));
-        suite.addTest(collatedSuite("fr", "testFrenchCollation"));
+         
+        // Only add tests for other locales if they are in fact supported 
+        // by the jvm.
+        Locale[] availableLocales = Collator.getAvailableLocales();
+        boolean norwegian = false; 
+        boolean polish = false;
+        boolean french = false;
+        for (int i=0; i<availableLocales.length ; i++) {
+            if("no".equals(availableLocales[i].getLanguage())) {
+                norwegian = true;
+            }
+            if("pl".equals(availableLocales[i].getLanguage())) {
+                polish = true;
+            }
+            if("fr".equals(availableLocales[i].getLanguage())) {
+                french = true;
+            }
+        }
+        if(norwegian) {
+            suite.addTest(collatedSuite("no", "testNorwayCollation"));
+        }
+        if(polish) {
+            suite.addTest(collatedSuite("pl", "testPolishCollation"));
+        }
+        if(french) {
+            suite.addTest(collatedSuite("fr", "testFrenchCollation"));
+        }
         return suite;
     }
   

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java Mon Feb  4 17:44:01 2008
@@ -1901,8 +1901,26 @@
         TestSuite suite = new TestSuite("CollationTest2");
         suite.addTest(new CollationTest2("testDefaultCollation"));
         suite.addTest(collatedTest("en", "testEnglishCollation"));
-        suite.addTest(collatedTest("no_NO", "testNorwayCollation"));
-        suite.addTest(collatedTest("pl", "testPolishCollation"));
+        
+        // Only add tests for other locales if they are in fact supported 
+        // by the jvm.
+        Locale[] availableLocales = Collator.getAvailableLocales();
+        boolean norwegian = false; 
+        boolean polish = false;
+        for (int i=0; i<availableLocales.length ; i++) {
+            if("no".equals(availableLocales[i].getLanguage())) {
+                norwegian = true;
+            }
+            if("pl".equals(availableLocales[i].getLanguage())) {
+                polish = true;
+            }
+        }
+        if(norwegian) {
+            suite.addTest(collatedTest("no_NO", "testNorwayCollation"));
+        }
+        if(polish) {
+            suite.addTest(collatedTest("pl", "testPolishCollation"));
+        }
         suite.addTest(collatedTest(null, "testDefaultJVMTerritoryCollation"));
         
         // add support to use external files for import/export calls.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForBitDataTest.java Mon Feb  4 17:44:01 2008
@@ -632,6 +632,9 @@
 
         /* testValues fixture */
 	public void testValues() throws SQLException {
+                // Empty the table before inserting 
+                Statement deleteStmt = createStatement();
+                deleteStmt.execute("delete from FBDVAL.T001");
 		PreparedStatement psI = prepareStatement("INSERT INTO FBDVAL.T001 VALUES(?, ?, ?, ?, ?)");
 		PreparedStatement psS = prepareStatement("SELECT C1, C2, C3, C4, ID FROM FBDVAL.T001 WHERE ID >= ? AND ID < ? ORDER BY ID");
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ForUpdateTest.java Mon Feb  4 17:44:01 2008
@@ -79,6 +79,10 @@
 				s.execute("create table t2 ( s smallint, c char(10), r real, ts timestamp )");
                                 s.execute("create table t3 (i int not null constraint t3pk primary key, b char(10))");
 				s.execute("create table t4 (c1 int)");	
+                                s.execute("create index t3bi on t3(b)");
+                                s.execute("insert into t3 values (1, 'hhhh'), (2, 'uuuu'), (3, 'yyyy'), (4, 'aaaa'), (5, 'jjjj'), (6, 'rrrr')");
+                                s.execute("insert into t3 values (7, 'iiii'), (8, 'wwww'), (9, 'rrrr'), (10, 'cccc'), (11, 'hhhh'), (12, 'rrrr')");
+                                s.execute("insert into t4 (c1) values (1),(2),(3)");
             		}
         	};
     	} 
@@ -260,10 +264,6 @@
  
 	public void testStatistics() throws SQLException {
         Statement stmt = createStatement();
-		stmt.execute("create index t3bi on t3(b)");
-		stmt.execute("insert into t3 values (1, 'hhhh'), (2, 'uuuu'), (3, 'yyyy'), (4, 'aaaa'), (5, 'jjjj'), (6, 'rrrr')");
-		stmt.execute("insert into t3 values (7, 'iiii'), (8, 'wwww'), (9, 'rrrr'), (10, 'cccc'), (11, 'hhhh'), (12, 'rrrr')");
-		commit();
 
 		String [][] expectedValues = { {"1", "hhhh"}, 
 				               {"2", "uuuu"}, 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java Mon Feb  4 17:44:01 2008
@@ -735,6 +735,14 @@
         } catch (SQLException e) {
             assertSQLState("42506", e);
         }
+        
+        // clean up
+        revoke("select", "s1", "t1", "public");
+        revoke("all privileges", "s1", "t1", users[1]);
+        revoke("all privileges", "s1", "t1", users[2]);
+        assertAllPrivileges(false, users[1], "S1", "T1", null);
+        assertAllPrivileges(false, users[2], "S1", "T1", null);
+        
     }
     
     /* End testcases from grantRevokeDDL */

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ScrollCursors1Test.java Mon Feb  4 17:44:01 2008
@@ -532,8 +532,6 @@
          
             rs.close();  
             ps_c1.close();
-            s.executeUpdate("drop table t1");
-            s.executeUpdate("drop table t2");                       
         }
 
         public void testNoHoldScrollableResults() throws SQLException{
@@ -683,7 +681,7 @@
             assertEquals(1, rs.getInt(1));
             assertEquals(2, rs.getInt(2));
             rs.close();
-            s.executeUpdate("drop table t1");
+            s.executeUpdate("drop table u1.t1");
         }
         
         

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateCursorTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateCursorTest.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateCursorTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/UpdateCursorTest.java Mon Feb  4 17:44:01 2008
@@ -145,6 +145,12 @@
 		ResultSet cursor;
 		int expectedValue = 1;
 
+		/* drop index and recreate it to be sure that it is ascending
+                 * (other subtests may have changed it)
+                 */
+		assertUpdateCount(update, 0, "drop index I11");
+		assertUpdateCount(update, 0, "create index I11 on T1 (c3, c1, c5)");
+
 		cursor = select.executeQuery(); // cursor is now open
 		cursorName = cursor.getCursorName();
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/_Suite.java Mon Feb  4 17:44:01 2008
@@ -20,6 +20,8 @@
 */
 package org.apache.derbyTesting.functionTests.tests.upgradeTests;
 
+import java.util.Enumeration;
+import java.util.Properties;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -130,9 +132,19 @@
         for (int i = 0; i < OLD_VERSIONS.length; i++) {
             // JSR169 support was only added with 10.1, so don't
             // run 10.0 to later upgrade if that's what our jvm is supporting.
-            if (!(JDBC.vmSupportsJSR169() && 
-                (OLD_VERSIONS[i][0]==10) && (OLD_VERSIONS[i][1]==0)))
-                suite.addTest(UpgradeRun.suite(OLD_VERSIONS[i]));
+            if ((JDBC.vmSupportsJSR169() && 
+                (OLD_VERSIONS[i][0]==10) && (OLD_VERSIONS[i][1]==0))) {
+                continue;
+            }
+            // Derby 10.3.1.4 does not boot on the phoneME advanced platform,
+            // (see DERBY-3176) so don't run upgrade tests in this combination.
+            if ( System.getProperty("java.vm.name").equals("CVM")
+                  && System.getProperty("java.vm.version").startsWith("phoneme")
+                  && OLD_VERSIONS[i][0]==10 && OLD_VERSIONS[i][1]==3 
+                  && OLD_VERSIONS[i][2]==1 && OLD_VERSIONS[i][3]==4 ) {
+                continue;
+            }
+            suite.addTest(UpgradeRun.suite(OLD_VERSIONS[i]));
         }
 
         return suite;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Mon Feb  4 17:44:01 2008
@@ -702,6 +702,25 @@
     }
 
     /**
+     * Assert equality between two <code>java.sql.Time</code> objects.
+     * If both input references are <code>null</code>, they are considered
+     * equal.
+     *
+     * @param msg String with message to supply with AssertionFailedError
+     * @param t1 first java.sql.Time object.
+     * @param t2 second java.sql.Time object.
+     * @throws AssertionFailedError if Time objects are not equal.
+     */
+    public static void assertEquals(String msg, Time t1, Time t2) {
+        if(null == t1 && null == t2) {
+            return;
+        }
+        assertNotNull(msg, t1);
+        assertNotNull(msg, t2);
+        assertEquals(msg, t1.toString(), t2.toString());
+    }
+    
+    /**
      * Assert that SQLState is as expected.  If the SQLState for
      * the top-level exception doesn't match, look for nested
      * exceptions and, if there are any, see if they have the

Modified: db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java?rev=618507&r1=618506&r2=618507&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/iapi/tools/i18n/LocalizedInput.java Mon Feb  4 17:44:01 2008
@@ -20,20 +20,21 @@
  */
 package org.apache.derby.iapi.tools.i18n;
 
+import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.io.IOException;
 
-public class LocalizedInput extends InputStreamReader{
+public class LocalizedInput extends BufferedReader{
 	private InputStream in;
 	public LocalizedInput(InputStream i){
-		super(i);
+		super(new InputStreamReader(i));
 		this.in = i;
 	}
 
 	LocalizedInput(InputStream i, String encode) throws UnsupportedEncodingException{
-		super(i,encode);
+		super(new InputStreamReader(i,encode));
 		this.in = i;
 	}
 	public boolean isStandardInput(){