db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1480843 - in /db/derby/code/branches/10.10: ./ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCDriversEmbeddedTest.java
Date Fri, 10 May 2013 00:52:47 GMT
Author: myrnavl
Date: Fri May 10 00:52:46 2013
New Revision: 1480843

URL: http://svn.apache.org/r1480843
Log:
DERBY-6181; fix AutoloadTest to support running concurrently when different base ports are
specified.
  backport revision 1480462 from trunk.

Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCDriversEmbeddedTest.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1480462

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java?rev=1480843&r1=1480842&r2=1480843&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
Fri May 10 00:52:46 2013
@@ -21,6 +21,7 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
+import java.net.InetAddress;
 import java.sql.Driver;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -226,21 +227,6 @@ public class AutoloadTest extends BaseJD
      * </ul>
      */
     static Test fullAutoloadSuite() {
-        if (!TestConfiguration.getCurrent().isDefaultBasePort())
-        {
-            // DERBY-6178
-            //     test is not currently coded to work properly when calling
-            //     system is depending on setting -Dderby.tests.basePort=3500
-            //     to avoid conflict on concurrent tests starting and stopping
-            //     network server.
-
-            // for now just skip this test if tests are setting a non-default
-            // base port.
-            return new TestSuite(
-                    "empty: test not supported with non-default base port: " + 
-                    TestConfiguration.getCurrent().getBasePort());
-        }
-
         TestSuite suite = new TestSuite("AutoloadTest:All");
         suite.addTest(new AutoloadTest(AutoloadTest.class));
         suite.addTest(new AutoloadTest(JDBCDriversEmbeddedTest.class));
@@ -262,15 +248,29 @@ public class AutoloadTest extends BaseJD
      * Run {@code AutoloadTest} in a separate JVM.
      */
     public void spawnProcess() throws Exception {
-        String[] cmd = {
-            "junit.textui.TestRunner", spawnedTestClass.getName()
-        };
-
-        SpawnedProcess proc =
-            new SpawnedProcess(execJavaCmd(cmd), spawnedTestClass.getName());
-
-        if (proc.complete() != 0) {
-            fail(proc.getFailMessage("Test process failed"));
+        if (TestConfiguration.isDefaultBasePort()) {
+            String[] cmd = {
+                    "junit.textui.TestRunner", spawnedTestClass.getName()
+                           };
+            SpawnedProcess proc = new SpawnedProcess
+                    (execJavaCmd(cmd), spawnedTestClass.getName());
+            if (proc.complete() != 0) {
+                fail(proc.getFailMessage("Test process failed"));
+            }
+        }
+        else 
+        {
+            // if we're not using the default port of 1527, ensure we're
+            // passing on the baseport value to the spawned process.
+            String[] cmd = {
+                    "-Dderby.tests.basePort=" + TestConfiguration.getBasePort(),
+                    "junit.textui.TestRunner", spawnedTestClass.getName()
+            };            
+            SpawnedProcess proc = new SpawnedProcess
+                    (execJavaCmd(cmd), spawnedTestClass.getName());
+            if (proc.complete() != 0) {
+                fail(proc.getFailMessage("Test process failed"));
+            }
         }
     }
 
@@ -518,7 +518,9 @@ public class AutoloadTest extends BaseJD
         
         String user = getTestConfiguration().getUserName();
         String pw = getTestConfiguration().getUserPassword();
-        NetworkServerControl control = new NetworkServerControl(user, pw);
+        int port = TestConfiguration.getBasePort();
+        final InetAddress host = InetAddress.getByName(TestConfiguration.getCurrent().getHostName());
+        NetworkServerControl control = new NetworkServerControl(host, port, user, pw);
 
         if (!serverShouldBeUp) {
             // If we expect the server not to come up, wait a little before

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCDriversEmbeddedTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCDriversEmbeddedTest.java?rev=1480843&r1=1480842&r2=1480843&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCDriversEmbeddedTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCDriversEmbeddedTest.java
Fri May 10 00:52:46 2013
@@ -20,6 +20,8 @@
  */
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
+import org.apache.derbyTesting.junit.BaseTestCase;
+
 import junit.framework.Test;
 
 /**
@@ -36,7 +38,15 @@ public class JDBCDriversEmbeddedTest ext
         // when this property is set and the embedded driver
         // is autoloaded by jdbc.drivers
         System.setProperty("derby.drda.startNetworkServer", "true");
- 
+        // if the property derby.tests.basePort has been set, we need to
+        // ensure we specify the portNumber as well, because we're then
+        // not using 1527 for checks and shutting down.
+        String portNumberString = System.getProperty("derby.tests.basePort");
+        if (portNumberString != null )
+        {
+            System.setProperty("derby.drda.portNumber", portNumberString);
+        } 
+        
         return getSuite("org.apache.derby.jdbc.EmbeddedDriver");
     }
 }



Mime
View raw message