db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r785049 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/derbynet/ functionTests/tests/jdbcapi/ functionTests/tests/replicationTests/ junit/
Date Tue, 16 Jun 2009 01:46:09 GMT
Author: kmarsden
Date: Tue Jun 16 01:46:08 2009
New Revision: 785049

URL: http://svn.apache.org/viewvc?rev=785049&view=rev
Log:
DERBY-4217 (partial)Make the default port for the suites.All run configurable with a system
property. patch file  DERBY-4217-dtp.patch.
Add support for derby.tests.port property

Contributed by Tiago Espina (tiago at espinhas dot net)



Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java
Tue Jun 16 01:46:08 2009
@@ -114,7 +114,7 @@
         expectedValues.setProperty("derby.drda.sslMode","off");
         expectedValues.setProperty("derby.drda.keepAlive","true");
         expectedValues.setProperty("derby.drda.minThreads","0");
-        expectedValues.setProperty("derby.drda.portNumber","1527");
+        expectedValues.setProperty("derby.drda.portNumber",TestConfiguration.getCurrent().getPort()+"");
         expectedValues.setProperty("derby.drda.logConnections","false");
         expectedValues.setProperty("derby.drda.timeSlice","0");
         expectedValues.setProperty("derby.drda.startNetworkServer","false");
@@ -149,7 +149,7 @@
         expectedValues.setProperty("derby.drda.trace.4","true");
         expectedValues.setProperty("derby.drda.keepAlive","true");
         expectedValues.setProperty("derby.drda.minThreads","0");
-        expectedValues.setProperty("derby.drda.portNumber","1527");
+        expectedValues.setProperty("derby.drda.portNumber",TestConfiguration.getCurrent().getPort()+"");
         expectedValues.setProperty("derby.drda.logConnections","true");
         expectedValues.setProperty("derby.drda.timeSlice","0");
         expectedValues.setProperty("derby.drda.startNetworkServer","false");
@@ -189,7 +189,7 @@
         expectedValues.setProperty("derby.drda.sslMode","off");
         expectedValues.setProperty("derby.drda.keepAlive","true");
         expectedValues.setProperty("derby.drda.minThreads","0");
-        expectedValues.setProperty("derby.drda.portNumber","1527");
+        expectedValues.setProperty("derby.drda.portNumber",TestConfiguration.getCurrent().getPort()+"");
         expectedValues.setProperty("derby.drda.logConnections","true");
         expectedValues.setProperty("derby.drda.timeSlice","0");
         expectedValues.setProperty("derby.drda.startNetworkServer","false");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Tue Jun 16 01:46:08 2009
@@ -39,6 +39,7 @@
 import javax.sql.PooledConnection;
 
 import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derby.jdbc.ClientConnectionPoolDataSource40;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
@@ -989,7 +990,7 @@
         // call setSecurityMechanism with secmec.
         JDBCDataSource.setBeanProperty(cpds,
                 "SecurityMechanism", secmec);
-        
+               
         // simulate case when connection will be re-used by getting 
         // a connection, closing it and then the next call to
         // getConnection will re-use the previous connection.  
@@ -1242,7 +1243,7 @@
     private HashMap addRequiredAttributes(HashMap attrs)
     {
         String hostName = TestConfiguration.DEFAULT_HOSTNAME;
-        int port = TestConfiguration.DEFAULT_PORT;
+        int port = TestConfiguration.getCurrent().getPort();
         if (usingDB2Client())
         {
             //attrs.put("retrieveMessagesFromServerOnGetMessage","true");
@@ -1276,6 +1277,7 @@
             attrs.put("user", user);
         if (password != null)
             attrs.put("password", password);
+
         attrs = addRequiredAttributes(attrs);
         ConnectionPoolDataSource cpds = 
             J2EEDataSource.getConnectionPoolDataSource();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
Tue Jun 16 01:46:08 2009
@@ -333,9 +333,9 @@
 
      // test fixtures from maxthreads
     public void testMaxThreads_0() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] maxthreadsCmd1 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "maxthreads", "0"};
+                "maxthreads", "0","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         // test maxthreads 0
         assertExecJavaCmdAsExpected(new String[]
                 {"Max threads changed to 0."}, maxthreadsCmd1, 0);
@@ -344,9 +344,9 @@
     }
 
     public void testMaxThreads_Neg1() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] maxthreadsCmd2 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "maxthreads", "-1", "-h", "localhost", "-p", "1527"};
+                "maxthreads", "-1", "-h", "localhost", "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         String host = TestUtil.getHostName();
         maxthreadsCmd2[4] = host;
         assertExecJavaCmdAsExpected(new String[]{"Max threads changed to 0."}, maxthreadsCmd2,
0);
@@ -360,9 +360,10 @@
      * @throws Exception
      */
     public void testMaxThreads_Neg12() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),
+                    TestConfiguration.getCurrent().getPort());
         String[] maxthreadsCmd3 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "maxthreads", "-12"};
+                "maxthreads", "-12","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         //test maxthreads -12
         assertExecJavaCmdAsExpected(new String[]{
                 "Invalid value, -12, for maxthreads.",
@@ -384,18 +385,18 @@
     }
 
     public void testMaxThreads_2147483647() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] maxthreadsCmd4 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "maxthreads", "2147483647"};
+                "maxthreads", "2147483647","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Max threads changed to 2147483647."}, maxthreadsCmd4,
0);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 2147483647, maxValue);
     }
 
     public void testMaxThreads_9000() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] maxthreadsCmd5 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "maxthreads", "9000"};
+                "maxthreads", "9000","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Max threads changed to 9000."}, maxthreadsCmd5,
0);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 9000, maxValue);
@@ -406,9 +407,9 @@
      * @throws Exception
      */
     public void testMaxThreads_Invalid() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] maxthreadsCmd5 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "maxthreads", "10000"};
+                "maxthreads", "10000","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Max threads changed to 10000."}, maxthreadsCmd5,
0);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 10000, maxValue);
@@ -435,14 +436,14 @@
     }
 
     public void testMaxThreadsCallable_0() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         server.setMaxThreads(0);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 0, maxValue);
     }
 
     public void testMaxThreadsCallable_Neg1() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         server.setMaxThreads(-1);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 0, maxValue);
@@ -453,7 +454,7 @@
      * @throws Exception
      */
     public void testMaxThreadsCallable_Neg12() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         try {
             server.setMaxThreads(-2);
             fail("Should have thrown an exception with 'DRDA_InvalidValue.U:Invalid value,
-2, for maxthreads.'");
@@ -463,14 +464,14 @@
     }
 
     public void testMaxThreadsCallable_2147483647() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         server.setMaxThreads(2147483647);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 2147483647, maxValue);
     }
 
     public void testMaxThreadsCallable_9000() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         server.setMaxThreads(9000);
         int maxValue = server.getMaxThreads();
         assertEquals("Fail! Max threads value incorrect!", 9000, maxValue);
@@ -479,9 +480,9 @@
       // timeslice test fixtures
     public void testTimeSlice_0() throws Exception {
         int value = 0;
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] timesliceCmd1 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "timeslice", "0"};
+                "timeslice", "0","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Time slice changed to 0."}, timesliceCmd1,
0);
         int timeSliceValue = server.getTimeSlice();
         assertEquals(value, timeSliceValue);
@@ -489,9 +490,9 @@
 
     public void testTimeSlice_Neg1() throws Exception {
         int value = 0;
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] timesliceCmd2 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "timeslice", "-1", "-h", "localhost", "-p", "1527"};
+                "timeslice", "-1", "-h", "localhost", "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         String host = TestUtil.getHostName();
         timesliceCmd2[4] = host;
         assertExecJavaCmdAsExpected(new String[]{"Time slice changed to 0."}, timesliceCmd2,
0);
@@ -501,9 +502,9 @@
 
     public void testTimeSlice_Neg12() throws Exception {
         int value = 0;
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] timesliceCmd3 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "timeslice", "-12"};
+                "timeslice", "-12","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Invalid value, -12, for timeslice.",
                 "Usage: NetworkServerControl <commands> ",
                 "Commands:",
@@ -523,9 +524,9 @@
 
     public void testTimeSlice_2147483647() throws Exception {
         int value = 2147483647;
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] timesliceCmd4 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "timeslice", "2147483647"};
+                "timeslice", "2147483647","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Time slice changed to 2147483647."}, timesliceCmd4,
0);
         int timeSliceValue = server.getTimeSlice();
         assertEquals(value, timeSliceValue);
@@ -533,9 +534,9 @@
 
     public void testTimeSlice_9000() throws Exception {
         int value = 9000;
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] timesliceCmd5 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "timeslice", "9000"};
+                "timeslice", "9000","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Time slice changed to 9000."}, timesliceCmd5,
0);
         int timeSliceValue = server.getTimeSlice();
         assertEquals(value, timeSliceValue);
@@ -543,9 +544,9 @@
 
     public void testTimeSlice_a() throws Exception {
         int value = 8000;
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         String[] timesliceCmd5 = new String[]{"org.apache.derby.drda.NetworkServerControl",
-                "timeslice", "8000"};
+                "timeslice", "8000","-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         assertExecJavaCmdAsExpected(new String[]{"Time slice changed to 8000."}, timesliceCmd5,
0);
         int timeSliceValue = server.getTimeSlice();
         assertEquals(value, timeSliceValue);
@@ -569,7 +570,7 @@
     }
 
     public void testTimeSliceCallable_0() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         int value = 0;
         server.setTimeSlice(0);
         int timeSliceValue = server.getTimeSlice();
@@ -577,7 +578,7 @@
     }
 
     public void testTimeSliceCallable_Neg1() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         int value = 0;
         server.setTimeSlice(-1);
         int timeSliceValue = server.getTimeSlice();
@@ -585,7 +586,7 @@
     }
 
     public void testTimeSliceCallable_Neg2() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         int value = 0;
         try {
             server.setTimeSlice(-2);
@@ -597,7 +598,7 @@
     }
 
     public void testTimeSliceCallable_2147483647() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         int value = 2147483647;
         server.setTimeSlice(2147483647);
         int timeSliceValue = server.getTimeSlice();
@@ -605,7 +606,7 @@
     }
 
     public void testTimeSliceCallable_9000() throws Exception {
-        NetworkServerControl server = new NetworkServerControl();
+        NetworkServerControl server = new NetworkServerControl(InetAddress.getLocalHost(),TestConfiguration.getCurrent().getPort());
         int value = 9000;
         server.setTimeSlice(9000);
         int timeSliceValue = server.getTimeSlice();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
Tue Jun 16 01:46:08 2009
@@ -50,26 +50,33 @@
     public void testPing() throws Exception {
         String currentHost = TestConfiguration.getCurrent().getHostName();
         String currentPort = Integer.toString(TestConfiguration.getCurrent().getPort());
+        String bogusPort = Integer.toString(TestConfiguration.getCurrent().getPort()-1);
         
         String[] pingCmd1 = new String[] {
                 "org.apache.derby.drda.NetworkServerControl", "ping" };
-        assertSuccessfulPing(pingCmd1);
-      
+        String[] pingCmd3 = new String[] {"org.apache.derby.drda.NetworkServerControl",
+                "ping", "-h", currentHost};
+        
+        /* 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() == TestConfiguration.DEFAULT_PORT) {
+	        assertSuccessfulPing(pingCmd1);
+            assertSuccessfulPing(pingCmd3);
+        }
+        
         String[] pingCmd2 = new String[] {
                 "org.apache.derby.drda.NetworkServerControl", "ping", "-h",
                 currentHost, "-p", currentPort};
         assertSuccessfulPing(pingCmd2);
         
-        String[] pingCmd3 = new String[] {"org.apache.derby.drda.NetworkServerControl",
-        "ping", "-h", currentHost};
-        assertSuccessfulPing(pingCmd3);
-        
         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", "9393"};
+        "ping", "-h", currentHost, "-p", bogusPort};
         assertFailedPing(pingCmd5,"Could not connect to Derby Network Server");
 
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
Tue Jun 16 01:46:08 2009
@@ -65,9 +65,11 @@
         "functionTests/tests/derbynet/ServerPropertiesTest.policy";
     private static String TARGET_POLICY_FILE_NAME = "server.policy";
     private int[] portsSoFar;
+    private int basePort;
     
     public ServerPropertiesTest(String name) {
         super(name);
+        this.basePort = TestConfiguration.getCurrent().getPort();
     }
     
     public static Test suite()
@@ -249,11 +251,8 @@
         Exception failException = null;
         // start with the default port + 1
         // there may be a smarter way to get the starting point...
-        int possiblePort = TestConfiguration.getCurrent().getPort();
-        if (!(possiblePort > 0))
-            possiblePort = 1528;
-        else
-            possiblePort = possiblePort + 1;
+        
+        int possiblePort = basePort + 1;
         try {
             boolean portOK = false;
             while (!portOK) {
@@ -409,15 +408,18 @@
         // we really expect the server to be down, let's
         // not do any waiting around
         NetworkServerTestSetup.setWaitTime(0);
-        if (canPingServer(1527, false)) {
+        if (canPingServer(basePort, false)) {
             // for now, shutdown
-            shutdownServer(1527, false);
+            shutdownServer(basePort, false);
         }
         NetworkServerTestSetup.setDefaultWaitTime();
 
-        // start the default, which at this point should be localhost and 1527
-        String actionResult = startServer(1527, false);
-        checkWhetherNeedToShutdown(new int[] {1527}, actionResult);
+        /* 
+         * The port should be default, but it might not be, so the second argument
+         * must be true to accommodate for every case.
+         */
+        String actionResult = startServer(basePort, true);
+        checkWhetherNeedToShutdown(new int[] {basePort}, actionResult);
         
         // set derby.drda.portNumber to an alternate number in derby.properties
         int firstAlternatePort = getAlternativePort();
@@ -443,19 +445,19 @@
         });
         if (b.booleanValue())
         {
-            checkWhetherNeedToShutdown(new int[] {1527}, "failed to write derby.properties");
+            checkWhetherNeedToShutdown(new int[] {TestConfiguration.getCurrent().getPort()},
"failed to write derby.properties");
         }
         // have to shutdown engine to force read of derby.properties
         TestConfiguration.getCurrent().shutdownEngine();
         actionResult = startServer(firstAlternatePort, false);
-        checkWhetherNeedToShutdown(new int[] {1527, firstAlternatePort}, actionResult);
+        checkWhetherNeedToShutdown(new int[] {basePort, firstAlternatePort}, actionResult);
 
         final int secondAlternatePort = getAlternativePort();
         // Now set system properties.
         setSystemProperty("derby.drda.portNumber", 
             new Integer(secondAlternatePort).toString());
         actionResult = startServer(secondAlternatePort, false);
-        checkWhetherNeedToShutdown( new int[] {1527, firstAlternatePort, secondAlternatePort},
+        checkWhetherNeedToShutdown( new int[] {basePort, firstAlternatePort, secondAlternatePort},
             actionResult);
         
         // now try with specifying port
@@ -464,7 +466,7 @@
         // command line parameter should take hold
         int thirdAlternatePort = getAlternativePort();
         actionResult = startServer(thirdAlternatePort, true);
-        checkWhetherNeedToShutdown(new int[] {1527, firstAlternatePort, secondAlternatePort,
+        checkWhetherNeedToShutdown(new int[] {basePort, firstAlternatePort, secondAlternatePort,
             thirdAlternatePort}, actionResult);
 
         // now with -p. 
@@ -478,7 +480,7 @@
         if (!canPingServer(fourthAlternatePort, true)) {
             actionResult = "Can not ping server specified with -p";
         }
-        checkWhetherNeedToShutdown(new int[] {1527, firstAlternatePort, secondAlternatePort,
+        checkWhetherNeedToShutdown(new int[] {basePort, firstAlternatePort, secondAlternatePort,
             thirdAlternatePort, fourthAlternatePort}, actionResult);
                         
         // shutdown with -p
@@ -491,24 +493,24 @@
         if (canPingServer(fourthAlternatePort, false)) {
             actionResult = "Can still ping server specified with -p";
         }
-        checkWhetherNeedToShutdown(new int[] {1527, firstAlternatePort, secondAlternatePort,
+        checkWhetherNeedToShutdown(new int[] {basePort, firstAlternatePort, secondAlternatePort,
             thirdAlternatePort, fourthAlternatePort}, actionResult);
             
         // shutdown with port specified in constructor
         actionResult = shutdownServer(thirdAlternatePort, true);
-        checkWhetherNeedToShutdown( new int[] {1527, firstAlternatePort, secondAlternatePort,
+        checkWhetherNeedToShutdown( new int[] {basePort, firstAlternatePort, secondAlternatePort,
             thirdAlternatePort}, actionResult);
         
         // shutdown using System property
         actionResult = shutdownServer(secondAlternatePort, false);
-        checkWhetherNeedToShutdown ( new int[] {1527, firstAlternatePort, secondAlternatePort},
+        checkWhetherNeedToShutdown ( new int[] {basePort, firstAlternatePort, secondAlternatePort},
             actionResult);
         // remove system property
         removeSystemProperty("derby.drda.portNumber");
 
         // shutdown server with port set in derby.properties
         actionResult = shutdownServer(firstAlternatePort, false);
-        checkWhetherNeedToShutdown ( new int[] {1527, firstAlternatePort},
+        checkWhetherNeedToShutdown ( new int[] {basePort, firstAlternatePort},
             actionResult);
         // remove derby.properties
         Boolean ret = (Boolean) AccessController.doPrivileged
@@ -520,15 +522,15 @@
         }
         );
         if (ret.booleanValue() == false) {
-            checkWhetherNeedToShutdown ( new int[] {1527, firstAlternatePort},
+            checkWhetherNeedToShutdown ( new int[] {basePort, firstAlternatePort},
                 "unable to remove derby.properties");
         }
         // have to shutdown engine to force re-evaluation of derby.properties
         TestConfiguration.getCurrent().shutdownEngine();
         
         // shutdown the default server
-        actionResult = shutdownServer(1527, false);
-        checkWhetherNeedToShutdown ( new int[] {1527}, actionResult);
+        actionResult = shutdownServer(basePort, true);
+        checkWhetherNeedToShutdown ( new int[] {basePort}, actionResult);
     }
     
     /**
@@ -581,13 +583,15 @@
         
         verifyProperties(expectedTraceOff);     
 
+        int port = TestConfiguration.getCurrent().getPort();
+
         String[] traceCmd = new String[] {
-            "org.apache.derby.drda.NetworkServerControl", "trace", "on" };
+            "org.apache.derby.drda.NetworkServerControl", "trace", "on", "-p",String.valueOf(port)
};
         assertSuccessfulCmd("Trace turned on for all sessions.", traceCmd);
         verifyProperties(expectedTraceOn);     
 
         traceCmd = new String[] {
-                "org.apache.derby.drda.NetworkServerControl", "trace", "off" };
+                "org.apache.derby.drda.NetworkServerControl", "trace", "off", "-p",String.valueOf(port)
};
         assertSuccessfulCmd("Trace turned off for all sessions", traceCmd);
         // traceAll should be back to false
         verifyProperties(expectedTraceOff);     
@@ -626,13 +630,15 @@
         
         verifyProperties(expectedLogConnectionsOff);     
 
+        int port = TestConfiguration.getCurrent().getPort();
+
         String[] cmd = new String[] {
-            "org.apache.derby.drda.NetworkServerControl", "logconnections", "on" };
+            "org.apache.derby.drda.NetworkServerControl", "logconnections", "on","-p",String.valueOf(port)
};
         assertSuccessfulCmd("Log Connections changed to on.", cmd);
         verifyProperties(expectedLogConnectionsOn);     
 
         cmd = new String[] {
-                "org.apache.derby.drda.NetworkServerControl", "logconnections", "off" };
+                "org.apache.derby.drda.NetworkServerControl", "logconnections", "off", "-p",String.valueOf(port)
};
         assertSuccessfulCmd("Log Connections changed to off.", cmd);
         // traceAll should be back to false
         verifyProperties(expectedLogConnectionsOff);    

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
Tue Jun 16 01:46:08 2009
@@ -68,7 +68,7 @@
             "derby.drda.sslMode=off\n" + 
             "derby.drda.keepAlive=true\n" + 
             "derby.drda.minThreads=0\n" + 
-            "derby.drda.portNumber=1527\n" + 
+            "derby.drda.portNumber="+TestConfiguration.getCurrent().getPort()+"\n" + 
             "derby.drda.logConnections=false\n" + 
             "derby.drda.timeSlice=0\n" + 
             "derby.drda.startNetworkServer=false\n" + 
@@ -88,7 +88,7 @@
             "derby.drda.sslMode=off\n" + 
             "derby.drda.keepAlive=true\n" + 
             "derby.drda.minThreads=0\n" + 
-            "derby.drda.portNumber=1527\n" + 
+            "derby.drda.portNumber="+TestConfiguration.getCurrent().getPort()+"\n" + 
             "derby.drda.logConnections=false\n" + 
             "derby.drda.timeSlice=0\n" + 
             "derby.drda.startNetworkServer=false\n" + 
@@ -203,7 +203,8 @@
      */	
     public void testSysinfo() throws Exception {
         String[] SysInfoCmd = 
-            new String[] {"org.apache.derby.drda.NetworkServerControl", "sysinfo"};
+            new String[] {"org.apache.derby.drda.NetworkServerControl", "sysinfo",
+            "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
 
         Process p = execJavaCmd(SysInfoCmd);
         String s = readProcessOutput(p);
@@ -223,7 +224,7 @@
     public void testSysinfoMethod() throws Exception {	
 
         String s = NetworkServerTestSetup.
-        getNetworkServerControlDefault().getSysinfo();
+        getNetworkServerControl(TestConfiguration.getCurrent().getPort()).getSysinfo();
         s = sed(s);
 
         print("testSysinfoMethod", s);
@@ -239,7 +240,8 @@
 
         String[] SysInfoLocaleCmd = 
             new String[] {"-Duser.language=de", "-Duser.country=DE", 
-                "org.apache.derby.drda.NetworkServerControl", "sysinfo"};
+                "org.apache.derby.drda.NetworkServerControl", "sysinfo",
+                "-p", String.valueOf(TestConfiguration.getCurrent().getPort())};
         Process p = execJavaCmd(SysInfoLocaleCmd);
         String s = readProcessOutput(p);
         s = sed(s);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
Tue Jun 16 01:46:08 2009
@@ -264,7 +264,8 @@
             return;
         
         ClientDataSource ds = new ClientDataSource();
-
+        ds.setPortNumber(TestConfiguration.getCurrent().getPort());
+        
         // DataSource - EMPTY; expect error 08001 in all cases
         // 08001: Required Derby DataSource property databaseName not set.
         dsConnectionRequests(new String[]  
@@ -435,6 +436,7 @@
         // DataSource
         // DataSource - retrieveMessageTextProperty
         ClientDataSource ds = new ClientDataSource();
+        ds.setPortNumber(TestConfiguration.getCurrent().getPort());
         ds.setDatabaseName(dbName);
         ds.setConnectionAttributes(retrieveMessageTextProperty + "=false");
         conn = ds.getConnection();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Tue Jun 16 01:46:08 2009
@@ -2286,6 +2286,8 @@
         // now with ConnectionPoolDataSource
         ClientConnectionPoolDataSource cpds = 
             new ClientConnectionPoolDataSource();
+        cpds.setPortNumber(TestConfiguration.getCurrent().getPort());
+        
         // ConnectionPoolDataSource - EMPTY
         dsConnectionRequests(new String[]  
             {"08001","08001","08001","08001",
@@ -2315,6 +2317,9 @@
 
         // now with XADataSource
         ClientXADataSource xads = new ClientXADataSource();
+        
+        xads.setPortNumber(TestConfiguration.getCurrent().getPort());
+        
         // XADataSource - EMPTY
         dsConnectionRequests(new String[]  
             {"08001","08001","08001","08001",
@@ -2606,6 +2611,8 @@
         // with ConnectionPoolDataSource
         // ConnectionPoolDataSource - retrieveMessageTextProperty
         ClientConnectionPoolDataSource cpds = new ClientConnectionPoolDataSource();
+        cpds.setPortNumber(TestConfiguration.getCurrent().getPort());
+        
         cpds.setDatabaseName(dbName);
         cpds.setConnectionAttributes(
                 retrieveMessageTextProperty + "=false");
@@ -2622,6 +2629,7 @@
         // now with XADataSource
         ClientXADataSource xads = new ClientXADataSource();
         //XADataSource - retrieveMessageTextProperty
+        xads.setPortNumber(TestConfiguration.getCurrent().getPort());
         xads.setDatabaseName(dbName);
         xads.setConnectionAttributes(
                 retrieveMessageTextProperty + "=false");

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
Tue Jun 16 01:46:08 2009
@@ -31,6 +31,7 @@
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * Framework to run replication tests.
@@ -59,7 +60,7 @@
       // create or connect to an encrypted db.
     
     static String masterServerHost = "localhost"; 
-    static int masterServerPort = 1527; // .. default..
+    static int masterServerPort = TestConfiguration.getCurrent().getPort(); // .. get current
ports..
     static String slaveServerHost = "localhost";
     static int slaveServerPort = 3527; // .. ..
     static String testClientHost = "localhost";
@@ -2012,7 +2013,7 @@
         masterServerHost = "localhost";
         util.DEBUG("masterServerHost: " + masterServerHost);
         
-        masterServerPort = 1527;
+        masterServerPort = TestConfiguration.getCurrent().getPort();
         util.DEBUG("masterServerPort: " + masterServerPort);
         
         slaveServerHost = "localhost";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=785049&r1=785048&r2=785049&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Tue Jun 16 01:46:08 2009
@@ -324,11 +324,11 @@
         if (cleanDB)
         {
             suite.addTest(new CleanDatabaseTestSetup(
-                    clientExistingServerSuite(testClass, hostName, portNumber)));
+                    clientExistingServerSuite(testClass, hostName, TestConfiguration.getCurrent().getPort())));
         }
         else
         {
-            suite.addTest(clientExistingServerSuite(testClass, hostName, portNumber));
+            suite.addTest(clientExistingServerSuite(testClass, hostName, TestConfiguration.getCurrent().getPort()));
         }
 
         return (suite);
@@ -499,7 +499,7 @@
         }
         
         Test r =
-                new ServerSetup(test, DEFAULT_HOSTNAME, DEFAULT_PORT);
+                new ServerSetup(test, DEFAULT_HOSTNAME, TestConfiguration.getCurrent().getPort());
         ((ServerSetup)r).setJDBCClient(JDBCClient.DERBYNETCLIENT); 
         
         return r;
@@ -521,7 +521,7 @@
         // which are specific to this test run (perhaps overridden on the
         // command line)?
         //
-        return new ServerSetup(test, DEFAULT_HOSTNAME, DEFAULT_PORT);
+        return new ServerSetup(test, DEFAULT_HOSTNAME, TestConfiguration.getCurrent().getPort());
     }
    /**
     * A variant of defaultServerDecorator allowing 
@@ -1102,18 +1102,12 @@
         hostName = props.getProperty(KEY_HOSTNAME, DEFAULT_HOSTNAME);
         isVerbose = Boolean.valueOf(props.getProperty(KEY_VERBOSE)).booleanValue();
         doTrace =  Boolean.valueOf(props.getProperty(KEY_TRACE)).booleanValue();
-        String portStr = props.getProperty(KEY_PORT);
-        if (portStr != null) {
-            try {
-                port = Integer.parseInt(portStr);
-            } catch (NumberFormatException nfe) {
-                // We lose stacktrace here, but it is not important. 
-                throw new NumberFormatException(
-                        "Port number must be an integer. Value: " + portStr); 
-            }
-        } else {
-            port = DEFAULT_PORT;
-        }
+        String port = BaseTestCase.getSystemProperty("derby.tests.port");
+		if (port == null) {
+			this.port = DEFAULT_PORT;
+		} else {
+			this.port = Integer.parseInt(port);
+		}
         String jmxPortStr = props.getProperty(KEY_JMX_PORT);
         if (jmxPortStr != null) {
             try {



Mime
View raw message