db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1157923 - in /db/derby/code/branches/10.8: ./ java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ java/testing/org/apache/derbyTesting/functionTests/tests/lang/ java/testing/org/apache/derbyTesting/functionTests/tests/tools/
Date Mon, 15 Aug 2011 17:42:33 GMT
Author: myrnavl
Date: Mon Aug 15 17:42:33 2011
New Revision: 1157923

URL: http://svn.apache.org/viewvc?rev=1157923&view=rev
Log:
DERBY-5287; tasks for 10.8.2. release
  backporting the following revisions to 10.8:
   1095247 (DERBY-4260) - derbynet.NetworkServerControlClientCommandTest) 
   1098033 (DERBY-5211) - tools.SysinfoCPCheckTest
   1134139 (DERBY-5252) - lang.GrantRevokeTest
  to facilitate testing in non-English locale.
  merge commands:
   svn merge -c (rev#) https://svn.apache.org/repos/asf/db/derby/code/trunk

Modified:
    db/derby/code/branches/10.8/   (props changed)
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoCPCheckTest.java

Propchange: db/derby/code/branches/10.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 15 17:42:33 2011
@@ -1,2 +1,2 @@
 /db/derby/code/branches/10.7:1061570,1061578,1082235
-/db/derby/code/trunk:1063809,1088633,1091000,1091221,1091285,1092067,1092795,1094315,1094572,1094728,1096741,1096890,1097247,1097249,1097460,1097469,1097471,1101059,1101839,1102620,1102826,1103681,1103718,1103742,1125305,1126358,1126468,1127825,1127883,1129136,1129764,1129797,1130077,1130084,1130632,1130895,1131030,1131272,1132546,1132664,1132860,1132928,1133304,1133317,1133741,1133752,1136363,1136371,1136397,1136844,1138201,1138341,1138444,1138787,1138795,1139449,1139451,1141924,1142583,1142635,1146644,1146915,1146962,1148344,1148354,1148658,1151101,1151612
+/db/derby/code/trunk:1063809,1088633,1091000,1091221,1091285,1092067,1092795,1094315,1094572,1094728,1095247,1096741,1096890,1097247,1097249,1097460,1097469,1097471,1098033,1101059,1101839,1102620,1102826,1103681,1103718,1103742,1125305,1126358,1126468,1127825,1127883,1129136,1129764,1129797,1130077,1130084,1130632,1130895,1131030,1131272,1132546,1132664,1132860,1132928,1133304,1133317,1133741,1133752,1134139,1136363,1136371,1136397,1136844,1138201,1138341,1138444,1138787,1138795,1139449,1139451,1141924,1142583,1142635,1146644,1146915,1146962,1148344,1148354,1148658,1151101,1151612

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java?rev=1157923&r1=1157922&r2=1157923&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
Mon Aug 15 17:42:33 2011
@@ -22,8 +22,6 @@ limitations under the License.
 package org.apache.derbyTesting.functionTests.tests.derbynet;
 
 import java.io.IOException;
-import java.util.Locale;
-
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -38,50 +36,95 @@ public class NetworkServerControlClientC
 
     public NetworkServerControlClientCommandTest(String name) {
         super(name);
-
+    }
+    
+    public void testPingWithoutArgs() throws InterruptedException, IOException {
+        if (!hasDefaultDerbyPortUsing()) {
+            /* If the port isn't the default one, we make sure that the test passes.
+             * The -p parameter isn't specified here.
+             * Changed to accomodate DERBY-4217
+             */
+            return;
+        }        
+        
+        String[] pingWithoutArgsCmd = new String[] {
+                "org.apache.derby.drda.NetworkServerControl", "ping" };
+        
+        pingWithoutArgsCmd = decorateCmdWithEnglishLocale(pingWithoutArgsCmd); 
+        
+        assertSuccessfulPing(pingWithoutArgsCmd);                
+    }
+    
+    private boolean hasDefaultDerbyPortUsing() {
+        return TestConfiguration.getCurrent().getPort() ==
+                DerbyConstants.DEFAULT_DERBY_PORT;
     }
 
-    /**
-     * Test various ping commands from the command line
-     * 
-     * @throws Exception
+    /*
+     * English locale is neccessary for running on non-English Locale.
+     * See #Derby-4260
      */
-    public void testPing() throws Exception {
-        String currentHost = TestConfiguration.getCurrent().getHostName();
-        String currentPort = Integer.toString(TestConfiguration.getCurrent().getPort());
-        String bogusPort = Integer.toString(
-                TestConfiguration.getCurrent().getBogusPort());
+    private String[] decorateCmdWithEnglishLocale(String[] cmd) {
+        String[] newCmd = new String[cmd.length + 1];
+        newCmd[0] = "-Dderby.ui.locale=en_US";
         
-        String[] pingCmd1 = new String[] {
-                "org.apache.derby.drda.NetworkServerControl", "ping" };
-        String[] pingCmd3 = new String[] {"org.apache.derby.drda.NetworkServerControl",
-                "ping", "-h", currentHost};
+        System.arraycopy(cmd, 0, newCmd, 1, cmd.length);
         
-        /* If the port isn't the default one, we make sure that these two tests pass.
-         * The -p parameter isn't specified here.
-         * Changed to accomodate DERBY-4217
-         */
-        if (TestConfiguration.getCurrent().getPort() ==
-                DerbyConstants.DEFAULT_DERBY_PORT) {
-	        assertSuccessfulPing(pingCmd1);
-            assertSuccessfulPing(pingCmd3);
-        }
+        return newCmd;
+    }
+    
+    public void testPingWithDefinedHost() throws InterruptedException, IOException {
+        if (!hasDefaultDerbyPortUsing()) {
+            /* If the port isn't the default one, we make sure that the test passes.
+             * The -p parameter isn't specified here.
+             * Changed to accomodate DERBY-4217
+             */
+            return;
+        }        
         
-        String[] pingCmd2 = new String[] {
+        String currentHost = TestConfiguration.getCurrent().getHostName();
+        String[] pingWithoutArgsCmd = new String[] {
+                "org.apache.derby.drda.NetworkServerControl", "ping", "-h", currentHost};
+                
+        pingWithoutArgsCmd = decorateCmdWithEnglishLocale(pingWithoutArgsCmd);
+                
+        assertSuccessfulPing(pingWithoutArgsCmd);
+    }
+    
+    public void testPingWithDefinedHostAndPort() throws InterruptedException, IOException
{
+        String currentPort = Integer.toString(TestConfiguration.getCurrent().getPort());
+        String currentHost = TestConfiguration.getCurrent().getHostName();
+        String[] pingWithoutArgsCmd = new String[] {
                 "org.apache.derby.drda.NetworkServerControl", "ping", "-h",
                 currentHost, "-p", currentPort};
-        assertSuccessfulPing(pingCmd2);
         
-        String[] pingCmd4 = new String[] {
-                "org.apache.derby.drda.NetworkServerControl", "ping", "-h",
-                "nothere" };
-        assertFailedPing(pingCmd4,"Unable to find host");
-        String[] pingCmd5= new String[] {"org.apache.derby.drda.NetworkServerControl",
-        "ping", "-h", currentHost, "-p", bogusPort};
-        assertFailedPing(pingCmd5,"Could not connect to Derby Network Server");
-
+        pingWithoutArgsCmd = decorateCmdWithEnglishLocale(pingWithoutArgsCmd);
+        
+        assertSuccessfulPing(pingWithoutArgsCmd);
     }
-
+    
+    public void testPingWithWrongHost() throws InterruptedException, IOException {
+        String[] pingWithoutArgsCmd = new String[] {
+                "org.apache.derby.drda.NetworkServerControl", "ping", "-h", "nothere"};
+                
+        pingWithoutArgsCmd = decorateCmdWithEnglishLocale(pingWithoutArgsCmd);
+                
+        assertFailedPing(pingWithoutArgsCmd, "Unable to find host");
+    }
+    
+    public void testPingWithBogusPort() throws InterruptedException, IOException {
+        String currentHost = TestConfiguration.getCurrent().getHostName();
+        String bogusPort = Integer.toString(
+                TestConfiguration.getCurrent().getBogusPort());
+        String[] pingWithoutArgsCmd = new String[] {
+                "org.apache.derby.drda.NetworkServerControl",
+                "ping", "-h", currentHost, "-p", bogusPort};
+                
+        pingWithoutArgsCmd = decorateCmdWithEnglishLocale(pingWithoutArgsCmd);
+                
+        assertFailedPing(pingWithoutArgsCmd, "Could not connect to Derby Network Server");
+    }
+    
     /**
      * Execute ping command and verify that it completes successfully
      * @param pingCmd array of java arguments for ping command
@@ -89,15 +132,9 @@ public class NetworkServerControlClientC
      * @throws IOException
      */
     private void  assertSuccessfulPing(String[] pingCmd) throws InterruptedException, IOException
{
-        
-/*        InputStream is = Utilities.execJavaCmd(pingCmd, 0);
-        byte[] b = new byte[80];
-        is.read(b, 0, 80);
-        String output = new String(b);
-        assertTrue(output.startsWith("Connection obtained"));
-*/
         assertExecJavaCmdAsExpected(new String[] {"Connection obtained"}, pingCmd, 0);
     }
+    
     /**
      * Execute ping command and verify that it fails with the expected message
      * 
@@ -107,32 +144,27 @@ public class NetworkServerControlClientC
      * @throws IOException
      */
     private void assertFailedPing(String[] pingCmd,String expectedMessage) throws InterruptedException,
IOException {
-        
-        /*InputStream is = Utilities.execJavaCmd(pingCmd, 1);
-        byte[] b = new byte[80];
-        is.read(b, 0, 80);
-        String output = new String(b);
-        assertTrue(output.startsWith(expectedMessage));*/
         assertExecJavaCmdAsExpected(new String[] {expectedMessage}, pingCmd, 1);
     }
     
 
     public static Test suite() {
 
-        TestSuite suite = new TestSuite("NetworkServerControlClientCommandTest");
-        
+        TestSuite suite = new TestSuite("NetworkServerControlClientCommandTest");       

 
-        // need network server, english locale so we can compare command output 
+        // need network server so we can compare command output 
         // and we don't run on J2ME because java command is different.
-        if (!Derby.hasServer() || !Locale.getDefault().getLanguage().equals("en") ||
+        if (!Derby.hasServer() ||
                 JDBC.vmSupportsJSR169())
             return suite;
+        
         Test test = TestConfiguration
                 .clientServerSuite(NetworkServerControlClientCommandTest.class);
         
         // no security manager because we exec a process and don't have permission for that.
         test = SecurityManagerSetup.noSecurityManager(test);
         suite.addTest(test);
+        
         return suite;
     }
 

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java?rev=1157923&r1=1157922&r2=1157923&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeTest.java
Mon Aug 15 17:42:33 2011
@@ -31,6 +31,7 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.Locale;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
@@ -668,7 +669,9 @@ public class GrantRevokeTest extends Bas
             grant("execute", "function s1", "nosuch", users[1]);
     	} catch (SQLException e) {
         	assertSQLState("42Y03", e);
-            assertEquals("'S1.NOSUCH' is not recognized as a function.", e.getMessage());
+        	if ( Locale.getDefault().getLanguage().equals("en") ) {
+        	    assertEquals("'S1.NOSUCH' is not recognized as a function.", e.getMessage());
+        	}
         }
     }
     
@@ -677,7 +680,9 @@ public class GrantRevokeTest extends Bas
             grant("execute", "function s1", "p1", users[1]);
     	} catch (SQLException e) {
         	assertSQLState("42Y03", e);
-            assertEquals("'S1.P1' is not recognized as a function.", e.getMessage());
+            if ( Locale.getDefault().getLanguage().equals("en") ) {
+                assertEquals("'S1.P1' is not recognized as a function.", e.getMessage());
+            }
         }
     }
     
@@ -694,7 +699,9 @@ public class GrantRevokeTest extends Bas
             grant("execute", "procedure s1", "nosuch", users[1]);
     	} catch (SQLException e) {
         	assertSQLState("42Y03", e);
-            assertEquals("'S1.NOSUCH' is not recognized as a procedure.", e.getMessage());
+        	if ( Locale.getDefault().getLanguage().equals("en") ) {
+        	    assertEquals("'S1.NOSUCH' is not recognized as a procedure.", e.getMessage());
+        	}
         }
     }
     
@@ -703,7 +710,9 @@ public class GrantRevokeTest extends Bas
             grant("execute", "procedure s1", "f2", users[1]);
     	} catch (SQLException e) {
         	assertSQLState("42Y03", e);
-            assertEquals("'S1.F2' is not recognized as a procedure.", e.getMessage());
+        	if ( Locale.getDefault().getLanguage().equals("en") ) {
+        	    assertEquals("'S1.F2' is not recognized as a procedure.", e.getMessage());
+        	}
         }
     }
     

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoCPCheckTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoCPCheckTest.java?rev=1157923&r1=1157922&r2=1157923&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoCPCheckTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoCPCheckTest.java
Mon Aug 15 17:42:33 2011
@@ -30,6 +30,7 @@ import java.io.OutputStream;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
 import java.security.AccessController;
+import java.util.Locale;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -37,6 +38,7 @@ import junit.framework.TestSuite;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.Derby;
 import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.LocaleTestSetup;
 
 public class SysinfoCPCheckTest extends BaseJDBCTestCase {
 
@@ -60,7 +62,7 @@ public class SysinfoCPCheckTest extends 
             isClient=false;
 
         Test suite = new TestSuite(SysinfoCPCheckTest.class, "Sysinfo ClassPath Checker");
       
-        return suite;
+        return new LocaleTestSetup(suite, Locale.ENGLISH);
     }
 
     /**



Mime
View raw message