[jboss-cvs] JBossAS SVN: r85016 - in projects/jboss-osgi/trunk: testsuite/scripts and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 2 07:12:31 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-03-02 07:12:31 -0500 (Mon, 02 Mar 2009)
New Revision: 85016
Added:
projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/StateFormat.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceB.java
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleX/
projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleX/SomePojo.java
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd
projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleX.bnd
Modified:
projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml
Log:
[JBOSGI-38] Investigate bundle install/start behaviour
Added: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/StateFormat.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/StateFormat.java (rev 0)
+++ projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/StateFormat.java 2009-03-02 12:12:31 UTC (rev 85016)
@@ -0,0 +1,58 @@
+/*
+ * 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$
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A string format helper for OSGi states
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 02-Mar-2009
+ */
+public abstract class StateFormat
+{
+ /**
+ * Return the string representation of a bundle state
+ */
+ public static String formatBundleState(int bundleState)
+ {
+ String retState = "[" + bundleState + "]";
+
+ if (Bundle.UNINSTALLED == bundleState)
+ retState = "[UNINSTALLED]";
+ else if (Bundle.INSTALLED == bundleState)
+ retState = "[INSTALLED]";
+ else if (Bundle.RESOLVED == bundleState)
+ retState = "[RESOLVED]";
+ else if (Bundle.STARTING == bundleState)
+ retState = "[STARTING]";
+ else if (Bundle.STOPPING == bundleState)
+ retState = "[STOPPING]";
+ else if (Bundle.ACTIVE == bundleState)
+ retState = "[ACTIVE]";
+
+ return retState;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/runtime/spi/src/main/java/org/jboss/osgi/spi/framework/StateFormat.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml 2009-03-02 12:12:01 UTC (rev 85015)
+++ projects/jboss-osgi/trunk/testsuite/scripts/antrun-test-jars.xml 2009-03-02 12:12:31 UTC (rev 85016)
@@ -54,6 +54,11 @@
</fileset>
</jar>
+ <!-- jbosgi38 -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi38-bundleA.jar" files="${tests.resources.dir}/jbosgi38/bundleA.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi38-bundleB.jar" files="${tests.resources.dir}/jbosgi38/bundleB.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jbosgi38-bundleX.jar" files="${tests.resources.dir}/jbosgi38/bundleX.bnd" />
+
<!-- http-service -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/http-service.jar" files="${tests.resources.dir}/service/http/http-service.bnd" />
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java 2009-03-02 12:12:31 UTC (rev 85016)
@@ -0,0 +1,225 @@
+/*
+ * 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.jbosgi38;
+
+//$Id$
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.junit.IntegrationTestCase;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+/**
+ * [JBOSGI-38] Investigate bundle install/start behaviour with random deployment order
+ *
+ * https://jira.jboss.org/jira/browse/OSGI-38
+ *
+ * Bundle A depends on bundle B, both share bundle X.
+ *
+ * A ---> B
+ * A ---> X <--- B
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 02-Mar-2009
+ */
+public class OSGI38TestCase extends IntegrationTestCase
+{
+ /*
+ * Install/Start the common bundle
+ */
+ public void testInstallStartX() throws Exception
+ {
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleX = null;
+ try
+ {
+ bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleX.getState());
+
+ bundleX.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleX.getState());
+ }
+ finally
+ {
+ bundleX.uninstall();
+ }
+ }
+
+ /*
+ * Install X, B
+ */
+ public void testInstallXBeforeB() throws Exception
+ {
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleB = null;
+ Bundle bundleX = null;
+ try
+ {
+ bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleX.getState());
+
+ bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleB.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+
+ bundleB.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ }
+ finally
+ {
+ uninstall(bundleB);
+ uninstall(bundleX);
+ }
+ }
+
+ /*
+ * Install X, B, A
+ */
+ public void testInstallBBeforeA() throws Exception
+ {
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleA = null;
+ Bundle bundleB = null;
+ Bundle bundleX = null;
+ try
+ {
+ bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleX.getState());
+
+ bundleB = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleB.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
+
+ bundleA = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleA.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
+
+ bundleA.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ }
+ finally
+ {
+ uninstall(bundleA);
+ uninstall(bundleB);
+ uninstall(bundleX);
+ }
+ }
+
+ /*
+ * Install B, X
+ */
+ public void testInstallBBeforeX() throws Exception
+ {
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleB = null;
+ Bundle bundleX = null;
+ try
+ {
+ 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
+ }
+
+ bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleX.getState());
+
+ bundleB.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+ }
+ finally
+ {
+ uninstall(bundleX);
+ uninstall(bundleB);
+ }
+ }
+
+ /*
+ * Install A, B, X
+ */
+ public void testInstallABeforeB() throws Exception
+ {
+ OSGiFramework framework = OSGiBootstrap.getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ Bundle bundleA = null;
+ Bundle bundleB = null;
+ Bundle bundleX = null;
+ try
+ {
+ bundleA = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleA.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
+
+ 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
+ }
+
+ bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
+ assertEquals("Bundle installed", Bundle.INSTALLED, bundleX.getState());
+
+ bundleA.start();
+ assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
+ }
+ finally
+ {
+ uninstall(bundleA);
+ uninstall(bundleB);
+ uninstall(bundleX);
+ }
+ }
+
+ private void uninstall(Bundle bnd)
+ {
+ try
+ {
+ if (bnd != null)
+ bnd.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ System.err.println(ex.toString());
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java 2009-03-02 12:12:31 UTC (rev 85016)
@@ -0,0 +1,43 @@
+/*
+ * 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.jbosgi38.bundleA;
+
+//$Id$
+
+import org.jboss.test.osgi.jbosgi38.bundleB.ServiceB;
+import org.jboss.test.osgi.jbosgi38.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 ServiceA
+{
+ private ServiceB serviceB;
+
+ public String callServiceB()
+ {
+ return serviceB.doStuffInB(new SomePojo("hello"));
+ }
+}
Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceB.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceB.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceB.java 2009-03-02 12:12:31 UTC (rev 85016)
@@ -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.jbosgi38.bundleB;
+
+//$Id$
+
+import org.jboss.test.osgi.jbosgi38.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/jbosgi38/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/jbosgi38/bundleX/SomePojo.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleX/SomePojo.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleX/SomePojo.java 2009-03-02 12:12:31 UTC (rev 85016)
@@ -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.jbosgi38.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/jbosgi38/bundleX/SomePojo.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd 2009-03-02 12:12:31 UTC (rev 85016)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi38-bundleA.jar src/test/resources/jbosgi38/bundleA.bnd
+
+Bundle-SymbolicName: jbosgi38-bundleA
+Export-Package: org.jboss.test.osgi.jbosgi38.bundleA
+Import-Package: org.jboss.test.osgi.jbosgi38.bundleB, org.jboss.test.osgi.jbosgi38.bundleX
+
Added: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd 2009-03-02 12:12:31 UTC (rev 85016)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi38-bundleB.jar src/test/resources/jbosgi38/bundleB.bnd
+
+Bundle-SymbolicName: jbosgi38-bundleB
+Export-Package: org.jboss.test.osgi.jbosgi38.bundleB
+Import-Package: org.jboss.test.osgi.jbosgi38.bundleX
+
Added: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleX.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleX.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleX.bnd 2009-03-02 12:12:31 UTC (rev 85016)
@@ -0,0 +1,5 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jbosgi38-bundleX.jar src/test/resources/jbosgi38/bundleX.bnd
+
+Bundle-SymbolicName: jbosgi38-bundleX
+Export-Package: org.jboss.test.osgi.jbosgi38.bundleX
+
More information about the jboss-cvs-commits
mailing list