db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r963706 - in /db/derby/code/branches/10.6: ./ java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Date Tue, 13 Jul 2010 13:22:54 GMT
Author: kristwaa
Date: Tue Jul 13 13:22:54 2010
New Revision: 963706

URL: http://svn.apache.org/viewvc?rev=963706&view=rev
Log:
DERBY-4700: Add method to obtain a bogus port in TestConfiguration

Merged fix from trunk (revision 963705).

Modified:
    db/derby/code/branches/10.6/   (props changed)
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 13 13:22:54 2010
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,958163,958522,958618,958939,959550,962716
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,958163,958522,958618,958939,959550,962716,963705
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java?rev=963706&r1=963705&r2=963706&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlClientCommandTest.java
Tue Jul 13 13:22:54 2010
@@ -50,7 +50,8 @@ public class NetworkServerControlClientC
     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 bogusPort = Integer.toString(
+                TestConfiguration.getCurrent().getBogusPort());
         
         String[] pingCmd1 = new String[] {
                 "org.apache.derby.drda.NetworkServerControl", "ping" };

Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=963706&r1=963705&r2=963706&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Tue Jul 13 13:22:54 2010
@@ -56,7 +56,7 @@ import junit.framework.TestSuite;
  * removed by <code>DropDatabaseSetup</code>.
  *
  */
-public class TestConfiguration {
+public final class TestConfiguration {
     /**
      * Default values for configurations
      */
@@ -1021,6 +1021,9 @@ public class TestConfiguration {
         this.jdbcClient = JDBCClient.getDefaultEmbedded();
         this.ssl = null;
         this.jmxPort = getNextAvailablePort();
+        this.bogusPort = getNextAvailablePort();
+        println("basePort=" + basePort + ", jmxPort=" + jmxPort +
+                ", bogusPort=" + bogusPort);
         url = createJDBCUrlWithDatabaseName(defaultDbName);
         initConnector(null);
  
@@ -1041,6 +1044,7 @@ public class TestConfiguration {
         this.doTrace = copy.doTrace;
         this.port = copy.port;
         this.jmxPort = copy.jmxPort;
+        this.bogusPort = copy.bogusPort;
         
         this.jdbcClient = copy.jdbcClient;
         this.hostName = copy.hostName;
@@ -1064,6 +1068,11 @@ public class TestConfiguration {
         this.doTrace = copy.doTrace;
         this.port = port;
         this.jmxPort = copy.jmxPort;
+        this.bogusPort = copy.bogusPort;
+        if (bogusPort == port) {
+            throw new IllegalStateException(
+                    "port cannot equal bogusPort: " + bogusPort);
+        }
         
         this.jdbcClient = client;
         this.hostName = hostName;
@@ -1087,6 +1096,11 @@ public class TestConfiguration {
         this.doTrace = copy.doTrace;
         this.port = port;
         this.jmxPort = copy.jmxPort;
+        this.bogusPort = copy.bogusPort;
+        if (bogusPort == port) {
+            throw new IllegalStateException(
+                    "port cannot equal bogusPort: " + bogusPort);
+        }
         
         this.jdbcClient = client;
         this.hostName = hostName;
@@ -1119,6 +1133,7 @@ public class TestConfiguration {
         this.doTrace = copy.doTrace;
         this.port = copy.port;
         this.jmxPort = copy.jmxPort;
+        this.bogusPort = copy.bogusPort;
         
         this.jdbcClient = copy.jdbcClient;
         this.hostName = copy.hostName;
@@ -1182,6 +1197,7 @@ public class TestConfiguration {
         this.doTrace = copy.doTrace;
         this.port = copy.port;
         this.jmxPort = copy.jmxPort;
+        this.bogusPort = copy.bogusPort;
         
         this.jdbcClient = copy.jdbcClient;
         this.hostName = copy.hostName;
@@ -1211,6 +1227,9 @@ public class TestConfiguration {
         doTrace =  Boolean.valueOf(props.getProperty(KEY_TRACE)).booleanValue();
         port = basePort;
         jmxPort = getNextAvailablePort();
+        bogusPort = getNextAvailablePort();
+        println("basePort=" + basePort + ", jmxPort=" + jmxPort +
+                ", bogusPort=" + bogusPort);
 
         ssl = props.getProperty(KEY_SSL);
         
@@ -1419,6 +1438,16 @@ public class TestConfiguration {
     }
 
     /**
+     * Returns a port number where no Derby network servers are supposed to
+     * be running.
+     *
+     * @return A port number where no Derby network servers are started.
+     */
+    public int getBogusPort() {
+        return bogusPort;
+    }
+
+    /**
      * Get ssl mode for network server
      * 
      * @return ssl mode
@@ -1600,6 +1629,20 @@ public class TestConfiguration {
     public boolean isVerbose() {
         return isVerbose;
     }
+
+    /**
+     * Private method printing debug information to standard out if debugging
+     * is enabled.
+     * <p>
+     * <em>Note:</em> This method may direct output to a different location
+     * than the println method in <tt>BaseJDBCTestCase</tt>.
+     */
+    private void println(CharSequence msg) {
+        if (isVerbose) {
+            System.out.println("DEBUG: {TC@" + hashCode() + "} " + msg);
+        }
+    }
+
     /**
      * Return JUnit test method trace flag.
      *
@@ -1705,6 +1748,7 @@ public class TestConfiguration {
     private final String hostName;
     private final JDBCClient jdbcClient;
     private final int jmxPort;
+    private final int bogusPort;
     private boolean isVerbose;
     private boolean doTrace;
     private String ssl;



Mime
View raw message