This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf-cellar.git


The following commit(s) were added to refs/heads/main by this push:
     new 0c67a788 Fix the tests and run them (#148)
0c67a788 is described below

commit 0c67a788c90d503ec5b1176bd58517777161523d
Author: JB Onofré <[email protected]>
AuthorDate: Sun Aug 31 16:46:16 2025 +0200

    Fix the tests and run them (#148)
    
    This closes #146
---
 assembly/src/main/resources/features.xml           |   1 +
 itests/pom.xml                                     |  39 ++
 .../karaf/cellar/itests/CellarBundleTest.java      |  28 +-
 .../cellar/itests/CellarConfigurationTest.java     |  72 +---
 .../karaf/cellar/itests/CellarEventTest.java       |  26 +-
 .../karaf/cellar/itests/CellarFeaturesTest.java    |  86 +----
 .../karaf/cellar/itests/CellarGroupsTest.java      |  78 ++--
 .../cellar/itests/CellarInstallationTest.java      |  65 +++-
 ...larChildNodesTest.java => CellarNodesTest.java} |  25 +-
 .../apache/karaf/cellar/itests/CellarObrTest.java  |  37 +-
 .../itests/CellarSampleCamelHazelcastTest.java     | 101 -----
 .../itests/CellarSampleDosgiGreeterTest.java       | 112 ------
 .../karaf/cellar/itests/CellarTestSupport.java     | 426 ++-------------------
 .../src/test/resources/controlled-exam.properties  |  29 ++
 .../test/resources/etc/org.ops4j.pax.logging.cfg   |  69 ++++
 itests/src/test/resources/etc/users.properties     |  33 ++
 itests/src/test/resources/log4j.properties         |  33 ++
 17 files changed, 426 insertions(+), 834 deletions(-)

diff --git a/assembly/src/main/resources/features.xml 
b/assembly/src/main/resources/features.xml
index 73dccdef..ca9beb95 100644
--- a/assembly/src/main/resources/features.xml
+++ b/assembly/src/main/resources/features.xml
@@ -56,6 +56,7 @@
         <conditional>
             <condition>feature</condition>
             <feature dependency="true">cellar-hazelcast</feature>
+            <feature dependency="true">jackson</feature>
             
<bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.features/${project.version}</bundle>
         </conditional>
     </feature>
diff --git a/itests/pom.xml b/itests/pom.xml
index 4d0b67e5..7b5a5619 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -34,6 +34,32 @@
 
     <dependencies>
 
+        <dependency>
+            <groupId>org.apache.karaf.itests</groupId>
+            <artifactId>common</artifactId>
+            <version>${karaf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.awaitility</groupId>
+            <artifactId>awaitility</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.hamcrest</artifactId>
+            <version>1.3_1</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.karaf</groupId>
             <artifactId>apache-karaf</artifactId>
@@ -103,6 +129,19 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkCount>1</forkCount>
+                    <reuseForks>false</reuseForks>
+                    <systemPropertyVariables>
+                        
<org.ops4j.pax.logging.DefaultServiceLog.level>INFO</org.ops4j.pax.logging.DefaultServiceLog.level>
+                        <cellar.version>${project.version}</cellar.version>
+                        
<pax.exam.configuration>file:src/test/resources/controlled-exam.properties</pax.exam.configuration>
+                    </systemPropertyVariables>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
index 44ca9326..5efbeabf 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarBundleTest.java
@@ -17,39 +17,33 @@ import static org.junit.Assert.assertNotNull;
 
 import org.apache.karaf.cellar.core.ClusterManager;
 import org.apache.karaf.features.FeaturesService;
+import org.apache.karaf.itests.KarafTestSupport;
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
 import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import java.util.stream.Stream;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class CellarBundleTest extends CellarTestSupport {
 
     @Test
-    @Ignore
     public void testCellarBundleModule() throws Exception {
-       FeaturesService featuresService = getOsgiService(FeaturesService.class);
-       assertNotNull(featuresService);
-       
         installCellar();
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
-
-        System.err.println(executeCommand("cluster:bundle-list default"));
-    }
 
-    @After
-    public void tearDown() {
-        try {
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
+        String bundles = executeCommand("cluster:bundle-list default");
+        System.out.println(bundles);
+        assertNotNull(bundles);
+        assertContains("local", bundles);
     }
 
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
index 919898fe..23783791 100644
--- 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
+++ 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarConfigurationTest.java
@@ -13,13 +13,7 @@
  */
 package org.apache.karaf.cellar.itests;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.junit.After;
-import org.junit.Ignore;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -30,62 +24,28 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 @ExamReactorStrategy(PerClass.class)
 public class CellarConfigurationTest extends CellarTestSupport {
 
-    private static final String TESTPID = "org.apache.karaf.cellar.tst";
-
     @Test
-    @Ignore
-    public void testCellarFeaturesModule() throws InterruptedException {
+    public void testCellarFeaturesModule() throws Exception {
         installCellar();
-        createCellarChild("child1");
-        createCellarChild("child2");
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
-
-        String node1 = getNodeIdOfChild("child1");
-        String node2 = getNodeIdOfChild("child2");
-        System.err.println(executeCommand("instance:list"));
 
-        String properties = executeCommand("instance:connect child1 
config:proplist --pid " + TESTPID);
-        System.err.println(properties);
-        assertFalse((properties.contains("myKey")));
+        System.out.println("Creating test cluster group ...");
+        executeCommand("cluster:group-create test");
 
-        //Test configuration sync - add property
-        System.err.println(executeCommand("config:propset --pid " + TESTPID + 
" myKey myValue"));
-        Thread.sleep(5000);
-        properties = executeCommand("instance:connect child1 config:proplist 
--pid " + TESTPID);
-        System.err.println(properties);
-        assertTrue(properties.contains("myKey = myValue"));
+        System.out.println("Creating configuration in the test cluster group 
...");
+        executeCommand("cluster:config-property-set test 
org.apache.karaf.cellar.tst test test");
+        String clusterConfig = executeCommand("cluster:config-property-list 
test org.apache.karaf.cellar.tst");
+        System.out.println(clusterConfig);
+        assertContains("test = test", clusterConfig);
 
-        //Test configuration sync - remove property
-        System.err.println(executeCommand("config:propdel --pid " + TESTPID + 
" myKey"));
-        Thread.sleep(5000);
-        properties = executeCommand("instance:connect child1 config:proplist 
--pid " + TESTPID);
-        System.err.println(properties);
-        assertFalse(properties.contains("myKey"));
+        String localConfig = executeCommand("config:list 
\"(service.pid=org.apache.karaf.cellar.tst)\"");
+        Assert.assertTrue(localConfig.isEmpty());
 
+        System.out.println("Local node joins the test cluster group ...");
+        System.out.println(executeCommand("cluster:group-join test"));
 
-        //Test configuration sync - add property - join later
-        System.err.println(executeCommand("cluster:group-set new-grp " + 
node1));
-        Thread.sleep(5000);
-        System.err.println(executeCommand("instance:connect child1 
config:propset --pid " + TESTPID + " myKey2 myValue2"));
-        properties = executeCommand("instance:connect child1 config:proplist 
--pid " + TESTPID);
-        Thread.sleep(5000);
-        System.err.println(executeCommand("cluster:group-set new-grp " + 
node2));
-        properties = executeCommand("instance:connect child2 config:proplist 
--pid " + TESTPID);
-        System.err.println(properties);
-        assertTrue(properties.contains("myKey2 = myValue2"));
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            destroyCellarChild("child1");
-            destroyCellarChild("child2");
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
+        localConfig = executeCommand("config:list 
\"(service.pid=org.apache.karaf.cellar.tst)\"");
+        System.out.println(localConfig);
+        assertContains("test = test", localConfig);
     }
 
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
index e05ba7ee..b283d4f3 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarEventTest.java
@@ -16,36 +16,34 @@ package org.apache.karaf.cellar.itests;
 import static org.junit.Assert.assertNotNull;
 
 import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.itests.KarafTestSupport;
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
 import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import java.util.stream.Stream;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class CellarEventTest extends CellarTestSupport {
 
     @Test
-    @Ignore
     public void testCellarEventFeatureInstall() throws Exception {
         installCellar();
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
-        
-        System.err.println(executeCommand("features:install cellar-event"));
-    }
 
-    @After
-    public void tearDown() {
-        try {
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
+        System.out.println(executeCommand("feature:install cellar-eventadmin", 
new RolePrincipal("admin")));
+        
+        String features = executeCommand("feature:list -i");
+        System.out.println(features);
+        assertContains("cellar-eventadmin", features);
     }
 
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
index 8001e358..168514da 100644
--- 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
+++ 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
@@ -13,15 +13,6 @@
  */
 package org.apache.karaf.cellar.itests;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Node;
-import org.junit.After;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -32,74 +23,35 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 @ExamReactorStrategy(PerClass.class)
 public class CellarFeaturesTest extends CellarTestSupport {
 
-    private static final String UNINSTALLED = "[uninstalled]";
-    private static final String INSTALLED = "[installed  ]";
-
     @Test
-    @Ignore
     public void testCellarFeaturesModule() throws InterruptedException {
         installCellar();
-        createCellarChild("child1");
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
 
-        System.err.println(executeCommand("instance:list"));
+        System.out.println("Checking if maven feature is installed locally 
...");
+        String features = executeCommand("feature:list -i");
+        System.out.println(features);
+        assertContainsNot("maven", features);
 
-        String eventadminFeatureStatus = executeCommand("instance:connect 
child1 features:list | grep eventadmin");
-        System.err.println(eventadminFeatureStatus);
-        assertTrue(eventadminFeatureStatus.startsWith(UNINSTALLED));
+        System.out.println("Creating test cluster group ...");
+        System.out.println(executeCommand("cluster:group-create test"));
 
-        //Test feature sync - install
-        System.err.println(executeCommand("features:install eventadmin"));
-        Thread.sleep(5000);
-        eventadminFeatureStatus = executeCommand("instance:connect child1 
features:list | grep eventadmin");
-        System.err.println(eventadminFeatureStatus);
-        assertTrue(eventadminFeatureStatus.startsWith(INSTALLED));
+        System.out.println("Adding Karaf standard features repository to the 
test cluster group ...");
+        System.out.println(executeCommand("cluster:feature-repo-add test 
mvn:org.apache.karaf.features/standard/" + System.getProperty("karaf.version") 
+ "/xml/features"));
 
-        //Test feature sync - uninstall
-        System.err.println(executeCommand("features:uninstall eventadmin"));
-        Thread.sleep(5000);
-        eventadminFeatureStatus = executeCommand("instance:connect child1 
features:list | grep eventadmin");
-        System.err.println(eventadminFeatureStatus);
-        assertTrue(eventadminFeatureStatus.startsWith(UNINSTALLED));
+        System.out.println("Installing maven feature on the test cluster group 
...");
+        System.out.println(executeCommand("cluster:feature-install test 
maven"));
 
-        //Test feature command - install
-        System.err.println(executeCommand("cluster:feature-install default 
eventadmin"));
-        Thread.sleep(5000);
-        eventadminFeatureStatus = executeCommand("instance:connect child1 
features:list | grep eventadmin");
-        System.err.println(eventadminFeatureStatus);
-        assertTrue(eventadminFeatureStatus.startsWith(INSTALLED));
+        String clusterFeatures = executeCommand("cluster:feature-list -i 
test");
+        System.out.println(clusterFeatures);
+        assertContains("maven", clusterFeatures);
 
-        //Test feature command - uninstall
-        System.err.println(executeCommand("cluster:feature-uninstall default 
eventadmin"));
-        Thread.sleep(5000);
-        eventadminFeatureStatus = executeCommand("instance:connect child1 
features:list | grep eventadmin");
-        System.err.println(eventadminFeatureStatus);
-        assertTrue(eventadminFeatureStatus.startsWith(UNINSTALLED));
-
-        //Test feature command - install - before a node joins
-        System.err.println(executeCommand("cluster:feature-install testgroup 
eventadmin"));
-        System.err.println(executeCommand("cluster:group-set testgroup " + 
getNodeIdOfChild("child1")));
-        Thread.sleep(5000);
-        eventadminFeatureStatus = executeCommand("instance:connect child1 
features:list | grep eventadmin");
-        System.err.println(eventadminFeatureStatus);
-        assertTrue(eventadminFeatureStatus.startsWith(INSTALLED));
-
-        Node localNode = clusterManager.getNode();
-        Set<Node> nodes = clusterManager.listNodes();
-        System.err.println(executeCommand("cluster:node-list"));
-        assertTrue("There should be at least 2 cellar nodes running", 2 <= 
nodes.size());
-    }
+        System.out.println("Local node join test cluster group ...");
+        System.out.println(executeCommand("cluster:group-join test"));
 
-    @After
-    public void tearDown() {
-        try {
-            destroyCellarChild("child1");
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
+        System.out.println("Checking maven feature installed locally ...");
+        features = executeCommand("feature:list -i");
+        System.out.println(features);
+        assertContains("maven", features);
     }
 
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
index 661e28af..00e8efa8 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarGroupsTest.java
@@ -13,66 +13,60 @@
  */
 package org.apache.karaf.cellar.itests;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Group;
-import org.apache.karaf.cellar.core.GroupManager;
-import org.apache.karaf.cellar.core.Node;
-import org.junit.After;
-import org.junit.Ignore;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class CellarGroupsTest extends CellarTestSupport {
 
     @Test
-    @Ignore
-    public void testGroupsWithChildNodes() throws InterruptedException {
+    public void testGroups() throws InterruptedException {
         installCellar();
-        createCellarChild("child1");
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
 
-        System.err.println(executeCommand("cluster:node-list"));
-        Node localNode = clusterManager.getNode();
-        Set<Node> nodes = clusterManager.listNodes();
-        assertTrue("There should be at least 2 cellar nodes running", 2 <= 
nodes.size());
+        String groupList = executeCommand("cluster:group-list");
+        System.out.println(groupList);
+        String[] groups = groupList.split("\n");
+        Assert.assertEquals(3, groups.length);
+        assertContains("default", groups[2]);
 
-        System.err.println(executeCommand("cluster:group-list"));
-        System.err.println(executeCommand("cluster:group-set testgroup " + 
localNode.getId()));
-        System.err.println(executeCommand("cluster:group-list"));
+        System.out.println("Creating test cluster group ...");
+        System.out.println(executeCommand("cluster:group-create test"));
 
-        GroupManager groupManager = getOsgiService(GroupManager.class);
-        assertNotNull(groupManager);
+        groupList = executeCommand("cluster:group-list");
+        System.out.println(groupList);
+        groups = groupList.split("\n");
+        Assert.assertEquals(4, groups.length);
+        assertContains("test", groups[2]);
+        assertContains("default", groups[3]);
 
-        Set<Group> groups = groupManager.listAllGroups();
-        assertEquals("There should be 2 cellar groups", 2, groups.size());
+        System.out.println("Local node join the test cluster group ...");
+        groupList = executeCommand("cluster:group-join test");
+        System.out.println(groupList);
+        groups = groupList.split("\n");
+        assertContains("x", groups[2]);
 
-        System.err.println(executeCommand("cluster:group-delete testgroup "));
-        System.err.println(executeCommand("cluster:group-list"));
-        groups = groupManager.listAllGroups();
-        assertEquals("There should be a single cellar group", 1, 
groups.size());
-    }
+        System.out.println("Local node quit the test cluster group ...");
+        groupList = executeCommand("cluster:group-quit test");
+        System.out.println(groupList);
+        groups = groupList.split("\n");
+        assertContainsNot("x", groups[2]);
 
-    @After
-    public void tearDown() {
-        try {
-            destroyCellarChild("child1");
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
+        System.out.println("Delete test cluster group ...");
+        executeCommand("cluster:group-delete test");
+        groupList = executeCommand("cluster:group-list");
+        System.out.println(groupList);
+        groups = groupList.split("\n");
+        Assert.assertEquals(3, groups.length);
+        assertContains("default", groups[2]);
     }
 
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
index b7f47ddb..de91bac0 100644
--- 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
+++ 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarInstallationTest.java
@@ -13,29 +13,78 @@
  */
 package org.apache.karaf.cellar.itests;
 
-import static org.junit.Assert.assertNotNull;
-
 import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.itests.KarafTestSupport;
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
+import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import java.util.stream.Stream;
+
+import static org.junit.Assert.*;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
 public class CellarInstallationTest extends CellarTestSupport {
 
     @Test
-    @Ignore
     public void testInstallation() throws InterruptedException {
         installCellar();
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
-        Thread.sleep(20000);
-        System.err.println(executeCommand("osgi:list"));
-        System.err.println(executeCommand("cluster:node-list"));
+
+        String bundles = executeCommand("bundle:list");
+        System.out.println("bundles");
+        assertContains("Hazelcast", bundles);
+        String nodes = executeCommand("cluster:node-list");
+        System.out.println(nodes);
+        assertNotNull(nodes);
+
+        System.out.println("Testing cluster shell commands ...");
+
+        String output = executeCommand("cluster:consumer-status");
+        System.out.println(output);
+        String[] lines = output.split("\n");
+        assertEquals(3, lines.length);
+        assertContains("ON", lines[2]);
+
+        output = executeCommand("cluster:producer-status");
+        System.out.println(output);
+        lines = output.split("\n");
+        assertEquals(3, lines.length);
+        assertContains("ON", lines[2]);
+
+        output = executeCommand("cluster:handler-status");
+        System.out.println(output);
+        lines = output.split("\n");
+        assertEquals(7, lines.length);
+
+        output = executeCommand("cluster:group-list");
+        System.out.println(output);
+        lines = output.split("\n");
+        assertEquals(3, lines.length);
+        assertContains("default", lines[2]);
+
+        output = executeCommand("cluster:bundle-list default");
+        System.out.println(output);
+        lines = output.split("\n");
+        assertTrue(lines.length > 3);
+
+        output = executeCommand("cluster:config-list default");
+        System.out.println(output);
+        lines = output.split("\n");
+        assertTrue(lines.length > 3);
+
+        output = executeCommand("cluster:feature-list default");
+        System.out.println(output);
+        lines = output.split("\n");
+        assertTrue(lines.length > 3);
     }
 
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarNodesTest.java
similarity index 72%
rename from 
itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java
rename to 
itests/src/test/java/org/apache/karaf/cellar/itests/CellarNodesTest.java
index 9119e1e9..880502fa 100644
--- 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarChildNodesTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarNodesTest.java
@@ -21,7 +21,6 @@ import java.util.Set;
 import org.apache.karaf.cellar.core.ClusterManager;
 import org.apache.karaf.cellar.core.Node;
 import org.junit.After;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.junit.PaxExam;
@@ -30,28 +29,30 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public class CellarChildNodesTest extends CellarTestSupport {
+public class CellarNodesTest extends CellarTestSupport {
 
-    @Test
-    @Ignore
-    public void testClusterWithChildNodes() throws InterruptedException {
+    @Test(timeout = 180000)
+    public void testClusterWithChildNodes() throws Exception {
         installCellar();
-        createCellarChild("child1");
-        Thread.sleep(DEFAULT_TIMEOUT);
+
+        createCellarInstance("child1");
+
         ClusterManager clusterManager = getOsgiService(ClusterManager.class);
         assertNotNull(clusterManager);
 
-        Node localNode = clusterManager.getNode();
+        System.out.println("Waiting the Cellar nodes ...");
         Set<Node> nodes = clusterManager.listNodes();
-        System.err.println(executeCommand("cluster:node-list"));
-        assertTrue("There should be at least 2 cellar nodes running", 2 <= 
nodes.size());
+        while (nodes.size() < 2) {
+            nodes = clusterManager.listNodes();
+            Thread.sleep(2000);
+            System.out.println(executeCommand("cluster:node-list"));
+        }
     }
 
     @After
     public void tearDown() {
         try {
-            destroyCellarChild("child1");
-            unInstallCellar();
+            stopAndDestroyCellarInstance("child1");
         } catch (Exception ex) {
             //Ignore
         }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
index e9ab7739..aa31413f 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarObrTest.java
@@ -16,36 +16,47 @@ package org.apache.karaf.cellar.itests;
 import static org.junit.Assert.assertNotNull;
 
 import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.itests.KarafTestSupport;
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
 import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 
+import java.util.stream.Stream;
+
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public class CellarObrTest extends CellarTestSupport {
+public class CellarObrTest extends KarafTestSupport {
+
+    @Configuration
+    public Option[] config() {
+        Option[] options = new Option[]{
+                
KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg",
 getConfigFile("/etc/org.ops4j.pax.logging.cfg")),
+                
KarafDistributionOption.editConfigurationFilePut("etc/system.properties", 
"cellar.version", System.getProperty("cellar.version"))
+        };
+        return Stream.of(super.config(), 
options).flatMap(Stream::of).toArray(Option[]::new);
+    }
 
     @Test
-    @Ignore
     public void testCellarObrFeatureInstall() throws Exception {
-        installCellar();
-        Thread.sleep(DEFAULT_TIMEOUT);
+        System.out.println(executeCommand("feature:repo-add cellar " + 
System.getProperty("cellar.version")));
+        System.out.println(executeCommand("feature:install cellar", new 
RolePrincipal("admin")));
         ClusterManager clusterManager = getOsgiService(ClusterManager.class);
         assertNotNull(clusterManager);
 
-        System.err.println(executeCommand("features:install cellar-obr"));
-    }
+        System.out.println(executeCommand("feature:install cellar-obr", new 
RolePrincipal("admin")));
+        String features = executeCommand("feature:list -i");
+        System.out.println(features);
 
-    @After
-    public void tearDown() {
-        try {
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
+        assertContains("cellar-obr", features);
     }
 
+
 }
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
deleted file mode 100644
index 6f855e7f..00000000
--- 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleCamelHazelcastTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.karaf.cellar.itests;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Node;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class CellarSampleCamelHazelcastTest extends CellarTestSupport {
-
-    @Test
-    @Ignore
-    public void testCamelSampleApp() throws InterruptedException {
-        installCellar();
-        createCellarChild("child1");
-        createCellarChild("child2");
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
-
-        System.err.println(executeCommand("feature:add-url 
mvn:org.apache.karaf.cellar.samples/camel-hazelcast-app/3.0.0-SNAPSHOT/xml/features"));
-
-        System.err.println(executeCommand("instance:list"));
-
-        System.err.println(executeCommand("cluster:node-list"));
-        Node localNode = clusterManager.getNode();
-        Set<Node> nodes = clusterManager.listNodes();
-        assertTrue("There should be at least 3 cellar nodes running", 3 <= 
nodes.size());
-
-        Thread.sleep(DEFAULT_TIMEOUT);
-
-        String node1 = getNodeIdOfChild("child1");
-        String node2 = getNodeIdOfChild("child2");
-
-        System.err.println("Child1: " + node1);
-        System.err.println("Child2: " + node2);
-
-        System.err.println(executeCommand("cluster:group-set producer-grp " + 
localNode.getId()));
-        System.err.println(executeCommand("cluster:group-set consumer-grp " + 
node1));
-        System.err.println(executeCommand("cluster:group-set consumer-grp " + 
node2));
-        System.err.println(executeCommand("cluster:group-list"));
-
-        System.err.println(executeCommand("cluster:feature-install 
consumer-grp cellar-sample-camel-consumer"));
-        System.err.println(executeCommand("cluster:feature-install 
producer-grp cellar-sample-camel-producer"));
-        Thread.sleep(10000);
-        System.err.println(executeCommand("feature:list"));
-        System.err.println(executeCommand("osgi:list"));
-
-        System.err.println(executeCommand("cluster:group-list"));
-        System.err.println(executeCommand("instance:connect child2  osgi:list 
-t 0"));
-
-        Thread.sleep(20000);
-        String output1 = executeCommand("instance:connect child1  log:display 
| grep \"Hallo Cellar\"");
-        System.err.println(output1);
-        String output2 = executeCommand("instance:connect child2  log:display 
| grep \"Hallo Cellar\"");
-        System.err.println(output2);
-        assertTrue("Expected at least 1 lines", 1 <= 
countOutputEntires(output1));
-        assertTrue("Expected at least 1 lines", 1 <= 
countOutputEntires(output2));
-    }
-
-    public int countOutputEntires(String output) {
-        String[] lines = output.split("\n");
-        return lines.length;
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            destroyCellarChild("child1");
-            destroyCellarChild("child2");
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
-    }
-
-}
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
deleted file mode 100644
index ad0b2798..00000000
--- 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarSampleDosgiGreeterTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-package org.apache.karaf.cellar.itests;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Set;
-
-import org.apache.karaf.cellar.core.ClusterManager;
-import org.apache.karaf.cellar.core.Node;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerClass.class)
-public class CellarSampleDosgiGreeterTest extends CellarTestSupport {
-
-    @Test
-    @Ignore
-    public void testDosgiGreeter() throws InterruptedException {
-        installCellar();
-        createCellarChild("child1");
-        createCellarChild("child2");
-        Thread.sleep(DEFAULT_TIMEOUT);
-        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
-        assertNotNull(clusterManager);
-
-        System.err.println(executeCommand("features:addurl 
mvn:org.apache.karaf.cellar.samples/dosgi-greeter/3.0.0-SNAPSHOT/xml/features"));
-
-        System.err.println(executeCommand("instance:list"));
-
-        System.err.println(executeCommand("cluster:node-list"));
-        Node localNode = clusterManager.getNode();
-        Set<Node> nodes = clusterManager.listNodes();
-        assertTrue("There should be at least 3 cellar nodes running", 3 <= 
nodes.size());
-
-        Thread.sleep(DEFAULT_TIMEOUT);
-
-        String node1 = getNodeIdOfChild("child1");
-        String node2 = getNodeIdOfChild("child2");
-
-        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:feature-install client-grp 
greeter-client"));
-        Thread.sleep(10000);
-        System.err.println(executeCommand("cluster:feature-install service-grp 
greeter-service"));
-        Thread.sleep(10000);
-        System.err.println(executeCommand("cluster:service-list"));
-
-        String greetOutput = executeCommand("dosgi-greeter:greet Hi 10");
-        System.err.println(greetOutput);
-        assertEquals("Expected 10 greets", 10, 
countGreetsFromNode(greetOutput, node1));
-        System.err.println(executeCommand("cluster:group-set service-grp " + 
node2));
-        Thread.sleep(10000);
-        Thread.sleep(10000);
-        System.err.println(executeCommand("cluster:group-list"));
-        System.err.println(executeCommand("instance:connect child2 osgi:list 
-t 0"));
-        System.err.println(executeCommand("cluster:list-services"));
-        greetOutput = executeCommand("dosgi-greeter:greet Hi 10");
-        System.err.println(greetOutput);
-        assertEquals("Expected 5 greets", 5, countGreetsFromNode(greetOutput, 
node1));
-        assertEquals("Expected 5 greets", 5, countGreetsFromNode(greetOutput, 
node2));
-    }
-
-    public int countGreetsFromNode(String output, String nodeId) {
-        int count = 0;
-        String[] greets = output.split("\n");
-        for (String greet : greets) {
-            if (greet.contains(nodeId)) {
-                count++;
-            }
-        }
-        return count;
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            destroyCellarChild("child1");
-            destroyCellarChild("child2");
-            unInstallCellar();
-        } catch (Exception ex) {
-            //Ignore
-        }
-    }
-
-}
diff --git 
a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java 
b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
index 918860a2..3af8fcba 100644
--- a/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
+++ b/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
@@ -13,414 +13,56 @@
  */
 package org.apache.karaf.cellar.itests;
 
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
+import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.itests.KarafTestSupport;
+import org.apache.karaf.jaas.boot.principal.RolePrincipal;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.DatagramSocket;
-import java.net.ServerSocket;
-import java.security.Principal;
-import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.concurrent.*;
-import java.util.concurrent.TimeoutException;
+import java.util.stream.Stream;
 
-import javax.inject.Inject;
-import javax.security.auth.Subject;
+import static org.junit.Assert.assertNotNull;
 
-import org.apache.karaf.shell.api.console.Session;
-import org.apache.karaf.shell.api.console.SessionFactory;
-import org.ops4j.pax.exam.*;
-import org.ops4j.pax.exam.karaf.options.*;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-public class CellarTestSupport {
-
-    static final Long COMMAND_TIMEOUT = 10000L;
-    static final Long DEFAULT_TIMEOUT = 20000L;
-    static final Long SERVICE_TIMEOUT = 30000L;
-    static final String GROUP_ID = "org.apache.karaf";
-    static final String ARTIFACT_ID = "apache-karaf";
-
-    static final String INSTANCE_STARTED = "Started";
-    static final String INSTANCE_STARTING = "Starting";
-
-    static final String DEBUG_OPTS = " --java-opts \"-Xdebug -Xnoagent 
-Djava.compiler=NONE 
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s\"";
-
-    ExecutorService executor = Executors.newCachedThreadPool();
-
-    @Inject
-    protected BundleContext bundleContext;
-
-    @Inject
-    protected SessionFactory sessionFactory;
-
-
-    /**
-     * @param probe
-     * @return
-     */
-    @ProbeBuilder
-    public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
-        probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, 
"*,org.apache.felix.service.*;status=provisional");
-        return probe;
-    }
-
-    /**
-     * This method configures Hazelcast TcpIp discovery for a given number of 
members.
-     * This configuration is required, when working with karaf instances.
-     *
-     * @param members
-     */
-    protected void configureLocalDiscovery(int members) {
-        StringBuilder membersBuilder = new StringBuilder();
-        membersBuilder.append("config:propset tcpIpMembers ");
-        membersBuilder.append("localhost:5701");
-        for (int i = 1; i < members; i++) {
-            
membersBuilder.append(",").append("localhost:").append(String.valueOf(5701 + 
i));
-        }
-
-        String editCmd = "config:edit org.apache.karaf.cellar.discovery";
-        String propsetCmd = membersBuilder.toString();
-        String updateCmd = "config:update";
-
-        executeCommand(editCmd);
-        executeCommand(propsetCmd);
-        executeCommand(updateCmd);
-    }
-
-    /**
-     * Installs the Cellar feature
-     */
-    protected void installCellar() {
-        System.err.println(executeCommand("feature:repo-add " + 
System.getProperty("cellar.feature.url")));
-        System.err.println(executeCommand("feature:repo-list"));
-        System.err.println(executeCommand("feature:list"));
-        executeCommand("feature:install cellar");
-    }
-
-    protected void unInstallCellar() {
-        System.err.println(executeCommand("feature:uninstall cellar"));
-    }
-
-    /**
-     * Creates a child instance that runs cellar.
-     */
-    protected void createCellarChild(String name) {
-        createCellarChild(name, false, 0);
-    }
-
-    protected void createCellarChild(String name, boolean debug, int port) {
-        int instances = 0;
-        String createCommand = "instance:create --featureURL " + 
System.getProperty("cellar.feature.url") + " --feature cellar ";
-        if (debug && port > 0) {
-            createCommand = createCommand + String.format(DEBUG_OPTS, port);
-        }
-        System.err.println(executeCommand(createCommand + " " + name));
-        System.err.println(executeCommand("instance:start " + name));
-
-        //Wait till the node is listed as Starting
-        System.err.print("Waiting for " + name + " to start ");
-        for (int i = 0; i < 5 && instances == 0; i++) {
-            String response = executeCommand("instance:list | grep " + name + 
" | grep -c " + INSTANCE_STARTED, COMMAND_TIMEOUT, true);
-            instances = Integer.parseInt(response.trim());
-            System.err.print(".");
-            try {
-                Thread.sleep(3000);
-            } catch (InterruptedException e) {
-                //Ignore
-            }
-        }
-
-        if (instances > 0) {
-            System.err.println(".Started!");
-        } else {
-            System.err.println(".Timed Out!");
-        }
-
-    }
-
-    /**
-     * Destroys the child node.
-     */
-    protected void destroyCellarChild(String name) {
-        System.err.println(executeCommand("instance:connect " + name + " 
feature:uninstall cellar"));
-        System.err.println(executeCommand("instance:stop " + name));
-    }
-
-    /**
-     * Returns the node id of a specific child instance.
-     */
-    protected String getNodeIdOfChild(String name) {
-        String node;
-        String nodesList = executeCommand("instance: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() {
-        return karafDistributionConfiguration().frameworkUrl(
-                
maven().groupId(GROUP_ID).artifactId(ARTIFACT_ID).versionAsInProject().type("tar.gz"))
-                .karafVersion(MavenUtils.getArtifactVersion(GROUP_ID, 
ARTIFACT_ID)).name("Apache Karaf").unpackDirectory(new File("target/paxexam/"));
-    }
+public class CellarTestSupport extends KarafTestSupport {
 
     @Configuration
     public Option[] config() {
         Option[] options = new Option[]{
-                cellarDistributionConfiguration(), keepRuntimeFolder(), 
logLevel(LogLevelOption.LogLevel.INFO),
-                editConfigurationFileExtend("etc/system.properties", 
"cellar.feature.url", 
maven().groupId("org.apache.karaf.cellar").artifactId("apache-karaf-cellar").versionAsInProject().classifier("features").type("xml").getURL()),
-                editConfigurationFileExtend("etc/config.properties", 
"org.apache.aries.blueprint.synchronous", "true")
-        };
-        String debug = System.getProperty("debugMain");
-        if (debug != null) {
-            int l = options.length;
-            options = Arrays.copyOf(options, l + 1);
-            options[l] = KarafDistributionOption.debugConfiguration();
-        }
-        return options;
-    }
-
-    protected String executeCommand(final String command, Principal ... 
principals) {
-        return executeCommand(command, COMMAND_TIMEOUT, false, principals);
-    }
-
-
-    protected String executeCommand(final String command, final Long timeout, 
final Boolean silent, final Principal... principals) {
-        waitForCommandService(command);
-
-        String response;
-        final ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();
-        final PrintStream printStream = new PrintStream(byteArrayOutputStream);
-        final SessionFactory sessionFactory = 
getOsgiService(SessionFactory.class);
-        final Session session = sessionFactory.create(System.in, printStream, 
System.err);
-
-        final Callable<String> commandCallable = new Callable<String>() {
-            @Override
-            public String call() throws Exception {
-                try {
-                    if (!silent) {
-                        System.err.println(command);
-                    }
-                    session.execute(command);
-                } catch (Exception e) {
-                    throw new RuntimeException(e.getMessage(), e);
-                }
-                printStream.flush();
-                return byteArrayOutputStream.toString();
-            }
+                
KarafDistributionOption.replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg",
 getConfigFile("/etc/org.ops4j.pax.logging.cfg")),
+                
KarafDistributionOption.editConfigurationFilePut("etc/system.properties", 
"cellar.version", System.getProperty("cellar.version"))
         };
-
-        FutureTask<String> commandFuture;
-        if (principals.length == 0) {
-            commandFuture = new FutureTask<String>(commandCallable);
-        } else {
-            // If principals are defined, run the command callable via 
Subject.doAs()
-            commandFuture = new FutureTask<String>(new Callable<String>() {
-                @Override
-                public String call() throws Exception {
-                    Subject subject = new Subject();
-                    subject.getPrincipals().addAll(Arrays.asList(principals));
-                    return Subject.doAs(subject, new 
PrivilegedExceptionAction<String>() {
-                        @Override
-                        public String run() throws Exception {
-                            return commandCallable.call();
-                        }
-                    });
-                }
-            });
-        }
-
-        try {
-            executor.submit(commandFuture);
-            response = commandFuture.get(timeout, TimeUnit.MILLISECONDS);
-        } catch (TimeoutException e) {
-            e.printStackTrace(System.err);
-            response = "SHELL COMMAND TIMED OUT: ";
-        } catch (ExecutionException e) {
-            Throwable cause = e.getCause().getCause();
-            throw new RuntimeException(cause.getMessage(), cause);
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
-        return response;
+        return Stream.of(super.config(), 
options).flatMap(Stream::of).toArray(Option[]::new);
     }
 
-    private void waitForCommandService(String command) {
-        // the commands are represented by services. Due to the asynchronous 
nature of services they may not be
-        // immediately available. This code waits the services to be 
available, in their secured form. It
-        // means that the code waits for the command service to appear with 
the roles defined.
-
-        if (command == null || command.length() == 0) {
-            return;
-        }
-
-        int spaceIdx = command.indexOf(' ');
-        if (spaceIdx > 0) {
-            command = command.substring(0, spaceIdx);
-        }
-        int colonIndx = command.indexOf(':');
-        String scope = (colonIndx > 0) ? command.substring(0, colonIndx) : "*";
-        String name  = (colonIndx > 0) ? command.substring(colonIndx + 1) : 
command;
-        try {
-            long start = System.currentTimeMillis();
-            long cur   = start;
-            while (cur - start < SERVICE_TIMEOUT) {
-                if (sessionFactory.getRegistry().getCommand(scope, name) != 
null) {
-                    return;
-                }
-                Thread.sleep(100);
-                cur = System.currentTimeMillis();
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-
-    protected Bundle getInstalledBundle(String symbolicName) {
-        for (Bundle b : bundleContext.getBundles()) {
-            if (b.getSymbolicName().equals(symbolicName)) {
-                return b;
-            }
-        }
-        for (Bundle b : bundleContext.getBundles()) {
-            System.err.println("Bundle: " + b.getSymbolicName());
-        }
-        throw new RuntimeException("Bundle " + symbolicName + " does not 
exist");
-    }
-
-    /**
-     * Explodes the dictionary into a ,-delimited list of key=value pairs
-     */
-    private static String explode(Dictionary dictionary) {
-        Enumeration keys = dictionary.keys();
-        StringBuffer result = new StringBuffer();
-        while (keys.hasMoreElements()) {
-            Object key = keys.nextElement();
-            result.append(String.format("%s=%s", key, dictionary.get(key)));
-            if (keys.hasMoreElements()) {
-                result.append(", ");
-            }
-        }
-        return result.toString();
-    }
-
-    protected <T> T getOsgiService(Class<T> type, long timeout) {
-        return getOsgiService(type, null, timeout);
-    }
-
-    protected <T> T getOsgiService(Class<T> type) {
-        return getOsgiService(type, null, SERVICE_TIMEOUT);
-    }
-
-    protected <T> T getOsgiService(Class<T> type, String filter, long timeout) 
{
-        ServiceTracker tracker = null;
-        try {
-            String flt;
-            if (filter != null) {
-                if (filter.startsWith("(")) {
-                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() 
+ ")" + filter + ")";
-                } else {
-                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() 
+ ")(" + filter + "))";
-                }
-            } else {
-                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
-            }
-            Filter osgiFilter = FrameworkUtil.createFilter(flt);
-            tracker = new ServiceTracker(bundleContext, osgiFilter, null);
-            tracker.open(true);
-            // Note that the tracker is not closed to keep the reference
-            // This is buggy, as the service reference may change i think
-            Object svc = type.cast(tracker.waitForService(timeout));
-            if (svc == null) {
-                Dictionary dic = bundleContext.getBundle().getHeaders();
-                System.err.println("Test bundle headers: " + explode(dic));
-
-                for (ServiceReference ref : 
asCollection(bundleContext.getAllServiceReferences(null, null))) {
-                    System.err.println("ServiceReference: " + ref);
-                }
-
-                for (ServiceReference ref : 
asCollection(bundleContext.getAllServiceReferences(null, flt))) {
-                    System.err.println("Filtered ServiceReference: " + ref);
-                }
-
-                throw new RuntimeException("Gave up waiting for service " + 
flt);
-            }
-            return type.cast(svc);
-        } catch (InvalidSyntaxException e) {
-            throw new IllegalArgumentException("Invalid filter", e);
-        } catch (InterruptedException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Finds a free port starting from the give port numner.
-     *
-     * @return
-     */
-    protected int getFreePort(int port) {
-        while (!isPortAvailable(port)) {
-            port++;
-        }
-        return port;
+    public void installCellar() {
+        System.out.println("Installing Cellar ...");
+        System.out.println(executeCommand("feature:repo-add cellar " + 
System.getProperty("cellar.version")));
+        System.out.println(executeCommand("feature:install cellar", new 
RolePrincipal("admin")));
+        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
+        assertNotNull(clusterManager);
     }
 
-    /**
-     * Returns true if port is available for use.
-     *
-     * @param port
-     * @return
-     */
-    public static boolean isPortAvailable(int port) {
-        ServerSocket ss = null;
-        DatagramSocket ds = null;
-        try {
-            ss = new ServerSocket(port);
-            ss.setReuseAddress(true);
-            ds = new DatagramSocket(port);
-            ds.setReuseAddress(true);
-            return true;
-        } catch (IOException e) {
-        } finally {
-            if (ds != null) {
-                ds.close();
-            }
+    public void createCellarInstance(String name) throws Exception {
+        System.out.println("Creating " + name + " Cellar instance ...");
+        System.out.println(executeCommand("instance:create --featureURL 
mvn:org.apache.karaf.cellar/apache-karaf-cellar/" + 
System.getProperty("cellar.version") + "/xml/features --feature cellar " + 
name));
+        System.out.println(executeCommand("instance:start " + name));
 
-            if (ss != null) {
-                try {
-                    ss.close();
-                } catch (IOException e) {
-                    /* should not be thrown */
-                }
-            }
+        System.out.println("Waiting " + name + " instance to be fully started 
...");
+        boolean started = false;
+        while (!started) {
+            Thread.sleep(2000);
+            String status = executeCommand("instance:status " + name);
+            System.out.println(status);
+            started = status.contains("Started");
         }
-        return false;
     }
 
-    /*
-     * Provides an iterable collection of references, even if the original 
array is null
-     */
-    private static Collection<ServiceReference> 
asCollection(ServiceReference[] references) {
-        return references != null ? Arrays.asList(references) : 
Collections.<ServiceReference>emptyList();
+    public void stopAndDestroyCellarInstance(String name) {
+        System.out.println("Stopping " + name + " Cellar instance ...");
+        System.out.println(executeCommand("instance:stop " + name));
+        System.out.println("Destroying " + name + " Cellar instance ...");
+        System.out.println(executeCommand("instance:destroy " + name));
     }
 
 }
diff --git a/itests/src/test/resources/controlled-exam.properties 
b/itests/src/test/resources/controlled-exam.properties
new file mode 100644
index 00000000..a3ddc119
--- /dev/null
+++ b/itests/src/test/resources/controlled-exam.properties
@@ -0,0 +1,29 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+# default, javaee, test (default), cdi
+# for "cdi" we use PaxExam.delegate = 
org.ops4j.pax.exam.junit.impl.InjectingRunner
+# otherwise it's PaxExam.delegate = org.ops4j.pax.exam.junit.impl.ProbeRunner
+# "test" adds some default @Configuration Option[]
+# "default" allows manual control over provided @Configuration/Option[]
+pax.exam.system = default
+
+# 10000 ms by default
+pax.exam.service.timeout = 3600000
+
+# "pax-logging" by default which adds 
link:classpath:META-INF/links/org.ops4j.pax.logging.api.link;start-level=2
+pax.exam.logging = pax-logging
diff --git a/itests/src/test/resources/etc/org.ops4j.pax.logging.cfg 
b/itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
new file mode 100644
index 00000000..7810329f
--- /dev/null
+++ b/itests/src/test/resources/etc/org.ops4j.pax.logging.cfg
@@ -0,0 +1,69 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+################################################################################
+
+# Common pattern layout for appenders
+log4j2.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{bundle.id} - 
%X{bundle.name} - %X{bundle.version} | %m%n
+
+# Root logger
+log4j2.rootLogger.level = INFO
+# uncomment to use asynchronous loggers, which require 
mvn:com.lmax/disruptor/3.3.2 library
+#log4j2.rootLogger.type = asyncRoot
+#log4j2.rootLogger.includeLocation = false
+log4j2.rootLogger.appenderRefs = RollingFile, PaxOsgi, Console
+log4j2.rootLogger.appenderRef.RollingFile.ref = RollingFile
+log4j2.rootLogger.appenderRef.PaxOsgi.ref = PaxOsgi
+log4j2.rootLogger.appenderRef.Console.ref = Console
+log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter
+log4j2.rootLogger.appenderRef.Console.filter.threshold.level = 
${karaf.log.console:-OFF}
+
+# Appenders configuration
+log4j2.appenders = console, rolling, osgi
+
+# CONSOLE appender not used by default
+log4j2.appender.console.type = Console
+log4j2.appender.console.name = Console
+log4j2.appender.console.layout.type = PatternLayout
+log4j2.appender.console.layout.pattern = ${log4j2.pattern}
+
+# File appender
+log4j2.appender.rolling.type = RollingRandomAccessFile
+log4j2.appender.rolling.name = RollingFile
+log4j2.appender.rolling.fileName = ${karaf.log}/karaf.log
+log4j2.appender.rolling.filePattern = ${karaf.log}/karaf.log.%i
+# uncomment to not force a disk flush
+#log4j2.appender.rolling.immediateFlush = false
+log4j2.appender.rolling.append = true
+log4j2.appender.rolling.layout.type = PatternLayout
+log4j2.appender.rolling.layout.pattern = ${log4j2.pattern}
+log4j2.appender.rolling.policies.type = Policies
+log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
+log4j2.appender.rolling.policies.size.size = 16MB
+
+# OSGi appender
+log4j2.appender.osgi.type = PaxOsgi
+log4j2.appender.osgi.name = PaxOsgi
+log4j2.appender.osgi.filter = *
+
+# help with identification of maven-related problems with pax-url-aether
+#log4j2.logger.aether.name = shaded.org.eclipse.aether
+#log4j2.logger.aether.level = TRACE
+#log4j2.logger.http-headers.name = shaded.org.apache.http.headers
+#log4j2.logger.http-headers.level = DEBUG
+#log4j2.logger.maven.name = org.ops4j.pax.url.mvn
+#log4j2.logger.maven.level = TRACE
\ No newline at end of file
diff --git a/itests/src/test/resources/etc/users.properties 
b/itests/src/test/resources/etc/users.properties
new file mode 100644
index 00000000..a3d328cb
--- /dev/null
+++ b/itests/src/test/resources/etc/users.properties
@@ -0,0 +1,33 @@
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+################################################################################
+
+#
+# This file contains the users, groups, and roles.
+# Each line has to be of the format:
+#
+# USER=PASSWORD,ROLE1,ROLE2,...
+# USER=PASSWORD,_g_:GROUP,...
+# _g_\:GROUP=ROLE1,ROLE2,...
+#
+# All users, groups, and roles entered in this file are available after Karaf 
startup
+# and modifiable via the JAAS command group. These users reside in a JAAS 
domain
+# with the name "karaf".
+#
+karaf = karaf,_g_:admingroup
+_g_\:admingroup = group,admin,manager,viewer,systembundles,ssh
\ No newline at end of file
diff --git a/itests/src/test/resources/log4j.properties 
b/itests/src/test/resources/log4j.properties
new file mode 100644
index 00000000..376a5579
--- /dev/null
+++ b/itests/src/test/resources/log4j.properties
@@ -0,0 +1,33 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, console, file
+
+# Console will only display warnings
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{ISO8601} | %-5.5p | 
%-32.32C %4L | %m%n
+
+# File appender will contain all info messages
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
+log4j.appender.file.file=target/test.log
+log4j.appender.file.append=true
\ No newline at end of file

Reply via email to