activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: Fixed the karaf webconsole test.
Date Tue, 01 Oct 2013 12:12:40 GMT
Updated Branches:
  refs/heads/trunk b8d5ca838 -> 92ee5c6ba


Fixed the karaf webconsole test.


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/92ee5c6b
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/92ee5c6b
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/92ee5c6b

Branch: refs/heads/trunk
Commit: 92ee5c6bab5c7b21bed6c0b3240670f305cfb276
Parents: b8d5ca8
Author: Claus Ibsen <claus.ibsen@gmail.com>
Authored: Tue Oct 1 14:12:24 2013 +0200
Committer: Claus Ibsen <claus.ibsen@gmail.com>
Committed: Tue Oct 1 14:12:33 2013 +0200

----------------------------------------------------------------------
 .../ActiveMQBrokerNdWebConsoleFeatureTest.java  | 42 ++++++++++++++------
 1 file changed, 30 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/92ee5c6b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
----------------------------------------------------------------------
diff --git a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
index 58e870f..044d8b3 100644
--- a/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
+++ b/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
@@ -22,6 +22,7 @@ import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
@@ -46,28 +47,45 @@ public class ActiveMQBrokerNdWebConsoleFeatureTest extends ActiveMQBrokerFeature
     @Override
     protected void produceMessage(String nameAndPayload) throws Exception {
         HttpClient client = new HttpClient();
+        client.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
 
         System.err.println(executeCommand("activemq:bstat").trim());
+        System.err.println("attempting to access web console..");
+
+        GetMethod get = new GetMethod(WEB_CONSOLE_URL + "index.jsp");
+
+        // Give console some time to start
+        boolean done = false;
+        int loop = 0;
+        while (!done && loop < 30) {
+            loop++;
+            try {
+                int code = client.executeMethod(get);
+                if (code > 399 && code < 500) {
+                    // code 4xx we should retry
+                    System.err.println("web console not accessible yet - status code " +
code);
+                    TimeUnit.SECONDS.sleep(1);
+                } else {
+                    done = true;
+                }
+            } catch (Exception ignored) {}
+        }
+        assertEquals("get succeeded on " + get, 200, get.getStatusCode());
+
         System.err.println("attempting publish via web console..");
 
+        // need to first get the secret
+        get = new GetMethod(WEB_CONSOLE_URL + "send.jsp");
+        get.setDoAuthentication(true);
+
         // set credentials
         client.getState().setCredentials(
                 new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
                 new UsernamePasswordCredentials(USER, PASSWORD)
          );
 
-        // need to first get the secret
-        GetMethod get = new GetMethod(WEB_CONSOLE_URL + "send.jsp");
-        get.setDoAuthentication(true);
-
-        // Give console some time to start
-        for (int i=0; i<20; i++) {
-            TimeUnit.SECONDS.sleep(1);
-            try {
-                i = client.executeMethod(get);
-            } catch (java.net.ConnectException ignored) {}
-        }
-        assertEquals("get succeeded on " + get, 200, get.getStatusCode());
+        int code = client.executeMethod(get);
+        assertEquals("get succeeded on " + get, 200, code);
 
         String response = get.getResponseBodyAsString();
         final String secretMarker = "<input type=\"hidden\" name=\"secret\" value=\"";


Mime
View raw message