From 45d5073d1ab854cdc6174e48c7ce818964a63c08 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 13 Jan 2009 22:40:13 +0000 Subject: 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 --- java/sca/tools/maven/maven-osgi-junit/pom.xml | 6 +-- .../tools/sca/osgi/junit/plugin/OSGiJUnitMojo.java | 46 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 8 deletions(-) (limited to 'java/sca/tools/maven/maven-osgi-junit') 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 @@ org.apache.maven maven-plugin-api - 2.0.7 + 2.0.8 org.apache.maven maven-project - 2.0.7 + 2.0.8 org.apache.tuscany.sca - tuscany-node-launcher-osgi + tuscany-node-launcher-equinox 2.0-SNAPSHOT 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)); } } -- cgit v1.2.3