You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2012/10/02 13:58:18 UTC
svn commit: r1392866 - in /karaf/trunk/itests: ./
src/test/java/org/apache/karaf/itests/
Author: cschneider
Date: Tue Oct 2 11:58:17 2012
New Revision: 1392866
URL: http://svn.apache.org/viewvc?rev=1392866&view=rev
Log:
KARAF-1887 Waiting for boot to finish and some other small improvements
Added:
karaf/trunk/itests/src/test/java/org/apache/karaf/itests/BootFeaturesTest.java (with props)
Modified:
karaf/trunk/itests/pom.xml
karaf/trunk/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
karaf/trunk/itests/src/test/java/org/apache/karaf/itests/LogTest.java
karaf/trunk/itests/src/test/java/org/apache/karaf/itests/RegionTest.java
karaf/trunk/itests/src/test/java/org/apache/karaf/itests/StandardFeaturesTest.java
Modified: karaf/trunk/itests/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/pom.xml?rev=1392866&r1=1392865&r2=1392866&view=diff
==============================================================================
--- karaf/trunk/itests/pom.xml (original)
+++ karaf/trunk/itests/pom.xml Tue Oct 2 11:58:17 2012
@@ -42,7 +42,6 @@
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
- <version>${project.version}</version>
<scope>test</scope>
<type>zip</type>
<exclusions>
@@ -55,7 +54,6 @@
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
- <version>${project.version}</version>
<scope>test</scope>
<type>tar.gz</type>
<exclusions>
@@ -74,7 +72,6 @@
<dependency>
<groupId>org.apache.karaf.tooling.exam</groupId>
<artifactId>org.apache.karaf.tooling.exam.container</artifactId>
- <version>${project.version}</version>
<scope>test</scope>
</dependency>
Added: karaf/trunk/itests/src/test/java/org/apache/karaf/itests/BootFeaturesTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/java/org/apache/karaf/itests/BootFeaturesTest.java?rev=1392866&view=auto
==============================================================================
--- karaf/trunk/itests/src/test/java/org/apache/karaf/itests/BootFeaturesTest.java (added)
+++ karaf/trunk/itests/src/test/java/org/apache/karaf/itests/BootFeaturesTest.java Tue Oct 2 11:58:17 2012
@@ -0,0 +1,17 @@
+package org.apache.karaf.itests;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.ExamReactorStrategy;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
+
+@RunWith(JUnit4TestRunner.class)
+@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
+public class BootFeaturesTest extends KarafTestSupport {
+
+ @Test
+ public void testBootFeatures() throws Exception {
+ assertFeaturesInstalled("standard", "config", "region", "package", "kar", "ssh", "management");
+ }
+}
Propchange: karaf/trunk/itests/src/test/java/org/apache/karaf/itests/BootFeaturesTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: karaf/trunk/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java?rev=1392866&r1=1392865&r2=1392866&view=diff
==============================================================================
--- karaf/trunk/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java (original)
+++ karaf/trunk/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java Tue Oct 2 11:58:17 2012
@@ -26,7 +26,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -40,6 +42,7 @@ import javax.management.remote.JMXServic
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
+import org.apache.karaf.features.BootFinished;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.tooling.exam.options.LogLevelOption;
@@ -68,6 +71,12 @@ public class KarafTestSupport {
@Inject
FeaturesService featureService;
+
+ /**
+ * To make sure the tests run only when the boot features are fully installed
+ */
+ @Inject
+ BootFinished bootFinished;
@ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
@@ -81,7 +90,7 @@ public class KarafTestSupport {
karafDistributionConfiguration().frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf").versionAsInProject().type("tar.gz"))
.name("Apache Karaf").unpackDirectory(new File("target/exam")),
keepRuntimeFolder(),
- logLevel(LogLevelOption.LogLevel.ERROR) };
+ logLevel(LogLevelOption.LogLevel.INFO) };
}
/**
@@ -231,5 +240,16 @@ public class KarafTestSupport {
}
Assert.fail("Feature " + featureName + " should be installed but is not");
}
+
+ public void assertFeaturesInstalled(String ... expectedFeatures) {
+ Set<String> expectedFeaturesSet = new HashSet<String>(Arrays.asList(expectedFeatures));
+ Feature[] features = featureService.listInstalledFeatures();
+ Set<String> installedFeatures = new HashSet<String>();
+ for (Feature feature : features) {
+ installedFeatures.add(feature.getName());
+ }
+ String msg = "Expecting the following features to be installed : " + expectedFeaturesSet + " but found " + installedFeatures;
+ Assert.assertTrue(msg, installedFeatures.containsAll(expectedFeaturesSet));
+ }
}
Modified: karaf/trunk/itests/src/test/java/org/apache/karaf/itests/LogTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/java/org/apache/karaf/itests/LogTest.java?rev=1392866&r1=1392865&r2=1392866&view=diff
==============================================================================
--- karaf/trunk/itests/src/test/java/org/apache/karaf/itests/LogTest.java (original)
+++ karaf/trunk/itests/src/test/java/org/apache/karaf/itests/LogTest.java Tue Oct 2 11:58:17 2012
@@ -26,14 +26,18 @@ import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
public class LogTest extends KarafTestSupport {
+ private static final Logger LOGGER = LoggerFactory.getLogger(LogTest.class);
@Test
public void setDebugAndDisplay() throws Exception {
System.out.println(executeCommand("log:set DEBUG"));
+ LOGGER.debug("Making sure there is DEBUG level output");
String displayOutput = executeCommand("log:display");
System.out.println(displayOutput);
assertTrue(displayOutput.contains("DEBUG"));
Modified: karaf/trunk/itests/src/test/java/org/apache/karaf/itests/RegionTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/java/org/apache/karaf/itests/RegionTest.java?rev=1392866&r1=1392865&r2=1392866&view=diff
==============================================================================
--- karaf/trunk/itests/src/test/java/org/apache/karaf/itests/RegionTest.java (original)
+++ karaf/trunk/itests/src/test/java/org/apache/karaf/itests/RegionTest.java Tue Oct 2 11:58:17 2012
@@ -13,32 +13,34 @@
*/
package org.apache.karaf.itests;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
-import static org.junit.Assert.assertTrue;
-
@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
public class RegionTest extends KarafTestSupport {
@Test
public void infoCommand() throws Exception {
+ Thread.sleep(1000);
String infoOutput = executeCommand("region:info");
System.out.println(infoOutput);
- assertTrue(infoOutput.contains("org.eclipse.equinox.region.kernel"));
- assertTrue(infoOutput.contains("org.apache.karaf.region.application"));
+ assertTrue("Region org.eclipse.equinox.region.kernel should be present", infoOutput.contains("org.eclipse.equinox.region.kernel"));
+ assertTrue("Region org.apache.karaf.region.application should be present", infoOutput.contains("org.apache.karaf.region.application"));
}
@Test
public void addRegionCommand() throws Exception {
+ Thread.sleep(2000);
System.out.println(executeCommand("region:addregion itest"));
String infoOutput = executeCommand("region:info");
System.out.println(infoOutput);
- assertTrue(infoOutput.contains("itest"));
+ assertTrue("Region itest should be present", infoOutput.contains("itest"));
}
}
Modified: karaf/trunk/itests/src/test/java/org/apache/karaf/itests/StandardFeaturesTest.java
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/src/test/java/org/apache/karaf/itests/StandardFeaturesTest.java?rev=1392866&r1=1392865&r2=1392866&view=diff
==============================================================================
--- karaf/trunk/itests/src/test/java/org/apache/karaf/itests/StandardFeaturesTest.java (original)
+++ karaf/trunk/itests/src/test/java/org/apache/karaf/itests/StandardFeaturesTest.java Tue Oct 2 11:58:17 2012
@@ -25,13 +25,7 @@ public class StandardFeaturesTest extend
@Test
public void testBootFeatures() throws Exception {
- assertFeatureInstalled("standard");
- assertFeatureInstalled("config");
- assertFeatureInstalled("region");
- assertFeatureInstalled("package");
- assertFeatureInstalled("kar");
- assertFeatureInstalled("ssh");
- assertFeatureInstalled("management");
+ assertFeaturesInstalled("standard", "config2", "region", "package", "kar", "ssh", "management");
}
private void installAndAssertFeature(String feature) throws Exception {