karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: Improve JmsTest itest (waiting the ActiveMQ broker fully started before starting the tests as it can provide "race" condition)
Date Fri, 23 Jan 2015 16:14:19 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 0c31cd2dc -> 3e16c8e37


Improve JmsTest itest (waiting the ActiveMQ broker fully started before starting the tests
as it can provide "race" condition)


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3e16c8e3
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3e16c8e3
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3e16c8e3

Branch: refs/heads/master
Commit: 3e16c8e37e39d46a8b23217e79f551fe18345e31
Parents: 0c31cd2
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Fri Jan 23 16:19:03 2015 +0100
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Fri Jan 23 16:19:56 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/karaf/itests/JmsTest.java   | 25 +++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/3e16c8e3/itests/src/test/java/org/apache/karaf/itests/JmsTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/JmsTest.java b/itests/src/test/java/org/apache/karaf/itests/JmsTest.java
index 0d4efa8..2a3aee0 100644
--- a/itests/src/test/java/org/apache/karaf/itests/JmsTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/JmsTest.java
@@ -27,6 +27,7 @@ import javax.jms.ConnectionFactory;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
+import java.net.Socket;
 import java.net.URI;
 import java.util.List;
 
@@ -39,9 +40,21 @@ public class JmsTest extends KarafTestSupport {
         installAndAssertFeature("jms");
         featureService.addRepository(new URI("mvn:org.apache.activemq/activemq-karaf/5.10.0/xml/features"));
         installAndAssertFeature("activemq-broker-noweb");
+        // check if ActiveMQ is completely started
+        System.out.println("Waiting for the ActiveMQ transport connector on 61616 ...");
+        boolean bound = false;
+        while (!bound) {
+            try {
+                Thread.sleep(2000);
+                Socket socket = new Socket("localhost", 61616);
+                bound = true;
+            } catch (Exception e) {
+                // wait the connection
+            }
+        }
     }
 
-    @Test
+    @Test(timeout = 120000)
     public void testCommands() throws Exception {
         // jms:create command
         System.out.println(executeCommand("jms:create -t ActiveMQ -u karaf -p karaf --url
tcp://localhost:61616 test"));
@@ -90,7 +103,7 @@ public class JmsTest extends KarafTestSupport {
         System.out.println(connectionFactories);
     }
 
-    @Test
+    @Test(timeout = 120000)
     public void testMBean() throws Exception {
         JMXConnector connector = null;
         try {
@@ -98,21 +111,27 @@ public class JmsTest extends KarafTestSupport {
             MBeanServerConnection connection = connector.getMBeanServerConnection();
             ObjectName name = new ObjectName("org.apache.karaf:type=jms,name=root");
             // create operation
+            System.out.println("JMS MBean create operation invocation");
             connection.invoke(name, "create", new String[]{ "testMBean", "activemq", "tcp://localhost:61616",
"karaf", "karaf" }, new String[]{ "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String", "java.lang.String" });
             // give time to fileinstall to load the blueprint file by looking for the connection
factory OSGi service
             getOsgiService(ConnectionFactory.class, "name=testMBean" , 30000);
             List<String> connectionFactories = (List<String>) connection.getAttribute(name,
"Connectionfactories");
             assertEquals(true, connectionFactories.size() >= 1);
             // send operation
+            System.out.println("JMS MBean send operation invocation");
             connection.invoke(name, "send", new String[]{ "testMBean", "queueMBean", "message",
null, "karaf", "karaf" }, new String[]{ "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String", "java.lang.String", "java.lang.String"});
             // count operation
+            System.out.println("JMS MBean count operation invocation");
             Integer count = (Integer) connection.invoke(name, "count", new String[]{ "testMBean",
"queueMBean", "karaf", "karaf" }, new String[]{ "java.lang.String", "java.lang.String", "java.lang.String",
"java.lang.String"});
             assertEquals(1, count.intValue());
             // queues operation
+            System.out.print("JMS MBean queues operation invocation: ");
             List<String> queues = (List<String>) connection.invoke(name, "queues",
new String[]{ "testMBean", "karaf", "karaf" }, new String[]{ "java.lang.String", "java.lang.String",
"java.lang.String"});
+            System.out.println(queues);
             assertTrue(queues.size() >= 1);
             // delete operation
-            connection.invoke(name, "delete", new String[]{ "testMBean" }, new String[]{
"java.lang.String" });
+            System.out.println("JMS MBean delete operation invocation");
+            connection.invoke(name, "delete", new String[]{"testMBean"}, new String[]{"java.lang.String"});
         } finally {
             close(connector);
         }


Mime
View raw message