summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-01-13 22:40:13 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-01-13 22:40:13 +0000
commit45d5073d1ab854cdc6174e48c7ce818964a63c08 (patch)
treeaf2106e5a6ee8a3df1dfe24746b4a93d86a34f85
parent19c66274ef2071a2bd6aa8ccf85c97b54369773c (diff)
Expose the EquinoxHost for the osgi junit plugin
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@734264 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java6
-rw-r--r--java/sca/tools/maven/maven-osgi-junit/pom.xml6
-rw-r--r--java/sca/tools/maven/maven-osgi-junit/src/main/java/org/apache/tuscany/tools/sca/osgi/junit/plugin/OSGiJUnitMojo.java46
3 files changed, 47 insertions, 11 deletions
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
index 6007c0dac2..74dedca4a8 100644
--- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
+++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -49,7 +49,7 @@ import org.osgi.framework.BundleContext;
/**
* Wraps the Equinox runtime.
*/
-class EquinoxHost {
+public class EquinoxHost {
private static Logger logger = Logger.getLogger(EquinoxHost.class.getName());
private BundleContext bundleContext;
@@ -119,7 +119,7 @@ class EquinoxHost {
*
* @return
*/
- BundleContext start() {
+ public BundleContext start() {
try {
if (!EclipseStarter.isRunning()) {
@@ -328,7 +328,7 @@ class EquinoxHost {
/**
* Stop the Equinox host.
*/
- void stop() {
+ public void stop() {
try {
// Uninstall all the bundles we've installed
diff --git a/java/sca/tools/maven/maven-osgi-junit/pom.xml b/java/sca/tools/maven/maven-osgi-junit/pom.xml
index 92607f46e6..3d21c71a97 100644
--- a/java/sca/tools/maven/maven-osgi-junit/pom.xml
+++ b/java/sca/tools/maven/maven-osgi-junit/pom.xml
@@ -34,18 +34,18 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
- <version>2.0.7</version>
+ <version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
- <version>2.0.7</version>
+ <version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-node-launcher-osgi</artifactId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/tools/maven/maven-osgi-junit/src/main/java/org/apache/tuscany/tools/sca/osgi/junit/plugin/OSGiJUnitMojo.java b/java/sca/tools/maven/maven-osgi-junit/src/main/java/org/apache/tuscany/tools/sca/osgi/junit/plugin/OSGiJUnitMojo.java
index a2251a6a2a..c967220768 100644
--- a/java/sca/tools/maven/maven-osgi-junit/src/main/java/org/apache/tuscany/tools/sca/osgi/junit/plugin/OSGiJUnitMojo.java
+++ b/java/sca/tools/maven/maven-osgi-junit/src/main/java/org/apache/tuscany/tools/sca/osgi/junit/plugin/OSGiJUnitMojo.java
@@ -38,8 +38,7 @@ import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
-import org.apache.tuscany.sca.node.osgi.launcher.FelixOSGiHost;
-import org.apache.tuscany.sca.node.osgi.launcher.LauncherBundleActivator;
+import org.apache.tuscany.sca.node.equinox.launcher.EquinoxHost;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -129,6 +128,44 @@ public class OSGiJUnitMojo extends AbstractMojo {
return artifact;
}
+
+ /**
+ * Returns a string representation of the given bundle.
+ *
+ * @param b
+ * @param verbose
+ * @return
+ */
+ static String string(Bundle bundle, boolean verbose) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(bundle.getBundleId()).append(" ").append(bundle.getSymbolicName());
+ int s = bundle.getState();
+ if ((s & Bundle.UNINSTALLED) != 0) {
+ sb.append(" UNINSTALLED");
+ }
+ if ((s & Bundle.INSTALLED) != 0) {
+ sb.append(" INSTALLED");
+ }
+ if ((s & Bundle.RESOLVED) != 0) {
+ sb.append(" RESOLVED");
+ }
+ if ((s & Bundle.STARTING) != 0) {
+ sb.append(" STARTING");
+ }
+ if ((s & Bundle.STOPPING) != 0) {
+ sb.append(" STOPPING");
+ }
+ if ((s & Bundle.ACTIVE) != 0) {
+ sb.append(" ACTIVE");
+ }
+
+ if (verbose) {
+ sb.append(" ").append(bundle.getLocation());
+ sb.append(" ").append(bundle.getHeaders());
+ }
+ return sb.toString();
+ }
+
public void execute() throws MojoExecutionException {
if (project.getPackaging().equals("pom")) {
@@ -170,13 +207,12 @@ public class OSGiJUnitMojo extends AbstractMojo {
// System.setProperty("TUSCANY_HOME", home);
// getLog().info(home);
try {
- FelixOSGiHost host = new FelixOSGiHost();
- host.setActivator(new LauncherBundleActivator(jarFiles));
+ EquinoxHost host = new EquinoxHost();
BundleContext context = host.start();
for (Bundle b : context.getBundles()) {
if (getLog().isDebugEnabled()) {
- getLog().debug(LauncherBundleActivator.toString(b, false));
+ getLog().debug(string(b, false));
}
}