FELIX-4294: adapted tests to the new dependency manager shell, which is now only using Gogo.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1550892 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/test/pom.xml b/dependencymanager/test/pom.xml
index 6031681..7fb679f 100644
--- a/dependencymanager/test/pom.xml
+++ b/dependencymanager/test/pom.xml
@@ -64,12 +64,12 @@
<version>3.1.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.shell</artifactId>
- <version>1.4.2</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ <version>0.10.0</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -156,6 +156,7 @@
<Bundle-Name>Apache Felix Dependency Manager Annotations Tests</Bundle-Name>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Export-Package>org.apache.felix.dm.test.components</Export-Package>
+ <Import-Package>org.apache.felix.service.command; status="provisional", *</Import-Package>
</instructions>
</configuration>
</plugin>
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/api/FELIX2955_ShellCommandTest.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/api/FELIX2955_ShellCommandTest.java
index 65e4d2d..f0b3f31 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/api/FELIX2955_ShellCommandTest.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/api/FELIX2955_ShellCommandTest.java
@@ -20,6 +20,7 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.util.regex.Pattern;
import junit.framework.Assert;
@@ -27,7 +28,8 @@
import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.test.components.Ensure;
import org.apache.felix.dm.test.integration.common.TestBase;
-import org.apache.felix.shell.ShellService;
+import org.apache.felix.service.command.CommandProcessor;
+import org.apache.felix.service.command.CommandSession;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.PaxExam;
@@ -54,7 +56,7 @@
Component shellClient = m.createComponent()
.setImplementation(new ShellClient(e))
.add(m.createServiceDependency()
- .setService(ShellService.class)
+ .setService(CommandProcessor.class)
.setRequired(true)
);
m.add(shellClient);
@@ -83,7 +85,7 @@
}
public class ShellClient {
- volatile ShellService m_shell;
+ volatile CommandProcessor m_commandProcessor;
private final Ensure m_ensure;
public ShellClient(Ensure e) {
@@ -94,28 +96,29 @@
Thread t = new Thread("Shell Client") {
public void run() {
m_ensure.step(1);
- execute("dm " + m_testBundleId,
- "[" + m_testBundleId + "] pax-exam-probe\n" +
- " ShellClient registered\n" +
- " org.apache.felix.shell.ShellService service required available\n",
- "");
+ execute("dm bid " + m_testBundleId,
+ "\\[" + m_testBundleId + "\\] PAXEXAM-PROBE.*\n" +
+ " \\[.*\\] ShellClient registered\n" +
+ " org.apache.felix.service.command.CommandProcessor service required available\n",
+ "");
+
m_ensure.step(2);
// see if there's anything that's not available
- execute("dm notavail " + m_testBundleId,
+ execute("dm notavail bid " + m_testBundleId,
"",
"");
m_ensure.step(3);
// check again, now there should be something missing
m_ensure.waitForStep(4, 5000);
- execute("dm notavail " + m_testBundleId,
- "[" + m_testBundleId + "] pax-exam-probe\n" +
- " Object unregistered\n" +
- " java.lang.Object service required unavailable\n",
- "");
+ execute("dm notavail bid " + m_testBundleId,
+ "\\[" + m_testBundleId + "\\] PAXEXAM-PROBE.*\n" +
+ " \\[.*\\] Object unregistered\n" +
+ " java.lang.Object service required unavailable\n",
+ "");
m_ensure.step(5);
m_ensure.waitForStep(6, 5000);
// this next step actually triggers the bug in FELIX-2955
- execute("dm notavail " + m_testBundleId,
+ execute("dm notavail bid " + m_testBundleId,
"",
"");
m_ensure.step(7);
@@ -133,9 +136,13 @@
try {
ByteArrayOutputStream output = new ByteArrayOutputStream();
ByteArrayOutputStream error = new ByteArrayOutputStream();
- m_shell.executeCommand(command, new PrintStream(output), new PrintStream(error));
- // In pax-exam 3.0.0, we have to work around something like "[25] PAXEXAM-PROBE-3f88597d-4bc5-4bf4-affb-74db4e453e71 ..."
- Assert.assertEquals(expectedOutput, output.toString().replaceAll("PAXEXAM-PROBE.*", "pax-exam-probe"));
+ CommandSession session = m_commandProcessor.createSession(System.in, new PrintStream(output), new PrintStream(error));
+ session.execute(command);
+
+ String out = output.toString();
+ Pattern p = Pattern.compile(expectedOutput, Pattern.MULTILINE);
+
+ Assert.assertTrue("\n\nexpected:\n\n" + expectedOutput + "\nbut got:\n\n" + out, p.matcher(out).matches());
Assert.assertEquals(expectedError, error.toString());
}
catch (Throwable throwable) {
diff --git a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/common/TestBase.java b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/common/TestBase.java
index a839dce..c74f501 100644
--- a/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/common/TestBase.java
+++ b/dependencymanager/test/src/test/java/org/apache/felix/dm/test/integration/common/TestBase.java
@@ -81,7 +81,7 @@
protected static final String TESTBUNDLE_SN_DEF = "org.apache.felix.dependencymanager.test";
// The package exported by our test bundle, which we import from all integration tests.
- private static final String TESTBUNDLE_PACKAGE = "org.apache.felix.dm.test.components";
+ private static final String TESTBUNDLE_PACKAGE = "org.apache.felix.dm.test.components, org.apache.felix.service.command;status=provisional";
// The actual JVM option set, extensions may implement a static
// initializer overwriting this value to have the configuration()
@@ -143,7 +143,7 @@
bootDelegationPackages("org.netbeans.*"), // For jvisualvm
mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.0.8"),
mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.6.0"),
- mavenBundle("org.apache.felix", "org.apache.felix.shell", "1.4.2"),
+ mavenBundle("org.apache.felix", "org.apache.felix.gogo.runtime", "0.10.0"),
mavenBundle("org.apache.felix", "org.apache.felix.deploymentadmin", "0.9.0").start(false),
mavenBundle("org.ops4j.pax.tinybundles", "tinybundles", "1.0.0"),
mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager","3.1.1-SNAPSHOT"),