You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/05/16 17:21:30 UTC

svn commit: r1339226 - in /karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests: CellarSampleDosgiGreeterTest.java CellarTestSupport.java

Author: jbonofre
Date: Wed May 16 15:21:30 2012
New Revision: 1339226

URL: http://svn.apache.org/viewvc?rev=1339226&view=rev
Log:
[KARAF-1474] Fix the child node extraction in itests

Modified:
    karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
    karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java

Modified: karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java?rev=1339226&r1=1339225&r2=1339226&view=diff
==============================================================================
--- karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java (original)
+++ karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java Wed May 16 15:21:30 2012
@@ -62,13 +62,14 @@ public class CellarSampleDosgiGreeterTes
         String node1 = getNodeIdOfChild("child1");
         String node2 = getNodeIdOfChild("child2");
 
-        System.err.println("Child1: " + node1);
-        System.err.println("Child2: " + node2);
+        System.err.println("Node 1: " + node1);
+        System.err.println("Node 2: " + node2);
 
+        executeCommand("cluster:group-create client-grp");
+        executeCommand("cluster:group-create service-grp");
         System.err.println(executeCommand("cluster:group-list"));
         System.err.println(executeCommand("cluster:group-set client-grp " + localNode.getId()));
         System.err.println(executeCommand("cluster:group-set service-grp " + node1));
-        System.err.println(executeCommand("cluster:group-list"));
 
         System.err.println(executeCommand("cluster:feature-install client-grp greeter-client"));
         Thread.sleep(10000);

Modified: karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java?rev=1339226&r1=1339225&r2=1339226&view=diff
==============================================================================
--- karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java (original)
+++ karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java Wed May 16 15:21:30 2012
@@ -149,15 +149,14 @@ public class CellarTestSupport {
      * Returns the node id of a specific child instance.
      */
     protected String getNodeIdOfChild(String name) {
-        String nodeId = null;
-        String nodesList = executeCommand("instance:connect " + name + " cluster:node-list | grep \\\\*", COMMAND_TIMEOUT, true);
-        String[] tokens = nodesList.split(" ");
-        if (tokens != null && tokens.length > 0) {
-            nodeId = tokens[tokens.length - 1].trim().replaceAll("\n", "");
-        }
-        //As of Karaf 2.2.5 grep will add the reset character at the end of the match.
-        nodeId = nodeId.replaceAll("\\u001B\\[m", "");
-        return nodeId;
+        String node;
+        String nodesList = executeCommand("admin:connect " + name + " cluster:node-list | grep \\\\*", COMMAND_TIMEOUT, true);
+        int stop = nodesList.indexOf(']');
+        node = nodesList.substring(0, stop);
+        int start = node.lastIndexOf('[');
+        node = node.substring(start + 1);
+        node = node.trim();
+        return node;
     }
 
     protected Option cellarDistributionConfiguration() {