[jboss-osgi-commits] JBoss-OSGI SVN: r88304 - in projects/jboss-osgi/trunk: bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap and 11 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Wed May 6 16:29:27 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-05-06 16:29:26 -0400 (Wed, 06 May 2009)
New Revision: 88304
Added:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/Capability.java
Removed:
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/Capability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/EmbeddedFrameworkWrapper.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiFrameworkWrapper.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/FELIX1040TestCase.java
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JMXCapability.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JNDICapability.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/MicrocontainerCapability.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerTestCase.java
projects/jboss-osgi/trunk/runtime/equinox/src/test/java/org/jboss/test/osgi/equinox/SystemBundleTestCase.java
projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/SystemBundleTestCase.java
projects/jboss-osgi/trunk/runtime/knopflerfish/src/test/java/org/jboss/test/osgi/knopflerfish/SystemBundleTestCase.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/AbstractRuntime.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/EmbeddedRuntime.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestSetup.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java
Log:
Migrate tests to use abstract osgi runtime
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JMXCapability.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JMXCapability.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JMXCapability.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -21,14 +21,12 @@
*/
package org.jboss.test.osgi.blueprint;
+//$Id$
+
import java.util.Properties;
-import org.jboss.osgi.spi.junit.Capability;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
+import org.jboss.osgi.spi.testing.Capability;
-//$Id$
-
/**
* [TODO]
*
@@ -39,15 +37,10 @@
{
public JMXCapability()
{
- Properties props = new Properties();
+ Properties props = getProperties();
props.setProperty("org.jboss.osgi.jmx.host", System.getProperty("jboss.bind.address", "localhost"));
props.setProperty("org.jboss.osgi.jmx.rmi.port", "1198");
- setProperties(props);
+
+ addBundle("bundles/jboss-osgi-jmx.jar");
}
-
- public void deploy(BundleContext context) throws BundleException
- {
- super.deploy(context);
- deploy(context, "bundles/jboss-osgi-jmx.jar", true);
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JNDICapability.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JNDICapability.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/JNDICapability.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -21,14 +21,12 @@
*/
package org.jboss.test.osgi.blueprint;
+//$Id$
+
import java.util.Properties;
-import org.jboss.osgi.spi.junit.Capability;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
+import org.jboss.osgi.spi.testing.Capability;
-//$Id$
-
/**
* [TODO]
*
@@ -39,17 +37,12 @@
{
public JNDICapability()
{
- Properties props = new Properties();
+ Properties props = getProperties();
props.setProperty("org.jboss.osgi.jndi.host", System.getProperty("jboss.bind.address", "localhost"));
props.setProperty("org.jboss.osgi.jndi.rmi.port", "1198");
props.setProperty("org.jboss.osgi.jndi.port", "1199");
- setProperties(props);
+
+ addBundle("bundles/jboss-common-core-bundle.jar");
+ addBundle("bundles/jboss-osgi-jndi.jar");
}
-
- public void deploy(BundleContext context) throws BundleException
- {
- super.deploy(context);
- deploy(context, "bundles/jboss-common-core-bundle.jar", true);
- deploy(context, "bundles/jboss-osgi-jndi.jar", true);
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/MicrocontainerCapability.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/MicrocontainerCapability.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/MicrocontainerCapability.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -21,14 +21,10 @@
*/
package org.jboss.test.osgi.blueprint;
-import java.util.Properties;
-
-import org.jboss.osgi.spi.junit.Capability;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
//$Id$
+import org.jboss.osgi.spi.testing.Capability;
+
/**
* [TODO]
*
@@ -39,16 +35,9 @@
{
public MicrocontainerCapability()
{
- Properties props = new Properties();
- setProperties(props);
+ addBundle("bundles/apache-xerces-bundle.jar");
+ addBundle("bundles/jaxb-bundle.jar");
+ addBundle("bundles/jbossxb-bundle.jar");
+ addBundle("bundles/jboss-osgi-microcontainer.jar");
}
-
- public void deploy(BundleContext context) throws BundleException
- {
- super.deploy(context);
- deploy(context, "bundles/apache-xerces-bundle.jar", true);
- deploy(context, "bundles/jaxb-bundle.jar", true);
- deploy(context, "bundles/jbossxb-bundle.jar", true);
- deploy(context, "bundles/jboss-osgi-microcontainer.jar", true);
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -24,12 +24,10 @@
//$Id$
package org.jboss.test.osgi.blueprint.bootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
+import org.jboss.osgi.spi.testing.AbstractBundle;
+import org.jboss.osgi.spi.testing.AbstractRuntime;
+import org.jboss.osgi.spi.testing.OSGiTest;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
/**
@@ -42,116 +40,104 @@
{
public void testApacheXercesBundle() throws BundleException
{
- OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = configProvider.getFramework();
+ AbstractRuntime runtime = getEmbeddedRuntime();
try
{
- BundleContext context = framework.getBundleContext();
+ AbstractBundle bundle = runtime.installBundle("bundles/apache-xerces-bundle.jar");
+ bundle.start();
- Bundle bundle = installBundle(context, "bundles/apache-xerces-bundle.jar", true);
-
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
}
finally
{
- framework.stop();
+ runtime.shutdown();
}
}
public void testJAXBBundle() throws BundleException
{
- OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = configProvider.getFramework();
+ AbstractRuntime runtime = getEmbeddedRuntime();
try
{
- BundleContext context = framework.getBundleContext();
-
- Bundle bundle = installBundle(context, "bundles/jaxb-bundle.jar", true);
-
+ AbstractBundle bundle = runtime.installBundle("bundles/jaxb-bundle.jar");
+ bundle.start();
+
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
}
finally
{
- framework.stop();
+ runtime.shutdown();
}
}
public void testJBossCommonCoreBundle() throws BundleException
{
- OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = configProvider.getFramework();
+ AbstractRuntime runtime = getEmbeddedRuntime();
try
{
- BundleContext context = framework.getBundleContext();
+ AbstractBundle bundle = runtime.installBundle("bundles/apache-xerces-bundle.jar");
+ bundle = runtime.installBundle("bundles/jboss-common-core-bundle.jar");
+ bundle.start();
- Bundle bundle = installBundle(context, "bundles/apache-xerces-bundle.jar", true);
- bundle = installBundle(context, "bundles/jboss-common-core-bundle.jar", true);
-
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
}
finally
{
- framework.stop();
+ runtime.shutdown();
}
}
public void testJBossXBBundle() throws BundleException
{
- OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = configProvider.getFramework();
+ AbstractRuntime runtime = getEmbeddedRuntime();
try
{
- BundleContext context = framework.getBundleContext();
+ AbstractBundle bundle = runtime.installBundle("bundles/apache-xerces-bundle.jar");
+ bundle = runtime.installBundle("bundles/jboss-common-core-bundle.jar");
+ bundle = runtime.installBundle("bundles/jaxb-bundle.jar");
+ bundle = runtime.installBundle("bundles/jbossxb-bundle.jar");
+ bundle.start();
- Bundle bundle = installBundle(context, "bundles/apache-xerces-bundle.jar", true);
- bundle = installBundle(context, "bundles/jboss-common-core-bundle.jar", true);
- bundle = installBundle(context, "bundles/jaxb-bundle.jar", true);
- bundle = installBundle(context, "bundles/jbossxb-bundle.jar", true);
-
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
}
finally
{
- framework.stop();
+ runtime.shutdown();
}
}
public void testJNDIBundle() throws BundleException
{
- OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = configProvider.getFramework();
+ AbstractRuntime runtime = getEmbeddedRuntime();
try
{
- BundleContext context = framework.getBundleContext();
+ AbstractBundle bundle = runtime.installBundle("bundles/jboss-common-core-bundle.jar");
+ bundle = runtime.installBundle("bundles/jboss-osgi-jndi.jar");
+ bundle.start();
- Bundle bundle = installBundle(context, "bundles/jboss-common-core-bundle.jar", true);
- bundle = installBundle(context, "bundles/jboss-osgi-jndi.jar", true);
-
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
}
finally
{
- framework.stop();
+ runtime.shutdown();
}
}
public void testJMXBundle() throws Exception
{
- OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = configProvider.getFramework();
+ AbstractRuntime runtime = getEmbeddedRuntime();
try
{
- BundleContext context = framework.getBundleContext();
+ AbstractBundle bundle = runtime.installBundle("bundles/jboss-common-core-bundle.jar");
+ bundle = runtime.installBundle("bundles/jboss-osgi-jndi.jar");
+ bundle = runtime.installBundle("bundles/jboss-osgi-jmx.jar");
+ bundle.start();
- Bundle bundle = installBundle(context, "bundles/jboss-common-core-bundle.jar", true);
- bundle = installBundle(context, "bundles/jboss-osgi-jndi.jar", true);
- bundle = installBundle(context, "bundles/jboss-osgi-jmx.jar", true);
-
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
}
finally
{
- framework.stop();
+ runtime.shutdown();
}
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -27,7 +27,7 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTest;
import org.osgi.framework.Bundle;
/**
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -29,14 +29,14 @@
import junit.framework.Test;
-import org.jboss.osgi.spi.junit.OSGiFrameworkWrapper;
-import org.jboss.osgi.spi.junit.OSGiTest;
-import org.jboss.osgi.spi.junit.OSGiTestSetup;
import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.testing.AbstractBundle;
+import org.jboss.osgi.spi.testing.AbstractRuntime;
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTestSetup;
import org.jboss.test.osgi.blueprint.JMXCapability;
import org.jboss.test.osgi.blueprint.JNDICapability;
import org.jboss.test.osgi.blueprint.jmx.bundle.FooMBean;
-import org.osgi.framework.BundleContext;
/**
* A test that deployes a bundle that registeres an MBean
@@ -46,7 +46,7 @@
*/
public class JMXTestCase extends OSGiTest
{
- private static OSGiFrameworkWrapper framework;
+ private static AbstractRuntime runtime;
public static Test suite()
{
@@ -56,18 +56,18 @@
protected void setUp() throws Exception
{
super.setUp();
- framework = wrapFramework(getBootstrapProvider().getFramework());
- framework.addCapability(new JNDICapability());
- framework.addCapability(new JMXCapability());
+ runtime = getRuntime();
+ runtime.addCapability(new JNDICapability());
+ runtime.addCapability(new JMXCapability());
- BundleContext sysContext = framework.getBundleContext();
- installBundle(sysContext, "jmx-test.jar", true);
+ AbstractBundle bundle = runtime.installBundle("jmx-test.jar");
+ bundle.start();
}
@Override
protected void tearDown() throws Exception
{
- framework.stop();
+ runtime.shutdown();
super.tearDown();
}
};
@@ -77,7 +77,7 @@
public void testMBeanAccess() throws Exception
{
ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
- FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
+ FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, runtime.getMBeanServer());
assertEquals("hello", foo.echo("hello"));
}
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -28,12 +28,12 @@
import junit.framework.Test;
-import org.jboss.osgi.spi.junit.OSGiFrameworkWrapper;
-import org.jboss.osgi.spi.junit.OSGiTest;
-import org.jboss.osgi.spi.junit.OSGiTestSetup;
+import org.jboss.osgi.spi.testing.AbstractBundle;
+import org.jboss.osgi.spi.testing.AbstractRuntime;
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTestSetup;
import org.jboss.test.osgi.blueprint.JNDICapability;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
/**
* A test that deployes a bundle that binds a String to JNDI
@@ -43,7 +43,7 @@
*/
public class JNDITestCase extends OSGiTest
{
- private static OSGiFrameworkWrapper framework;
+ private static AbstractRuntime runtime;
public static Test suite()
{
@@ -53,14 +53,14 @@
protected void setUp() throws Exception
{
super.setUp();
- framework = wrapFramework(getBootstrapProvider().getFramework());
- framework.addCapability(new JNDICapability());
+ runtime = getRuntime();
+ runtime.addCapability(new JNDICapability());
}
@Override
protected void tearDown() throws Exception
{
- framework.stop();
+ runtime.shutdown();
super.tearDown();
}
};
@@ -69,9 +69,9 @@
public void testJNDIAccess() throws Exception
{
- BundleContext sysContext = framework.getBundleContext();
-
- Bundle bundle = installBundle(sysContext, "jndi-test.jar", true);
+ AbstractBundle bundle = runtime.installBundle("jndi-test.jar");
+ bundle.start();
+
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
InitialContext iniCtx = new InitialContext();
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/mcservice/MicrocontainerTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -38,11 +38,11 @@
import junit.framework.Test;
import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.junit.OSGiFrameworkWrapper;
-import org.jboss.osgi.spi.junit.OSGiTest;
-import org.jboss.osgi.spi.junit.OSGiTestSetup;
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
+import org.jboss.osgi.spi.testing.AbstractRuntime;
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTestSetup;
import org.jboss.test.osgi.blueprint.JMXCapability;
import org.jboss.test.osgi.blueprint.JNDICapability;
import org.jboss.test.osgi.blueprint.MicrocontainerCapability;
@@ -55,7 +55,7 @@
*/
public class MicrocontainerTestCase extends OSGiTest
{
- private static OSGiFrameworkWrapper framework;
+ private static AbstractRuntime runtime;
public static Test suite()
{
@@ -65,16 +65,16 @@
protected void setUp() throws Exception
{
super.setUp();
- framework = wrapFramework(getBootstrapProvider().getFramework());
- framework.addCapability(new JNDICapability());
- //framework.addCapability(new JMXCapability());
- //framework.addCapability(new MicrocontainerCapability());
+ runtime = getRuntime();
+ runtime.addCapability(new JNDICapability());
+ //runtime.addCapability(new JMXCapability());
+ //runtime.addCapability(new MicrocontainerCapability());
}
@Override
protected void tearDown() throws Exception
{
- framework.stop();
+ runtime.shutdown();
super.tearDown();
}
};
@@ -86,7 +86,7 @@
public void _testServiceAccess() throws Exception
{
- MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, getMBeanServer());
+ MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
List<String> registeredBeans = mcService.getRegisteredBeans();
assertTrue("BundleContext registered with MC", registeredBeans.contains(BEAN_SYSTEM_BUNDLE_CONTEXT));
assertTrue("MainDeployer registered with MC", registeredBeans.contains(BEAN_MAIN_DEPLOYER));
@@ -99,10 +99,10 @@
*/
public void _testBundleDeployment() throws Exception
{
- MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, getMBeanServer());
+ MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
mcService.deploy(getTestArchiveURL("mcservice-bundleA.jar"));
- ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, getMBeanServer());
+ ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
Set<ObjectName> bundles = frameworkMBean.getBundles();
assertTrue("Managed bundle registered", bundles.toString().indexOf("jboss.osgi:bundle=mcservice-bundleA") > 0);
@@ -111,10 +111,10 @@
public void _testBeansDeployment() throws Exception
{
- MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, getMBeanServer());
+ MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
mcService.deploy(getTestArchiveURL("mcservice-bundleB.jar"));
- ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, getMBeanServer());
+ ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
Set<ObjectName> bundles = frameworkMBean.getBundles();
assertTrue("Managed bundle registered", bundles.toString().indexOf("jboss.osgi:bundle=mcservice-bundleB") > 0);
Modified: projects/jboss-osgi/trunk/runtime/equinox/src/test/java/org/jboss/test/osgi/equinox/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/equinox/src/test/java/org/jboss/test/osgi/equinox/SystemBundleTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/runtime/equinox/src/test/java/org/jboss/test/osgi/equinox/SystemBundleTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -27,7 +27,7 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTest;
import org.osgi.framework.Bundle;
/**
Modified: projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/SystemBundleTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/runtime/felix/src/test/java/org/jboss/test/osgi/felix/SystemBundleTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -27,7 +27,7 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTest;
import org.osgi.framework.Bundle;
/**
Modified: projects/jboss-osgi/trunk/runtime/knopflerfish/src/test/java/org/jboss/test/osgi/knopflerfish/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/runtime/knopflerfish/src/test/java/org/jboss/test/osgi/knopflerfish/SystemBundleTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/runtime/knopflerfish/src/test/java/org/jboss/test/osgi/knopflerfish/SystemBundleTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -27,7 +27,7 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTest;
import org.osgi.framework.Bundle;
/**
Deleted: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/Capability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/Capability.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/Capability.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.junit;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-//$Id$
-
-/**
- * [TODO]
- *
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public abstract class Capability
-{
- private OSGiFrameworkWrapper framework;
- private Properties props;
- private List<Bundle> bundles = new ArrayList<Bundle>();
-
- public Capability()
- {
- }
-
- public Capability(Properties props)
- {
- this.props = props;
- }
-
- public Properties getProperties()
- {
- return props;
- }
-
- public void setProperties(Properties props)
- {
- this.props = props;
- }
-
- public void setFrameworkWrapper(OSGiFrameworkWrapper framework)
- {
- this.framework = framework;
- }
-
- protected void initProperties(BundleContext context)
- {
- if (props != null)
- {
- Enumeration<?> keys = props.propertyNames();
- while (keys.hasMoreElements())
- {
- String key = (String)keys.nextElement();
- String value = props.getProperty(key);
- System.setProperty(key, value);
- }
- }
- }
-
- protected void deploy(BundleContext context, String bundlePath, boolean start) throws BundleException
- {
- addBundle(framework.installBundle(context, bundlePath, start));
- }
-
- protected void addBundle(Bundle bundle)
- {
- bundles.add(0, bundle);
- }
-
- public void deploy(BundleContext context) throws BundleException
- {
- initProperties(context);
- }
-
- public void undeploy(BundleContext context) throws BundleException
- {
- for (Bundle bundle : bundles)
- {
- bundle.uninstall();
- }
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/EmbeddedFrameworkWrapper.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/EmbeddedFrameworkWrapper.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/EmbeddedFrameworkWrapper.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.junit;
-
-//$Id$
-
-import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-/**
- * [TODO]
- *
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public class EmbeddedFrameworkWrapper extends OSGiFrameworkWrapper
-{
- private OSGiTestHelper helper = new OSGiTestHelper();
-
- public EmbeddedFrameworkWrapper(OSGiFramework framework)
- {
- super(framework);
- }
-
- @Override
- public Bundle installBundle(BundleContext context, String bundlePath, boolean start) throws BundleException
- {
- return helper.installBundle(context, bundlePath, start);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiFrameworkWrapper.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiFrameworkWrapper.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiFrameworkWrapper.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.junit;
-
-//$Id$
-
-import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-/**
- * [TODO]
- *
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public abstract class OSGiFrameworkWrapper
-{
- private OSGiFramework framework;
-
- public OSGiFrameworkWrapper(OSGiFramework framework)
- {
- this.framework = framework;
- }
-
- public BundleContext getBundleContext()
- {
- return framework.getBundleContext();
- }
-
- public void addCapability(Capability cap) throws BundleException
- {
- cap.setFrameworkWrapper(this);
- BundleContext context = framework.getBundleContext();
- cap.deploy(context);
- }
-
- public void removeCapability(Capability cap) throws BundleException
- {
- BundleContext context = framework.getBundleContext();
- cap.undeploy(context);
- }
-
- public abstract Bundle installBundle(BundleContext context, String bundlePath, boolean start) throws BundleException;
-
- public void start()
- {
- framework.start();
- }
-
- public void stop()
- {
- framework.stop();
- }
-
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTest.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -31,7 +31,6 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
import org.jboss.osgi.spi.logging.LogEntryCache;
import org.jboss.virtual.VFS;
import org.osgi.framework.Bundle;
@@ -146,9 +145,4 @@
{
return delegate.getMBeanServer();
}
-
- protected OSGiFrameworkWrapper wrapFramework(OSGiFramework framework)
- {
- return delegate.wrapFramework(framework);
- }
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestHelper.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -207,9 +207,4 @@
return server;
}
-
- public OSGiFrameworkWrapper wrapFramework(OSGiFramework framework)
- {
- return new EmbeddedFrameworkWrapper(framework);
- }
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -32,7 +32,6 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
import org.jboss.virtual.VFS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -116,9 +115,4 @@
{
return delegate.getMBeanServer();
}
-
- protected OSGiFrameworkWrapper wrapFramework(OSGiFramework framework)
- {
- return delegate.wrapFramework(framework);
- }
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/AbstractRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/AbstractRuntime.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/AbstractRuntime.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -21,8 +21,15 @@
*/
package org.jboss.osgi.spi.testing;
-import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.management.MBeanServer;
+
+import org.jboss.logging.Logger;
import org.jboss.osgi.spi.logging.LogEntryCache;
import org.osgi.framework.BundleException;
@@ -34,13 +41,70 @@
*/
public abstract class AbstractRuntime
{
- public abstract AbstractBundle installBundle(URL bundleURL) throws BundleException;
+ // Provide logging
+ final Logger log = Logger.getLogger(AbstractRuntime.class);
+ private OSGiTestHelper helper;
+ private Map<String, AbstractBundle> bundles = new HashMap<String, AbstractBundle>();
+ private List<Capability> capabilities = new ArrayList<Capability>();
+
+ public AbstractRuntime(OSGiTestHelper helper)
+ {
+ this.helper = helper;
+ }
+
+ public OSGiTestHelper getTestHelper()
+ {
+ return helper;
+ }
+
+ public abstract AbstractBundle installBundle(String location) throws BundleException;
+
+ public void addCapability(Capability capability) throws BundleException
+ {
+ for (String location : capability.getBundles())
+ {
+ AbstractBundle bundle = installBundle(location);
+ bundle.start();
+
+ bundles.put(location, bundle);
+ }
+ capabilities.add(capability);
+ }
+
+ public void removeCapability(Capability capability)
+ {
+ capabilities.remove(capability);
+
+ List<String> bundleLocations = capability.getBundles();
+ Collections.reverse(bundleLocations);
+
+ for (String location : bundleLocations)
+ {
+ AbstractBundle bundle = bundles.get(location);
+ try
+ {
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.error("Cannot uninstall bundle: " + bundle);
+ }
+ }
+ }
+
+ public abstract MBeanServer getMBeanServer();
+
public abstract void startLogEntryTracking(LogEntryCache logEntryCache);
public abstract void stopLogEntryTracking();
+
+ public void shutdown()
{
- // TODO Auto-generated method stub
-
+ while (capabilities.size() > 0)
+ {
+ Capability capability = capabilities.get(0);
+ removeCapability(capability);
+ }
}
}
Copied: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/Capability.java (from rev 88284, projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/Capability.java)
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/Capability.java (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/Capability.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -0,0 +1,59 @@
+/*
+ * 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.testing;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * [TODO]
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public abstract class Capability
+{
+ private Properties props = new Properties();
+ private List<String> bundles = new ArrayList<String>();
+
+ public Capability()
+ {
+ }
+
+ public Properties getProperties()
+ {
+ return props;
+ }
+
+ protected void addBundle(String bundle)
+ {
+ bundles.add(bundle);
+ }
+
+ public List<String> getBundles()
+ {
+ return new ArrayList<String>(bundles);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/EmbeddedRuntime.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/EmbeddedRuntime.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -22,7 +22,13 @@
package org.jboss.osgi.spi.testing;
import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Properties;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
import org.jboss.osgi.spi.logging.LogEntryCache;
@@ -41,21 +47,36 @@
*/
public class EmbeddedRuntime extends AbstractRuntime
{
- private OSGiBootstrapProvider bootProvider;
-
- public EmbeddedRuntime(OSGiBootstrapProvider bootProvider)
+ public EmbeddedRuntime(OSGiTestHelper helper)
{
- this.bootProvider = bootProvider;
+ super(helper);
}
@Override
- public AbstractBundle installBundle(URL bundleURL) throws BundleException
+ public AbstractBundle installBundle(String location) throws BundleException
{
+ URL bundleURL = getTestHelper().getTestArchiveURL(location);
Bundle bundle = getBundleContext().installBundle(bundleURL.toExternalForm());
return new EmbeddedBundle(bundle);
}
@Override
+ public void addCapability(Capability capability) throws BundleException
+ {
+ // Copy the properties to the System props
+ Properties props = capability.getProperties();
+ Enumeration<?> names = props.propertyNames();
+ while (names.hasMoreElements())
+ {
+ String key = (String)names.nextElement();
+ String value = props.getProperty(key);
+ System.setProperty(key, value);
+ }
+
+ super.addCapability(capability);
+ }
+
+ @Override
public void startLogEntryTracking(final LogEntryCache logEntryCache)
{
// Track the LogReaderService to add the LogEntryCache as LogListener
@@ -77,9 +98,36 @@
{
}
+ @Override
+ public void shutdown()
+ {
+ super.shutdown();
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
+ bootProvider.getFramework().stop();
+ }
+
private BundleContext getBundleContext()
{
+ OSGiBootstrapProvider bootProvider = getTestHelper().getBootstrapProvider();
OSGiFramework framework = bootProvider.getFramework();
return framework.getBundleContext();
}
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public MBeanServer getMBeanServer()
+ {
+ ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+ if (serverArr.size() > 1)
+ throw new IllegalStateException("Multiple MBeanServer instances not supported");
+
+ MBeanServer server = null;
+ if (serverArr.size() == 1)
+ server = serverArr.get(0);
+
+ if (server == null)
+ server = MBeanServerFactory.createMBeanServer();
+
+ return server;
+ }
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -38,12 +38,13 @@
// Provide logging
final Logger log = Logger.getLogger(OSGiTest.class);
- private OSGiTestHelper delegate = new OSGiTestHelper();
+ private OSGiTestHelper delegate;
@Override
protected void setUp() throws Exception
{
log.debug("### START " + getLongName());
+ delegate = new OSGiTestHelper();
super.setUp();
}
@@ -71,6 +72,11 @@
return delegate.getRuntime();
}
+ protected EmbeddedRuntime getEmbeddedRuntime()
+ {
+ return delegate.getEmbeddedRuntime();
+ }
+
protected URL getResourceURL(String resource)
{
return delegate.getResourceURL(resource);
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestHelper.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -39,6 +39,7 @@
private static final String SYSPROP_TEST_RESOURCES_DIRECTORY = "test.resources.directory";
private static final String SYSPROP_TEST_ARCHIVE_DIRECTORY = "test.archive.directory";
+ // The OSGiBootstrapProvider is a lazy property of the helper
private OSGiBootstrapProvider bootProvider;
private static String testResourcesDir;
@@ -50,19 +51,24 @@
testArchiveDir = System.getProperty(SYSPROP_TEST_ARCHIVE_DIRECTORY, "target/test-libs");
}
+ public OSGiBootstrapProvider getBootstrapProvider()
+ {
+ if (bootProvider == null)
+ bootProvider = OSGiBootstrap.getBootstrapProvider();
+
+ return bootProvider;
+ }
+
public AbstractRuntime getRuntime()
{
return getEmbeddedRuntime();
}
- public AbstractRuntime getEmbeddedRuntime()
+ public EmbeddedRuntime getEmbeddedRuntime()
{
- if (bootProvider == null)
- bootProvider = OSGiBootstrap.getBootstrapProvider();
-
- return new EmbeddedRuntime(bootProvider);
+ return new EmbeddedRuntime(this);
}
-
+
public AbstractRuntime getRemoteRuntime()
{
return null;
@@ -84,6 +90,19 @@
return resURL;
}
+ /** Try to discover the URL for the deployment archive */
+ public URL getTestArchiveURL(String archive)
+ {
+ try
+ {
+ return getTestArchiveFile(archive).toURI().toURL();
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ }
+
/** Try to discover the File for the test resource */
private File getResourceFile(String resource)
{
@@ -98,19 +117,6 @@
throw new IllegalArgumentException("Cannot obtain '" + testResourcesDir + "/" + resource + "'");
}
- /** Try to discover the URL for the deployment archive */
- public URL getTestArchiveURL(String archive)
- {
- try
- {
- return getTestArchiveFile(archive).toURI().toURL();
- }
- catch (MalformedURLException ex)
- {
- throw new IllegalStateException(ex);
- }
- }
-
/** Try to discover the File for the deployment archive */
private File getTestArchiveFile(String archive)
{
@@ -124,5 +130,4 @@
throw new IllegalArgumentException("Cannot obtain '" + testArchiveDir + "/" + archive + "'.");
}
-
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestSetup.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestSetup.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiTestSetup.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -21,22 +21,12 @@
*/
package org.jboss.osgi.spi.testing;
-import java.io.File;
-import java.net.MalformedURLException;
import java.net.URL;
-import javax.management.MBeanServer;
-
import junit.extensions.TestSetup;
import junit.framework.TestSuite;
import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.virtual.VFS;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
/**
* An OSGi Test Setup
@@ -49,7 +39,7 @@
// Provide logging
final Logger log = Logger.getLogger(OSGiTestSetup.class);
- private OSGiTestHelper delegate = new OSGiTestHelper();
+ private OSGiTestHelper helper;
private Class<?> testCase;
public OSGiTestSetup(Class<?> testCase)
@@ -62,6 +52,7 @@
protected void setUp() throws Exception
{
log.debug("### START SETUP " + testCase.getName());
+ helper = new OSGiTestHelper();
super.setUp();
}
@@ -71,4 +62,19 @@
super.tearDown();
log.debug("### END SETUP " + testCase.getName());
}
+
+ public AbstractRuntime getRuntime()
+ {
+ return helper.getRuntime();
+ }
+
+ public URL getResourceURL(String resource)
+ {
+ return helper.getResourceURL(resource);
+ }
+
+ public URL getTestArchiveURL(String archive)
+ {
+ return helper.getTestArchiveURL(archive);
+ }
}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/LogServiceTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -23,17 +23,14 @@
//$Id: LogServiceTestCase.java 87330 2009-04-15 10:57:57Z thomas.diesler at jboss.com $
-import java.net.URL;
import java.util.List;
-import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.logging.LogEntryCache;
+import org.jboss.osgi.spi.logging.LogEntryFilter;
import org.jboss.osgi.spi.testing.AbstractBundle;
import org.jboss.osgi.spi.testing.AbstractRuntime;
import org.jboss.osgi.spi.testing.OSGiTest;
-import org.jboss.osgi.spi.logging.LogEntryCache;
-import org.jboss.osgi.spi.logging.LogEntryFilter;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogEntry;
import org.osgi.service.log.LogService;
@@ -69,8 +66,7 @@
public void testLogEntryFilter() throws Exception
{
// Install and start the test bundle
- URL testURL = getTestArchiveURL("example/example-log.jar");
- AbstractBundle bundleA = runtime.installBundle(testURL);
+ AbstractBundle bundleA = runtime.installBundle("example/example-log.jar");
bundleA.start();
// Verify that the bundle is active
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/bootstrap/BootstrapTestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -27,7 +27,7 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
+import org.jboss.osgi.spi.testing.OSGiTest;
import org.osgi.framework.Bundle;
/**
Deleted: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/FELIX1040TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/FELIX1040TestCase.java 2009-05-06 20:01:26 UTC (rev 88303)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/FELIX1040TestCase.java 2009-05-06 20:29:26 UTC (rev 88304)
@@ -1,82 +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.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-/**
- * [FELIX-1040] Bundle may start with unresolved packages
- *
- * https://issues.apache.org/jira/browse/FELIX-1040
- *
- * @author thomas.diesler at jboss.com
- * @since 17-Apr-2009
- */
-public class FELIX1040TestCase extends OSGiTest
-{
- public void testVerifyUnresolved() throws Exception
- {
- OSGiFramework fwOne = createBootstrapProvider().getFramework();
- try
- {
- BundleContext ctxOne = fwOne.getBundleContext();
-
- Bundle bundleA = ctxOne.installBundle(getTestArchiveURL("jbosgi37-bundleA.jar").toExternalForm());
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleA.getState());
-
- bundleA.start();
- }
- finally
- {
- fwOne.stop();
- }
-
- OSGiFramework fwTwo = createBootstrapProvider().getFramework();
- try
- {
- BundleContext ctxTwo = fwTwo.getBundleContext();
-
- Bundle bundleB = ctxTwo.installBundle(getTestArchiveURL("jbosgi39-bundleB.jar").toExternalForm());
- assertEquals("Bundle installed", Bundle.INSTALLED, bundleB.getState());
-
- try
- {
- bundleB.start();
- fail("Unresolved constraint expected");
- }
- catch (BundleException ex)
- {
- // expected
- }
- }
- finally
- {
- fwTwo.stop();
- }
- }
-}
\ No newline at end of file
More information about the jboss-osgi-commits
mailing list