Fix problem with exported commands not being available from the console, fix integration tests
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@772643 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/gshell/gshell-admin/pom.xml b/karaf/gshell/gshell-admin/pom.xml
index e9bef99..644ea1e 100644
--- a/karaf/gshell/gshell-admin/pom.xml
+++ b/karaf/gshell/gshell-admin/pom.xml
@@ -161,6 +161,7 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/gshell/gshell-config/pom.xml b/karaf/gshell/gshell-config/pom.xml
index 9867abb..b240ba7 100644
--- a/karaf/gshell/gshell-config/pom.xml
+++ b/karaf/gshell/gshell-config/pom.xml
@@ -76,6 +76,7 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/gshell/gshell-features/pom.xml b/karaf/gshell/gshell-features/pom.xml
index 9f41944..4a4701e 100644
--- a/karaf/gshell/gshell-features/pom.xml
+++ b/karaf/gshell/gshell-features/pom.xml
@@ -92,9 +92,10 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
- org.apache.felix.karaf.gshell.core,
org.apache.geronimo.gshell.wisdom.registry,
+ org.apache.felix.karaf.gshell.core,
org.springframework.beans.factory.config,
*
</Import-Package>
diff --git a/karaf/gshell/gshell-log/pom.xml b/karaf/gshell/gshell-log/pom.xml
index 54f765d..7434fdc 100644
--- a/karaf/gshell/gshell-log/pom.xml
+++ b/karaf/gshell/gshell-log/pom.xml
@@ -77,6 +77,7 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/gshell/gshell-obr/pom.xml b/karaf/gshell/gshell-obr/pom.xml
index 6ade759..f7e9e6b 100644
--- a/karaf/gshell/gshell-obr/pom.xml
+++ b/karaf/gshell/gshell-obr/pom.xml
@@ -68,8 +68,11 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
+ <Export-Package>
+ ${pom.artifactId}*;version=${project.version}
+ </Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/gshell/gshell-osgi/pom.xml b/karaf/gshell/gshell-osgi/pom.xml
index b0af3a7..8fe8173 100644
--- a/karaf/gshell/gshell-osgi/pom.xml
+++ b/karaf/gshell/gshell-osgi/pom.xml
@@ -70,6 +70,7 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/gshell/gshell-packages/pom.xml b/karaf/gshell/gshell-packages/pom.xml
index 8479242..617769d 100644
--- a/karaf/gshell/gshell-packages/pom.xml
+++ b/karaf/gshell/gshell-packages/pom.xml
@@ -71,6 +71,7 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/gshell/gshell-wrapper/pom.xml b/karaf/gshell/gshell-wrapper/pom.xml
index ef6cc5a..02b3456 100644
--- a/karaf/gshell/gshell-wrapper/pom.xml
+++ b/karaf/gshell/gshell-wrapper/pom.xml
@@ -99,6 +99,7 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
+ org.apache.geronimo.gshell.command,
org.apache.geronimo.gshell.wisdom.command,
org.apache.geronimo.gshell.wisdom.registry,
org.apache.felix.karaf.gshell.core,
diff --git a/karaf/itests/pom.xml b/karaf/itests/pom.xml
index 006b543..18828f4 100644
--- a/karaf/itests/pom.xml
+++ b/karaf/itests/pom.xml
@@ -89,35 +89,6 @@
<version>4.5</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.ops4j.pax.runner.profiles</groupId>
- <artifactId>log</artifactId>
- <version>1.3.0</version>
- <type>composite</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.runner.profiles</groupId>
- <artifactId>felix.config</artifactId>
- <version>1.0.10</version>
- <type>composite</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.runner.profiles</groupId>
- <artifactId>spring</artifactId>
- <version>2.5.6</version>
- <type>composite</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.runner.profiles</groupId>
- <artifactId>spring.dm</artifactId>
- <version>1.2.0-rc1</version>
- <type>composite</type>
- <scope>test</scope>
- </dependency>
</dependencies>
<repositories>
@@ -125,10 +96,6 @@
<id>ops4j.releases</id>
<url>http://repository.ops4j.org/maven2</url>
</repository>
- <repository>
- <id>ops4j.profiles</id>
- <url>http://scm.ops4j.org/repos/ops4j/projects/pax/runner-repository</url>
- </repository>
</repositories>
<pluginRepositories>
<pluginRepository>
diff --git a/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/AbstractIntegrationTest.java b/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/AbstractIntegrationTest.java
index 74e731a..3096f17 100644
--- a/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/AbstractIntegrationTest.java
+++ b/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/AbstractIntegrationTest.java
@@ -16,6 +16,8 @@
*/
package org.apache.felix.karaf.gshell.itests;
+import java.util.Dictionary;
+
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
@@ -39,6 +41,7 @@
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 abstract class AbstractIntegrationTest {
@@ -71,11 +74,23 @@
}
Filter osgiFilter = FrameworkUtil.createFilter(flt);
tracker = new ServiceTracker(bundleContext, osgiFilter, null);
- tracker.open();
+ tracker.open(true);
// Note that the tracker is not closed to keep the reference
- // This is buggy, has the service reference may change i think
+ // 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: " + dic);
+ ServiceReference[] refs = bundleContext.getAllServiceReferences(null, null);
+ for (ServiceReference ref : refs) {
+ System.err.println("ServiceReference: " + ref);
+ }
+ refs = bundleContext.getAllServiceReferences(null, flt);
+ for (ServiceReference ref : refs) {
+ System.err.println("Filtered ServiceReference: " + ref);
+ }
+
throw new RuntimeException("Gave up waiting for service " + flt);
}
return type.cast(svc);
@@ -104,50 +119,4 @@
return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
}
- @Configuration
- public static Option[] configuration() {
- Option[] options = options(
- // install log service using pax runners profile abstraction (there are more profiles, like DS)
- profile("log").version("1.3.0"),
- profile("felix.config").version("1.0.10"),
- profile("spring.dm").version("1.2.0-rc1"),
-
- // this is how you set the default log level when using pax logging (logProfile)
- systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
- systemProperty("karaf.name").value("root"),
- systemProperty("karaf.base").value("target/smx.base"),
- systemProperty("karaf.startLocalConsole").value("false"),
- systemProperty("karaf.startRemoteShell").value("false"),
-
- // hack system packages
- systemPackages("org.apache.felix.karaf.main.spi;version=1.0.0", "org.apache.felix.karaf.jaas.boot"),
- bootClasspathLibrary(mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.boot")).afterFramework(),
- bootClasspathLibrary(mavenBundle("org.apache.felix.karaf", "org.apache.felix.karaf.main")).afterFramework(),
-
- // Bundles
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.jline"),
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-httpclient"),
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-jexl"),
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-vfs"),
- mavenBundle("org.apache.mina", "mina-core"),
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.oro"),
- mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.config"),
- mavenBundle("org.apache.sshd", "sshd-core"),
- mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.core"),
- mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.osgi"),
- mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.log").noStart(),
-
-
-// mavenBundle("org.apache.felix", "org.apache.felix.bundlerepository"),
-
- scanFeatures(
- maven().groupId("org.apache.felix.karaf").artifactId("apache-felix-karaf").type("xml").classifier("features").versionAsInProject(),
- "obr", "wrapper"
- ),
-
- felix()
- );
- return options;
- }
-
}
diff --git a/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/CoreTest.java b/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/CoreTest.java
index e0cd93a..a29c6a4 100644
--- a/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/CoreTest.java
+++ b/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/CoreTest.java
@@ -19,27 +19,37 @@
import org.apache.geronimo.gshell.commandline.CommandLineExecutionFailed;
import org.apache.geronimo.gshell.registry.NoSuchCommandException;
import org.apache.geronimo.gshell.shell.Shell;
+import org.apache.geronimo.gshell.command.Command;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.bootClasspathLibrary;
+import static org.ops4j.pax.exam.CoreOptions.felix;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
@RunWith(JUnit4TestRunner.class)
-public class CoreTest extends AbstractIntegrationTest{
+public class CoreTest extends AbstractIntegrationTest {
@Test
public void testHelp() throws Exception {
+ Thread.sleep(5000);
+
Shell shell = getOsgiService(Shell.class);
shell.execute("help");
}
@Test
public void testInstallCommand() throws Exception {
+ Thread.sleep(5000);
+
Shell shell = getOsgiService(Shell.class);
try {
@@ -53,10 +63,14 @@
Bundle b = getInstalledBundle("org.apache.felix.karaf.gshell.log");
b.start();
+ Thread.sleep(1000);
+
shell.execute("log/display");
b.stop();
+ Thread.sleep(1000);
+
try {
shell.execute("log/display");
fail("command should not exist");
@@ -68,6 +82,8 @@
@Test
public void testCommandGroup() throws Exception {
+ Thread.sleep(5000);
+
Shell shell = getOsgiService(Shell.class);
shell.execute("osgi");
shell.execute("help");
@@ -78,6 +94,9 @@
public void testCommandGroupAfterInstall() throws Exception {
Bundle b = getInstalledBundle("org.apache.felix.karaf.gshell.log");
b.start();
+
+ Thread.sleep(5000);
+
Shell shell = getOsgiService(Shell.class);
shell.execute("log");
shell.execute("help");
@@ -86,7 +105,53 @@
@Configuration
public static Option[] configuration() {
- return AbstractIntegrationTest.configuration();
+ Option[] options = options(
+ // this is how you set the default log level when using pax logging (logProfile)
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+ systemProperty("karaf.name").value("root"),
+ systemProperty("karaf.home").value("target/karaf.home"),
+ systemProperty("karaf.base").value("target/karaf.home"),
+ systemProperty("karaf.startLocalConsole").value("false"),
+ systemProperty("karaf.startRemoteShell").value("false"),
+
+ // hack system packages
+ systemPackages("org.apache.felix.karaf.main.spi;version=1.0.0", "org.apache.felix.karaf.jaas.boot;version=1.2.0"),
+ bootClasspathLibrary(mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.boot")).afterFramework(),
+ bootClasspathLibrary(mavenBundle("org.apache.felix.karaf", "org.apache.felix.karaf.main")).afterFramework(),
+
+ // Log
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ // Felix Config Admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ // Spring-DM
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.aopalliance"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"),
+ mavenBundle("org.springframework", "spring-aop"),
+ mavenBundle("org.springframework", "spring-beans"),
+ mavenBundle("org.springframework", "spring-context"),
+ mavenBundle("org.springframework", "spring-core"),
+ mavenBundle("org.springframework.osgi", "spring-osgi-core"),
+ mavenBundle("org.springframework.osgi", "spring-osgi-extender"),
+ mavenBundle("org.springframework.osgi", "spring-osgi-io"),
+
+ // Bundles
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.jline"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-httpclient"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-jexl"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-vfs"),
+ mavenBundle("org.apache.mina", "mina-core"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.oro"),
+ mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.config"),
+ mavenBundle("org.apache.sshd", "sshd-core"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.core"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.run"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.osgi"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.log").noStart(),
+
+ felix()
+ );
+ return options;
}
}
diff --git a/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/FeaturesTest.java b/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/FeaturesTest.java
index 2255846..0b84c73 100644
--- a/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/FeaturesTest.java
+++ b/karaf/itests/src/test/java/org/apache/felix/karaf/gshell/itests/FeaturesTest.java
@@ -16,10 +16,25 @@
*/
package org.apache.felix.karaf.gshell.itests;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
import org.apache.geronimo.gshell.shell.Shell;
+import org.apache.geronimo.gshell.command.Command;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.waitForRBCFor;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.bootClasspathLibrary;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.maven;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
@@ -28,14 +43,69 @@
@Test
public void testFeatures() throws Exception {
+ Thread.sleep(5000);
+
Shell shell = getOsgiService(Shell.class);
- shell.execute("obr");
- shell.execute("wrapper");
+ shell.execute("obr/listUrl");
+ shell.execute("wrapper/install --help");
}
@Configuration
public static Option[] configuration() {
- return AbstractIntegrationTest.configuration();
+ Option[] options = options(
+ // this is how you set the default log level when using pax logging (logProfile)
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+ systemProperty("karaf.name").value("root"),
+ systemProperty("karaf.home").value("target/karaf.home"),
+ systemProperty("karaf.base").value("target/karaf.home"),
+ systemProperty("karaf.startLocalConsole").value("false"),
+ systemProperty("karaf.startRemoteShell").value("false"),
+
+ // hack system packages
+ systemPackages("org.apache.felix.karaf.main.spi;version=1.0.0", "org.apache.felix.karaf.jaas.boot;version=1.2.0"),
+ bootClasspathLibrary(mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.boot")).afterFramework(),
+ bootClasspathLibrary(mavenBundle("org.apache.felix.karaf", "org.apache.felix.karaf.main")).afterFramework(),
+
+ // Log
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+ mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+ // Felix Config Admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+ // Felix Preferences Service
+ mavenBundle("org.apache.felix", "org.apache.felix.prefs"),
+ // Spring-DM
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.aopalliance"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"),
+ mavenBundle("org.springframework", "spring-aop"),
+ mavenBundle("org.springframework", "spring-beans"),
+ mavenBundle("org.springframework", "spring-context"),
+ mavenBundle("org.springframework", "spring-core"),
+ mavenBundle("org.springframework.osgi", "spring-osgi-core"),
+ mavenBundle("org.springframework.osgi", "spring-osgi-extender"),
+ mavenBundle("org.springframework.osgi", "spring-osgi-io"),
+
+ // Bundles
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.jline"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-httpclient"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-jexl"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-vfs"),
+ mavenBundle("org.apache.mina", "mina-core"),
+ mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.oro"),
+ mavenBundle("org.apache.felix.karaf.jaas", "org.apache.felix.karaf.jaas.config"),
+ mavenBundle("org.apache.sshd", "sshd-core"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.core"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.run"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.osgi"),
+ mavenBundle("org.apache.felix.karaf.gshell", "org.apache.felix.karaf.gshell.log").noStart(),
+
+ scanFeatures(
+ maven().groupId("org.apache.felix.karaf").artifactId("apache-felix-karaf").type("xml").classifier("features").versionAsInProject(),
+ "obr", "wrapper"
+ ),
+
+ felix()
+ );
+ return options;
}
}