JBoss-OSGI SVN: r90238 - in projects/jboss-osgi/trunk/blueprint: testsuite/src/test/java/org/jboss/test/osgi/blueprint/context and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-16 04:14:25 -0400 (Tue, 16 Jun 2009)
New Revision: 90238
Modified:
projects/jboss-osgi/trunk/blueprint/impl/pom.xml
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
Log:
Ignore BP impl in apidocs
Modified: projects/jboss-osgi/trunk/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-06-16 08:03:11 UTC (rev 90237)
+++ projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-06-16 08:14:25 UTC (rev 90238)
@@ -80,6 +80,19 @@
</plugins>
</build>
+ <!-- Reporting -->
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <show>protected</show>
+ <excludePackageNames>org.jboss.osgi.*</excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+
<!-- Profiles -->
<profiles>
</profiles>
Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java 2009-06-16 08:03:11 UTC (rev 90237)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java 2009-06-16 08:14:25 UTC (rev 90238)
@@ -55,7 +55,6 @@
public static BundleContext context;
private static OSGiRuntime runtime;
- private static OSGiBundle bundle;
@BeforeClass
public static void beforeClass() throws Exception
@@ -67,7 +66,7 @@
runtime.addCapability(new MicrocontainerCapability());
runtime.addCapability(new BlueprintCapability());
- bundle = runtime.installBundle("context-basic.jar");
+ OSGiBundle bundle = runtime.installBundle("context-basic.jar");
bundle.start();
}
}
@@ -76,16 +75,11 @@
public static void afterClass() throws Exception
{
if (context == null)
- {
- if (bundle != null)
- bundle.uninstall();
-
runtime.shutdown();
- }
}
@Test
- public void testBlueprintContext() throws Exception
+ public void testBlueprintBundleInstall() throws Exception
{
if (context == null)
BridgeFactory.getBridge().run();
@@ -94,8 +88,20 @@
Bundle bundle = context.getBundle();
assertEquals("context-basic", bundle.getSymbolicName());
+ }
+
+ @Test
+ public void testBlueprintContext() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge().run();
+ assumeNotNull(context);
+
ServiceReference sref = context.getServiceReference(BlueprintContext.class.getName());
assertNotNull("BlueprintContext registered", sref);
+
+ BlueprintContext bpContext = (BlueprintContext)context.getService(sref);
+
}
}
\ No newline at end of file
15 years
JBoss-OSGI SVN: r90237 - projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-16 04:03:11 -0400 (Tue, 16 Jun 2009)
New Revision: 90237
Modified:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
Log:
optimize uninstall code
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 07:55:57 UTC (rev 90236)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 08:03:11 UTC (rev 90237)
@@ -44,7 +44,6 @@
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiServiceReference;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.service.log.LogReaderService;
@@ -112,7 +111,6 @@
{
OSGiBundle bundle = installBundle(location);
bundle.start();
- bundles.put(location, bundle);
}
else
{
@@ -137,20 +135,7 @@
Collections.reverse(bundleLocations);
for (String location : bundleLocations)
- {
- OSGiBundle bundle = bundles.remove(location);
- if (bundle != null)
- {
- try
- {
- bundle.uninstall();
- }
- catch (BundleException ex)
- {
- log.error("Cannot uninstall bundle: " + bundle);
- }
- }
- }
+ failsafeUninstall(bundles.remove(location));
}
List<Capability> dependencies = capability.getDependencies();
@@ -183,25 +168,13 @@
stopLogEntryTracking();
// Uninstall the registered bundles
- ArrayList<String> bundleLocations = new ArrayList<String>(bundles.keySet());
- Collections.reverse(bundleLocations);
+ ArrayList<String> locations = new ArrayList<String>(bundles.keySet());
+ Collections.reverse(locations);
- while (bundleLocations.size() > 0)
+ while (locations.size() > 0)
{
- String location = bundleLocations.remove(0);
- OSGiBundle bundle = bundles.remove(location);
- if (bundle != null)
- {
- try
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- bundle.uninstall();
- }
- catch (BundleException ex)
- {
- log.warn("Cannot uninstall: " + bundle, ex);
- }
- }
+ String location = locations.remove(0);
+ failsafeUninstall(bundles.remove(location));
}
// Uninstall the capabilities
@@ -284,4 +257,18 @@
return symbolicName;
}
+ private void failsafeUninstall(OSGiBundle bundle)
+ {
+ if (bundle != null)
+ {
+ try
+ {
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.warn("Cannot uninstall bundle: " + bundle, ex);
+ }
+ }
+ }
}
15 years
JBoss-OSGI SVN: r90236 - in projects/jboss-osgi/trunk: spi/src/main/java/org/jboss/osgi/spi/testing/internal and 9 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-16 03:55:57 -0400 (Tue, 16 Jun 2009)
New Revision: 90236
Added:
projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/
projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java
Removed:
projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
Modified:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath
Log:
Runtime maintains single bundle list for shutdown
Copied: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties (from rev 90230, projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties)
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-06-16 07:55:57 UTC (rev 90236)
@@ -0,0 +1,38 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id$
+#
+
+# The OSGiFramework implementation
+org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${test.archive.directory}/../osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Husky socket connector properties
+org.jboss.osgi.husky.runtime.connector.host=localhost
+org.jboss.osgi.husky.runtime.connector.port=5401
+
+# Framework bootdelegation
+# org.osgi.framework.bootdelegation=org.osgi.service.log
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=\
+ org.jboss.logging, \
+ org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.capability;version=1.0, \
+ org.jboss.osgi.spi.management;version=1.0, \
+ org.jboss.osgi.spi.service;version=1.0, \
+ org.jboss.osgi.spi.testing;version=1.0, \
+ org.osgi.framework;version=1.4
+
+# Bundles that need to be installed with the Framework automatically
+org.jboss.osgi.spi.framework.autoInstall=\
+ file://${test.archive.directory}/bundles/org.osgi.compendium.jar
+
+# Bundles that need to be started automatically
+org.jboss.osgi.spi.framework.autoStart=\
+ file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
+ file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Deleted: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties 2009-06-16 07:55:57 UTC (rev 90236)
@@ -1,38 +0,0 @@
-#
-# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
-#
-# $Id$
-#
-
-# The OSGiFramework implementation
-org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
-
-# Properties to configure the Framework
-org.osgi.framework.storage=${test.archive.directory}/../osgi-store
-org.osgi.framework.storage.clean=onFirstInit
-
-# Husky socket connector properties
-org.jboss.osgi.husky.runtime.connector.host=localhost
-org.jboss.osgi.husky.runtime.connector.port=5401
-
-# Framework bootdelegation
-# org.osgi.framework.bootdelegation=org.osgi.service.log
-
-# Extra System Packages
-org.osgi.framework.system.packages.extra=\
- org.jboss.logging, \
- org.jboss.osgi.spi;version=1.0, \
- org.jboss.osgi.spi.capability;version=1.0, \
- org.jboss.osgi.spi.management;version=1.0, \
- org.jboss.osgi.spi.service;version=1.0, \
- org.jboss.osgi.spi.testing;version=1.0, \
- org.osgi.framework;version=1.4
-
-# Bundles that need to be installed with the Framework automatically
-org.jboss.osgi.spi.framework.autoInstall=\
- file://${test.archive.directory}/bundles/org.osgi.compendium.jar
-
-# Bundles that need to be started automatically
-org.jboss.osgi.spi.framework.autoStart=\
- file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
- file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -75,7 +75,7 @@
service.deploy(bundleURL);
OSGiBundle bundle = getBundle(symbolicName, null);
- return registerBundleForUninstall(bundle);
+ return registerBundleForUninstall(location, bundle);
}
public OSGiBundle[] getBundles()
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -26,7 +26,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.Attributes;
@@ -61,8 +61,7 @@
final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
private OSGiTestHelper helper;
- private List<OSGiBundle> registeredBundles = new ArrayList<OSGiBundle>();
- private Map<String, OSGiBundle> capBundles = new HashMap<String, OSGiBundle>();
+ private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
private List<Capability> capabilities = new ArrayList<Capability>();
private LogReaderService logReaderService;
@@ -88,9 +87,9 @@
return logReaderService;
}
- protected OSGiBundle registerBundleForUninstall(OSGiBundle bundle)
+ protected OSGiBundle registerBundleForUninstall(String location, OSGiBundle bundle)
{
- registeredBundles.add(bundle);
+ bundles.put(location, bundle);
return bundle;
}
@@ -109,11 +108,11 @@
for (String location : capability.getBundles())
{
String symName = getSymbolicName(location);
- if (capBundles.get(location) == null && getBundle(symName, null) == null)
+ if (bundles.get(location) == null && getBundle(symName, null) == null)
{
OSGiBundle bundle = installBundle(location);
bundle.start();
- capBundles.put(location, bundle);
+ bundles.put(location, bundle);
}
else
{
@@ -139,7 +138,7 @@
for (String location : bundleLocations)
{
- OSGiBundle bundle = capBundles.remove(location);
+ OSGiBundle bundle = bundles.remove(location);
if (bundle != null)
{
try
@@ -184,19 +183,25 @@
stopLogEntryTracking();
// Uninstall the registered bundles
- Collections.reverse(registeredBundles);
- while (registeredBundles.size() > 0)
+ ArrayList<String> bundleLocations = new ArrayList<String>(bundles.keySet());
+ Collections.reverse(bundleLocations);
+
+ while (bundleLocations.size() > 0)
{
- OSGiBundle bundle = registeredBundles.remove(0);
- try
+ String location = bundleLocations.remove(0);
+ OSGiBundle bundle = bundles.remove(location);
+ if (bundle != null)
{
- if (bundle.getState() != Bundle.UNINSTALLED)
- bundle.uninstall();
+ try
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.warn("Cannot uninstall: " + bundle, ex);
+ }
}
- catch (BundleException ex)
- {
- log.warn("Cannot uninstall: " + bundle, ex);
- }
}
// Uninstall the capabilities
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -79,7 +79,7 @@
deploy(location);
ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName);
RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
- return registerBundleForUninstall(bundle);
+ return registerBundleForUninstall(location, bundle);
}
catch (RuntimeException rte)
{
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath 2009-06-16 07:48:03 UTC (rev 90235)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/.classpath 2009-06-16 07:55:57 UTC (rev 90236)
@@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Added: projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java 2009-06-16 07:55:57 UTC (rev 90236)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.trailblazer.web;
+
+//$Id$
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.log.LogService;
+
+
+/**
+ * A servlet that gets registered with the {@link HttpService} to
+ * render the Trailblazer portal
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 10-May-2009
+ */
+@SuppressWarnings("serial")
+public class MainServlet extends HttpServlet
+{
+ private LogService log;
+
+ private BundleContext context;
+
+ public MainServlet(BundleContext context)
+ {
+ this.log = new LogServiceTracker(context);
+ this.context = context;
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ String path = req.getPathInfo();
+ if (path == null)
+ path = "/";
+
+ renderHeader(req, res);
+
+ renderFooter(req, res);
+
+ out.close();
+ }
+
+ private void renderHeader(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<link rel='stylesheet' href='" + req.getServletPath() + "/style/osgishop.css' type='text/css'>");
+ out.println("</head>");
+ out.println("<body>");
+
+ out.println("<a href='" + req.getServletPath() + "'>home</a>");
+ out.println("<a href='" + req.getServletPath() + "/cart'>cart</a>");
+ out.println("<p/>");
+ out.println("<table><tr valign='top'><td width='400'>");
+ }
+
+ private void renderFooter(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ out.println("</td><td>");
+
+ renderNotes(req, res);
+
+ out.println("</td></tr>");
+ out.println("</table>");
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ private void renderNotes(HttpServletRequest req, HttpServletResponse res) throws IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ String path = req.getPathInfo();
+ if (path == null)
+ path = "/";
+
+ if (path.equals("/"))
+ path = "/home";
+
+ out.println("<div class='notes'>");
+
+ String notesPath = "notes" + path;
+
+ if (path.equals("/list"))
+ {
+ String paramShop = req.getParameter("shop");
+ if (paramShop != null)
+ notesPath += "-" + paramShop;
+ }
+
+ notesPath = notesPath.toLowerCase() + ".html";
+
+ URL htmlRes = context.getBundle().getResource(notesPath);
+ if (htmlRes != null)
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(htmlRes.openStream()));
+ String line = br.readLine();
+ while (line != null)
+ {
+ out.println(line);
+ line = br.readLine();
+ }
+ }
+ else
+ {
+ out.println("Cannot find: " + notesPath);
+ }
+ out.println("</div>");
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/trailblazer/src/main/java/org/jboss/osgi/trailblazer/web/MainServlet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years
JBoss-OSGI SVN: r90200 - projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-15 12:26:08 -0400 (Mon, 15 Jun 2009)
New Revision: 90200
Modified:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java
Log:
assertNotUninstalled
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-15 16:24:55 UTC (rev 90199)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-15 16:26:08 UTC (rev 90200)
@@ -44,6 +44,7 @@
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiServiceReference;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.service.log.LogReaderService;
@@ -92,13 +93,13 @@
registeredBundles.add(bundle);
return bundle;
}
-
+
public void addCapability(Capability capability) throws BundleException
{
// Add dependent capabilies
for (Capability dependency : capability.getDependencies())
addCapability(dependency);
-
+
// Check if the service provided by the capability exists already
OSGiServiceReference sref = getServiceReference(capability.getServiceName());
if (sref == null)
@@ -152,10 +153,10 @@
}
}
}
-
+
List<Capability> dependencies = capability.getDependencies();
Collections.reverse(dependencies);
-
+
// Remove dependent capabilities
for (Capability dependency : dependencies)
removeCapability(dependency);
@@ -189,14 +190,15 @@
OSGiBundle bundle = registeredBundles.remove(0);
try
{
- bundle.uninstall();
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ bundle.uninstall();
}
catch (BundleException ex)
{
log.warn("Cannot uninstall: " + bundle, ex);
}
}
-
+
// Uninstall the capabilities
Collections.reverse(capabilities);
while (capabilities.size() > 0)
@@ -268,7 +270,7 @@
throw new IllegalStateException("Cannot get manifest from: " + location);
}
-
+
Attributes attribs = manifest.getMainAttributes();
String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
if (symbolicName == null)
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java 2009-06-15 16:24:55 UTC (rev 90199)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java 2009-06-15 16:26:08 UTC (rev 90200)
@@ -26,6 +26,7 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.management.ManagedBundleMBean;
import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -42,6 +43,7 @@
private OSGiRuntimeImpl runtime;
private ManagedBundleMBean bundle;
+ private boolean uninstalled;
private String location;
public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle, String location)
@@ -54,57 +56,66 @@
@Override
public int getState()
{
- return bundle.getState();
+ return (uninstalled == true ? Bundle.UNINSTALLED : bundle.getState());
}
@Override
public String getSymbolicName()
{
+ assertNotUninstalled();
return bundle.getSymbolicName();
}
@Override
public String getVersion()
{
+ assertNotUninstalled();
return getHeaders().get(Constants.BUNDLE_VERSION);
}
@Override
public Dictionary<String, String> getHeaders()
{
+ assertNotUninstalled();
return bundle.getHeaders();
}
@Override
public long getBundleId()
{
+ assertNotUninstalled();
return bundle.getBundleId();
}
@Override
public String getProperty(String key)
{
+ assertNotUninstalled();
return bundle.getProperty(key);
}
@Override
public void start() throws BundleException
{
+ assertNotUninstalled();
bundle.start();
}
@Override
public void stop() throws BundleException
{
+ assertNotUninstalled();
bundle.stop();
}
@Override
public void uninstall() throws BundleException
{
+ assertNotUninstalled();
try
{
runtime.undeploy(location);
+ uninstalled = true;
}
catch (RuntimeException rte)
{
@@ -115,4 +126,10 @@
log.error("Cannot uninstall: " + location);
}
}
+
+ private void assertNotUninstalled()
+ {
+ if (uninstalled == true)
+ throw new IllegalStateException("Bundle already uninstalled: " + location);
+ }
}
15 years
JBoss-OSGI SVN: r90195 - in projects/jboss-osgi/trunk/husky: harness/src/main/java/org/jboss/osgi/husky/internal and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-15 09:10:49 -0400 (Mon, 15 Jun 2009)
New Revision: 90195
Added:
projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java
Modified:
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/Response.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicResponse.java
projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
Log:
Add support for multiple test methods
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java 2009-06-15 12:10:16 UTC (rev 90194)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/BridgeFactory.java 2009-06-15 13:10:49 UTC (rev 90195)
@@ -23,19 +23,23 @@
// $Id$
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import org.jboss.osgi.husky.internal.BasicBridge;
import org.jboss.osgi.husky.internal.Util;
/**
- * Loads the configured test {@link Bridge} instance.
+ * Loads the configured {@link Bridge} instance.
*
* @author Thomas.Diesler(a)jboss.com
* @since 16-May-2009
*/
public abstract class BridgeFactory
{
+ private static Map<Object, Bridge> bridgeCache = new HashMap<Object, Bridge>();
+
/**
* Loads the bridge class that is configed through the system property {@link Bridge}.
* If there is no such property, it returns an instance of {@link BasicBridge}.
@@ -43,11 +47,20 @@
public static Bridge getBridge()
{
Properties props = System.getProperties();
- String className = props.getProperty(Bridge.class.getName());
- return (className != null ? getBridge(props) : new BasicBridge(props));
+ return getBridgeInternal(null, props);
}
/**
+ * Get the cached instance of the bridge class that is configed through the system property {@link Bridge}.
+ * If there is no cached instance it creates a new instance.
+ */
+ public static Bridge getBridge(Object key)
+ {
+ Properties props = System.getProperties();
+ return getBridgeInternal(key, props);
+ }
+
+ /**
* Loads the bridge class that is configed through the property {@link Bridge}.
*
* If the loaded bridge has a constructor that takes a {@link Properties} parameter,
@@ -55,12 +68,26 @@
*
* @param props bridge properties
*/
- public static Bridge getBridge(Properties props)
+ public static Bridge getBridge(Object key, Properties props)
{
- String className = props.getProperty(Bridge.class.getName());
- if (className == null)
- throw new IllegalStateException("Cannot find property: " + Bridge.class.getName());
+ String className = props.getProperty(Bridge.class.getName());
+ if (className == null)
+ throw new IllegalStateException("Cannot find property: " + Bridge.class.getName());
- return (Bridge)Util.loadInstance(className, props);
+ return getBridgeInternal(key, props);
}
+
+ private static Bridge getBridgeInternal(Object key, Properties props)
+ {
+ Bridge bridge = bridgeCache.get(key);
+ if (bridge == null)
+ {
+ String className = props.getProperty(Bridge.class.getName(), BasicBridge.class.getName());
+ bridge = (Bridge)Util.loadInstance(className, props);
+
+ if (key != null)
+ bridgeCache.put(key, bridge);
+ }
+ return bridge;
+ }
}
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/Response.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/Response.java 2009-06-15 12:10:16 UTC (rev 90194)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/Response.java 2009-06-15 13:10:49 UTC (rev 90195)
@@ -43,11 +43,6 @@
List<Failure> getFailures();
/**
- * Add a list of failures to the response
- */
- void addAllFailures(List<Failure> failures);
-
- /**
* Add a failure to the response
*/
void addFailure(Failure failure);
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicResponse.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicResponse.java 2009-06-15 12:10:16 UTC (rev 90194)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/BasicResponse.java 2009-06-15 13:10:49 UTC (rev 90195)
@@ -51,12 +51,4 @@
{
failures.add(failure);
}
-
- public void addAllFailures(List<Failure> fails)
- {
- for (Failure failure : fails)
- {
- failures.add(failure);
- }
- }
}
Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-06-15 12:10:16 UTC (rev 90194)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-06-15 13:10:49 UTC (rev 90195)
@@ -24,6 +24,7 @@
//$Id$
import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeNotNull;
import org.jboss.osgi.husky.BridgeFactory;
import org.jboss.osgi.husky.annotation.ProvideContext;
@@ -77,11 +78,10 @@
public void testBundleContext() throws Exception
{
if (context == null)
- {
BridgeFactory.getBridge().run();
- return;
- }
+ assumeNotNull(context);
+
Bundle bundle = context.getBundle();
assertEquals("context-basic", bundle.getSymbolicName());
}
Added: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java 2009-06-15 13:10:49 UTC (rev 90195)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.husky.context;
+
+//$Id$
+
+import static org.junit.Assert.*;
+import static org.junit.Assume.assumeNotNull;
+
+import org.jboss.osgi.husky.BridgeFactory;
+import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.spi.capability.HuskyCapability;
+import org.jboss.osgi.spi.capability.JMXCapability;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * Test BundleContext injection
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class MultipleMethodsTestCase
+{
+ @ProvideContext
+ public static BundleContext context;
+ private static OSGiRuntime runtime;
+
+ private static int testCount;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ if (context == null)
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ runtime.addCapability(new JMXCapability());
+ runtime.addCapability(new HuskyCapability());
+
+ OSGiBundle bundle = runtime.installBundle("context-basic.jar");
+ bundle.start();
+ }
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (context == null)
+ runtime.shutdown();
+ }
+
+ @Test
+ public void testA() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge(MultipleMethodsTestCase.class).run();
+
+ assumeNotNull(context);
+
+ testCount++;
+ assertEquals("testA", 1, testCount);
+ }
+
+ @Test
+ public void testB() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge(MultipleMethodsTestCase.class).run();
+
+ assumeNotNull(context);
+
+ testCount++;
+ assertEquals("testB", 2, testCount);
+ }
+
+ @Test
+ public void testC() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge(MultipleMethodsTestCase.class).run();
+
+ assumeNotNull(context);
+
+ testCount++;
+ assertEquals("testC", 3, testCount);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/MultipleMethodsTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
15 years
JBoss-OSGI SVN: r90194 - in projects/jboss-osgi/trunk: husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-15 08:10:16 -0400 (Mon, 15 Jun 2009)
New Revision: 90194
Removed:
projects/jboss-osgi/trunk/husky/testsuite/${basedir}/
Modified:
projects/jboss-osgi/trunk/husky/testsuite/pom.xml
projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
Log:
[JBOSGi-93] - Uninstall bundles on OSGiRuntime.shutdown()
Modified: projects/jboss-osgi/trunk/husky/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/pom.xml 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/pom.xml 2009-06-15 12:10:16 UTC (rev 90194)
@@ -116,53 +116,11 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>log4j.output.dir</name>
- <value>${project.build.directory}</value>
- </property>
- <property>
- <name>org.jboss.osgi.husky.Invoker</name>
- <value>org.jboss.osgi.husky.internal.OSGiInvoker</value>
- </property>
- <property>
- <name>test.archive.directory</name>
- <value>${project.build.directory}/test-libs</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
</plugins>
</build>
<!-- Profiles -->
<profiles>
-
- <!--
- Name: remote-testing
- Descr: Setup for remote integration testing
- -->
- <profile>
- <id>remote-testing</id>
- <activation>
- <property>
- <name>target.container</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>true</skipTests>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
</project>
Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-06-15 12:10:16 UTC (rev 90194)
@@ -51,7 +51,6 @@
public BundleContext context;
private OSGiRuntime runtime;
- private OSGiBundle bundle;
@Before
public void setUp() throws BundleException
@@ -62,7 +61,7 @@
runtime.addCapability(new JMXCapability());
runtime.addCapability(new HuskyCapability());
- bundle = runtime.installBundle("context-basic.jar");
+ OSGiBundle bundle = runtime.installBundle("context-basic.jar");
bundle.start();
}
}
@@ -71,12 +70,7 @@
public void tearDown() throws BundleException
{
if (context == null)
- {
- if (bundle != null)
- bundle.uninstall();
-
runtime.shutdown();
- }
}
@Test
Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java 2009-06-15 12:10:16 UTC (rev 90194)
@@ -50,9 +50,8 @@
{
@ProvideContext
public static BundleContext context;
-
+
private static OSGiRuntime runtime;
- private static OSGiBundle bundle;
@BeforeClass
public static void beforeClass() throws BundleException
@@ -63,21 +62,16 @@
runtime.addCapability(new JMXCapability());
runtime.addCapability(new HuskyCapability());
- bundle = runtime.installBundle("context-basic.jar");
+ OSGiBundle bundle = runtime.installBundle("context-basic.jar");
bundle.start();
}
}
@AfterClass
- public static void afterDown() throws BundleException
+ public static void afterClass() throws BundleException
{
if (context == null)
- {
- if (bundle != null)
- bundle.uninstall();
-
runtime.shutdown();
- }
}
@Test
Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-framework.properties 2009-06-15 12:10:16 UTC (rev 90194)
@@ -8,7 +8,7 @@
org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-org.osgi.framework.storage=${basedir}/target/osgi-store
+org.osgi.framework.storage=${test.archive.directory}/../osgi-store
org.osgi.framework.storage.clean=onFirstInit
# Husky socket connector properties
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java 2009-06-15 12:10:16 UTC (rev 90194)
@@ -128,11 +128,7 @@
/**
* Shutdown the {@link OSGiRuntime}.
*
- * This will remove all added {@link Capability}.
- *
- * The installed bundles are currently NOT uninstalled automatically.
- *
- * [TODO] JBOSGI-93
+ * This will remove all installed {@link OSGiBundle}s and added {@link Capability}.
*/
void shutdown();
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-06-15 12:10:16 UTC (rev 90194)
@@ -75,7 +75,7 @@
service.deploy(bundleURL);
OSGiBundle bundle = getBundle(symbolicName, null);
- return bundle;
+ return registerBundleForUninstall(bundle);
}
public OSGiBundle[] getBundles()
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-15 12:10:16 UTC (rev 90194)
@@ -60,6 +60,7 @@
final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
private OSGiTestHelper helper;
+ private List<OSGiBundle> registeredBundles = new ArrayList<OSGiBundle>();
private Map<String, OSGiBundle> capBundles = new HashMap<String, OSGiBundle>();
private List<Capability> capabilities = new ArrayList<Capability>();
private LogReaderService logReaderService;
@@ -86,6 +87,12 @@
return logReaderService;
}
+ protected OSGiBundle registerBundleForUninstall(OSGiBundle bundle)
+ {
+ registeredBundles.add(bundle);
+ return bundle;
+ }
+
public void addCapability(Capability capability) throws BundleException
{
// Add dependent capabilies
@@ -175,12 +182,26 @@
stopLogEntryTracking();
- List<Capability> reverse = new ArrayList<Capability>(capabilities);
- Collections.reverse(reverse);
+ // Uninstall the registered bundles
+ Collections.reverse(registeredBundles);
+ while (registeredBundles.size() > 0)
+ {
+ OSGiBundle bundle = registeredBundles.remove(0);
+ try
+ {
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.warn("Cannot uninstall: " + bundle, ex);
+ }
+ }
- while (reverse.size() > 0)
+ // Uninstall the capabilities
+ Collections.reverse(capabilities);
+ while (capabilities.size() > 0)
{
- Capability capability = reverse.remove(0);
+ Capability capability = capabilities.get(0);
removeCapability(capability);
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-06-15 11:53:41 UTC (rev 90193)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-06-15 12:10:16 UTC (rev 90194)
@@ -77,8 +77,9 @@
try
{
deploy(location);
- ManagedBundleMBean bundle = getRemoteFramework().getBundle(symbolicName);
- return new RemoteBundle(this, bundle, location);
+ ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName);
+ RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
+ return registerBundleForUninstall(bundle);
}
catch (RuntimeException rte)
{
15 years
JBoss-OSGI SVN: r90187 - in projects/jboss-osgi/trunk: blueprint/testsuite and 21 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-15 07:28:40 -0400 (Mon, 15 Jun 2009)
New Revision: 90187
Added:
projects/jboss-osgi/trunk/husky/testsuite/${basedir}/
projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/
projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/
projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/
projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id
projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
Modified:
projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml
projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
projects/jboss-osgi/trunk/husky/harness/.project
projects/jboss-osgi/trunk/husky/harness/pom.xml
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java
projects/jboss-osgi/trunk/husky/pom.xml
projects/jboss-osgi/trunk/husky/testsuite/pom.xml
projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/pom.xml
projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
Log:
[JBOSGI-102] Add support for static Husky context injection
Modified: projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/pom.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -69,7 +69,7 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Modified: projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/scripts/assembly-bundles.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -19,7 +19,7 @@
<include>*:jboss-osgi-blueprint:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
- <include>*:jboss-osgi-husky:jar</include>
+ <include>*:jboss-osgi-husky-harness:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-microcontainer:jar</include>
Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeNotNull;
import org.jboss.osgi.husky.BridgeFactory;
import org.jboss.osgi.husky.annotation.ProvideContext;
@@ -33,9 +34,9 @@
import org.jboss.osgi.spi.capability.MicrocontainerCapability;
import org.jboss.osgi.spi.testing.OSGiBundle;
import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTest;
-import org.junit.After;
-import org.junit.Before;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -48,22 +49,20 @@
* @author thomas.diesler(a)jboss.com
* @since 13-May-2009
*/
-public class BlueprintContextTestCase extends OSGiTest
+public class BlueprintContextTestCase
{
@ProvideContext
- public BundleContext context;
+ public static BundleContext context;
- private OSGiRuntime runtime;
- private OSGiBundle bundle;
+ private static OSGiRuntime runtime;
+ private static OSGiBundle bundle;
- @Before
- public void setUp() throws Exception
+ @BeforeClass
+ public static void beforeClass() throws Exception
{
- super.setUp();
-
if (context == null)
{
- runtime = getDefaultRuntime();
+ runtime = new OSGiTestHelper().getDefaultRuntime();
runtime.addCapability(new HuskyCapability());
runtime.addCapability(new MicrocontainerCapability());
runtime.addCapability(new BlueprintCapability());
@@ -73,8 +72,8 @@
}
}
- @After
- public void tearDown() throws Exception
+ @AfterClass
+ public static void afterClass() throws Exception
{
if (context == null)
{
@@ -83,19 +82,16 @@
runtime.shutdown();
}
-
- super.tearDown();
}
@Test
public void testBlueprintContext() throws Exception
{
if (context == null)
- {
BridgeFactory.getBridge().run();
- return;
- }
+ assumeNotNull(context);
+
Bundle bundle = context.getBundle();
assertEquals("context-basic", bundle.getSymbolicName());
Modified: projects/jboss-osgi/trunk/husky/harness/.project
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/.project 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/.project 2009-06-15 11:28:40 UTC (rev 90187)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jboss-osgi-husky</name>
+ <name>jboss-osgi-husky-harness</name>
<comment></comment>
<projects>
</projects>
Modified: projects/jboss-osgi/trunk/husky/harness/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/pom.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/pom.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,13 +18,13 @@
<name>JBossOSGi Husky - Harness</name>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
<packaging>bundle</packaging>
<!-- Parent -->
<parent>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky-parent</artifactId>
+ <artifactId>jboss-osgi-husky</artifactId>
<version>1.0.0.Beta3</version>
</parent>
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/AbstractBridge.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -70,18 +70,21 @@
for (Failure failure : failures)
{
String failedClass = failure.getClassName();
- String failedMethod = failure.getMethodName();
- if (failedClass.equals(testClass.getName()) && failedMethod.equals(testMethod))
+ if (failedClass.equals(testClass.getName()))
{
- Throwable failureCause = failure.getException();
- if (failureCause instanceof RuntimeException)
- throw (RuntimeException)failureCause;
- if (failureCause instanceof Error)
- throw (Error)failureCause;
+ String failedMethod = failure.getMethodName();
+ if (failedMethod == null || failedMethod.equals(testMethod))
+ {
+ Throwable failureCause = failure.getException();
+ if (failureCause instanceof RuntimeException)
+ throw (RuntimeException)failureCause;
+ if (failureCause instanceof Error)
+ throw (Error)failureCause;
- AssertionFailedError error = new AssertionFailedError(failure.getMessage());
- error.initCause(failureCause);
- throw error;
+ AssertionFailedError error = new AssertionFailedError(failure.getMessage());
+ error.initCause(failureCause);
+ throw error;
+ }
}
}
}
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/JMXInvocation.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -59,7 +59,7 @@
InputStream reqBytes = new ByteArrayInputStream(baos.toByteArray());
- ObjectName objectName = JMXConnector.getObjectName();
+ ObjectName objectName = JMXConnector.OBJECT_NAME;
InputStream resBytes = (InputStream)server.invoke(objectName, "process", new Object[] { reqBytes }, new String[] { InputStream.class.getName() });
// Unmarshall the Response
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/internal/OSGiInvoker.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -57,7 +57,7 @@
{
return new SocketInvocation().invoke(req);
}
- else if (server.isRegistered(JMXConnector.getObjectName()))
+ else if (server.isRegistered(JMXConnector.OBJECT_NAME))
{
return new JMXInvocation().invoke(server, req);
}
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/Runner.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -55,7 +55,7 @@
Response runTests(Context context, Class<?> testClass);
/**
- * Inject the {@link Context} inte the test case instance
+ * Inject the {@link Context} in the test case instance
*/
- void injectContext(Object test, Context context) throws Exception;
+ void injectContext(Class<?> testClass, Object test, Context context) throws Exception;
}
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/junit/JUnitRunner.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -24,7 +24,9 @@
// $Id$
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import org.jboss.osgi.husky.Context;
import org.jboss.osgi.husky.Response;
@@ -50,6 +52,20 @@
*/
public Response runTests(final Context context, final Class<?> testClass)
{
+ // Inject the context in potentially static fields
+ try
+ {
+ injectContext(testClass, null, context);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot initialize test case: " + testClass.getName(), ex);
+ }
+
BlockJUnit4ClassRunner runner;
try
{
@@ -58,15 +74,15 @@
@Override
protected Object createTest() throws Exception
{
- Object test = super.createTest();
- injectContext(test, context);
- return test;
+ Object target = super.createTest();
+ injectContext(testClass, target, context);
+ return target;
}
};
}
catch (InitializationError ex)
{
- throw new IllegalStateException("Cannot initialize test case: " + testClass.getName());
+ throw new IllegalStateException("Cannot initialize test case: " + testClass.getName(), ex);
}
Result result = new Result();
@@ -88,15 +104,15 @@
return response;
}
- public void injectContext(Object test, Context context) throws Exception
+ public void injectContext(Class<?> testClass, Object target, Context context) throws Exception
{
- Class<? extends Object> testClass = test.getClass();
- for (Field field : testClass.getFields())
+ for (Field field : testClass.getDeclaredFields())
{
ProvideContext anProvide = field.getAnnotation(ProvideContext.class);
if (anProvide != null)
{
- field.set(test, context);
+ if ((field.getModifiers() & Modifier.STATIC) != 0 || target != null)
+ injectField(field, target, context);
}
}
for (Method method : testClass.getDeclaredMethods())
@@ -104,8 +120,19 @@
ProvideContext anProvide = method.getAnnotation(ProvideContext.class);
if (anProvide != null)
{
- method.invoke(test, context);
+ if ((method.getModifiers() & Modifier.STATIC) != 0 || target != null)
+ injectMethod(method, target, context);
}
}
}
+
+ protected void injectMethod(Method method, Object target, Context value) throws IllegalAccessException, InvocationTargetException
+ {
+ method.invoke(target, value);
+ }
+
+ protected void injectField(Field field, Object target, Context value) throws IllegalAccessException
+ {
+ field.set(target, value);
+ }
}
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -34,7 +34,6 @@
import org.jboss.osgi.husky.runtime.Connector;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
/**
@@ -46,10 +45,26 @@
*/
public class JMXConnector extends AbstractConnector implements JMXConnectorMBean
{
+ /*
+ * The ObjectName for this service: jboss.osgi.husky:service=jmx-connector
+ */
+ public static ObjectName OBJECT_NAME;
+
private LogService log;
private BundleContext context;
- private ServiceRegistration sreg;
-
+
+ static
+ {
+ try
+ {
+ OBJECT_NAME = ObjectName.getInstance("jboss.osgi.husky:service=jmx-connector");
+ }
+ catch (MalformedObjectNameException ex)
+ {
+ // ignore
+ }
+ }
+
public JMXConnector(BundleContext context)
{
this.log = new LogServiceTracker(context);
@@ -61,40 +76,24 @@
ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
if (sref == null)
throw new IllegalStateException("Cannot obtain MBeanServer service");
-
+
Properties props = new Properties();
props.setProperty("transport", "jmx");
- sreg = context.registerService(Connector.class.getName(), this, props);
-
+ context.registerService(Connector.class.getName(), this, props);
+
MBeanServer server = (MBeanServer)context.getService(sref);
- server.registerMBean(this, getObjectName());
- log.log(LogService.LOG_INFO, "JMXConnector registered: " + getObjectName());
+ server.registerMBean(this, OBJECT_NAME);
+ log.log(LogService.LOG_INFO, "JMXConnector registered: " + OBJECT_NAME);
}
public void stop() throws Exception
{
- if (sreg != null)
- sreg.unregister();
-
ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
if (sref != null)
{
MBeanServer server = (MBeanServer)context.getService(sref);
- if (server.isRegistered(getObjectName()));
- server.unregisterMBean(getObjectName());
+ if (server.isRegistered(OBJECT_NAME))
+ server.unregisterMBean(OBJECT_NAME);
}
}
-
- public static ObjectName getObjectName()
- {
- try
- {
- return ObjectName.getInstance("jboss.osgi.husky:service=jmx-connector");
- }
- catch (MalformedObjectNameException ex)
- {
- // should never get here
- return null;
- }
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnectorMBean.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -25,8 +25,6 @@
import java.io.InputStream;
-import org.jboss.osgi.husky.Request;
-import org.jboss.osgi.husky.Response;
import org.jboss.osgi.husky.runtime.PackageListener;
/**
@@ -37,16 +35,14 @@
*/
public interface JMXConnectorMBean
{
- /**
- * Consumes the serialized version of an {@link Request} and
- * return the the {@link Response} from the test run
- *
+ /*
+ * Consumes the serialized version of an {@link Request} and return the the {@link Response} from the test run
* @param reqStream the input stream to read the {@link Request} from
* @return the input stream to read the {@link Response} from
*/
InputStream process(InputStream reqStream);
-
- /**
+
+ /*
* Add a {@link PackageListener} to this connector
*/
void addPackageListener(PackageListener listener);
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/OSGiJUnitRunner.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -24,56 +24,46 @@
// $Id$
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jboss.osgi.husky.Context;
-import org.jboss.osgi.husky.annotation.ProvideContext;
-import org.jboss.osgi.husky.runtime.Runner;
import org.jboss.osgi.husky.runtime.junit.JUnitRunner;
import org.osgi.framework.BundleContext;
/**
- * An implementation of a {@link Runner} that uses the JUnit4 Test Runner.
+ * An extension to the {@link JUnitRunner} that injects the OSGi BundleContext.
*
* @author Thomas.Diesler(a)jboss.com
* @since 16-May-2009
*/
public class OSGiJUnitRunner extends JUnitRunner
{
- public void injectContext(Object test, Context context) throws Exception
+ @Override
+ protected void injectField(Field field, Object target, Context context) throws IllegalAccessException
{
BundleContext bundleContext = context.getAttachment(BundleContext.class);
- Class<? extends Object> testClass = test.getClass();
-
- for (Field field : testClass.getFields())
+ if (field.getType().isAssignableFrom(BundleContext.class))
{
- ProvideContext anProvide = field.getAnnotation(ProvideContext.class);
- if (anProvide != null)
- {
- if (field.getType().isAssignableFrom(BundleContext.class))
- {
- field.set(test, bundleContext);
- }
- else
- {
- field.set(test, context);
- }
- }
+ field.set(target, bundleContext);
}
- for (Method method : testClass.getDeclaredMethods())
+ else
{
- ProvideContext anProvide = method.getAnnotation(ProvideContext.class);
- if (anProvide != null)
- {
- if (method.getParameterTypes()[0].isAssignableFrom(BundleContext.class))
- {
- method.invoke(test, bundleContext);
- }
- else
- {
- method.invoke(test, context);
- }
- }
+ field.set(target, context);
}
}
+
+ @Override
+ protected void injectMethod(Method method, Object target, Context context) throws IllegalAccessException, InvocationTargetException
+ {
+ BundleContext bundleContext = context.getAttachment(BundleContext.class);
+ if (method.getParameterTypes()[0].isAssignableFrom(BundleContext.class))
+ {
+ method.invoke(target, bundleContext);
+ }
+ else
+ {
+ method.invoke(target, context);
+ }
+ }
}
Modified: projects/jboss-osgi/trunk/husky/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/pom.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/pom.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -19,7 +19,7 @@
<description>JBoss OSGi Test Support</description>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky-parent</artifactId>
+ <artifactId>jboss-osgi-husky</artifactId>
<packaging>pom</packaging>
<parent>
Added: projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/${basedir}/target/osgi-store/bundle0/bundle.id 2009-06-15 11:28:40 UTC (rev 90187)
@@ -0,0 +1 @@
+2
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/husky/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/pom.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/testsuite/pom.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -24,7 +24,7 @@
<!-- Parent -->
<parent>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky-parent</artifactId>
+ <artifactId>jboss-osgi-husky</artifactId>
<version>1.0.0.Beta3</version>
</parent>
@@ -32,8 +32,11 @@
<dependencies>
<dependency>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
- <version>${version}</version>
+ <artifactId>jboss-osgi-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
<scope>provided</scope>
</dependency>
Modified: projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/husky/testsuite/scripts/assembly-bundles.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -17,7 +17,7 @@
<includes>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
- <include>*:jboss-osgi-husky:jar</include>
+ <include>*:jboss-osgi-husky-harness:jar</include>
<include>*:org.apache.felix.log:jar</include>
<include>*:org.osgi.compendium:jar</include>
</includes>
Added: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.husky.context;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeNotNull;
+
+import org.jboss.osgi.husky.BridgeFactory;
+import org.jboss.osgi.husky.annotation.ProvideContext;
+import org.jboss.osgi.spi.capability.HuskyCapability;
+import org.jboss.osgi.spi.capability.JMXCapability;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * Test BundleContext injection
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 13-May-2009
+ */
+public class StaticContextTestCase
+{
+ @ProvideContext
+ public static BundleContext context;
+
+ private static OSGiRuntime runtime;
+ private static OSGiBundle bundle;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ if (context == null)
+ {
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ runtime.addCapability(new JMXCapability());
+ runtime.addCapability(new HuskyCapability());
+
+ bundle = runtime.installBundle("context-basic.jar");
+ bundle.start();
+ }
+ }
+
+ @AfterClass
+ public static void afterDown() throws BundleException
+ {
+ if (context == null)
+ {
+ if (bundle != null)
+ bundle.uninstall();
+
+ runtime.shutdown();
+ }
+ }
+
+ @Test
+ public void testBundleContext() throws Exception
+ {
+ if (context == null)
+ BridgeFactory.getBridge().run();
+
+ assumeNotNull(context);
+
+ Bundle bundle = context.getBundle();
+ assertEquals("context-basic", bundle.getSymbolicName());
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/StaticContextTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/pom.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -46,7 +46,6 @@
<version.jboss.osgi.common.core>2.2.11</version.jboss.osgi.common.core>
<version.jboss.osgi.deployers>1.0.0.Beta2</version.jboss.osgi.deployers>
<version.jboss.osgi.hotdeploy>1.0.0.Beta2</version.jboss.osgi.hotdeploy>
- <version.jboss.osgi.husky>1.0.0.Beta2</version.jboss.osgi.husky>
<version.jboss.osgi.integration.jbossas>1.0.0.Beta2</version.jboss.osgi.integration.jbossas>
<version.jboss.osgi.jaxb>2.1.10</version.jboss.osgi.jaxb>
<version.jboss.osgi.jmx>1.0.0.Beta2</version.jboss.osgi.jmx>
@@ -163,8 +162,8 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
- <version>${version.jboss.osgi.husky}</version>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>org.jboss.osgi</groupId>
@@ -182,6 +181,11 @@
<version>${version.jboss.osgi.runtime.knopflerfish}</version>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-spi</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-apache-xerces</artifactId>
<version>${version.jboss.osgi.apache.xerces}</version>
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/capability/HuskyCapability.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -47,6 +47,6 @@
super("org.jboss.osgi.husky.runtime.Connector");
addDependency(new JMXCapability());
- addBundle("bundles/jboss-osgi-husky.jar");
+ addBundle("bundles/jboss-osgi-husky-harness.jar");
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-06-15 11:28:40 UTC (rev 90187)
@@ -175,9 +175,12 @@
stopLogEntryTracking();
- while (capabilities.size() > 0)
+ List<Capability> reverse = new ArrayList<Capability>(capabilities);
+ Collections.reverse(reverse);
+
+ while (reverse.size() > 0)
{
- Capability capability = capabilities.get(0);
+ Capability capability = reverse.remove(0);
removeCapability(capability);
}
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,7 +18,7 @@
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
- <include>*:jboss-osgi-husky:jar</include>
+ <include>*:jboss-osgi-husky-harness:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-jndi:jar</include>
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,7 +18,7 @@
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
- <include>*:jboss-osgi-husky:jar</include>
+ <include>*:jboss-osgi-husky-harness:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-jndi:jar</include>
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -29,7 +29,6 @@
<dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
- <version>${version}</version>
</dependency>
<dependency>
@@ -79,7 +78,7 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
+ <artifactId>jboss-osgi-husky-harness</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml 2009-06-15 11:09:43 UTC (rev 90186)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml 2009-06-15 11:28:40 UTC (rev 90187)
@@ -18,7 +18,7 @@
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
- <include>*:jboss-osgi-husky:jar</include>
+ <include>*:jboss-osgi-husky-harness:jar</include>
<include>*:jboss-osgi-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-jndi:jar</include>
15 years
JBoss-OSGI SVN: r89961 - projects/jboss-osgi/projects/parent/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-07 00:15:18 -0400 (Sun, 07 Jun 2009)
New Revision: 89961
Modified:
projects/jboss-osgi/projects/parent/trunk/pom.xml
Log:
javadoc: show=protected
Modified: projects/jboss-osgi/projects/parent/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-06-06 22:35:09 UTC (rev 89960)
+++ projects/jboss-osgi/projects/parent/trunk/pom.xml 2009-06-07 04:15:18 UTC (rev 89961)
@@ -188,7 +188,7 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
- <show>public</show>
+ <show>protected</show>
<excludePackageNames>*.internal:*.incubator</excludePackageNames>
</configuration>
</plugin>
15 years
JBoss-OSGI SVN: r89959 - in projects/jboss-osgi/trunk/testsuite/trailblazer: src/test/resources/trailblazer and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-06 11:49:09 -0400 (Sat, 06 Jun 2009)
New Revision: 89959
Modified:
projects/jboss-osgi/trunk/testsuite/trailblazer/pom.xml
projects/jboss-osgi/trunk/testsuite/trailblazer/src/test/resources/trailblazer/shop-sports.bnd
Log:
Fix trailblazer
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/pom.xml 2009-06-06 05:50:24 UTC (rev 89958)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/pom.xml 2009-06-06 15:49:09 UTC (rev 89959)
@@ -17,7 +17,7 @@
<!-- Properties -->
<properties>
<trailblazer.java.path>https://anonsvn.jboss.org/repos/jbossas/projects/jboss-osgi/trunk/testsui...</trailblazer.java.path>
- <userguide.html>http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/ws/jboss-osgi/bui...</userguide.html>
+ <userguide.html>http://jbmuc.dyndns.org/jboss-osgi-${version}/userguide/html</userguide.html>
</properties>
<!-- Build -->
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/src/test/resources/trailblazer/shop-sports.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/trailblazer/src/test/resources/trailblazer/shop-sports.bnd 2009-06-06 05:50:24 UTC (rev 89958)
+++ projects/jboss-osgi/trunk/testsuite/trailblazer/src/test/resources/trailblazer/shop-sports.bnd 2009-06-06 15:49:09 UTC (rev 89959)
@@ -9,6 +9,5 @@
javax.naming, \
org.osgi.framework, \
org.osgi.service.log, \
- org.jboss.osgi.jndi, \
org.jboss.osgi.common.log, \
org.jboss.test.osgi.trailblazer
15 years
JBoss-OSGI SVN: r89919 - in projects/jboss-osgi/trunk/docbook: en/modules and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-06-05 15:42:05 -0400 (Fri, 05 Jun 2009)
New Revision: 89919
Added:
projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration-future.png
projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration-tree.png
projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration.png
Modified:
projects/jboss-osgi/trunk/docbook/en/modules/ch030-runtime.xml
projects/jboss-osgi/trunk/docbook/src/main/graphics/jbossosgi-runtime.odp
Log:
Add latest blog images & slides
Added: projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration-future.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration-future.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration-tree.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration-tree.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration.png
===================================================================
(Binary files differ)
Property changes on: projects/jboss-osgi/trunk/docbook/en/images/jbossas-integration.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch030-runtime.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch030-runtime.xml 2009-06-05 18:39:42 UTC (rev 89918)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch030-runtime.xml 2009-06-05 19:42:05 UTC (rev 89919)
@@ -31,7 +31,7 @@
into the 'deploy' folder. Management of the runtime is provided through a <link linkend="SecWebConsole">Web Console</link></para>
<para>Integration of the <ulink url="http://www.jboss.org/jbossmc">JBoss Microcontainer</ulink> as an OSGi service allows you
- to write your applications in a POJO programming model without much "polution" of OSGi specific API - the MC will do the
+ to write your applications in a POJO programming model without much "pollution" of OSGi specific API - the MC will do the
wiring for you. Future releases of JBoss OSGi will come with a full implementation of
<ulink url="http://jbossosgi.blogspot.com/2009/04/osgi-blueprint-service-rfc-124.html">Blueprint Service (RFC-124)</ulink>,
which standardizes this idea and takes it further.</para>
Modified: projects/jboss-osgi/trunk/docbook/src/main/graphics/jbossosgi-runtime.odp
===================================================================
(Binary files differ)
15 years