[jboss-cvs] JBossAS SVN: r87064 - in projects/jboss-osgi/trunk: build/hudson/hudson-home/jobs/JBoss-6.0.0 and 14 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 9 07:08:56 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-04-09 07:08:56 -0400 (Thu, 09 Apr 2009)
New Revision: 87064
Added:
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceB.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleX/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleX/SomePojo.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/HttpServiceRemoteTestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointService.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointServlet.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanServiceRemoteTestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/Foo.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/FooMBean.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleB.bnd
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleX.bnd
Removed:
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39EmbeddedTestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointService.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointServlet.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/junit/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/Foo.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/FooMBean.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanTestService.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/junit/
Modified:
projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-5.1.0/config.xml
projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml
projects/jboss-osgi/trunk/runtime/felix/pom.xml
projects/jboss-osgi/trunk/testsuite/pom.xml
projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39RemoteTestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/resources/service/http/http-service.bnd
projects/jboss-osgi/trunk/testsuite/src/test/resources/service/microcontainer/microcontainer-service.bnd
Log:
Cleanup testsuite
Modified: projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-5.1.0/config.xml
===================================================================
--- projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-5.1.0/config.xml 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-5.1.0/config.xml 2009-04-09 11:08:56 UTC (rev 87064)
@@ -10,6 +10,10 @@
<remote>https://svn.jboss.org/repos/jbossas/branches/Branch_5_x</remote>
<local>jbossas</local>
</hudson.scm.SubversionSCM_-ModuleLocation>
+ <hudson.scm.SubversionSCM_-ModuleLocation>
+ <remote>@hudson.osgi.url@</remote>
+ <local>jboss-osgi</local>
+ </hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
<useUpdate>true</useUpdate>
<browser class="hudson.scm.browsers.FishEyeSVN">
@@ -25,18 +29,43 @@
<builders>
<hudson.tasks.Shell>
<command>
+HUDSONDIR=$WORKSPACE/jboss-osgi//build/hudson
-JBOSS_VERSION=jboss-5.1.0.Beta1
+JBOSS_VERSION=jboss-5.1.0.CR1
+
+JBOSS_HOME=$WORKSPACE/jbossas/build/output/$JBOSS_VERSION
JBOSS_ZIP=$HUDSON_HOME/../jboss/$JBOSS_VERSION.zip
+JBOSS_BINDADDR=@jboss.bind.address@
+#
# Build JBoss
+#
cd jbossas
build/build.sh clean main
-# Remove existing jboss.zip
+#
+# Start JBossAS
+#
+$HUDSONDIR/jboss/bin/jboss.sh $JBOSS_HOME start $JBOSS_BINDADDR
+
+#
+# Was it successfully started?
+#
+$HUDSONDIR/jboss/bin/http-spider.sh $JBOSS_BINDADDR:8080 $WORKSPACE
+if [ -e $WORKSPACE/spider.failed ]; then
+ tail -n 200 $JBOSS_HOME/server/default/log/server.log
+ $HUDSONDIR/jboss/bin/jboss.sh $JBOSS_HOME stop $JBOSS_BINDADDR
+ exit 1
+fi
+
+#
+# Remove existing jboss.zip
+#
rm -f $JBOSS_ZIP
-# Create new jboss.zip
+#
+# Create new jboss.zip
+#
cd build/output
zip -r $JBOSS_ZIP $JBOSS_VERSION/*
Modified: projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml
===================================================================
--- projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/JBoss-6.0.0/config.xml 2009-04-09 11:08:56 UTC (rev 87064)
@@ -10,6 +10,10 @@
<remote>https://svn.jboss.org/repos/jbossas/trunk</remote>
<local>jbossas</local>
</hudson.scm.SubversionSCM_-ModuleLocation>
+ <hudson.scm.SubversionSCM_-ModuleLocation>
+ <remote>@hudson.osgi.url@</remote>
+ <local>jboss-osgi</local>
+ </hudson.scm.SubversionSCM_-ModuleLocation>
</locations>
<useUpdate>true</useUpdate>
<browser class="hudson.scm.browsers.FishEyeSVN">
@@ -25,18 +29,43 @@
<builders>
<hudson.tasks.Shell>
<command>
+HUDSONDIR=$WORKSPACE/jboss-osgi//build/hudson
JBOSS_VERSION=jboss-6.0.0.Alpha1
+
+JBOSS_HOME=$WORKSPACE/jbossas/build/output/$JBOSS_VERSION
JBOSS_ZIP=$HUDSON_HOME/../jboss/$JBOSS_VERSION.zip
+JBOSS_BINDADDR=@jboss.bind.address@
+#
# Build JBoss
+#
cd jbossas
build/build.sh clean main
-# Remove existing jboss.zip
+#
+# Start JBossAS
+#
+$HUDSONDIR/jboss/bin/jboss.sh $JBOSS_HOME start $JBOSS_BINDADDR
+
+#
+# Was it successfully started?
+#
+$HUDSONDIR/jboss/bin/http-spider.sh $JBOSS_BINDADDR:8080 $WORKSPACE
+if [ -e $WORKSPACE/spider.failed ]; then
+ tail -n 200 $JBOSS_HOME/server/default/log/server.log
+ $HUDSONDIR/jboss/bin/jboss.sh $JBOSS_HOME stop $JBOSS_BINDADDR
+ exit 1
+fi
+
+#
+# Remove existing jboss.zip
+#
rm -f $JBOSS_ZIP
-# Create new jboss.zip
+#
+# Create new jboss.zip
+#
cd build/output
zip -r $JBOSS_ZIP $JBOSS_VERSION/*
Modified: projects/jboss-osgi/trunk/runtime/felix/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/pom.xml 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/runtime/felix/pom.xml 2009-04-09 11:08:56 UTC (rev 87064)
@@ -196,10 +196,6 @@
<!-- Exclude tests that require remote access -->
<exclude>org/jboss/test/osgi/deployer/**</exclude>
<exclude>org/jboss/test/osgi/**/*RemoteTestCase.java</exclude>
- <exclude>org/jboss/test/osgi/service/http/junit/*TestCase.java</exclude>
- <exclude>org/jboss/test/osgi/service/microcontainer/junit/*TestCase.java</exclude>
- <!-- [JBOSGI-39] Bundle gets wired to an already uninstalled bundle -->
- <exclude>org/jboss/test/osgi/jbosgi39/*TestCase.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -233,10 +229,6 @@
<configuration>
<argLine>${surefire.security.args}</argLine>
<excludes>
- <!-- [JBOSGI-40] Cannot run embedded tests with SecurityManager -->
- <exclude>org/jboss/test/osgi/**/*EmbeddedTestCase.java</exclude>
- <!-- [JBOSGI-39] Bundle gets wired to an already uninstalled bundle -->
- <exclude>org/jboss/test/osgi/jbosgi39/*TestCase.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-04-09 11:08:56 UTC (rev 87064)
@@ -84,7 +84,7 @@
<!--
Name: framework-any
- Descr: Create the testsuite.zip and skip tests if there is a framework specified
+ Descr: Create the testsuite.zip and skip tests
-->
<profile>
<id>framework-any</id>
@@ -191,10 +191,6 @@
<!-- Exclude tests that require remote access -->
<exclude>org/jboss/test/osgi/deployer/**</exclude>
<exclude>org/jboss/test/osgi/**/*RemoteTestCase.java</exclude>
- <exclude>org/jboss/test/osgi/service/http/junit/*TestCase.java</exclude>
- <exclude>org/jboss/test/osgi/service/microcontainer/junit/*TestCase.java</exclude>
- <!-- [JBOSGI-39] Bundle gets wired to an already uninstalled bundle -->
- <exclude>org/jboss/test/osgi/jbosgi39/*TestCase.java</exclude>
</excludes>
</configuration>
</plugin>
@@ -228,10 +224,6 @@
<configuration>
<argLine>${surefire.security.args}</argLine>
<excludes>
- <!-- [JBOSGI-40] Cannot run embedded tests with SecurityManager -->
- <exclude>org/jboss/test/osgi/**/*EmbeddedTestCase.java</exclude>
- <!-- [JBOSGI-39] Bundle gets wired to an already uninstalled bundle -->
- <exclude>org/jboss/test/osgi/jbosgi39/*TestCase.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml 2009-04-09 11:08:56 UTC (rev 87064)
@@ -59,6 +59,10 @@
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi38-bundleB.jar" files="${tests.resources.dir}/jbosgi38/jbosgi38-bundleB.bnd" />
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi38-bundleX.jar" files="${tests.resources.dir}/jbosgi38/jbosgi38-bundleX.bnd" />
+ <!-- jbosgi39 -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi39-bundleB.jar" files="${tests.resources.dir}/jbosgi39/jbosgi39-bundleB.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi39-bundleX.jar" files="${tests.resources.dir}/jbosgi39/jbosgi39-bundleX.bnd" />
+
<!-- jbosgi41 -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi41-bundleA.jar" files="${tests.resources.dir}/jbosgi41/jbosgi41-bundleA.bnd" />
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39EmbeddedTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39EmbeddedTestCase.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39EmbeddedTestCase.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,97 +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.jbosgi39;
-
-//$Id$
-
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.IntegrationTest;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-/**
- * [JBOSGI-39] Bundle undeploy does not clean up properly
- *
- * https://jira.jboss.org/jira/browse/JBOSGI-39
- *
- * Bundle B depends on bundle X.
- *
- * B ---> X
- *
- * @author thomas.diesler at jboss.com
- * @since 04-Mar-2009
- */
-public class OSGI39EmbeddedTestCase extends IntegrationTest
-{
- static OSGiBootstrapProvider bootProvider;
-
- @Override
- protected OSGiBootstrapProvider getBootstrapProvider()
- {
- if (bootProvider == null)
- bootProvider = createBootstrapProvider();
-
- return bootProvider;
- }
-
- public void testFirstRun() throws Exception
- {
- installBBeforeX();
- }
-
- public void testSecondRun() throws Exception
- {
- installBBeforeX();
- }
-
- private void installBBeforeX() throws Exception
- {
- OSGiFramework framework = getBootstrapProvider().getFramework();
- BundleContext sysContext = framework.getSystemBundleContext();
-
- Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleB.jar").toExternalForm());
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
-
- try
- {
- bundleB.start();
- fail("Unresolved constraint expected");
- }
- catch (BundleException ex)
- {
- // expected
- }
-
- Bundle bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
-
- bundleB.start();
-
- assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
- assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
-
- // Uninstall X before B
- bundleX.uninstall();
- bundleB.uninstall();
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39RemoteTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39RemoteTestCase.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39RemoteTestCase.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -26,9 +26,10 @@
import org.jboss.osgi.spi.framework.RemoteBundle;
import org.jboss.osgi.spi.junit.IntegrationTest;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
/**
- * [JBOSGI-39] Bundle undeploy does not clean up properly
+ * [JBOSGI-39] Bundle gets wired to an already uninstalled bundle
*
* https://jira.jboss.org/jira/browse/JBOSGI-39
*
@@ -41,29 +42,63 @@
*/
public class OSGI39RemoteTestCase extends IntegrationTest
{
- public void testFirstRun() throws Exception
+ public void testVerifyUnresolved() throws Exception
{
- installBBeforeX();
+ RemoteBundle bundleB = deployBundle("jbosgi39-bundleB");
+
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+
+ try
+ {
+ bundleB.start();
+ fail("Unresolved constraint expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+
+ RemoteBundle bundleX = deployBundle("jbosgi39-bundleX");
+
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ undeployBundle("jbosgi39-bundleB");
+ undeployBundle("jbosgi39-bundleX");
}
- public void testSecondRun() throws Exception
+ /*
+ * 4.3.11 Uninstalling Bundles
+ *
+ * Once this method returns, the state of the OSGi Service Platform must be the same as if the bundle had never been installed, unless:
+ *
+ * - The uninstalled bundle has exported any packages (via its Export-Package manifest header)
+ * - The uninstalled bundle was selected by the Framework as the exporter of these packages.
+ *
+ * If none of the old exports are used, then the old exports must be removed. Otherwise, all old exports must remain available
+ * for existing bundles and future resolves until the refreshPackages method is called or the Framework is restarted.
+ */
+ public void testWiringToUninstalled() throws Exception
{
- installBBeforeX();
- }
+ RemoteBundle bundleX = deployBundle("jbosgi39-bundleX");
+ RemoteBundle bundleB = deployBundle("jbosgi39-bundleB");
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.ACTIVE, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
- private void installBBeforeX() throws Exception
- {
- RemoteBundle bundleB = deployBundle("jbosgi38-bundleB");
+ // Undeploy X before B
+ undeployBundle("jbosgi39-bundleX");
+ undeployBundle("jbosgi39-bundleB");
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+ // Install B without X
+ bundleB = deployBundle("jbosgi39-bundleB");
- RemoteBundle bundleX = deployBundle("jbosgi38-bundleX");
+ bundleB.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundleX.getState());
assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
-
- // Undeploy X before B
- undeployBundle("jbosgi38-bundleX");
- undeployBundle("jbosgi38-bundleB");
+
+ undeployBundle("jbosgi39-bundleB");
}
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39EmbeddedTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/OSGI39TestCase.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,160 @@
+/*
+ * 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.jbosgi39;
+
+//$Id$
+
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.junit.IntegrationTest;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * [JBOSGI-39] Bundle gets wired to an already uninstalled bundle
+ *
+ * https://jira.jboss.org/jira/browse/JBOSGI-39
+ *
+ * Bundle B depends on bundle X.
+ *
+ * B ---> X
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 04-Mar-2009
+ */
+public class OSGI39TestCase extends IntegrationTest
+{
+ public void testVerifyUnresolved() throws Exception
+ {
+ OSGiFramework framework = getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleB.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+
+ try
+ {
+ bundleB.start();
+ fail("Unresolved constraint expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+
+ Bundle bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleX.jar").toExternalForm());
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ bundleX.uninstall();
+ }
+
+ /*
+ * 4.3.11 Uninstalling Bundles
+ *
+ * Once this method returns, the state of the OSGi Service Platform must be the same as if the bundle had never been installed, unless:
+ *
+ * - The uninstalled bundle has exported any packages (via its Export-Package manifest header)
+ * - The uninstalled bundle was selected by the Framework as the exporter of these packages.
+ *
+ * If none of the old exports are used, then the old exports must be removed. Otherwise, all old exports must remain available
+ * for existing bundles and future resolves until the refreshPackages method is called or the Framework is restarted.
+ */
+ public void testWiringToUninstalled() throws Exception
+ {
+ OSGiFramework framework = getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleX.jar").toExternalForm());
+ Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleB.jar").toExternalForm());
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ // Uninstall X before B
+ bundleX.uninstall();
+ bundleB.uninstall();
+
+ // Install B without X
+ bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleB.jar").toExternalForm());
+
+ bundleB.start();
+
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ }
+
+ public void testWiringToUninstalledPackageAdmin() throws Exception
+ {
+ OSGiFramework framework = getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleX.jar").toExternalForm());
+ Bundle bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleB.jar").toExternalForm());
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ // Uninstall X before B
+ bundleX.uninstall();
+ bundleB.uninstall();
+
+ // Forces the update (replacement) or removal of packages exported by the specified bundles.
+ ServiceReference sref = sysContext.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packAdmin = (PackageAdmin)sysContext.getService(sref);
+ packAdmin.refreshPackages(null);
+
+ // Install B without X
+ bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleB.jar").toExternalForm());
+
+ try
+ {
+ bundleB.start();
+ fail("Unresolved constraint expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+
+ bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi39-bundleX.jar").toExternalForm());
+
+ bundleB.start();
+
+ assertEquals("Bundle resolved", Bundle.RESOLVED, bundleX.getState());
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+
+ bundleB.uninstall();
+ bundleX.uninstall();
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,48 @@
+/*
+ * 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.jbosgi39.bundleB;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class ServiceActivator implements BundleActivator
+{
+ private ServiceRegistration registration;
+
+ public void start(BundleContext context)
+ {
+ ServiceB service = new ServiceB();
+ registration = context.registerService(ServiceB.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceB.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceB.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceB.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,40 @@
+/*
+ * 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.jbosgi39.bundleB;
+
+//$Id$
+
+import org.jboss.test.osgi.jbosgi39.bundleX.SomePojo;
+
+/**
+ * ServiceA has a dependency on ServiceB, both have a dependency on SomePojo
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 02-Mar-2009
+ */
+public class ServiceB
+{
+ public String doStuffInB(SomePojo obj)
+ {
+ return obj.toString();
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceB.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleX/SomePojo.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleX/SomePojo.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleX/SomePojo.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,41 @@
+/*
+ * 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.jbosgi39.bundleX;
+
+
+//$Id$
+
+public class SomePojo
+{
+ private String message;
+
+ public SomePojo(String message)
+ {
+ this.message = message;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + message + "]";
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi39/bundleX/SomePojo.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointService.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointService.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,99 +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.service.http;
-
-//$Id$
-
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpService;
-
-/**
- * A service that creates an Http context through the HttpService
- *
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public class EndpointService implements ServiceListener
-{
- private BundleContext context;
-
- public EndpointService(BundleContext context)
- {
- this.context = context;
- context.addServiceListener(this);
- }
-
- private void registerService()
- {
- try
- {
- HttpService httpService = getHttpService();
-
- Properties initParams = new Properties();
- initParams.setProperty("initProp", "SomeValue");
- httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
- httpService.registerResources("/file", "/res", null);
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Cannot register context", ex);
- }
- }
-
- private void unregisterService()
- {
- HttpService httpService = getHttpService();
- httpService.unregister("/servlet");
- httpService.unregister("/file");
- context.removeServiceListener(this);
- }
-
- private HttpService getHttpService()
- {
- ServiceReference sref = context.getServiceReference(HttpService.class.getName());
- if (sref == null)
- throw new IllegalStateException("HttpService not registered");
-
- return (HttpService)context.getService(sref);
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- Object service = context.getService(event.getServiceReference());
- if (service == this)
- {
- if (event.getType() == ServiceEvent.REGISTERED)
- {
- registerService();
- }
- else if (event.getType() == ServiceEvent.UNREGISTERING)
- {
- unregisterService();
- }
- }
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointServlet.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointServlet.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointServlet.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,83 +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.service.http;
-
-//$Id$
-
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.service.startlevel.StartLevel;
-import org.osgi.util.tracker.ServiceTracker;
-
- at SuppressWarnings("serial")
-public class EndpointServlet extends HttpServlet
-{
- private BundleContext context;
-
- // This hides the default ctor and verifies that this instance is used
- public EndpointServlet(BundleContext context)
- {
- this.context = context;
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
- {
- PrintWriter out = res.getWriter();
-
- String testParam = req.getParameter("test");
- if ("plain".equals(testParam))
- {
- out.println("Hello from Servlet");
- }
- else if ("initProp".equals(testParam))
- {
- String value = getInitParameter(testParam);
- out.println(testParam + "=" + value);
- }
- else if ("context".equals(testParam))
- {
- out.println(context.getBundle().getSymbolicName());
- }
- else if ("startLevel".equals(testParam))
- {
- ServiceTracker tracker = new ServiceTracker(context, StartLevel.class.getName(), null);
- tracker.open();
-
- StartLevel service = (StartLevel)tracker.getService();
- out.println("startLevel=" + service.getStartLevel());
- }
- else
- {
- throw new IllegalArgumentException("Invalid 'test' parameter: " + testParam);
- }
-
- out.close();
- }
-}
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/HttpServiceRemoteTestCase.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/junit/EndpointServiceTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/HttpServiceRemoteTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/HttpServiceRemoteTestCase.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,83 @@
+/*
+ * 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.service.http;
+
+//$Id$
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.osgi.spi.junit.IntegrationTest;
+import org.jboss.osgi.spi.junit.IntegrationTestSetup;
+
+/**
+ * A test that deployes a bundle that containes a HttpServlet which
+ * is registered through the OSGi HttpService
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class HttpServiceRemoteTestCase extends IntegrationTest
+{
+ public static Test suite()
+ {
+ return new IntegrationTestSetup(HttpServiceRemoteTestCase.class, "http-service.jar");
+ }
+
+ public void testServletAccess() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=plain");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("Hello from Servlet", br.readLine());
+ }
+
+ public void testServletInitProps() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=initProp");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("initProp=SomeValue", br.readLine());
+ }
+
+ public void testServletBundleContext() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=context");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("http-service-test", br.readLine());
+ }
+
+ public void testServletStartLevel() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() + ":8090/servlet?test=startLevel");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("startLevel=1", br.readLine());
+ }
+
+ public void testResourceAccess() throws Exception
+ {
+ URL url = new URL("http://" + getServerHost() + ":8090/file/message.txt");
+ BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
+ assertEquals("Hello from Resource", br.readLine());
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/ServiceActivator.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/ServiceActivator.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,61 +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.service.http;
-
-//$Id$
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler at jboss.com
- * @since 04-Feb-2009
- */
-public class ServiceActivator implements BundleActivator
-{
- private ServiceRegistration registration;
-
- /*
- * Implements BundleActivator.start().
- * Registers an instance of a HttpEndpoint Service using the bundle context.
- */
- public void start(BundleContext context)
- {
- EndpointService service = new EndpointService(context);
- registration = context.registerService(EndpointService.class.getName(), service, null);
- }
-
- /*
- * Implements BundleActivator.stop().
- */
- public void stop(BundleContext context)
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointService.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointService.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointService.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointService.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,99 @@
+/*
+ * 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.service.http.bundle;
+
+//$Id$
+
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpService;
+
+/**
+ * A service that creates an Http context through the HttpService
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class EndpointService implements ServiceListener
+{
+ private BundleContext context;
+
+ public EndpointService(BundleContext context)
+ {
+ this.context = context;
+ context.addServiceListener(this);
+ }
+
+ private void registerService()
+ {
+ try
+ {
+ HttpService httpService = getHttpService();
+
+ Properties initParams = new Properties();
+ initParams.setProperty("initProp", "SomeValue");
+ httpService.registerServlet("/servlet", new EndpointServlet(context), initParams, null);
+ httpService.registerResources("/file", "/res", null);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Cannot register context", ex);
+ }
+ }
+
+ private void unregisterService()
+ {
+ HttpService httpService = getHttpService();
+ httpService.unregister("/servlet");
+ httpService.unregister("/file");
+ context.removeServiceListener(this);
+ }
+
+ private HttpService getHttpService()
+ {
+ ServiceReference sref = context.getServiceReference(HttpService.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("HttpService not registered");
+
+ return (HttpService)context.getService(sref);
+ }
+
+ public void serviceChanged(ServiceEvent event)
+ {
+ Object service = context.getService(event.getServiceReference());
+ if (service == this)
+ {
+ if (event.getType() == ServiceEvent.REGISTERED)
+ {
+ registerService();
+ }
+ else if (event.getType() == ServiceEvent.UNREGISTERING)
+ {
+ unregisterService();
+ }
+ }
+ }
+}
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointServlet.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/EndpointServlet.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointServlet.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/EndpointServlet.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,83 @@
+/*
+ * 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.service.http.bundle;
+
+//$Id$
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.startlevel.StartLevel;
+import org.osgi.util.tracker.ServiceTracker;
+
+ at SuppressWarnings("serial")
+public class EndpointServlet extends HttpServlet
+{
+ private BundleContext context;
+
+ // This hides the default ctor and verifies that this instance is used
+ public EndpointServlet(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
+ {
+ PrintWriter out = res.getWriter();
+
+ String testParam = req.getParameter("test");
+ if ("plain".equals(testParam))
+ {
+ out.println("Hello from Servlet");
+ }
+ else if ("initProp".equals(testParam))
+ {
+ String value = getInitParameter(testParam);
+ out.println(testParam + "=" + value);
+ }
+ else if ("context".equals(testParam))
+ {
+ out.println(context.getBundle().getSymbolicName());
+ }
+ else if ("startLevel".equals(testParam))
+ {
+ ServiceTracker tracker = new ServiceTracker(context, StartLevel.class.getName(), null);
+ tracker.open();
+
+ StartLevel service = (StartLevel)tracker.getService();
+ out.println("startLevel=" + service.getStartLevel());
+ }
+ else
+ {
+ throw new IllegalArgumentException("Invalid 'test' parameter: " + testParam);
+ }
+
+ out.close();
+ }
+}
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/ServiceActivator.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/http/bundle/ServiceActivator.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,61 @@
+/*
+ * 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.service.http.bundle;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 04-Feb-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+ private ServiceRegistration registration;
+
+ /*
+ * Implements BundleActivator.start().
+ * Registers an instance of a HttpEndpoint Service using the bundle context.
+ */
+ public void start(BundleContext context)
+ {
+ EndpointService service = new EndpointService(context);
+ registration = context.registerService(EndpointService.class.getName(), service, null);
+ }
+
+ /*
+ * Implements BundleActivator.stop().
+ */
+ public void stop(BundleContext context)
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/Foo.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/Foo.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/Foo.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,32 +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.service.microcontainer;
-
-//$Id$
-
-public class Foo implements FooMBean
-{
- public String echo(String msg)
- {
- return msg;
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/FooMBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/FooMBean.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/FooMBean.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,29 +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.service.microcontainer;
-
-//$Id$
-
-public interface FooMBean
-{
- String echo(String msg);
-}
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanServiceRemoteTestCase.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/junit/MicrocontainerServiceTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanServiceRemoteTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanServiceRemoteTestCase.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,52 @@
+/*
+ * 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.service.microcontainer;
+
+//$Id$
+
+import junit.framework.Test;
+
+import org.jboss.osgi.spi.junit.IntegrationTest;
+import org.jboss.osgi.spi.junit.IntegrationTestSetup;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.test.osgi.service.microcontainer.bundle.FooMBean;
+import org.jboss.test.osgi.service.microcontainer.bundle.MBeanTestService;
+
+/**
+ * A test that deployes a bundle that registeres an MBean
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 12-Feb-2009
+ */
+public class MBeanServiceRemoteTestCase extends IntegrationTest
+{
+ public static Test suite()
+ {
+ return new IntegrationTestSetup(MBeanServiceRemoteTestCase.class, "microcontainer-service.jar");
+ }
+
+ public void testMBeanAccess() throws Exception
+ {
+ FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, MBeanTestService.OBJECT_NAME, getServer());
+ assertEquals("hello", foo.echo("hello"));
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanTestService.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanTestService.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanTestService.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,106 +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.service.microcontainer;
-
-//$Id$
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.osgi.service.MicrocontainerService;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A service that registers an MBean
- *
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public class MBeanTestService implements ServiceListener
-{
- public static ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.osgi:service=mbean-test-service");
-
- private BundleContext context;
- private MBeanServer mbeanServer;
-
- public MBeanTestService(BundleContext context)
- {
- this.context = context;
- context.addServiceListener(this);
- }
-
- private void registerService()
- {
- try
- {
- MicrocontainerService mcService = getMicrocontainerService();
- mbeanServer = mcService.getMbeanServer();
- mbeanServer.registerMBean(new Foo(), OBJECT_NAME);
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Cannot register mbean", ex);
- }
- }
-
- private void unregisterService()
- {
- try
- {
- if (mbeanServer != null && mbeanServer.isRegistered(OBJECT_NAME))
- mbeanServer.unregisterMBean(OBJECT_NAME);
- }
- catch (Exception ex)
- {
- throw new RuntimeException("Cannot unregister mbean", ex);
- }
- }
-
- private MicrocontainerService getMicrocontainerService()
- {
- ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
- if (sref == null)
- throw new IllegalStateException("MicrocontainerService not registered");
-
- return (MicrocontainerService)context.getService(sref);
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- Object service = context.getService(event.getServiceReference());
- if (service == this)
- {
- if (event.getType() == ServiceEvent.REGISTERED)
- {
- registerService();
- }
- else if (event.getType() == ServiceEvent.UNREGISTERING)
- {
- unregisterService();
- }
- }
- }
-}
Deleted: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/ServiceActivator.java 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/ServiceActivator.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,54 +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.service.microcontainer;
-
-//$Id$
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler at jboss.com
- * @since 04-Feb-2009
- */
-public class ServiceActivator implements BundleActivator
-{
- private ServiceRegistration registration;
-
- public void start(BundleContext context)
- {
- MBeanTestService service = new MBeanTestService(context);
- registration = context.registerService(MBeanTestService.class.getName(), service, null);
- }
-
- public void stop(BundleContext context)
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
- }
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/Foo.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/Foo.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/Foo.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,34 @@
+/*
+ * 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.service.microcontainer.bundle;
+
+
+
+//$Id$
+
+public class Foo implements FooMBean
+{
+ public String echo(String msg)
+ {
+ return msg;
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/Foo.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/FooMBean.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/FooMBean.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/FooMBean.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,29 @@
+/*
+ * 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.service.microcontainer.bundle;
+
+//$Id$
+
+public interface FooMBean
+{
+ String echo(String msg);
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/FooMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java (from rev 87033, projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/MBeanTestService.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/MBeanTestService.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,107 @@
+/*
+ * 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.service.microcontainer.bundle;
+
+//$Id$
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.service.MicrocontainerService;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.jboss.test.osgi.service.microcontainer.bundle.Foo;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A service that registers an MBean
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class MBeanTestService implements ServiceListener
+{
+ public static ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.osgi:service=mbean-test-service");
+
+ private BundleContext context;
+ private MBeanServer mbeanServer;
+
+ public MBeanTestService(BundleContext context)
+ {
+ this.context = context;
+ context.addServiceListener(this);
+ }
+
+ private void registerService()
+ {
+ try
+ {
+ MicrocontainerService mcService = getMicrocontainerService();
+ mbeanServer = mcService.getMbeanServer();
+ mbeanServer.registerMBean(new Foo(), OBJECT_NAME);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Cannot register mbean", ex);
+ }
+ }
+
+ private void unregisterService()
+ {
+ try
+ {
+ if (mbeanServer != null && mbeanServer.isRegistered(OBJECT_NAME))
+ mbeanServer.unregisterMBean(OBJECT_NAME);
+ }
+ catch (Exception ex)
+ {
+ throw new RuntimeException("Cannot unregister mbean", ex);
+ }
+ }
+
+ private MicrocontainerService getMicrocontainerService()
+ {
+ ServiceReference sref = context.getServiceReference(MicrocontainerService.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("MicrocontainerService not registered");
+
+ return (MicrocontainerService)context.getService(sref);
+ }
+
+ public void serviceChanged(ServiceEvent event)
+ {
+ Object service = context.getService(event.getServiceReference());
+ if (service == this)
+ {
+ if (event.getType() == ServiceEvent.REGISTERED)
+ {
+ registerService();
+ }
+ else if (event.getType() == ServiceEvent.UNREGISTERING)
+ {
+ unregisterService();
+ }
+ }
+ }
+}
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/ServiceActivator.java 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,54 @@
+/*
+ * 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.service.microcontainer.bundle;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 04-Feb-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+ private ServiceRegistration registration;
+
+ public void start(BundleContext context)
+ {
+ MBeanTestService service = new MBeanTestService(context);
+ registration = context.registerService(MBeanTestService.class.getName(), service, null);
+ }
+
+ public void stop(BundleContext context)
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/service/microcontainer/bundle/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleB.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleB.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleB.bnd 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi39-bundleB.jar src/test/resources/jbosgi39/bundleB.bnd
+
+Bundle-SymbolicName: jbosgi39-bundleB
+Bundle-Activator: org.jboss.test.osgi.jbosgi39.bundleB.ServiceActivator
+Export-Package: org.jboss.test.osgi.jbosgi39.bundleB
+
Added: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleX.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleX.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi39/jbosgi39-bundleX.bnd 2009-04-09 11:08:56 UTC (rev 87064)
@@ -0,0 +1,5 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi39-bundleX.jar src/test/resources/jbosgi39/bundleX.bnd
+
+Bundle-SymbolicName: jbosgi39-bundleX
+Export-Package: org.jboss.test.osgi.jbosgi39.bundleX
+
Modified: projects/jboss-osgi/trunk/testsuite/src/test/resources/service/http/http-service.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/service/http/http-service.bnd 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/service/http/http-service.bnd 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,8 +1,8 @@
# bnd build -classpath target/test-classes -output target/test-libs/http-service.jar src/test/resources/service/http/http-service.bnd
Bundle-SymbolicName: http-service-test
-Bundle-Activator: org.jboss.test.osgi.service.http.ServiceActivator
-Export-Package: org.jboss.test.osgi.service.http
+Bundle-Activator: org.jboss.test.osgi.service.http.bundle.ServiceActivator
+Export-Package: org.jboss.test.osgi.service.http.bundle
Include-Resource: res/message.txt=message.txt
# For some reason this does not work
Modified: projects/jboss-osgi/trunk/testsuite/src/test/resources/service/microcontainer/microcontainer-service.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/service/microcontainer/microcontainer-service.bnd 2009-04-09 10:51:48 UTC (rev 87063)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/service/microcontainer/microcontainer-service.bnd 2009-04-09 11:08:56 UTC (rev 87064)
@@ -1,5 +1,5 @@
# bnd build -classpath target/test-classes -output target/test-libs/microcontainer-service.jar src/test/resources/service/microcontainer/microcontainer-service.bnd
Bundle-SymbolicName: microcontainer-service-test
-Bundle-Activator: org.jboss.test.osgi.service.microcontainer.ServiceActivator
-Export-Package: org.jboss.test.osgi.service.microcontainer
+Bundle-Activator: org.jboss.test.osgi.service.microcontainer.bundle.ServiceActivator
+Export-Package: org.jboss.test.osgi.service.microcontainer.bundle
More information about the jboss-cvs-commits
mailing list