db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1233536 - in /db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting: functionTests/tests/derbynet/ junit/
Date Thu, 19 Jan 2012 19:06:32 GMT
Author: mikem
Date: Thu Jan 19 19:06:31 2012
New Revision: 1233536

URL: http://svn.apache.org/viewvc?rev=1233536&view=rev
Log:
DERBY-5547: NSSecurityMechanismTest.testNetworkServerSecurityMechanism() fails intermittently

backporting svn #1222155 from trunk to 10.8 branch.

Wait for previous network server to stop before starting a new one. 


Modified:
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
    db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java?rev=1233536&r1=1233535&r2=1233536&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/DerbyNetNewServerTest.java
Thu Jan 19 19:06:31 2012
@@ -58,7 +58,15 @@ public class DerbyNetNewServerTest exten
             return new TestSuite("DerbyNetNewServerTest.empty");
         }
     }
-        
+
+    protected void setUp() throws Exception {
+        // The test cases in this test start a new network server. Wait until
+        // the network server in the previous test case has shut down
+        // completely and released the network port before attempting to start
+        // a new server.
+        NetworkServerTestSetup.waitForAvailablePort();
+    }
+
     public void testStartWithPrintWriter()
             throws UnknownHostException,
             Exception {

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java?rev=1233536&r1=1233535&r2=1233536&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NSSecurityMechanismTest.java
Thu Jan 19 19:06:31 2012
@@ -412,6 +412,10 @@ public class NSSecurityMechanismTest ext
             }
         }
 
+        // Before attempting to start a new server, wait for the previous
+        // server to complete and release the server port.
+        NetworkServerTestSetup.waitForAvailablePort();
+
         setSystemProperty("derby.drda.securityMechanism",
                 derby_drda_securityMechanism);
         try {

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=1233536&r1=1233535&r2=1233536&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
Thu Jan 19 19:06:31 2012
@@ -393,6 +393,10 @@ public class ServerPropertiesTest  exten
         }
         NetworkServerTestSetup.setDefaultWaitTime();
 
+        // Wait until the server has shut down completely and released the
+        // port.
+        NetworkServerTestSetup.waitForAvailablePort();
+
         /* 
          * The port should be default, but it might not be, so the second argument
          * must be true to accommodate for every case.

Modified: db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java?rev=1233536&r1=1233535&r2=1233536&view=diff
==============================================================================
--- db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
(original)
+++ db/derby/code/branches/10.8/java/testing/org/apache/derbyTesting/junit/NetworkServerTestSetup.java
Thu Jan 19 19:06:31 2012
@@ -26,6 +26,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.ServerSocket;
+import java.net.UnknownHostException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
@@ -217,9 +218,14 @@ final public class NetworkServerTestSetu
      * by earlier test cases, or until the timeout specified by
      * {@link #getWaitTime()} has elapsed.
      *
-     * @throws Exception if the port didn't become available before the timeout
+     * @throws AssertionFailedError if the port didn't become available before
+     * the timeout
+     * @throws InterruptedException if the thread was interrupted while waiting
+     * for the port to become available
+     * @throws UnknownHostException if the host name couldn't be resolved
      */
-    private void waitForAvailablePort() throws Exception {
+    public static void waitForAvailablePort()
+            throws InterruptedException, UnknownHostException {
         TestConfiguration conf = TestConfiguration.getCurrent();
         InetAddress serverAddress = InetAddress.getByName(conf.getHostName());
         int port = conf.getPort();
@@ -248,7 +254,7 @@ final public class NetworkServerTestSetu
      * @param addr the address of the network interface
      * @throws IOException if a server socket couldn't be opened
      */
-    private void probeServerPort(final int port, final InetAddress addr)
+    private static void probeServerPort(final int port, final InetAddress addr)
             throws IOException {
         try {
             AccessController.doPrivileged(new PrivilegedExceptionAction() {



Mime
View raw message