Author: thomas.diesler(a)jboss.com
Date: 2009-06-03 07:52:41 -0400 (Wed, 03 Jun 2009)
New Revision: 89723
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleService.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple.bnd
Removed:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractInstanceProvider.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/ServiceActivator.java
Modified:
projects/jboss-osgi/trunk/docbook/en/modules/ch20-runtime.xml
projects/jboss-osgi/trunk/docbook/en/modules/ch40-developer-guide.xml
projects/jboss-osgi/trunk/docbook/en/modules/ch50-husky-testing.xml
projects/jboss-osgi/trunk/integration/deployers/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/MicrocontainerBootstrapProvider.java
projects/jboss-osgi/trunk/testsuite/example/.project
projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/JMXTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd
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:
More dev guide - WIP
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch20-runtime.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch20-runtime.xml 2009-06-03 11:33:45 UTC
(rev 89722)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch20-runtime.xml 2009-06-03 11:52:41 UTC
(rev 89723)
@@ -36,7 +36,7 @@
<ulink
url="http://jbossosgi.blogspot.com/2009/04/osgi-blueprint-service-rf...
Service (RFC-124)</ulink>,
which standardizes this idea and takes it further.</para>
- <para>Great care has been taken about testability of deployed components and
services. The <link linkend="SecWritingTests">Husky Test
Framework</link>
+ <para>Great care has been taken about testability of deployed components and
services. The <link linkend="ChapHuskyTesting">Husky Test
Framework</link>
allows you to write plain JUnit tests that do not have a requirement on a specific
test runner nor need to extend any specific test base class.
Access to the Runtime has been abstracted sufficiently that you can run the same test
case against an embedded (bootstrapped from within the test case)
as well as a remote instance of the Runtime. You can run your OSGi tests from
<ulink url="http://maven.apache.org">Maven</ulink>,
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch40-developer-guide.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch40-developer-guide.xml 2009-06-03
11:33:45 UTC (rev 89722)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch40-developer-guide.xml 2009-06-03
11:52:41 UTC (rev 89723)
@@ -76,31 +76,6 @@
<listitem><ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/framework/MicrocontainerBootstrapProvider.html">MicrocontainerBootstrapProvider</ulink></listitem>
</itemizedlist>
-
- <programlisting role="XML"><![CDATA[
- <deployment xmlns="urn:jboss:bean-deployer:2.0" ...>
-
- <!-- The OSGiFramework -->
- <bean name="jboss.osgi:service=Framework"
class="org.jboss.osgi.felix.framework.FelixIntegration">
- <property name="felixProperties">
- <map keyClass="java.lang.String"
valueClass="java.lang.String">
-
<entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
- <entry>
- <key>org.osgi.framework.system.packages</key>
- <value>
- org.osgi.framework; version=1.4,
- org.osgi.util.tracker
- </value>
- </entry>
- </map>
- </property>
- </bean>
-
- ...
-
- </deployment>
- ]]></programlisting>
-
<para>OSGiBootstrapProvider implementations that read their configurtation from
some other source are possible, but currently not
part of the JBoss OSGi SPI.</para>
@@ -119,24 +94,35 @@
takes care of a specific aspect of bundle deployment.</para>
<itemizedlist>
+ <listitem><emphasis
role="bold">BundleClassLoaderDeployer</emphasis> - Creates a
BundleClassLoader for the deployed Bundle</listitem>
+ <listitem><emphasis
role="bold">BundleContainedBeansDeployer</emphasis> - Deploy the bundle
contained MC beans onto the Kernel</listitem>
+ <listitem><emphasis
role="bold">BundleManagementDeployer</emphasis> - Register the Bundle
as MBean with JMX</listitem>
<listitem><emphasis
role="bold">BundleMetaDataDeployer</emphasis> - Create BundleMetaData
from Manifest Headers</listitem>
- <listitem><emphasis
role="bold">BundleStructureDeployer</emphasis> - Determine the
structure of a Bundle deployment</listitem>
<listitem><emphasis
role="bold">BundleRealDeployer</emphasis> - Installs the Bundle into
the Framework's SystemContext</listitem>
- <listitem><emphasis
role="bold">BundleClassLoaderDeployer</emphasis> - Creates a
BundleClassLoader for the deployed Bundle</listitem>
<listitem><emphasis
role="bold">BundleStartStopDeployer</emphasis> - Starts the Bundle when
dependencies are resolved</listitem>
- <listitem><emphasis
role="bold">BundleManagementDeployer</emphasis> - Register the Bundle
as MBean with JMX</listitem>
+ <listitem><emphasis
role="bold">BundleStructureDeployer</emphasis> - Determine the
structure of a Bundle deployment</listitem>
</itemizedlist>
+ <emphasis role="bold">BundleClassLoaderDeployer</emphasis>
+
+ <para>The BundleClassLoaderDeployer attaches a ClassLoaderFactory that creates
a BundleClassLoader for the deployed Bundle.
+ A BundleClassLoader delegates all classloading concerns to the underlying
Bundle.</para>
+
+ <emphasis role="bold">BundleContainedBeansDeployer</emphasis>
+
+ <para>The BundleContainedBeansDeployer is a ComponentDeployer that deployes the
MC bean components onto
+ the Kernel.</para>
+
+ <emphasis role="bold">BundleManagementDeployer</emphasis>
+
+ <para>The BundleManagementDeployer registers the Bundle as <ulink
url="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/Standa...
with JMX.
+ Please see the section on <link linkend="SecJMXView">Management
View</link> for details.</para>
+
<emphasis role="bold">BundleMetaDataDeployer</emphasis>
<para>The BundleMetaDataDeployer creates the BundleMetaData from Manifest
Headers. If the manifest does not contain
a header named <emphasis
role="bold">Bundle-SymbolicName</emphasis> this deployer does nothing.
</para>
- <emphasis role="bold">BundleStructureDeployer</emphasis>
-
- <para>The BundleStructureDeployer determines the structure of a Bundle
deployment. It ignores all deployments that
- are not top-level or do not have a manifest header named <emphasis
role="bold">Bundle-SymbolicName</emphasis></para>
-
<emphasis role="bold">BundleRealDeployer</emphasis>
<para>The BundleRealDeployer installs the Bundle into the Framework's
SystemContext. Optionally you can configure a list of
@@ -145,11 +131,6 @@
<para>On undeploy the Bundle gets uninstalled from the Framework's
SystemContext.</para>
- <emphasis role="bold">BundleClassLoaderDeployer</emphasis>
-
- <para>The BundleClassLoaderDeployer attaches a ClassLoaderFactory that creates
a BundleClassLoader for the deployed Bundle.
- A BundleClassLoader delegates all classloading concerns to the underlying
Bundle.</para>
-
<emphasis role="bold">BundleStartStopDeployer</emphasis>
<para>The BundleStartStopDeployer currently works in two modes:</para>
@@ -179,10 +160,10 @@
<entry><key>org.jboss.osgi.deferred.start</key><value>true</value></entry>
]]></programlisting>
- <emphasis role="bold">BundleManagementDeployer</emphasis>
+ <emphasis role="bold">BundleStructureDeployer</emphasis>
- <para>The BundleManagementDeployer registers the Bundle as <ulink
url="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/Standa...
with JMX.
- Please see the section on <link linkend="SecJMXView">Management
View</link> for details.</para>
+ <para>The BundleStructureDeployer determines the structure of a Bundle
deployment. It ignores all deployments that
+ are not top-level or do not have a manifest header named <emphasis
role="bold">Bundle-SymbolicName</emphasis></para>
</sect1>
@@ -193,82 +174,26 @@
<emphasis role="bold">The ManagedFramework</emphasis>
- <para>The <code>ManagedFramework</code> gives you access to the
MBean views of the deployed Bundles. It is registerd under the name:</para>
+ <para>The <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/management/ManagedFrameworkMBean.html">
+ ManagedFramework</ulink> gives you access to the MBean views of the deployed
Bundles. It is registerd under the name:</para>
<itemizedlist>
<listitem><emphasis
role="bold">jboss.osgi:service=ManagedFramework</emphasis></listitem>
</itemizedlist>
- <programlisting role="JAVA">
- public interface ManagedFrameworkMBean
- {
- /**
- * Get the list of all installed bundles
- */
- Set<ObjectName> getBundles();
-
- /**
- * Get the installed bundle
- */
- ObjectName getBundle(String symbolicName);
- }
- </programlisting>
-
<emphasis role="bold">The ManagedBundle</emphasis>
- <para>The <code>ManagedBundle</code> gives you access to the MBean
views of a deployed Bundle. It is registerd under the name:</para>
+ <para>The <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/management/ManagedBundle.html">
+ ManagedBundle</ulink> gives you access to the MBean views of a deployed Bundle.
It is registerd under the name:</para>
<itemizedlist>
<listitem><emphasis
role="bold">jboss.osgi:bundle=[SymbolicName],id=[BundleId]</emphasis></listitem>
</itemizedlist>
- <programlisting role="JAVA">
- public interface ManagedBundleMBean
- {
- /**
- * Returns this bundle's current state.
- * A bundle can be in only one state at any time.
- *
- * @return An element of UNINSTALLED,INSTALLED, RESOLVED,STARTING,
STOPPING,ACTIVE.
- */
- int getState();
-
- /**
- * Get the bundles object name.
- */
- ObjectName getObjectName();
-
- /**
- * Returns this bundle's unique identifier.
- */
- long getBundleId();
-
- /**
- * Returns the symbolic name of this bundle as specified by its
Bundle-SymbolicName manifest header
- */
- String getSymbolicName();
-
- /**
- * Returns the value of the specified property from the BundleContext.
- */
- String getProperty(String key);
-
- /**
- * Starts this bundle with no options
- */
- void start() throws BundleException;
-
- /**
- * Stops this bundle with no options.
- */
- void stop() throws BundleException;
- }
- </programlisting>
-
<emphasis role="bold">Accessing the Management
Objects</emphasis>
<para>If you work with the JBoss OSGi Testsuite you get access to the Managed
Objects through the JBoss OSGi SPI provided
- <ulink
url="http://junit.sourceforge.net/">JUnit</ulink>
support package <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/junit/package-summary.html">org.jboss.osgi.spi.junit</ulink>.
+ <ulink
url="http://junit.sourceforge.net/">JUnit</ulink>
support package <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/testing/package-summary.html">org.jboss.osgi.spi.testing</ulink>.
</para>
<para>If you install JBoss OSGi in an already existing JBossAS instance you
also get access to the Managed Objects through the JBoss provided
@@ -286,127 +211,156 @@
</sect1>
<sect1 xml:id="SecWritingTests">
- <title>Writing Testcases</title>
+ <title>Writing Test Cases</title>
<para>JBoss OSGi comes with <ulink
url="http://www.junit.org">JUnit</ulink> test support as part of the
SPI provided
- <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/junit/package-summary.html">org.jboss.osgi.spi.junit</ulink>
- package. There are two distinct test scenarios that we support</para>
+ <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/testing/package-summary.html">org.jboss.osgi.spi.testing</ulink>
+ package. There are two distinct test scenarios that we support:</para>
<itemizedlist>
<listitem>Embedded OSGi Framework</listitem>
<listitem>Remote OSGi Framework</listitem>
</itemizedlist>
- <emphasis role="bold">Testing an embedded OSGi
Framework</emphasis>
+ <para>The remote scenario can actually be separated again in:</para>
- <para>In the embedded scenario the testcase bootstraps the OSGi Framework and
installes and tests the bundles locally. The base class for
- embedded OSGi testing is <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/junit/OSGiTest.html">org.jboss.osgi.spi.junit.OSGiTest</ulink>.
- </para>
-
- <programlisting role="JAVA">
- public class EmbeddedTestCase extends OSGiTest
- {
- public void testSomeBundle() throws Exception
- {
- // Bootstrap the Framework and get the system bundle
- OSGiFramework framework = getBootstrapProvider().getFramework();
- BundleContext sysContext = framework.getSystemBundleContext();
-
- // Install and start the test bundle
- Bundle bundleA = installBundle(sysContext, "some-bundle.jar", true);
-
- // Verify that the bundle is active
- assertEquals("Test bundle ACTIVE", Bundle.ACTIVE,
bundleA.getState());
- }
- }
- </programlisting>
-
- <para>Due to classloading restrictions it is not possible to interact with the
services that get registered in the OSGi Framework
- directly. Instead, there must be some means for the bundle under test to communicate
with the test case that lives outside the
- Framework. We use an approach where the test case registeres a <ulink
url="http://www.osgi.org/javadoc/r4v41/org/osgi/service/log/LogListe...
- with the <ulink
url="http://www.osgi.org/javadoc/r4v41/org/osgi/service/log/LogReade...;.
Log messages are filtered and
- can be verified by the test case. For this to work certain conditions must be
true:</para>
-
<itemizedlist>
- <listitem>The Framework must have a LogService installed</listitem>
- <listitem>The bundle under test must write log messages to
LogService</listitem>
- <listitem>The LogListener must be seen by the classloader that loads the test
case</listitem>
+ <listitem>Standalone JBoss OSGi Runtime</listitem>
+ <listitem>JBoss OSGi Runtime running in JBossAS</listitem>
</itemizedlist>
-
- <programlisting role="JAVA">
- // Setup log entry tracking
- LogEntryCache logEntryCache = new LogEntryCache();
- logEntryCache.addFilter(new LogEntryFilter("example-log(.*)",
LogService.LOG_INFO, "\\[ServiceA\\](.*)"));
- // Start log entry tracking
- startLogEntryTracking(logEntryCache);
+ <para>A test case that takes advantage of the SPI provided OSGi runtime
abstration would transparently handle these scenarios.</para>
- // do stuff
+ <sect2 xml:id="SecWritingTestsSimpleTestCase">
+
+ <title>Simple Test Case</title>
- // Verify the received log entries
- List entries = logEntryCache.getLog();
- assertEquals("Number of entries", 1, entries.size());
- assertEquals("[ServiceA] new Service", entries.get(0).getMessage());
+ <para>The test case bootstraps the OSGi Runtime, installes/starts the bundle,
asserts the bundle state and finally
+ shuts down the OSGi Runtime. Please note, this is a plain JUnit4 test case that
transparently handles embedded/remote
+ nature of the OSGi Runtime.
+ </para>
+
+ <programlisting role="JAVA">
+ public class SimpleTestCase
+ {
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Get the default runtime
+ OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+ try
+ {
+ // Install the bundle
+ OSGiBundle bundle =
runtime.installBundle("example-simple.jar");
+ assertEquals("Bundle installed", Bundle.INSTALLED,
bundle.getState());
+
+ // Start the bundle
+ bundle.start();
+ assertEquals("Bundle active", Bundle.ACTIVE,
bundle.getState());
+
+ // Uninstall the bundle
+ bundle.uninstall();
+ }
+ finally
+ {
+ // Shutdown the runtime
+ runtime.shutdown();
+ }
+ }
+ }
+ </programlisting>
+
+ <para>To run the test in embedded mode (which is the default) you would
execute your test runner like this
+ </para>
+
+ <programlisting role="JAVA">
+ [tdiesler@tddell example]$ mvn -Dtest=SimpleTestCase test
+ ...
+ Running org.jboss.test.osgi.example.simple.SimpleTestCase
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.361 sec
+ </programlisting>
+
+ <para>To run the test against the remote JBoss OSGi Runtime you would execute
your test runner like this
+ </para>
+
+ <programlisting role="JAVA">
+ [tdiesler@tddell example]$ mvn -Dtarget.container=runtime -Dtest=SimpleTestCase
test
+ ...
+ Running org.jboss.test.osgi.example.simple.SimpleTestCase
+ Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.303 sec
+ </programlisting>
+
+ <para>In the runtime console you should see</para>
+
+ <programlisting role="JAVA">
+ 12:44:30,960 INFO [jboss-osgi-common] Installed: example-simple [8]
+ 12:44:31,081 INFO [example-simple] Start: example-simple [8]
+ 12:44:31,089 INFO [example-simple] Stop: example-simple [8]
+ 12:44:31,095 INFO [jboss-osgi-common] Uninstalled: example-simple [8]
+ </programlisting>
- // Stop log entry tracking
- stopLogEntryTracking();
- </programlisting>
-
- <emphasis role="bold">Testing a remote OSGi
Framework</emphasis>
+ <para>Due to classloading restrictions it is not possible to interact with
the services that get registered in the OSGi Framework
+ directly. Instead, there must be some means for the bundle under test to
communicate with the test case that lives outside the
+ Framework. The approach of OSGi testing based on remote log messages is covered in
+ <ulink
url="http://jbossosgi.blogspot.com/2009/04/non-intrusive-osgi-bundle...
intrusive OSGi Bundle Testing</ulink>.</para>
+
+ <para>The next section explains how to write a plain JUnit test that is then
executed within the OSGi Runtime.</para>
+ </sect2>
- <para>In the remote scenario the testcase deploys the test bundle on the remote
OSGi Framework. The base class for embedded OSGi testing
- is <ulink
url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/junit/IntegrationTest.html">org.jboss.osgi.spi.junit.IntegrationTest</ulink>.
- </para>
-
- <programlisting role="JAVA">
- public class RemoteTestCase extends IntegrationTest
- {
- public void testSomeBundle() throws Exception
- {
- // Deploy the test bundle
- RemoteBundle bundleA = deployBundle("some-bundle.jar");
-
- // Verify that the bundle is active
- assertEquals("Test bundle ACTIVE", Bundle.ACTIVE,
bundleA.getState());
+ <sect2 xml:id="SecWritingTestsSimpleHuskyTestCase">
+
+ <title>Simple Husky Test Case</title>
+
+ <para>The test case does everthing identical to <link
linkend="SecWritingTestsSimpleTestCase">SimpleTestCase</link> (setUp
and tearDown not shown),
+ but only executes the code in the test method when Husky injected the
BundleContext.
+ </para>
+
+ <programlisting role="JAVA">
+ public class SimpleHuskyTestCase
+ {
+ @ProvideContext
+ public BundleContext context;
+
+ ...
+
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Tell Husky to run this test method within the OSGi Runtime
+ if (context == null)
+ BridgeFactory.getBridge().run();
+
+ // Stop here if the context is not injected
+ assumeNotNull(context);
+
+ // Get the SimpleService reference
+ ServiceReference sref =
context.getServiceReference(SimpleService.class.getName());
+ assertNotNull("SimpleService Not Null", sref);
+
+ // Access the SimpleService
+ SimpleService service = (SimpleService)context.getService(sref);
+ assertEquals("hello", service.echo("hello"));
+ }
+ }
+ </programlisting>
+
+ <para>Running this test is also no different from <link
linkend="SecWritingTestsSimpleTestCase">SimpleTestCase</link>.</para>
- // Undeploy the test bundle
- undeployBundle("some-bundle.jar");
- }
- }
- </programlisting>
-
- <para>The test approach is simmilar to the embedded scenario. The test bundle
writes log messages to the LogService. A RemoteLogListener transmits
- the log messages to the RemoteLogReaderService that is installed locally. The test
case registeres a LogListener with the RemoteLogReaderService.
- Log messages are filtered and can be verified by the test case. Again, certain
conditions must be true:</para>
-
- <itemizedlist>
- <listitem>The remote Framework must have a LogService
installed</listitem>
- <listitem>The <emphasis
role="bold">jboss-osgi-remotelog.jar</emphasis> bundle must be
installed in both the remote and local Framework</listitem>
- <listitem>The bundle under test must write log messages to
LogService</listitem>
- <listitem>The LogListener must be seen by the classloader that loads the test
case</listitem>
- </itemizedlist>
+ <para>In the runtime console you should see</para>
+
+ <programlisting role="JAVA">
+ 13:29:15,924 INFO [jboss-osgi-common] Installed: example-simple-husky [16]
+ 13:29:15,972 INFO [example-simple-husky] Start: example-simple-husky [16]
+ 13:29:15,981 INFO [jboss-osgi-husky] Test-Package
[org.jboss.test.osgi.example.simple] in bundle: example-simple-husky [16]
+ 13:29:16,160 INFO [example-simple-husky] echo: hello
+ 13:29:16,191 INFO [example-simple-husky] Stop: example-simple-husky [16]
+ 13:29:16,196 INFO [jboss-osgi-common] Uninstalled: example-simple-husky [16]
+ </programlisting>
- <programlisting role="JAVA">
- // Setup log entry tracking
- LogEntryCache logEntryCache = new LogEntryCache();
- logEntryCache.addFilter(new LogEntryFilter("example-log(.*)",
LogService.LOG_INFO, "\\[ServiceA\\](.*)"));
+ <para>To learn more about the magic of the BridgeFactory have a look at
<link linkend="ChapHuskyTesting">Husky Test Framework</link>
+ which comes next.</para>
+ </sect2>
- // Start log entry tracking
- startRemoteLogEntryTracking(logEntryCache);
-
- // do stuff
-
- // Verify the received log entries
- List entries = logEntryCache.getLog();
- assertEquals("Number of entries", 1, entries.size());
- assertEquals("[ServiceA] new Service", entries.get(0).getMessage());
-
- // Stop log entry tracking
- stopRemoteLogEntryTracking();
- </programlisting>
-
- <para>For details on how to setup remote log message tracking, have a look at
<xref linkend="SecRemoteLogService"/>.</para>
-
</sect1>
</chapter>
Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch50-husky-testing.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch50-husky-testing.xml 2009-06-03
11:33:45 UTC (rev 89722)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch50-husky-testing.xml 2009-06-03
11:52:41 UTC (rev 89723)
@@ -3,7 +3,7 @@
-->
<chapter xml:id="ChapHuskyTesting">
- <title>Husky OSGi Test Framework</title>
+ <title>Husky Test Framework</title>
<sect1 xml:id="SecHuskyOverview">
<title>Overview</title>
Modified:
projects/jboss-osgi/trunk/integration/deployers/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java
===================================================================
---
projects/jboss-osgi/trunk/integration/deployers/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/integration/deployers/src/main/java/org/jboss/osgi/deployer/BundleContainedBeansDeployer.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -35,6 +35,12 @@
import org.jboss.kernel.spi.deployment.KernelDeployment;
import org.osgi.framework.Bundle;
+/**
+ * Deploy the bundle contained MC beans onto the Kernel.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 06-May-2009
+ */
public class BundleContainedBeansDeployer extends
AbstractComponentDeployer<KernelDeployment, BeanMetaData>
{
/*
Deleted:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractInstanceProvider.java
===================================================================
---
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractInstanceProvider.java 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/AbstractInstanceProvider.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -1,52 +0,0 @@
-/*
- * 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.spi.framework;
-
-// $Id: $
-
-/**
- * Provide a named instance from the configuration.
- *
- * @author ales.justin(a)jboss.com
- * @author thomas.diesler(a)jboss.com
- */
-public abstract class AbstractInstanceProvider implements NamedInstanceProvider
-{
- public <T> T getInstance(String name, Class<T> expectedType)
- {
- if (name == null)
- throw new IllegalArgumentException("Null name");
-
- if (expectedType == null)
- throw new IllegalArgumentException("Null expected type.");
-
- Object attribute = getInstance(name);
- if (attribute != null)
- {
- if (expectedType.isInstance(attribute) == false)
- throw new IllegalArgumentException("Not of expected type [" +
expectedType + "]: " + attribute);
-
- return expectedType.cast(attribute);
- }
- return null;
- }
-}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/MicrocontainerBootstrapProvider.java
===================================================================
---
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/MicrocontainerBootstrapProvider.java 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/MicrocontainerBootstrapProvider.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -34,6 +34,28 @@
/**
* Bootstrap the OSGiFramework through the MC
+ *
+ * <pre>
+ * <deployment xmlns="urn:jboss:bean-deployer:2.0" ...>
+ *
+ * <!-- The OSGiFramework -->
+ * <bean name="jboss.osgi:service=Framework"
class="org.jboss.osgi.felix.framework.FelixIntegration">
+ * <property name="felixProperties">
+ * <map keyClass="java.lang.String"
valueClass="java.lang.String">
+ *
<entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+ * <entry>
+ * <key>org.osgi.framework.system.packages</key>
+ * <value>
+ * org.osgi.framework; version=1.4,
+ * org.osgi.util.tracker
+ * </value>
+ * </entry>
+ * </map>
+ * </property>
+ * </bean>
+ * ...
+ * </deployment>
+ * </pre>
*
* @author thomas.diesler(a)jboss.com
* @since 18-Jun-2008
Modified: projects/jboss-osgi/trunk/testsuite/example/.project
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/.project 2009-06-03 11:33:45 UTC (rev
89722)
+++ projects/jboss-osgi/trunk/testsuite/example/.project 2009-06-03 11:52:41 UTC (rev
89723)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jboss-osgi-testsuite</name>
+ <name>jboss-osgi-testsuite-example</name>
<comment></comment>
<projects>
</projects>
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-06-03
11:33:45 UTC (rev 89722)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-06-03
11:52:41 UTC (rev 89723)
@@ -58,6 +58,10 @@
<bnd classpath="${tests.classes.dir}"
output="${tests.output.dir}/test-libs/example-mcservice-bundleA.jar"
files="${tests.resources.dir}/mcservice/example-mcservice-bundleA.bnd" />
<bnd classpath="${tests.classes.dir}"
output="${tests.output.dir}/test-libs/example-mcservice-bundleB.jar"
files="${tests.resources.dir}/mcservice/example-mcservice-bundleB.bnd" />
+ <!-- simple -->
+ <bnd classpath="${tests.classes.dir}"
output="${tests.output.dir}/test-libs/example-simple.jar"
files="${tests.resources.dir}/simple/example-simple.bnd" />
+ <bnd classpath="${tests.classes.dir}"
output="${tests.output.dir}/test-libs/example-simple-husky.jar"
files="${tests.resources.dir}/simple/example-simple-husky.bnd" />
+
<!-- Please add alphabetically -->
</target>
Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-06-03
11:33:45 UTC (rev 89722)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-bundles.xml 2009-06-03
11:52:41 UTC (rev 89723)
@@ -18,6 +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-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-jndi:jar</include>
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/JMXTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/JMXTestCase.java 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/JMXTestCase.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.example.jmx;
-//$Id$
+//$Id: $
import static org.jboss.test.osgi.example.jmx.bundle.FooMBean.MBEAN_NAME;
import static org.junit.Assert.assertEquals;
Copied:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
(from rev 89712,
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/ServiceActivator.java)
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,42 @@
+/*
+ * 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.example.log.bundle;
+
+//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class LogServiceActivator implements BundleActivator
+{
+ public void start(final BundleContext context)
+ {
+ ServiceA service = new ServiceA(context);
+ context.registerService(ServiceA.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ // Do Nothing. It is unnecessary to unregister services or Framework listeners
+ // because they must be clean up by the Framework anyway.
+ }
+}
\ No newline at end of file
Deleted:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/ServiceActivator.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/ServiceActivator.java 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/ServiceActivator.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -1,42 +0,0 @@
-/*
- * 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.example.log.bundle;
-
-//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler(a)jboss.com $
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class ServiceActivator implements BundleActivator
-{
- public void start(final BundleContext context)
- {
- ServiceA service = new ServiceA(context);
- context.registerService(ServiceA.class.getName(), service, null);
- }
-
- public void stop(BundleContext context)
- {
- // Do Nothing. It is unnecessary to unregister services or Framework listeners
- // because they must be clean up by the Framework anyway.
- }
-}
\ No newline at end of file
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,111 @@
+/*
+ * 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.example.simple;
+
+//$Id$
+
+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;
+import org.jboss.osgi.spi.capability.HuskyCapability;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.test.osgi.example.simple.bundle.SimpleService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 12-Feb-2009
+ */
+public class SimpleHuskyTestCase
+{
+ @ProvideContext
+ public BundleContext context;
+
+ private OSGiRuntime runtime;
+ private OSGiBundle bundle;
+
+ @Before
+ public void setUp() throws BundleException
+ {
+ if (context == null)
+ {
+ // Get the default runtime
+ runtime = new OSGiTestHelper().getDefaultRuntime();
+ runtime.addCapability(new HuskyCapability());
+
+ // Install the bundle
+ bundle = runtime.installBundle("example-simple-husky.jar");
+ assertEquals("Bundle installed", Bundle.INSTALLED,
bundle.getState());
+
+ // Start the bundle
+ bundle.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+ }
+ }
+
+ @After
+ public void tearDown() throws BundleException
+ {
+ // Only do this if we are not within the OSGi Runtime
+ if (context == null)
+ {
+ // Uninstall the bundle
+ if (bundle != null)
+ bundle.uninstall();
+
+ // Shutdown the runtime
+ runtime.shutdown();
+ }
+ }
+
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Tell Husky to run this test method within the OSGi Runtime
+ if (context == null)
+ BridgeFactory.getBridge().run();
+
+ // Stop here if the context is not injected
+ assumeNotNull(context);
+
+ // Get the SimpleService reference
+ ServiceReference sref =
context.getServiceReference(SimpleService.class.getName());
+ assertNotNull("SimpleService Not Null", sref);
+
+ // Access the SimpleService
+ SimpleService service = (SimpleService)context.getService(sref);
+ assertEquals("hello", service.echo("hello"));
+ }
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleHuskyTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,67 @@
+/*
+ * 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.example.simple;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 12-Feb-2009
+ */
+public class SimpleTestCase
+{
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Get the default runtime
+ OSGiRuntime runtime = new OSGiTestHelper().getDefaultRuntime();
+
+ try
+ {
+ // Install the bundle
+ OSGiBundle bundle = runtime.installBundle("example-simple.jar");
+ assertEquals("Bundle installed", Bundle.INSTALLED,
bundle.getState());
+
+ // Start the bundle
+ bundle.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+
+ // Uninstall the bundle
+ bundle.uninstall();
+ }
+ finally
+ {
+ // Shutdown the runtime
+ runtime.shutdown();
+ }
+ }
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleActivator.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleActivator.java
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleActivator.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,55 @@
+/*
+ * 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.example.simple.bundle;
+
+//$Id$
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleActivator implements BundleActivator
+{
+ private LogService log;
+
+ public void start(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+ log.log(LogService.LOG_INFO, "Start: " + context.getBundle());
+
+ // Register a service
+ SimpleService service = new SimpleService(context);
+ context.registerService(SimpleService.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ log.log(LogService.LOG_INFO, "Stop: " + context.getBundle());
+ }
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleService.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleService.java
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleService.java 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,50 @@
+/*
+ * 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.example.simple.bundle;
+
+//$Id$
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A SimpleService
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleService
+{
+ private LogService log;
+
+ public SimpleService(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+ }
+
+ public String echo(String msg)
+ {
+ log.log(LogService.LOG_INFO, "echo: " + msg);
+ return msg;
+ }
+}
\ No newline at end of file
Property changes on:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/bundle/SimpleService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-felix.properties 2009-06-03
11:52:41 UTC (rev 89723)
@@ -20,9 +20,11 @@
org.jboss.net.protocol, \
org.jboss.osgi.common.log;version=1.0, \
org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.capability;version=1.0, \
org.jboss.osgi.spi.logging;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.jboss.virtual, \
org.jboss.virtual.plugins.registry, \
org.jboss.virtual.plugins.context.jar, \
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd 2009-06-03
11:52:41 UTC (rev 89723)
@@ -2,5 +2,5 @@
Bundle-SymbolicName: example-log
-Bundle-Activator: org.jboss.test.osgi.example.log.bundle.ServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.log.bundle.LogServiceActivator
Export-Package: org.jboss.test.osgi.example.log.bundle
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple-husky.bnd 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,13 @@
+# bnd build -classpath target/test-classes -output
target/test-libs/example-simple-husky.jar
src/test/resources/example/simple/example-simple-husky.bnd
+
+Bundle-SymbolicName: example-simple-husky
+
+Bundle-Activator: org.jboss.test.osgi.example.simple.bundle.SimpleActivator
+
+# Export the package that contains tthe test case
+Export-Package: org.jboss.test.osgi.example.simple
+
+Private-Package: org.jboss.test.osgi.example.simple.bundle
+
+# Tell Husky that there are test cases in this package
+Test-Package: org.jboss.test.osgi.example.simple
\ No newline at end of file
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple.bnd
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple.bnd
(rev 0)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/simple/example-simple.bnd 2009-06-03
11:52:41 UTC (rev 89723)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example-simple.jar
src/test/resources/example/simple/example-simple.bnd
+
+Bundle-SymbolicName: example-simple
+
+Bundle-Activator: org.jboss.test.osgi.example.simple.bundle.SimpleActivator
+Export-Package: org.jboss.test.osgi.example.simple.bundle
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-06-03
11:33:45 UTC (rev 89722)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/assembly-bundles.xml 2009-06-03
11:52:41 UTC (rev 89723)
@@ -18,6 +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-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-03 11:33:45 UTC (rev 89722)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-06-03 11:52:41 UTC (rev 89723)
@@ -77,6 +77,11 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-husky</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-jmx</artifactId>
<scope>provided</scope>
Modified: projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml
===================================================================
---
projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml 2009-06-03
11:33:45 UTC (rev 89722)
+++
projects/jboss-osgi/trunk/testsuite/trailblazer/scripts/assembly-bundles.xml 2009-06-03
11:52:41 UTC (rev 89723)
@@ -18,6 +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-jaxb:jar</include>
<include>*:jboss-osgi-jmx:jar</include>
<include>*:jboss-osgi-jndi:jar</include>