activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r905593 - in /activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport: http/HttpTransportBrokerTest.java https/HttpsTransportBrokerTest.java
Date Tue, 02 Feb 2010 11:55:16 GMT
Author: gtully
Date: Tue Feb  2 11:55:13 2010
New Revision: 905593

URL: http://svn.apache.org/viewvc?rev=905593&view=rev
Log:
merge -c 904005 https://svn.apache.org/repos/asf/activemq/trunk - validate jetty availabilty
via socket connect to take out the guess work on loaded machines - avoid connection refused
intermittent failures

Modified:
    activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/http/HttpTransportBrokerTest.java
    activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsTransportBrokerTest.java

Modified: activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/http/HttpTransportBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/http/HttpTransportBrokerTest.java?rev=905593&r1=905592&r2=905593&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/http/HttpTransportBrokerTest.java
(original)
+++ activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/http/HttpTransportBrokerTest.java
Tue Feb  2 11:55:13 2010
@@ -16,7 +16,11 @@
  */
 package org.apache.activemq.transport.http;
 
+import java.net.Socket;
 import java.net.URI;
+import java.net.URL;
+
+import javax.net.SocketFactory;
 
 import junit.framework.Test;
 import junit.textui.TestRunner;
@@ -24,9 +28,13 @@
 import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.transport.TransportBrokerTestSupport;
+import org.apache.activemq.util.Wait;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class HttpTransportBrokerTest extends TransportBrokerTestSupport {
 
+    private static final Log LOG = LogFactory.getLog(HttpTransportBrokerTest.class);
     protected String getBindLocation() {
         return "http://localhost:8081";
     }
@@ -34,10 +42,28 @@
     protected void setUp() throws Exception {
         maxWait = 2000;
         super.setUp();
-        Thread.sleep(500);
+        waitForJettySocketToAccept(getBindLocation());
     }
     
-	protected BrokerService createBroker() throws Exception {
+    private void waitForJettySocketToAccept(String bindLocation) throws Exception {
+        final URL url = new URL(bindLocation);
+        assertTrue("Jetty endpoint is available", Wait.waitFor(new Wait.Condition() {
+
+            public boolean isSatisified() throws Exception {
+                boolean canConnect = false;
+                try {
+                    Socket socket = SocketFactory.getDefault().createSocket(url.getHost(),
url.getPort());
+                    socket.close();
+                    canConnect = true;
+                } catch (Exception e) {
+                    LOG.warn("verify jettty available, failed to connect to " + url + e);
+                }
+                return canConnect;
+            }}, 60 * 1000));
+        
+    }
+
+    protected BrokerService createBroker() throws Exception {
 		BrokerService broker = BrokerFactory.createBroker(new URI("broker:()/localhost?persistent=false&useJmx=false"));
 		connector = broker.addConnector(getBindLocation());
 		return broker;
@@ -46,7 +72,7 @@
 	protected void tearDown() throws Exception {
         super.tearDown();
         // Give the jetty server enough time to shutdown before starting another one
-        Thread.sleep(500);
+        Thread.sleep(100);
     }
 
     public static Test suite() {

Modified: activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsTransportBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsTransportBrokerTest.java?rev=905593&r1=905592&r2=905593&view=diff
==============================================================================
--- activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsTransportBrokerTest.java
(original)
+++ activemq/branches/activemq-5.3/activemq-optional/src/test/java/org/apache/activemq/transport/https/HttpsTransportBrokerTest.java
Tue Feb  2 11:55:13 2010
@@ -35,15 +35,6 @@
         System.setProperty("javax.net.ssl.keyStoreType", "jks");
         //System.setProperty("javax.net.debug", "ssl,handshake,data,trustmanager");
         super.setUp();
-
-        Thread.sleep(2000);
-        Thread.yield();
-    }
-
-    protected void tearDown() throws Exception {
-        super.tearDown();
-        // Give the jetty server more time to shutdown before starting another one
-        Thread.sleep(1000);
     }
     
     public static Test suite() {



Mime
View raw message