Author: thomas.diesler(a)jboss.com
Date: 2010-03-10 11:12:51 -0500 (Wed, 10 Mar 2010)
New Revision: 102229
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractDeploymentTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractFrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/AbstractServiceMixTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/e/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/e/E.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/JMXServicesUnitTestCase#testAtJmx.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/jmx-services.xml
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTestDelegate.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/NativeFrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServicesTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/smoke/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/org/
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java
Log:
Migrate all framework tests to OSGiTest.
This removes all dependencies on jboss-vfs
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-10
16:06:33 UTC (rev 102228)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-10
16:12:51 UTC (rev 102229)
@@ -289,9 +289,8 @@
</property>
</systemProperties>
<excludes>
- <!-- excludes listed here need to have a jira issue associated
+ <!-- excludes listed here need to have a jira issue associated -->
<exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude>
- -->
</excludes>
</configuration>
</plugin>
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractDeploymentTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractDeploymentTest.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractDeploymentTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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;
+
+// $Id: $
+
+import java.net.URL;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.osgi.framework.deployers.AbstractDeployment;
+import org.jboss.osgi.vfs.VirtualFile;
+
+/**
+ * Parent for deployment tests.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 10-Mar-2010
+ */
+public abstract class AbstractDeploymentTest extends AbstractFrameworkTest
+{
+ protected BasicXMLDeployer deployer;
+
+ protected Kernel getKernel()
+ {
+ return getBundleManager().getKernel();
+ }
+
+ protected Object getBean(Object beanName)
+ {
+ return getBean(beanName, ControllerState.INSTALLED);
+ }
+
+ protected Object getBean(Object name, ControllerState state)
+ {
+ KernelControllerContext context = getControllerContext(name, state);
+ return context.getTarget();
+ }
+
+ protected KernelControllerContext getControllerContext(Object name)
+ {
+ return getControllerContext(name, ControllerState.INSTALLED);
+ }
+
+ protected KernelControllerContext getControllerContext(Object name, ControllerState
state)
+ {
+ KernelController controller = getKernel().getController();
+ KernelControllerContext context =
(KernelControllerContext)controller.getContext(name, state);
+ if (context == null)
+ throw new IllegalStateException("Bean not found " + name + " at
state " + state);
+ return context;
+ }
+
+ protected ControllerState change(KernelControllerContext context, ControllerState
required) throws Throwable
+ {
+ Controller controller = getKernel().getController();
+ controller.change(context, required);
+ return context.getState();
+ }
+
+ protected void checkComplete() throws Exception
+ {
+ getDeployerClient().checkComplete();
+ }
+
+ public DeploymentUnit getDeploymentUnit(Deployment deployment) throws Exception
+ {
+ DeployerClient deployerClient = getDeployerClient();
+ MainDeployerStructure deployerStructure = (MainDeployerStructure)deployerClient;
+ return deployerStructure.getDeploymentUnit(deployment.getName());
+ }
+
+ public void undeploy(Deployment deployment) throws Exception
+ {
+ DeployerClient deployerClient = getDeployerClient();
+ deployerClient.undeploy(deployment);
+ }
+
+ protected DeployerClient getDeployerClient()
+ {
+ return getBundleManager().getDeployerClient();
+ }
+
+ protected KernelDeployment deploy(URL urlDeployment) throws Throwable
+ {
+ return getDeployer().deploy(urlDeployment);
+ }
+
+ protected void undeploy(URL urlDeployment) throws Throwable
+ {
+ getDeployer().undeploy(urlDeployment);
+ }
+
+ protected BasicXMLDeployer getDeployer()
+ {
+ if (deployer == null)
+ {
+ deployer = new BasicXMLDeployer(getKernel());
+ }
+ return deployer;
+ }
+
+ protected Deployment deployBeans(String name, Class<?> beanClass) throws
Exception
+ {
+ return deployBeans(name, null, new Class<?>[] { beanClass });
+ }
+
+ protected Deployment deployBeans(String name, BeanMetaData bmd, Class<?>...
packages) throws Exception
+ {
+ Deployment deployment = addBeans(name, bmd, packages);
+ getDeployerClient().checkComplete();
+ return deployment;
+ }
+
+ protected Deployment addBeans(String name, BeanMetaData bmd, Class<?>...
packages) throws Exception
+ {
+ VirtualFile assembly = assembleArchive(name, new String[0], packages);
+
+ if (bmd == null)
+ {
+ Class<?> beanClass = packages[0];
+ BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder(beanClass.getSimpleName(), beanClass.getName());
+ bmd = builder.getBeanMetaData();
+ }
+
+ Deployment deployment = AbstractDeployment.createDeployment(assembly);
+ MutableAttachments att =
(MutableAttachments)deployment.getPredeterminedManagedObjects();
+ att.addAttachment(BeanMetaData.class, bmd);
+
+ getDeployerClient().addDeployment(deployment);
+ getDeployerClient().process();
+ return deployment;
+ }
+}
Copied:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractFrameworkTest.java
(from rev 102224,
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/NativeFrameworkTest.java)
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractFrameworkTest.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/AbstractFrameworkTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -0,0 +1,409 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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;
+
+// $Id: $
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.launch.OSGiFramework;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.osgi.testing.OSGiTest;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.SynchronousBundleListener;
+import org.osgi.framework.launch.Framework;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * Parent for native framework tests.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 10-Mar-2010
+ */
+public abstract class AbstractFrameworkTest extends OSGiTest implements ServiceListener,
SynchronousBundleListener, FrameworkListener
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(AbstractFrameworkTest.class);
+
+ protected static Framework framework;
+ protected static BundleContext context;
+
+ private final List<FrameworkEvent> frameworkEvents = new
CopyOnWriteArrayList<FrameworkEvent>();
+ private final List<BundleEvent> bundleEvents = new
CopyOnWriteArrayList<BundleEvent>();
+ private final List<ServiceEvent> serviceEvents = new
CopyOnWriteArrayList<ServiceEvent>();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+ framework = bootProvider.getFramework();
+ framework.start();
+
+ // Get the system context
+ context = framework.getBundleContext();
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception
+ {
+ if (framework != null)
+ {
+ framework.stop();
+ framework.waitForStop(2000);
+ framework = null;
+ }
+ }
+
+ protected PackageAdmin getPackageAdmin()
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ return (PackageAdmin)context.getService(sref);
+ }
+
+ protected OSGiBundleManager getBundleManager()
+ {
+ return ((OSGiFramework)framework).getBundleManager();
+ }
+
+ protected void assertLoadClass(Bundle bundle, String className, Bundle exporter)
+ {
+ Class<?> clazz = assertLoadClass(bundle, className);
+ Bundle actual = getPackageAdmin().getBundle(clazz);
+ assertEquals(exporter, actual);
+ }
+
+ @Override
+ public void frameworkEvent(FrameworkEvent event)
+ {
+ synchronized (frameworkEvents)
+ {
+ log.debug("FrameworkEvent type=" +
ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
+ frameworkEvents.add(event);
+ frameworkEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoFrameworkEvent() throws Exception
+ {
+ log.debug("frameworkEvents=" + frameworkEvents);
+ assertEquals(0, frameworkEvents.size());
+ }
+
+ protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends
Throwable> expectedThrowable) throws Exception
+ {
+ waitForEvent(frameworkEvents, type);
+ log.debug("frameworkEvents=" + frameworkEvents);
+ int size = frameworkEvents.size();
+ assertTrue("" + size, size > 0);
+ FrameworkEvent event = frameworkEvents.remove(0);
+ assertEquals(ConstantsHelper.frameworkEvent(type),
ConstantsHelper.frameworkEvent(event.getType()));
+ Throwable t = event.getThrowable();
+ if (expectedThrowable == null)
+ {
+ if (t != null)
+ {
+ log.error("Unexpected error in Framework event: ", t);
+ fail("Unexpected throwable: " + t);
+ }
+ }
+ else
+ {
+ String message = expectedThrowable.getSimpleName() + " is assignable from
" + t.getClass().getSimpleName();
+ assertTrue(message, expectedThrowable.isAssignableFrom(t.getClass()));
+ }
+ assertEquals(bundle, event.getSource());
+ assertEquals(bundle, event.getBundle());
+ }
+
+ @Override
+ public void bundleChanged(BundleEvent event)
+ {
+ synchronized (bundleEvents)
+ {
+ log.debug("BundleChanged type=" +
ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
+ bundleEvents.add(event);
+ bundleEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoBundleEvent() throws Exception
+ {
+ log.debug("bundleEvents=" + bundleEvents);
+ assertEquals(0, bundleEvents.size());
+ }
+
+ protected void assertBundleEvent(int type, Bundle bundle) throws Exception
+ {
+ waitForEvent(bundleEvents, type);
+
+ log.debug("bundleEvents=" + bundleEvents);
+ int size = bundleEvents.size();
+ assertTrue("" + size, size > 0);
+
+ if (bundle instanceof AbstractBundleState)
+ bundle = ((AbstractBundleState)bundle).getBundle();
+
+ BundleEvent foundEvent = null;
+ for (int i = 0; i < bundleEvents.size(); i++)
+ {
+ BundleEvent aux = bundleEvents.get(i);
+ if (type == aux.getType())
+ {
+ if (bundle.equals(aux.getSource()) &&
bundle.equals(aux.getBundle()))
+ {
+ bundleEvents.remove(aux);
+ foundEvent = aux;
+ break;
+ }
+ }
+ }
+
+ if (foundEvent == null)
+ fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + "
from " + bundle);
+ }
+
+ @Override
+ public void serviceChanged(ServiceEvent event)
+ {
+ synchronized (serviceEvents)
+ {
+ log.debug("ServiceChanged type=" +
ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
+ serviceEvents.add(event);
+ serviceEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoServiceEvent() throws Exception
+ {
+ log.debug("serviceEvents=" + serviceEvents);
+ assertEquals(0, serviceEvents.size());
+ }
+
+ protected void assertServiceEvent(int type, ServiceReference reference) throws
Exception
+ {
+ waitForEvent(serviceEvents, type);
+ log.debug("serviceEvents=" + serviceEvents);
+ int size = serviceEvents.size();
+ assertTrue("" + size, size > 0);
+ ServiceEvent event = serviceEvents.remove(0);
+ assertEquals(ConstantsHelper.serviceEvent(type),
ConstantsHelper.serviceEvent(event.getType()));
+ assertEquals(reference, event.getSource());
+ assertEquals(reference, event.getServiceReference());
+ }
+
+ protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws
Exception
+ {
+ assertNoAllReferences(bundleContext, clazz, null);
+ }
+
+ protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
+ if (actual != null)
+ log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
+ else
+ log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
+ assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
+ }
+
+ protected void assertAllReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
+ {
+ assertAllReferences(bundleContext, clazz, null, expected);
+ }
+
+ protected void assertAllReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
+ if (actual != null)
+ log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
+ else
+ log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
+ assertArrayEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
+ }
+
+ protected void assertNoReferences(BundleContext bundleContext, String clazz) throws
Exception
+ {
+ assertNoReferences(bundleContext, clazz, null);
+ }
+
+ protected void assertNoReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
+ if (actual != null)
+ log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
+ else
+ log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
+ assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
+ }
+
+ protected void assertReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
+ {
+ assertReferences(bundleContext, clazz, null, expected);
+ }
+
+ protected void assertReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
+ if (actual != null)
+ log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
+ else
+ log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
+ assertArrayEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
+ }
+
+ protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws
Exception
+ {
+ ServiceReference actual = bundleContext.getServiceReference(clazz);
+ if (actual != null)
+ log.debug(bundleContext + " got " + actual + " for clazz=" +
clazz);
+ else
+ log.debug(bundleContext + " got nothing for clazz=" + clazz);
+ assertNull("Expected no references for clazz=" + clazz, actual);
+ }
+
+ protected void assertGetReference(BundleContext bundleContext, String clazz,
ServiceReference expected) throws Exception
+ {
+ ServiceReference actual = bundleContext.getServiceReference(clazz);
+ if (actual != null)
+ log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz);
+ else
+ log.debug(bundleContext + " got nothing for clazz=" + clazz);
+ assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
+ }
+
+ protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
+ {
+ Set<Bundle> actual = new HashSet<Bundle>();
+ Bundle[] users = reference.getUsingBundles();
+ if (users != null)
+ actual.addAll(Arrays.asList(users));
+
+ Set<Bundle> expected = new HashSet<Bundle>();
+ expected.addAll(Arrays.asList(bundles));
+
+ log.debug(reference + " users=" + actual);
+
+ // switch - check expected on actual, since actual might be proxy
+ assertEquals(actual, expected);
+ }
+
+ protected <T> T assertInstanceOf(Object o, Class<T> expectedType)
+ {
+ return assertInstanceOf(o, expectedType, false);
+ }
+
+ protected <T> T assertInstanceOf(Object o, Class<T> expectedType, boolean
allowNull)
+ {
+ if (expectedType == null)
+ fail("Null expectedType");
+
+ if (o == null)
+ {
+ if (allowNull == false)
+ fail("Null object not allowed.");
+ else
+ return null;
+ }
+
+ try
+ {
+ return expectedType.cast(o);
+ }
+ catch (ClassCastException e)
+ {
+ fail("Object " + o + " of class " + o.getClass().getName() +
" is not an instanceof " + expectedType.getName());
+ // should not reach this
+ return null;
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ private void waitForEvent(List events, int type) throws InterruptedException
+ {
+ // Timeout for event delivery: 3 sec
+ int timeout = 30;
+
+ boolean eventFound = false;
+ while (eventFound == false && 0 < timeout)
+ {
+ synchronized (events)
+ {
+ events.wait(100);
+ for (Object aux : events)
+ {
+ if (aux instanceof BundleEvent)
+ {
+ BundleEvent event = (BundleEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof ServiceEvent)
+ {
+ ServiceEvent event = (ServiceEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof FrameworkEvent)
+ {
+ FrameworkEvent event = (FrameworkEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ }
+ }
+ timeout--;
+ }
+ }
+}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTest.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -1,146 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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;
-
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-
-/**
- * Deployers test - generic deployment test.
- *
- * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
- */
-public abstract class DeployersTest extends FrameworkTest
-{
- protected DeployersTest(String name)
- {
- super(name);
- }
-
- public static DeployersTestDelegate getDelegate(Class<?> clazz) throws
Exception
- {
- return new DeployersTestDelegate(clazz);
- }
-
- protected DeployersTestDelegate getDelegate()
- {
- return (DeployersTestDelegate)super.getDelegate();
- }
-
- protected void checkComplete() throws Exception
- {
- getDelegate().checkComplete();
- }
-
- protected Deployment addDeployment(VirtualFile file) throws Exception
- {
- return getDelegate().addDeployment(file);
- }
-
- protected <T> Deployment addDeployment(VirtualFile file, T metadata,
Class<T> expectedType) throws Exception
- {
- return getDelegate().addDeployment(file, metadata, expectedType);
- }
-
- protected Deployment assertDeploy(VirtualFile file) throws Exception
- {
- return getDelegate().assertDeploy(file);
- }
-
- protected <T> Deployment assertDeploy(VirtualFile file, T metadata,
Class<T> expectedType) throws Exception
- {
- return getDelegate().assertDeploy(file, metadata, expectedType);
- }
-
- protected DeploymentUnit getDeploymentUnit(Deployment deployment) throws Exception
- {
- return getDelegate().getDeploymentUnit(deployment);
- }
-
- protected void undeploy(Deployment deployment) throws Exception
- {
- getDelegate().undeploy(deployment);
- }
-
- protected Deployment addBean(String name, Class<?> beanClass, Class<?> ...
references) throws Exception
- {
- return addBean(name, beanClass, null, references);
- }
-
- protected Deployment addBean(String name, Class<?> beanClass, BeanMetaData bmd,
Class<?> ... references) throws Exception
- {
- AssembledDirectory dir = createAssembledDirectory(name, "");
- if (beanClass != null)
- addPackage(dir, beanClass);
- if (references != null)
- {
- for (Class<?> reference : references)
- addPackage(dir, reference);
- }
- if (bmd == null)
- {
- BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder(beanClass.getSimpleName(), beanClass.getName());
- bmd = builder.getBeanMetaData();
- }
- return addDeployment(dir, bmd, BeanMetaData.class);
- }
-
- protected Deployment deployBean(String name, Class<?> beanClass, Class<?>
... references) throws Exception
- {
- return deployBean(name, beanClass, null, references);
- }
-
- protected Deployment deployBean(String name, Class<?> beanClass, BeanMetaData
bmd, Class<?> ... references) throws Exception
- {
- AssembledDirectory dir = createAssembledDirectory(name, "");
- addPackage(dir, beanClass);
- if (references != null)
- {
- for (Class<?> reference : references)
- addPackage(dir, reference);
- }
- if (bmd == null)
- {
- BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder(beanClass.getSimpleName(), beanClass.getName());
- bmd = builder.getBeanMetaData();
- }
- return assertDeploy(dir, bmd, BeanMetaData.class);
- }
-
- protected Bundle getBundle(Deployment deployment) throws Exception
- {
- return getBundle(getDeploymentUnit(deployment));
- }
-
- protected Bundle getBundle(DeploymentUnit unit) throws Exception
- {
- AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
- assertNotNull(bundle);
- return bundle.getBundleInternal();
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTestDelegate.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTestDelegate.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/DeployersTestDelegate.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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;
-
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Deployers test - generic deployment test delegate.
- *
- * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
- */
-public class DeployersTestDelegate extends FrameworkTestDelegate
-{
- public DeployersTestDelegate(Class<?> clazz) throws Exception
- {
- super(clazz);
- }
-
- public void checkComplete() throws Exception
- {
- getDeployerClient().checkComplete();
- }
-
- public Deployment addDeployment(VirtualFile file) throws Exception
- {
- return addDeployment(file, null, null);
- }
-
- public <T> Deployment addDeployment(VirtualFile file, T metadata, Class<T>
expectedType) throws Exception
- {
- Deployment deployment = createDeployment(file, metadata, expectedType);
- DeployerClient deployerClient = getDeployerClient();
- deployerClient.addDeployment(deployment);
- deployerClient.process();
- return deployment;
- }
-
- public Deployment assertDeploy(VirtualFile file) throws Exception
- {
- return assertDeploy(file, null, null);
- }
-
- public <T> Deployment assertDeploy(VirtualFile file, T metadata, Class<T>
expectedType) throws Exception
- {
- Deployment deployment = createDeployment(file, metadata, expectedType);
- DeployerClient deployerClient = getDeployerClient();
- deployerClient.deploy(deployment);
- return deployment;
- }
-
- public DeploymentUnit getDeploymentUnit(Deployment deployment) throws Exception
- {
- DeployerClient deployerClient = getDeployerClient();
- MainDeployerStructure deployerStructure = (MainDeployerStructure) deployerClient;
- return deployerStructure.getDeploymentUnit(deployment.getName());
- }
-
- public void undeploy(Deployment deployment) throws Exception
- {
- DeployerClient deployerClient = getDeployerClient();
- deployerClient.undeploy(deployment);
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -1,649 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.test.kernel.junit.MicrocontainerTest;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.SynchronousBundleListener;
-
-/**
- * OSGiTestCase - Parent Test Case for OSGi tests.
- *
- * @author <a href="baileyje(a)gmail.com">John Bailey</a>
- * @version $Revision: 87848 $
- */
-@Deprecated // This has a dependency on VFS21 - use OSGiTest.
-public abstract class FrameworkTest extends MicrocontainerTest implements
FrameworkListener, SynchronousBundleListener, ServiceListener
-{
- private final List<FrameworkEvent> frameworkEvents = new
CopyOnWriteArrayList<FrameworkEvent>();
- private final List<BundleEvent> bundleEvents = new
CopyOnWriteArrayList<BundleEvent>();
- private final List<ServiceEvent> serviceEvents = new
CopyOnWriteArrayList<ServiceEvent>();
-
- /**
- * Create a new OSGiTestCase.
- *
- * @param name the test name
- */
- public FrameworkTest(String name)
- {
- super(name);
- }
-
- public static FrameworkTestDelegate getDelegate(Class<?> clazz) throws
Exception
- {
- return new FrameworkTestDelegate(clazz);
- }
-
- /**
- * Get OSGiTestDelegate
- */
- protected FrameworkTestDelegate getDelegate()
- {
- return (FrameworkTestDelegate)super.getDelegate();
- }
-
- /**
- * Get BundleManager from Delegate
- *
- * @return The BundleManager
- */
- protected OSGiBundleManager getBundleManager()
- {
- return getDelegate().getBundleManager();
- }
-
- /**
- * Get the system bundle
- *
- * @return the system bundle
- */
- protected Bundle getSystemBundle()
- {
- return getBundleManager().getBundleById(0).getBundleInternal();
- }
-
- /**
- * Add the base bundles
- *
- * @param expected the collection to add to
- */
- protected void addBaseBundles(Collection<Bundle> expected)
- {
- expected.add(getSystemBundle());
- }
-
- /**
- * Create a bundle
- *
- * @param root the location of the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle addBundle(String root, String child) throws Exception
- {
- return getDelegate().addBundle(root, child);
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle addBundle(VirtualFile file) throws Exception
- {
- return getDelegate().addBundle(file);
- }
-
- /**
- * Create a bundle
- *
- * @param root the location of the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle deployBundle(String root, String child) throws Exception
- {
- return getDelegate().deployBundle(root, child);
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle deployBundle(VirtualFile file) throws Exception
- {
- return getDelegate().deployBundle(file);
- }
-
- protected Bundle installBundle(String location) throws BundleException
- {
- return getBundleManager().installBundle(location, null).getBundleInternal();
- }
-
- protected Bundle installBundle(String location, InputStream instream) throws
BundleException
- {
- return getBundleManager().installBundle(location, instream).getBundleInternal();
- }
-
- protected Bundle installBundle(VirtualFile bundleFile) throws BundleException
- {
- return
getBundleManager().installBundle(AbstractVFS.adapt(bundleFile)).getBundleInternal();
- }
-
- /**
- * Remove a bundle
- *
- * @param bundle the bundle to remove
- * @throws Exception for any error
- */
- protected void uninstall(Bundle bundle) throws Exception
- {
- getDelegate().uninstall(bundle);
- }
-
- protected DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- return getDelegate().getDeploymentUnit(bundle);
- }
-
- protected VirtualFile assembleBundle(String name, String resources, Class<?>...
packages) throws Exception
- {
- return getDelegate().assembleBundle(name, new String[] { resources }, packages);
- }
-
- protected VirtualFile assembleBundle(String name, String[] resourcePaths,
Class<?>... packages) throws Exception
- {
- return getDelegate().assembleBundle(name, resourcePaths, packages);
- }
-
- protected Bundle deployBundle(String name, Class<?>... packages) throws
Exception
- {
- return getDelegate().deployBundle(name, null, (String[]) null, packages);
- }
-
- protected Bundle deployBundle(String name, String resourcePath, Class<?>...
packages) throws Exception
- {
- return getDelegate().deployBundle(name, null, resourcePath, packages);
- }
-
- protected Bundle deployBundle(String name, String[] resourcePaths, Class<?>...
packages) throws Exception
- {
- return getDelegate().deployBundle(name, null, resourcePaths, packages);
- }
-
- protected Bundle deployBundle(String name, OSGiMetaData metaData, Class<?>...
packages) throws Exception
- {
- return getDelegate().deployBundle(name, metaData, (String[]) null, packages);
- }
-
- protected Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath,
Class<?>... packages) throws Exception
- {
- return getDelegate().deployBundle(name, metaData, resourcePath, packages);
- }
-
- protected Bundle deployBundle(String name, OSGiMetaData metaData, String[]
resourcePaths, Class<?>... packages) throws Exception
- {
- return getDelegate().deployBundle(name, metaData, resourcePaths, packages);
- }
-
- protected AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return getDelegate().createAssembledDirectory(name, "");
- }
-
- protected AssembledDirectory createAssembledDirectory(String name, String rootName)
throws Exception
- {
- return getDelegate().createAssembledDirectory(name, rootName);
- }
-
- protected void addPackage(AssembledDirectory dir, Class<?> reference) throws
Exception
- {
- getDelegate().addPackage(dir, reference);
- }
-
- protected void addPath(final AssembledDirectory dir, String path, String name) throws
Exception
- {
- getDelegate().addPath(dir, path, name);
- }
-
- protected void assertBundleState(int expState, int wasState)
- {
- String expstr = ConstantsHelper.bundleState(expState);
- String wasstr = ConstantsHelper.bundleState(wasState);
- assertEquals("Bundle " + expstr, expstr, wasstr);
- }
-
- protected void assertClassEquality(Class<?> expected, Class<?> actual)
- {
- assertTrue("Should be the same " +
ClassLoaderUtils.classToString(expected) + " and " +
ClassLoaderUtils.classToString(actual), expected == actual);
- }
-
- protected void assertNoClassEquality(Class<?> expected, Class<?> actual)
- {
- assertTrue("Should NOT be the same " +
ClassLoaderUtils.classToString(expected) + " and " +
ClassLoaderUtils.classToString(actual), expected != actual);
- }
-
- protected void assertClassLoader(Class<?> clazz, Bundle expected)
- {
- if (expected == null)
- return;
- ClassLoader cl = clazz.getClassLoader();
- ClassLoader bundleClassLoader = getBundleClassLoader(expected);
- boolean result = bundleClassLoader.equals(cl);
- assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected
classloader=" + expected, result);
- }
-
- protected ClassLoader getBundleClassLoader(Bundle expected)
- {
- return getDeploymentUnit(expected).getClassLoader();
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference)
throws Exception
- {
- return assertLoadClass(start, reference, start);
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference,
Bundle expected) throws Exception
- {
- return assertLoadClass(start, reference, expected, false);
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference,
Bundle expected, boolean isReference) throws Exception
- {
- Class<?> result = assertLoadClass(reference.getName(), start, expected);
- if (isReference)
- assertClassEquality(reference, result);
- else
- assertNoClassEquality(reference, result);
- return result;
- }
-
- protected Class<?> assertLoadClass(String name, Bundle bundle, Bundle expected)
- {
- Class<?> result = null;
- try
- {
- result = bundle.loadClass(name);
- getLog().debug("Got class: " + ClassLoaderUtils.classToString(result)
+ " for " + name + " from " + bundle);
- }
- catch (ClassNotFoundException e)
- {
- failure("Did not expect CNFE for " + name + " from " +
bundle, e);
- }
- assertClassLoader(result, expected);
- return result;
- }
-
- protected void assertLoadClassFail(Bundle start, Class<?> reference)
- {
- assertLoadClassFail(start, reference.getName());
- }
-
- protected void assertLoadClassFail(Bundle start, String name)
- {
- try
- {
- start.loadClass(name);
- fail("Should not be here!");
- }
- catch (Exception expected)
- {
- checkThrowable(ClassNotFoundException.class, expected);
- }
- }
-
- protected URL getBundleResource(Bundle bundle, String path)
- {
- return getDelegate().getBundleResource(bundle, path);
- }
-
- protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws
Exception
- {
- return getDelegate().getBundleResources(bundle, path);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws
Exception
- {
- assertNoAllReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
- {
- assertAllReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz) throws
Exception
- {
- assertNoReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
- {
- assertReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
- }
-
- protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws
Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- getLog().debug(bundleContext + " got " + actual + " for
clazz=" + clazz);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
- assertNull("Expected no references for clazz=" + clazz, actual);
- }
-
- protected void assertGetReference(BundleContext bundleContext, String clazz,
ServiceReference expected) throws Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
- assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
- }
-
- protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
- {
- Set<Bundle> actual = new HashSet<Bundle>();
- Bundle[] users = reference.getUsingBundles();
- if (users != null)
- actual.addAll(Arrays.asList(users));
-
- Set<Bundle> expected = new HashSet<Bundle>();
- expected.addAll(Arrays.asList(bundles));
-
- getLog().debug(reference + " users=" + actual);
-
- // switch - check expected on actual, since actual might be proxy
- assertEquals(actual, expected);
- }
-
- protected void assertBundle(Bundle b1, Bundle b2)
- {
- assertNotNull(b1);
- assertNotNull(b2);
- assertEquals(b1.getBundleId(), b2.getBundleId());
- }
-
- protected void assertObjectClass(String expected, ServiceReference reference)
- {
- assertObjectClass(new String[] { expected }, reference);
- }
-
- protected void assertObjectClass(String[] expected, ServiceReference reference)
- {
- Object actual = reference.getProperty(Constants.OBJECTCLASS);
- if (actual == null)
- fail("no object class???");
- if (actual instanceof String[] == false)
- fail(actual + " is not a string array??? " +
actual.getClass().getName());
- assertEquals(expected, (String[])actual);
- }
-
- public void frameworkEvent(FrameworkEvent event)
- {
- synchronized (frameworkEvents)
- {
- getLog().debug("FrameworkEvent type=" +
ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
- frameworkEvents.add(event);
- frameworkEvents.notifyAll();
- }
- }
-
- protected void assertNoFrameworkEvent() throws Exception
- {
- getLog().debug("frameworkEvents=" + frameworkEvents);
- assertEquals(0, frameworkEvents.size());
- }
-
- protected void assertFrameworkEvent(int type) throws Exception
- {
- assertFrameworkEvent(type, getSystemBundle(), null);
- }
-
- protected void assertFrameworkEvent(int type, Class<? extends Throwable>
expectedThrowable) throws Exception
- {
- assertFrameworkEvent(type, getSystemBundle(), expectedThrowable);
- }
-
- protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends
Throwable> expectedThrowable) throws Exception
- {
- waitForEvent(frameworkEvents, type);
- getLog().debug("frameworkEvents=" + frameworkEvents);
- int size = frameworkEvents.size();
- assertTrue("" + size, size > 0);
- FrameworkEvent event = frameworkEvents.remove(0);
- assertEquals(ConstantsHelper.frameworkEvent(type),
ConstantsHelper.frameworkEvent(event.getType()));
- Throwable t = event.getThrowable();
- if (expectedThrowable == null)
- {
- if (t != null)
- {
- getLog().error("Unexpected error in Framework event: ", t);
- fail("Unexpected throwable: " + t);
- }
- }
- else
- {
- checkThrowable(BundleException.class, t);
- checkDeepThrowable(expectedThrowable, t);
- }
- assertEquals(bundle, event.getSource());
- assertEquals(bundle, event.getBundle());
- }
-
- public void bundleChanged(BundleEvent event)
- {
- synchronized (bundleEvents)
- {
- getLog().debug("BundleChanged type=" +
ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
- bundleEvents.add(event);
- bundleEvents.notifyAll();
- }
- }
-
- protected void assertNoBundleEvent() throws Exception
- {
- getLog().debug("bundleEvents=" + bundleEvents);
- assertEquals(0, bundleEvents.size());
- }
-
- protected void assertBundleEvent(int type, Bundle bundle) throws Exception
- {
- waitForEvent(bundleEvents, type);
-
- getLog().debug("bundleEvents=" + bundleEvents);
- int size = bundleEvents.size();
- assertTrue("" + size, size > 0);
-
- if (bundle instanceof AbstractBundleState)
- bundle = ((AbstractBundleState)bundle).getBundle();
-
- BundleEvent foundEvent = null;
- for(int i=0; i < bundleEvents.size(); i++)
- {
- BundleEvent aux = bundleEvents.get(i);
- if (type == aux.getType())
- {
- if (bundle.equals(aux.getSource()) &&
bundle.equals(aux.getBundle()))
- {
- bundleEvents.remove(aux);
- foundEvent = aux;
- break;
- }
- }
- }
-
- if (foundEvent == null)
- fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + "
from " + bundle);
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- synchronized (serviceEvents)
- {
- getLog().debug("ServiceChanged type=" +
ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
- serviceEvents.add(event);
- serviceEvents.notifyAll();
- }
- }
-
- protected void assertNoServiceEvent() throws Exception
- {
- getLog().debug("serviceEvents=" + serviceEvents);
- assertEquals(0, serviceEvents.size());
- }
-
- protected void assertServiceEvent(int type, ServiceReference reference) throws
Exception
- {
- waitForEvent(serviceEvents, type);
- getLog().debug("serviceEvents=" + serviceEvents);
- int size = serviceEvents.size();
- assertTrue("" + size, size > 0);
- ServiceEvent event = serviceEvents.remove(0);
- assertEquals(ConstantsHelper.serviceEvent(type),
ConstantsHelper.serviceEvent(event.getType()));
- assertEquals(reference, event.getSource());
- assertEquals(reference, event.getServiceReference());
- }
-
- @SuppressWarnings("rawtypes")
- private void waitForEvent(List events, int type) throws InterruptedException
- {
- // Timeout for event delivery: 3 sec
- int timeout = 30;
-
- boolean eventFound = false;
- while (eventFound == false && 0 < timeout)
- {
- synchronized (events)
- {
- events.wait(100);
- for (Object aux : events)
- {
- if (aux instanceof BundleEvent)
- {
- BundleEvent event = (BundleEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof ServiceEvent)
- {
- ServiceEvent event = (ServiceEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof FrameworkEvent)
- {
- FrameworkEvent event = (FrameworkEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- }
- }
- timeout--;
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -1,381 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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 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 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;
-
-// $Id: $
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Enumeration;
-
-import junit.framework.AssertionFailedError;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * A OSGiTestDelegate
- *
- * @author <a href="baileyje(a)gmail.com">John Bailey</a>
- * @author Thomas.Diesler(a)jboss.com
- */
-public class FrameworkTestDelegate extends MicrocontainerTestDelegate
-{
- private OSGiBundleManager bundleManager;
-
- /**
- * Create a new OSGiTestDelegate.
- * @param clazz test class
- * @throws Exception for any error
- */
- FrameworkTestDelegate(Class<?> clazz) throws Exception
- {
- super(clazz);
- }
-
- /**
- * Deploys the jboss-osgi-bootstrap.xml bean descriptor to setup OSGi deployers
- */
- protected void deploy() throws Exception
- {
- String common = "/bootstrap/jboss-osgi-bootstrap.xml";
- URL url = getClass().getResource(common);
- if (url == null)
- throw new IllegalStateException(common + " not found");
- deploy(url);
- try
- {
- super.deploy();
- deployBundles();
- }
- catch (Throwable t)
- {
- undeploy();
- if (t instanceof Exception)
- throw (Exception)t;
- if (t instanceof Error)
- throw (Error)t;
- throw new RuntimeException("Error during deploy", t);
- }
- }
-
- protected void undeploy()
- {
- undeployBundles();
- super.undeploy();
- }
-
- @SuppressWarnings("unchecked")
- protected void deployBundles() throws Exception
- {
- try
- {
- Method method = clazz.getMethod("deployBundles",
FrameworkTestDelegate.class);
- log.debug("Deploying Bundles...");
- method.invoke(null, this);
- }
- catch (NoSuchMethodException e)
- {
- log.debug("No deployBundles() in " + clazz.getName());
- }
- }
-
- protected void undeployBundles()
- {
- OSGiBundleManager bundleManager = getBundleManager();
- Collection<AbstractBundleState> bundles = bundleManager.getBundles();
- for (AbstractBundleState aux : bundles)
- {
- try
- {
- if (aux.getBundleId() != 0)
- {
- AbstractDeployedBundleState bundleState =
(AbstractDeployedBundleState)aux;
- bundleManager.uninstallBundle(bundleState);
- }
- }
- catch (Throwable t)
- {
- getLog().warn("Error undeploying bundle: " + aux, t);
- }
- }
- }
-
- public OSGiBundleManager getBundleManager()
- {
- if (bundleManager == null)
- {
- bundleManager = getBean("OSGiBundleManager",
ControllerState.INSTALLED, OSGiBundleManager.class);
- try
- {
- if (bundleManager.isFrameworkActive() == false)
- bundleManager.startFramework();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start bundle manager",
ex);
- }
- }
- return bundleManager;
- }
-
- public DeployerClient getDeployerClient()
- {
- return getBundleManager().getDeployerClient();
- }
-
- /**
- * Create a bundle
- *
- * @param root the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- public Bundle addBundle(String root, String child) throws Exception
- {
- URL resourceRoot = getClass().getResource(root);
- if (resourceRoot == null)
- throw new AssertionFailedError("Resource not found: " + root);
- URL childResource = new URL(resourceRoot, child);
- AbstractBundleState bundleState = getBundleManager().installBundle(childResource);
- return bundleState.getBundleInternal();
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- public Bundle addBundle(VirtualFile file) throws Exception
- {
- AbstractBundleState bundleState =
getBundleManager().installBundle(AbstractVFS.adapt(file));
- return bundleState.getBundleInternal();
- }
-
- /**
- * Remove a bundle
- *
- * @param bundle the bundle to remove
- * @throws Exception for any error
- */
- public void uninstall(Bundle bundle) throws Exception
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- {
- AbstractDeployedBundleState bundleState =
OSGiBundleState.assertBundleState(bundle);
- getBundleManager().uninstallBundle(bundleState);
- }
- }
-
- public DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- DeploymentUnit deploymentUnit =
getBundleManager().getDeployment(bundle.getBundleId());
- if (deploymentUnit == null)
- throw new AssertionFailedError("Bundle not installed: " + bundle);
- return deploymentUnit;
- }
-
- public VirtualFile assembleBundle(String name, String resources, Class<?>...
packages) throws Exception
- {
- return assembleBundle(name, new String[] { resources }, packages);
- }
-
- public VirtualFile assembleBundle(String name, String[] resourcePaths,
Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", resourcePaths, packages);
- return assembledDirectory;
- }
-
- public Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath,
Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", new String[] { resourcePath }, packages);
- return deployBundle(assembledDirectory, metaData);
- }
-
- public Bundle deployBundle(String name, OSGiMetaData metaData, String[] resourcePaths,
Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", resourcePaths, packages);
- return deployBundle(assembledDirectory, metaData);
- }
-
- public Bundle deployBundle(VirtualFile virtualFile, OSGiMetaData metaData) throws
Exception
- {
- Deployment deployment = createDeployment(virtualFile, metaData);
- return deployBundle(deployment);
- }
-
- public Bundle deployBundle(String root, String child) throws Exception
- {
- URL resourceRoot = getClass().getResource(root);
- if (resourceRoot == null)
- throw new AssertionFailedError("Resource not found: " + root);
- URL childResource = new URL(resourceRoot, child);
- return deployBundle(childResource);
- }
-
- public Bundle deployBundle(URL url) throws Exception
- {
- // Get the root file
- VirtualFile root;
- try
- {
- root = VFS.getRoot(url);
- }
- catch (IOException e)
- {
- throw new BundleException("Invalid url=" + url, e);
- }
-
- return deployBundle(root);
- }
-
- public Bundle deployBundle(VirtualFile file) throws Exception
- {
- return deployBundle(file, null);
- }
-
- public Bundle deployBundle(Deployment deployment) throws Exception
- {
- DeployerClient deployerClient = getDeployerClient();
- MainDeployerStructure deployerStructure = (MainDeployerStructure) deployerClient;
- deployerClient.deploy(deployment);
- try
- {
- DeploymentUnit unit =
deployerStructure.getDeploymentUnit(deployment.getName());
- AbstractBundleState bundleState =
unit.getAttachment(AbstractBundleState.class);
- if (bundleState == null)
- throw new IllegalStateException("Unable to determine bundle state for
" + deployment.getName());
-
- return bundleState.getBundleInternal();
- }
- catch (Exception e)
- {
- deployerClient.undeploy(deployment);
- throw e;
- }
- }
-
- public Deployment createDeployment(VirtualFile virtualFile) throws Exception
- {
- return createDeployment(virtualFile, null);
- }
-
- public Deployment createDeployment(VirtualFile virtualFile, OSGiMetaData metaData)
throws Exception
- {
- return createDeployment(virtualFile, metaData, OSGiMetaData.class);
- }
-
- @SuppressWarnings({"unchecked"})
- public <T> Deployment createDeployment(VirtualFile virtualFile, T metaData,
Class<T> expectedType) throws Exception
- {
- VFSDeployment deployment =
VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
- if (metaData != null)
- {
- if (expectedType == null)
- expectedType = (Class<T>)metaData.getClass();
-
- MutableAttachments att =
(MutableAttachments)deployment.getPredeterminedManagedObjects();
- att.addAttachment(expectedType, metaData);
- }
- return deployment;
- }
-
- public AssembledDirectory createAssembledDirectory(String name, String rootName,
String[] resourcePaths, Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name, rootName);
- if (resourcePaths != null)
- {
- for (String path : resourcePaths)
- addPath(assembledDirectory, path, "");
- }
- if (packages != null)
- {
- for (Class<?> reference : packages)
- addPackage(assembledDirectory, reference);
- }
- return assembledDirectory;
- }
-
- public AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return createAssembledDirectory(name, "");
- }
-
- public AssembledDirectory createAssembledDirectory(String name, String rootName)
throws Exception
- {
- return AssembledDirectory.createAssembledDirectory(name, rootName);
- }
-
- public void addPackage(AssembledDirectory dir, Class<?> reference) throws
Exception
- {
- String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
- dir.addResources(reference, new String[] { packagePath + "/*.class" },
new String[0]);
- }
-
- public void addPath(final AssembledDirectory dir, String path, String name) throws
Exception
- {
- URL url = getClass().getResource(path);
- if (url == null)
- throw new AssertionFailedError(path + " not found");
-
- VirtualFile file = VFS.getVirtualFile(url, name);
- // TODO - remove this filter after new VFS relase
- SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
- dir.addPath(file, noJars);
- }
-
- public URL getBundleResource(Bundle bundle, String path)
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
- }
-
- public Enumeration<URL> getBundleResources(Bundle bundle, String path) throws
Exception
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/NativeFrameworkTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/NativeFrameworkTest.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/NativeFrameworkTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -1,402 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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;
-
-// $Id: $
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.osgi.testing.OSGiTest;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.SynchronousBundleListener;
-import org.osgi.framework.launch.Framework;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * Parent for native framework tests.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 10-Mar-2010
- */
-public abstract class NativeFrameworkTest extends OSGiTest implements ServiceListener,
SynchronousBundleListener, FrameworkListener
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(NativeFrameworkTest.class);
-
- protected static Framework framework;
- protected static BundleContext context;
-
- private final List<FrameworkEvent> frameworkEvents = new
CopyOnWriteArrayList<FrameworkEvent>();
- private final List<BundleEvent> bundleEvents = new
CopyOnWriteArrayList<BundleEvent>();
- private final List<ServiceEvent> serviceEvents = new
CopyOnWriteArrayList<ServiceEvent>();
-
- @BeforeClass
- public static void beforeClass() throws Exception
- {
- OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
- framework = bootProvider.getFramework();
- framework.start();
-
- // Get the system context
- context = framework.getBundleContext();
- }
-
- @AfterClass
- public static void afterClass() throws Exception
- {
- if (framework != null)
- {
- framework.stop();
- framework.waitForStop(2000);
- framework = null;
- }
- }
-
- protected PackageAdmin getPackageAdmin()
- {
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- return (PackageAdmin)context.getService(sref);
- }
-
- protected void assertLoadClass(Bundle bundle, String className, Bundle exporter)
- {
- Class<?> clazz = assertLoadClass(bundle, className);
- Bundle actual = getPackageAdmin().getBundle(clazz);
- assertEquals(exporter, actual);
- }
-
- @Override
- public void frameworkEvent(FrameworkEvent event)
- {
- synchronized (frameworkEvents)
- {
- log.debug("FrameworkEvent type=" +
ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
- frameworkEvents.add(event);
- frameworkEvents.notifyAll();
- }
- }
-
- protected void assertNoFrameworkEvent() throws Exception
- {
- log.debug("frameworkEvents=" + frameworkEvents);
- assertEquals(0, frameworkEvents.size());
- }
-
- protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends
Throwable> expectedThrowable) throws Exception
- {
- waitForEvent(frameworkEvents, type);
- log.debug("frameworkEvents=" + frameworkEvents);
- int size = frameworkEvents.size();
- assertTrue("" + size, size > 0);
- FrameworkEvent event = frameworkEvents.remove(0);
- assertEquals(ConstantsHelper.frameworkEvent(type),
ConstantsHelper.frameworkEvent(event.getType()));
- Throwable t = event.getThrowable();
- if (expectedThrowable == null)
- {
- if (t != null)
- {
- log.error("Unexpected error in Framework event: ", t);
- fail("Unexpected throwable: " + t);
- }
- }
- else
- {
- String message = expectedThrowable.getSimpleName() + " is assignable from
" + t.getClass().getSimpleName();
- assertTrue(message, expectedThrowable.isAssignableFrom(t.getClass()));
- }
- assertEquals(bundle, event.getSource());
- assertEquals(bundle, event.getBundle());
- }
-
- @Override
- public void bundleChanged(BundleEvent event)
- {
- synchronized (bundleEvents)
- {
- log.debug("BundleChanged type=" +
ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
- bundleEvents.add(event);
- bundleEvents.notifyAll();
- }
- }
-
- protected void assertNoBundleEvent() throws Exception
- {
- log.debug("bundleEvents=" + bundleEvents);
- assertEquals(0, bundleEvents.size());
- }
-
- protected void assertBundleEvent(int type, Bundle bundle) throws Exception
- {
- waitForEvent(bundleEvents, type);
-
- log.debug("bundleEvents=" + bundleEvents);
- int size = bundleEvents.size();
- assertTrue("" + size, size > 0);
-
- if (bundle instanceof AbstractBundleState)
- bundle = ((AbstractBundleState)bundle).getBundle();
-
- BundleEvent foundEvent = null;
- for (int i = 0; i < bundleEvents.size(); i++)
- {
- BundleEvent aux = bundleEvents.get(i);
- if (type == aux.getType())
- {
- if (bundle.equals(aux.getSource()) &&
bundle.equals(aux.getBundle()))
- {
- bundleEvents.remove(aux);
- foundEvent = aux;
- break;
- }
- }
- }
-
- if (foundEvent == null)
- fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + "
from " + bundle);
- }
-
- @Override
- public void serviceChanged(ServiceEvent event)
- {
- synchronized (serviceEvents)
- {
- log.debug("ServiceChanged type=" +
ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
- serviceEvents.add(event);
- serviceEvents.notifyAll();
- }
- }
-
- protected void assertNoServiceEvent() throws Exception
- {
- log.debug("serviceEvents=" + serviceEvents);
- assertEquals(0, serviceEvents.size());
- }
-
- protected void assertServiceEvent(int type, ServiceReference reference) throws
Exception
- {
- waitForEvent(serviceEvents, type);
- log.debug("serviceEvents=" + serviceEvents);
- int size = serviceEvents.size();
- assertTrue("" + size, size > 0);
- ServiceEvent event = serviceEvents.remove(0);
- assertEquals(ConstantsHelper.serviceEvent(type),
ConstantsHelper.serviceEvent(event.getType()));
- assertEquals(reference, event.getSource());
- assertEquals(reference, event.getServiceReference());
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws
Exception
- {
- assertNoAllReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
- else
- log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
- {
- assertAllReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
- else
- log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
- assertArrayEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz) throws
Exception
- {
- assertNoReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
- else
- log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
- {
- assertReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz + " filter=" + filter);
- else
- log.debug(bundleContext + " got nothing for clazz=" + clazz + "
filter=" + filter);
- assertArrayEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
- }
-
- protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws
Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- log.debug(bundleContext + " got " + actual + " for clazz=" +
clazz);
- else
- log.debug(bundleContext + " got nothing for clazz=" + clazz);
- assertNull("Expected no references for clazz=" + clazz, actual);
- }
-
- protected void assertGetReference(BundleContext bundleContext, String clazz,
ServiceReference expected) throws Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- log.debug(bundleContext + " got " + Arrays.asList(actual) + " for
clazz=" + clazz);
- else
- log.debug(bundleContext + " got nothing for clazz=" + clazz);
- assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
- }
-
- protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
- {
- Set<Bundle> actual = new HashSet<Bundle>();
- Bundle[] users = reference.getUsingBundles();
- if (users != null)
- actual.addAll(Arrays.asList(users));
-
- Set<Bundle> expected = new HashSet<Bundle>();
- expected.addAll(Arrays.asList(bundles));
-
- log.debug(reference + " users=" + actual);
-
- // switch - check expected on actual, since actual might be proxy
- assertEquals(actual, expected);
- }
-
- protected <T> T assertInstanceOf(Object o, Class<T> expectedType)
- {
- return assertInstanceOf(o, expectedType, false);
- }
-
- protected <T> T assertInstanceOf(Object o, Class<T> expectedType, boolean
allowNull)
- {
- if (expectedType == null)
- fail("Null expectedType");
-
- if (o == null)
- {
- if (allowNull == false)
- fail("Null object not allowed.");
- else
- return null;
- }
-
- try
- {
- return expectedType.cast(o);
- }
- catch (ClassCastException e)
- {
- fail("Object " + o + " of class " + o.getClass().getName() +
" is not an instanceof " + expectedType.getName());
- // should not reach this
- return null;
- }
- }
-
- @SuppressWarnings("rawtypes")
- private void waitForEvent(List events, int type) throws InterruptedException
- {
- // Timeout for event delivery: 3 sec
- int timeout = 30;
-
- boolean eventFound = false;
- while (eventFound == false && 0 < timeout)
- {
- synchronized (events)
- {
- events.wait(100);
- for (Object aux : events)
- {
- if (aux instanceof BundleEvent)
- {
- BundleEvent event = (BundleEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof ServiceEvent)
- {
- ServiceEvent event = (ServiceEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof FrameworkEvent)
- {
- FrameworkEvent event = (FrameworkEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- }
- }
- timeout--;
- }
- }
-}
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -39,7 +39,7 @@
import java.util.Set;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -57,12 +57,12 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class BundleContextUnitTestCase extends NativeFrameworkTest
+public class BundleContextUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testGetBundle() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly1 = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
BundleContext context1 = null;
try
@@ -77,7 +77,7 @@
Set<Bundle> expected = new HashSet<Bundle>(Arrays.asList(framework,
bundle1));
assertEquals(expected, actual);
- VirtualFile assembly2 = assembleBundle("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
+ VirtualFile assembly2 = assembleArchive("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
BundleContext context2 = null;
try
@@ -176,7 +176,7 @@
@Test
public void testProperties() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -258,7 +258,7 @@
@Test
public void testServiceListener() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -351,7 +351,7 @@
@Test
public void testBundleListener() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -409,7 +409,7 @@
@Test
public void testFrameworkListener() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -448,7 +448,7 @@
@Test
public void testGetDataFile() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -469,7 +469,7 @@
@Test
public void testStopedBundleContext() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -33,7 +33,7 @@
import java.util.Set;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -46,12 +46,12 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class BundleEntriesUnitTestCase extends NativeFrameworkTest
+public class BundleEntriesUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testEntriesNotInstalled() throws Exception
{
- VirtualFile assembly = assembleBundle("entries-simple",
"/bundles/entries/entries-simple", new Class[0]);
+ VirtualFile assembly = assembleArchive("entries-simple",
"/bundles/entries/entries-simple", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
bundle.uninstall();
try
@@ -77,7 +77,7 @@
@Test
public void testFindEntriesNoPath() throws Exception
{
- VirtualFile assembly = assembleBundle("entries-simple",
"/bundles/entries/entries-simple", new Class[0]);
+ VirtualFile assembly = assembleArchive("entries-simple",
"/bundles/entries/entries-simple", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -97,7 +97,7 @@
@Test
public void testEntries() throws Exception
{
- VirtualFile assembly = assembleBundle("entries-simple",
"/bundles/entries/entries-simple", new Class[0]);
+ VirtualFile assembly = assembleArchive("entries-simple",
"/bundles/entries/entries-simple", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -27,7 +27,7 @@
import static org.junit.Assert.fail;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.bundle.support.a.FailOnStartActivator;
import org.jboss.test.osgi.bundle.support.b.LifecycleService;
import org.junit.Test;
@@ -42,7 +42,7 @@
* @author thomas.Diesler(a)jboss.com
* @since 15-Dec-2009
*/
-public class BundleLifecycleTestCase extends NativeFrameworkTest
+public class BundleLifecycleTestCase extends AbstractFrameworkTest
{
/**
@@ -51,7 +51,7 @@
@Test
public void testSimpleStart() throws Exception
{
- VirtualFile assemblyA = assembleBundle("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
+ VirtualFile assemblyA = assembleArchive("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -76,7 +76,7 @@
@Test
public void testDependencyNotAvailable() throws Exception
{
- VirtualFile assemblyA = assembleBundle("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
+ VirtualFile assemblyA = assembleArchive("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -86,7 +86,7 @@
ServiceReference sref =
context.getServiceReference(LifecycleService.class.getName());
assertNull("Service not available", sref);
- VirtualFile assemblyB = assembleBundle("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+ VirtualFile assemblyB = assembleArchive("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -118,14 +118,14 @@
@Test
public void testDependencyAvailable() throws Exception
{
- VirtualFile assemblyA = assembleBundle("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
+ VirtualFile assemblyA = assembleArchive("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertBundleState(Bundle.ACTIVE, bundleA.getState());
- VirtualFile assemblyB = assembleBundle("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+ VirtualFile assemblyB = assembleArchive("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -151,13 +151,13 @@
@Test
public void testStartRetry() throws Exception
{
- VirtualFile assemblyA = assembleBundle("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
+ VirtualFile assemblyA = assembleArchive("lifecycle-service",
"/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
assertBundleState(Bundle.INSTALLED, bundleA.getState());
- VirtualFile assemblyB = assembleBundle("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+ VirtualFile assemblyB = assembleArchive("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -200,7 +200,7 @@
@Test
public void testFailToResolve() throws Exception
{
- VirtualFile assemblyA = assembleBundle("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
+ VirtualFile assemblyA = assembleArchive("lifecycle-failstart",
"/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
Bundle bundleB = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -232,7 +232,7 @@
{
try
{
- VirtualFile assembly = assembleBundle("missing-symbolic-name",
"/bundles/lifecycle/invalid01");
+ VirtualFile assembly = assembleArchive("missing-symbolic-name",
"/bundles/lifecycle/invalid01");
context.installBundle(assembly.toURL().toExternalForm());
fail("BundleException expected");
}
@@ -243,7 +243,7 @@
try
{
- VirtualFile assembly = assembleBundle("invalid-export",
"/bundles/lifecycle/invalid02");
+ VirtualFile assembly = assembleArchive("invalid-export",
"/bundles/lifecycle/invalid02");
context.installBundle(assembly.toURL().toExternalForm());
fail("BundleException expected");
}
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -37,7 +37,7 @@
import org.jboss.osgi.vfs.VFSUtils;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -52,13 +52,13 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class BundleUnitTestCase extends NativeFrameworkTest
+public class BundleUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testBundleId() throws Exception
{
long id1 = -1;
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -87,7 +87,7 @@
@Test
public void testSymbolicName() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -103,7 +103,7 @@
@Test
public void testState() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -125,7 +125,7 @@
@Test
public void testGetBundleContext() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -161,8 +161,8 @@
@Test
public void testUpdate() throws Exception
{
- VirtualFile assemble1 = assembleBundle("bundle1",
"/bundles/update/update-bundle1");
- VirtualFile assemble2 = assembleBundle("bundle2",
"/bundles/update/update-bundle2");
+ VirtualFile assemble1 = assembleArchive("bundle1",
"/bundles/update/update-bundle1");
+ VirtualFile assemble2 = assembleArchive("bundle2",
"/bundles/update/update-bundle2");
Manifest manifest = VFSUtils.getManifest(assemble2);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -200,11 +200,11 @@
@Test
public void testSingleton() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundle10",
"/bundles/singleton/singleton1");
+ VirtualFile assemblyA = assembleArchive("bundle10",
"/bundles/singleton/singleton1");
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
- VirtualFile assemblyB = assembleBundle("bundle20",
"/bundles/singleton/singleton2");
+ VirtualFile assemblyB = assembleArchive("bundle20",
"/bundles/singleton/singleton2");
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
bundleB.uninstall();
fail("Should not be here!");
@@ -222,11 +222,11 @@
@Test
public void testNotSingleton() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundle1",
"/bundles/singleton/singleton1");
+ VirtualFile assemblyA = assembleArchive("bundle1",
"/bundles/singleton/singleton1");
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
- VirtualFile assemblyB = assembleBundle("not-singleton",
"/bundles/singleton/not-singleton");
+ VirtualFile assemblyB = assembleArchive("not-singleton",
"/bundles/singleton/not-singleton");
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -247,7 +247,7 @@
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testGetHeaders() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -28,7 +28,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -42,7 +42,7 @@
* @author thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class SystemBundleUnitTestCase extends NativeFrameworkTest
+public class SystemBundleUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testBundleId() throws Exception
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -26,7 +26,7 @@
import static org.junit.Assert.fail;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
import org.junit.Test;
@@ -41,18 +41,18 @@
* @author thomas.diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class RequireBundleUnitTestCase extends NativeFrameworkTest
+public class RequireBundleUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testSimpleRequireBundle() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("simplerequirebundleA",
"/bundles/classloader/simplerequirebundleA", B.class);
+ VirtualFile assemblyB = assembleArchive("simplerequirebundleA",
"/bundles/classloader/simplerequirebundleA", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -74,13 +74,13 @@
@Test
public void testSimpleRequireBundleFails() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("simplerequirebundlefails",
"/bundles/classloader/simplerequirebundlefails", B.class);
+ VirtualFile assemblyB = assembleArchive("simplerequirebundlefails",
"/bundles/classloader/simplerequirebundlefails", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -105,13 +105,13 @@
@Test
public void testVersionRequireBundle() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("versionrequirebundleA",
"/bundles/classloader/versionrequirebundleA", B.class);
+ VirtualFile assemblyB = assembleArchive("versionrequirebundleA",
"/bundles/classloader/versionrequirebundleA", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -133,13 +133,13 @@
@Test
public void testVersionRequireBundleFails() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("versionrequirebundlefails",
"/bundles/classloader/versionrequirebundlefails", B.class);
+ VirtualFile assemblyB = assembleArchive("versionrequirebundlefails",
"/bundles/classloader/versionrequirebundlefails", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -164,13 +164,13 @@
@Test
public void testOptionalRequireBundle() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("optionalrequirebundleA",
"/bundles/classloader/optionalrequirebundleA", B.class);
+ VirtualFile assemblyB = assembleArchive("optionalrequirebundleA",
"/bundles/classloader/optionalrequirebundleA", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -192,13 +192,13 @@
@Test
public void testOptionalRequireBundleFails() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("optionalrequirebundlefails",
"/bundles/classloader/optionalrequirebundlefails", B.class);
+ VirtualFile assemblyB = assembleArchive("optionalrequirebundlefails",
"/bundles/classloader/optionalrequirebundlefails", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -224,7 +224,7 @@
//Bundle-Version: 1.0.0
//Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
@@ -236,7 +236,7 @@
//Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
//Require-Bundle: org.jboss.test.osgi.classloader.bundleA;visibility:=reexport
//Export-Package: org.jboss.test.osgi.classloader.support.b
- VirtualFile assemblyB = assembleBundle("reexportrequirebundleA",
"/bundles/classloader/reexportrequirebundleA", B.class);
+ VirtualFile assemblyB = assembleArchive("reexportrequirebundleA",
"/bundles/classloader/reexportrequirebundleA", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
@@ -248,7 +248,7 @@
//Bundle-Name: BundleC
//Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleC
//Require-Bundle: org.jboss.test.osgi.classloader.bundleB
- VirtualFile assemblyC = assembleBundle("reexportrequirebundleB",
"/bundles/classloader/reexportrequirebundleB");
+ VirtualFile assemblyC = assembleArchive("reexportrequirebundleB",
"/bundles/classloader/reexportrequirebundleB");
Bundle bundleC = context.installBundle(assemblyC.toURL().toExternalForm());
try
@@ -275,20 +275,20 @@
@Test
public void testNoReExportRequireBundle() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("noreexportrequirebundleA",
"/bundles/classloader/noreexportrequirebundleA", B.class);
+ VirtualFile assemblyB = assembleArchive("noreexportrequirebundleA",
"/bundles/classloader/noreexportrequirebundleA", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
bundleB.start();
assertLoadClass(bundleB, A.class.getName(), bundleA);
assertLoadClass(bundleB, B.class.getName(), bundleB);
- VirtualFile assemblyC = assembleBundle("reexportrequirebundleB",
"/bundles/classloader/reexportrequirebundleB");
+ VirtualFile assemblyC = assembleArchive("reexportrequirebundleB",
"/bundles/classloader/reexportrequirebundleB");
Bundle bundleC = context.installBundle(assemblyC.toURL().toExternalForm());
try
{
@@ -314,13 +314,13 @@
@Test
public void testAttributeRequireBundle() throws Exception
{
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
- VirtualFile assemblyB = assembleBundle("attributerequirebundleA",
"/bundles/classloader/attributerequirebundleA", B.class);
+ VirtualFile assemblyB = assembleArchive("attributerequirebundleA",
"/bundles/classloader/attributerequirebundleA", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -345,7 +345,7 @@
// Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
// Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
// Bundle-Version: 1.0.0
- VirtualFile assemblyA = assembleBundle("bundleA",
"/bundles/classloader/bundleA", A.class);
+ VirtualFile assemblyA = assembleArchive("bundleA",
"/bundles/classloader/bundleA", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -354,7 +354,7 @@
// Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
// Require-Bundle:
org.jboss.test.osgi.classloader.bundleA;doesnotexist=true;test=y
- VirtualFile assemblyB = assembleBundle("attributerequirebundlefails",
"/bundles/classloader/attributerequirebundlefails", B.class);
+ VirtualFile assemblyB = assembleArchive("attributerequirebundlefails",
"/bundles/classloader/attributerequirebundlefails", B.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -27,7 +27,7 @@
import static org.junit.Assert.assertSame;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.compendium.support.a.PA;
import org.jboss.test.osgi.compendium.support.b.Other;
import org.junit.Test;
@@ -40,12 +40,12 @@
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
* @author thomas.diesler(a)jboss.com
*/
-public class PackageAdminTestCase extends NativeFrameworkTest
+public class PackageAdminTestCase extends AbstractFrameworkTest
{
@Test
public void testGetBudleFromClass() throws Exception
{
- VirtualFile assemblyA = assembleBundle("smoke-assembled",
"/bundles/smoke/smoke-assembled", PA.class);
+ VirtualFile assemblyA = assembleArchive("smoke-assembled",
"/bundles/smoke/smoke-assembled", PA.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -60,7 +60,7 @@
Bundle notFound = pa.getBundle(getClass());
assertNull(notFound);
- VirtualFile assemblyB = assembleBundle("simple",
"/bundles/simple/simple-bundle1", Other.class);
+ VirtualFile assemblyB = assembleArchive("simple",
"/bundles/simple/simple-bundle1", Other.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -31,7 +31,7 @@
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.fragments.fragA.FragBeanA;
import org.jboss.test.osgi.fragments.subA.SubBeanA;
import org.junit.After;
@@ -50,7 +50,7 @@
* @author thomas.diesler(a)jboss.com
* @since 07-Jan-2010
*/
-public class FragmentTestCase extends NativeFrameworkTest
+public class FragmentTestCase extends AbstractFrameworkTest
{
private Framework framework;
private BundleContext context;
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -46,13 +46,13 @@
{
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -85,7 +85,7 @@
{
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -111,13 +111,13 @@
{
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -154,7 +154,7 @@
// Bundle-SymbolicName: selfimport
// Export-Package: org.jboss.test.osgi.classloader.support.a
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/selfimport", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/selfimport", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -180,13 +180,13 @@
{
//Bundle-SymbolicName: packageimportversion
//Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[0.0.0,1.0.0]"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversion");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageimportversion");
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: packageexportversion100
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -219,13 +219,13 @@
{
//Bundle-SymbolicName: packageimportversionfails
//Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[3.0,4.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversionfails");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageimportversionfails");
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: packageexportversion100
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -258,7 +258,7 @@
{
//Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageimportoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -284,13 +284,13 @@
{
//Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageimportoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -323,7 +323,7 @@
{
//Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageimportoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -334,7 +334,7 @@
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -367,13 +367,13 @@
{
//Bundle-SymbolicName: bundlenameimport
//Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundlenameimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/bundlenameimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: simpleexport
//Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -406,13 +406,13 @@
{
//Bundle-SymbolicName: bundlenameimport
//Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundlenameimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/bundlenameimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: sigleton;singleton:=true
//Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/singleton", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/singleton", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -445,13 +445,13 @@
{
//Bundle-SymbolicName: bundleversionimport
//Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-version="[0.0.0,1.0.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundleversionimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/bundleversionimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -484,13 +484,13 @@
{
//Bundle-SymbolicName: bundleversionimportfails
//Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-version="[1.0.0,2.0.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundleversionimportfails");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/bundleversionimportfails");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -524,13 +524,13 @@
{
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundle");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -563,7 +563,7 @@
{
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundle");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -589,7 +589,7 @@
{
//Bundle-SymbolicName: requirebundleoptional
//Require-Bundle: simpleexport;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleoptional");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundleoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -612,13 +612,13 @@
{
//Bundle-SymbolicName: requirebundleversion
//Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversion");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundleversion");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -651,13 +651,13 @@
{
//Bundle-SymbolicName: versionrequirebundlefails
//Require-Bundle: simpleexport;bundle-version="[1.0.0,2.0.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversionfails");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundleversionfails");
Bundle bundleA = framework.installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -690,15 +690,15 @@
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleexport", A.class);
// Bundle-SymbolicName: simpleexportother
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexportother", A.class);
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+ VirtualFile fileC = assembleArchive("bundleC",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
@@ -750,15 +750,15 @@
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleexport", A.class);
// Bundle-SymbolicName: simpleexportother
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexportother", A.class);
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+ VirtualFile fileC = assembleArchive("bundleC",
"/bundles/resolver/simpleimport");
Bundle bundleB = framework.installBundle(fileB);
try
@@ -810,15 +810,15 @@
{
//Bundle-SymbolicName: packageexportversion100
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportversion100", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportversion100", A.class);
//Bundle-SymbolicName: packageexportversion200
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=2.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion200", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageexportversion200", A.class);
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+ VirtualFile fileC = assembleArchive("bundleC",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
@@ -865,15 +865,15 @@
{
//Bundle-SymbolicName: packageexportversion200
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=2.0.0
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportversion200", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportversion200", A.class);
//Bundle-SymbolicName: packageexportversion100
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+ VirtualFile fileC = assembleArchive("bundleC",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
@@ -920,15 +920,15 @@
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleexport", A.class);
// Bundle-SymbolicName: simpleexportother
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexportother", A.class);
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+ VirtualFile fileC = assembleArchive("bundleC",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
@@ -980,15 +980,15 @@
{
// Bundle-SymbolicName: simpleexportother
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexportother", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleexportother", A.class);
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleexport", A.class);
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+ VirtualFile fileC = assembleArchive("bundleC",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
@@ -1040,13 +1040,13 @@
{
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleimport");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -1070,7 +1070,7 @@
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattribute");
bundleB = framework.installBundle(fileB);
try
{
@@ -1103,13 +1103,13 @@
{
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: packageimportattributefails
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattributefails");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -1142,13 +1142,13 @@
{
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattribute");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -1181,13 +1181,13 @@
{
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleimport");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -1220,7 +1220,7 @@
{
//Bundle-SymbolicName: systempackageimport
//Import-Package: org.osgi.framework;version=1.4
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/systempackageimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/systempackageimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -60,7 +60,7 @@
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -115,7 +115,7 @@
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/simpleimport");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -148,7 +148,7 @@
// Bundle-SymbolicName: singleton;singleton:=true
// Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/singleton", A.class);
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/singleton", A.class);
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -170,7 +170,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundle");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -197,7 +197,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleoptional");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundleoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -224,7 +224,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversion");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/requirebundleversion");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -251,7 +251,7 @@
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattribute");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -263,7 +263,7 @@
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleimport");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -278,7 +278,7 @@
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattribute");
bundleB = framework.installBundle(fileB);
try
{
@@ -309,7 +309,7 @@
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattribute");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -321,7 +321,7 @@
//Bundle-SymbolicName: packageimportattributefails
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattributefails");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -352,7 +352,7 @@
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattributemandatory");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -366,7 +366,7 @@
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattribute");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -397,7 +397,7 @@
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory");
+ VirtualFile fileA = assembleArchive("bundleA",
"/bundles/resolver/packageexportattributemandatory");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -411,7 +411,7 @@
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ VirtualFile fileB = assembleArchive("bundleB",
"/bundles/resolver/simpleimport");
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -426,7 +426,7 @@
//Bundle-SymbolicName: packageimportattributefails
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
- fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
+ fileB = assembleArchive("bundleB",
"/bundles/resolver/packageimportattributefails");
bundleB = framework.installBundle(fileB);
try
{
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/AbstractServiceMixTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/AbstractServiceMixTest.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/AbstractServiceMixTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.lang.reflect.Method;
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.test.osgi.AbstractDeploymentTest;
+import org.osgi.framework.Bundle;
+
+/**
+ * Test MC's services.
+ *
+ * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractServiceMixTest extends AbstractDeploymentTest
+{
+ protected static Object getter(Object target, String getter, String name) throws
Throwable
+ {
+ assertNotNull("Target " + name + " is not null", target);
+ Class<?> clazz = target.getClass();
+ Method m = clazz.getDeclaredMethod(getter);
+ return m.invoke(target);
+ }
+
+ protected static Object setter(Object target, String setter, Object value, String
name) throws Throwable
+ {
+ assertNotNull("Target " + name + " is not null", target);
+ assertNotNull("Value is not null", value);
+ Class<?> clazz = target.getClass();
+ Method m = clazz.getDeclaredMethod(setter, value.getClass());
+ return m.invoke(target, value);
+ }
+
+ protected Bundle getBundle(Deployment deployment) throws Exception
+ {
+ return getBundle(getDeploymentUnit(deployment));
+ }
+
+ protected Bundle getBundle(DeploymentUnit unit) throws Exception
+ {
+ AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
+ assertNotNull(bundle);
+ return bundle.getBundleInternal();
+ }
+}
\ No newline at end of file
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -29,7 +29,7 @@
import java.util.Hashtable;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.b.B;
import org.junit.Test;
@@ -48,13 +48,13 @@
* @author thomas.diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class GetServiceReferencesUnitTestCase extends NativeFrameworkTest
+public class GetServiceReferencesUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testGetServiceReferences() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1", A.class);
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1", A.class);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -174,7 +174,7 @@
private void assertGetServiceReferencesNotAssignable(String className) throws
Exception
{
- VirtualFile assemblyA = assembleBundle("simple1",
"/bundles/simple/simple-bundle1", A.class);
+ VirtualFile assemblyA = assembleArchive("simple1",
"/bundles/simple/simple-bundle1", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -192,7 +192,7 @@
ServiceReference reference1 = registration1.getReference();
assertNotNull(reference1);
- VirtualFile assemblyB = assembleBundle("simple2",
"/bundles/simple/simple-bundle2", A.class);
+ VirtualFile assemblyB = assembleArchive("simple2",
"/bundles/simple/simple-bundle2", A.class);
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -276,7 +276,7 @@
private void assertGetServiceReferencesAssignable(String className) throws Exception
{
- VirtualFile assemblyA = assembleBundle("service2",
"/bundles/service/service-bundle2", A.class);
+ VirtualFile assemblyA = assembleArchive("service2",
"/bundles/service/service-bundle2", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -294,7 +294,7 @@
ServiceReference reference1 = registration1.getReference();
assertNotNull(reference1);
- VirtualFile assemblyB = assembleBundle("service1",
"/bundles/service/service-bundle1");
+ VirtualFile assemblyB = assembleArchive("service1",
"/bundles/service/service-bundle1");
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -369,7 +369,7 @@
{
String className = A.class.getName();
- VirtualFile assemblyA = assembleBundle("service2",
"/bundles/service/service-bundle2", A.class);
+ VirtualFile assemblyA = assembleArchive("service2",
"/bundles/service/service-bundle2", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -390,7 +390,7 @@
ServiceReference reference1 = registration1.getReference();
assertNotNull(reference1);
- VirtualFile assemblyB = assembleBundle("service1",
"/bundles/service/service-bundle1");
+ VirtualFile assemblyB = assembleArchive("service1",
"/bundles/service/service-bundle1");
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -480,7 +480,7 @@
String className = A.class.getName();
String wrongClassName = B.class.getName();
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1", A.class);
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1", A.class);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -24,7 +24,7 @@
import static org.junit.Assert.*;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.service.support.BrokenServiceFactory;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -41,14 +41,14 @@
* @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class GetUnGetServiceUnitTestCase extends NativeFrameworkTest
+public class GetUnGetServiceUnitTestCase extends AbstractFrameworkTest
{
static String OBJCLASS = BundleContext.class.getName();
@Test
public void testGetUnServiceErrors() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -87,7 +87,7 @@
@Test
public void testGetService() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -114,7 +114,7 @@
@Test
public void testGetServiceAfterStop() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -148,7 +148,7 @@
@Test
public void testErrorInGetService() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -174,7 +174,7 @@
@Test
public void testErrorInUnGetService() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -203,7 +203,7 @@
@Test
public void testUnGetServiceResult() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly1 = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -222,7 +222,7 @@
assertTrue(bundleContext.ungetService(reference));
assertFalse(bundleContext.ungetService(reference));
- VirtualFile assembly2 = assembleBundle("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
+ VirtualFile assembly2 = assembleArchive("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -21,35 +21,44 @@
*/
package org.jboss.test.osgi.service;
-import junit.framework.Test;
-import org.jboss.test.osgi.service.support.MockInvokerMBean;
+// $Id: $
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URL;
+
import javax.management.ObjectName;
+import org.jboss.test.osgi.AbstractDeploymentTest;
+import org.jboss.test.osgi.service.support.MockInvokerMBean;
+import org.junit.Test;
+
/**
* Test MC's jmx support.
*
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
+ * @author Thomas.Diesler(a)jboss.com
*/
-public class JMXServicesUnitTestCase extends ServicesTest
+public class JMXServicesUnitTestCase extends AbstractDeploymentTest
{
- public JMXServicesUnitTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(JMXServicesUnitTestCase.class);
- }
-
+ @Test
public void testAtJmx() throws Throwable
{
- MockInvokerMBean invoker = (MockInvokerMBean) getBean("Invoker");
- assertNotNull(invoker.getServer());
- ObjectName name = invoker.getServiceName();
- assertNotNull(name);
- assertEquals("jboss:service=invoker,type=unified",
name.getCanonicalName());
+ URL beans = getResourceURL("service/jmx-services.xml");
+ deploy(beans);
+ try
+ {
+ MockInvokerMBean invoker = (MockInvokerMBean)getBean("Invoker");
+ assertNotNull(invoker.getServer());
+ ObjectName name = invoker.getServiceName();
+ assertNotNull(name);
+ assertEquals("jboss:service=invoker,type=unified",
name.getCanonicalName());
+ }
+ finally
+ {
+ undeploy(beans);
+ }
}
public void testMBeans() throws Throwable
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -27,7 +27,7 @@
import java.util.Hashtable;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -43,7 +43,7 @@
* @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class RegisterServiceUnitTestCase extends NativeFrameworkTest
+public class RegisterServiceUnitTestCase extends AbstractFrameworkTest
{
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
@@ -54,7 +54,7 @@
String OBJCLASS = BundleContext.class.getName();
String[] OBJCLASSES = new String[] { OBJCLASS };
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -189,7 +189,7 @@
Dictionary<String, Object> properties = new Hashtable<String,
Object>();
properties.put(Constants.OBJECTCLASS, new String[] { "rubbish" });
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -220,7 +220,7 @@
@Test
public void testRegisterService() throws Exception
{
- VirtualFile assembly = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -247,7 +247,7 @@
@Test
public void testBundleUninstall() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly1 = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -260,7 +260,7 @@
Object actual = bundleContext.getService(reference);
assertEquals(bundleContext, actual);
- VirtualFile assembly2 = assembleBundle("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
+ VirtualFile assembly2 = assembleArchive("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
@@ -288,7 +288,7 @@
@Test
public void testRegisteredServices() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
+ VirtualFile assembly1 = assembleArchive("simple-bundle1",
"/bundles/simple/simple-bundle1", new Class[0]);
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -301,7 +301,7 @@
Object actual = bundleContext.getService(reference);
assertEquals(bundleContext, actual);
- VirtualFile assembly2 = assembleBundle("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
+ VirtualFile assembly2 = assembleArchive("simple-bundle2",
"/bundles/simple/simple-bundle2", new Class[0]);
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -26,7 +26,7 @@
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.jboss.test.osgi.service.support.a.A;
import org.junit.Test;
@@ -43,7 +43,7 @@
* @author Thomas.Diesler(a)jboss.com
* @version $Revision$
*/
-public class ServiceFactoryUnitTestCase extends NativeFrameworkTest
+public class ServiceFactoryUnitTestCase extends AbstractFrameworkTest
{
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
@@ -52,7 +52,7 @@
@Test
public void testRegisterServiceFactory() throws Exception
{
- VirtualFile assemblyA = assembleBundle("simple1",
"/bundles/simple/simple-bundle1", A.class);
+ VirtualFile assemblyA = assembleArchive("simple1",
"/bundles/simple/simple-bundle1", A.class);
Bundle bundleA = context.installBundle(assemblyA.toURL().toExternalForm());
try
{
@@ -77,7 +77,7 @@
assertEquals(bundleA.getSymbolicName(),
serviceFactory.getBundle.getSymbolicName());
assertEquals(1, serviceFactory.getCount);
- VirtualFile assemblyB = assembleBundle("simple2",
"/bundles/simple/simple-bundle2");
+ VirtualFile assemblyB = assembleArchive("simple2",
"/bundles/simple/simple-bundle2");
Bundle bundleB = context.installBundle(assemblyB.toURL().toExternalForm());
try
{
@@ -108,7 +108,7 @@
{
String OBJCLASS = BundleContext.class.getName();
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -139,7 +139,7 @@
{
String OBJCLASS = BundleContext.class.getName();
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -174,7 +174,7 @@
{
String[] OBJCLASSES = {String.class.getName(), BundleContext.class.getName()};
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -21,22 +21,29 @@
*/
package org.jboss.test.osgi.service;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.List;
-import junit.framework.Test;
-
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.test.osgi.service.support.LazyBundle;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.c.C;
import org.jboss.test.osgi.service.support.d.D;
-import org.jboss.virtual.AssembledDirectory;
+import org.jboss.test.osgi.service.support.e.E;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -47,24 +54,16 @@
*
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
-public class ServiceMixUnitTestCase extends ServicesTest
+public class ServiceMixUnitTestCase extends AbstractServiceMixTest
{
- public ServiceMixUnitTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(ServiceMixUnitTestCase.class);
- }
-
+ @Test
public void testGetServiceReferenceFromMC() throws Throwable
{
- Deployment bean = deployBean("beanA", A.class);
+ Deployment bean = deployBeans("beanA", A.class);
try
{
- Bundle bundle1 = installBundle(assembleBundle("simple1",
"/bundles/service/service-bundle1"));
+ VirtualFile assembly1 = assembleArchive("simple1",
"/bundles/service/service-bundle1");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
bundle1.start();
@@ -76,13 +75,13 @@
try
{
Bundle refsBundle = ref1.getBundle();
- assertBundle(refsBundle, getBundle(bean));
+ assertEquals(refsBundle, getBundle(bean));
assertNotNull(bundleContext1.getService(ref1));
assertUsingBundles(ref1, bundle1);
ServiceReference[] inUse = bundle1.getServicesInUse();
- assertEquals(new ServiceReference[]{ref1}, inUse);
+ assertArrayEquals(new ServiceReference[] { ref1 }, inUse);
}
finally
{
@@ -96,7 +95,7 @@
}
finally
{
- uninstall(bundle1);
+ bundle1.uninstall();
}
}
finally
@@ -105,17 +104,19 @@
}
}
+ @Test
public void testInjectionToMC() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C",
C.class.getName());
builder.addPropertyMetaData("a", builder.createContextualInject());
BeanMetaData bmd = builder.getBeanMetaData();
- Deployment bean = addBean("beanA", C.class, bmd, A.class);
+ Deployment bean = addBeans("beanA", bmd, A.class, C.class);
try
{
KernelControllerContext kcc = getControllerContext("C", null);
- Bundle bundle1 = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle3"));
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle3");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
bundle1.start();
@@ -153,7 +154,7 @@
}
finally
{
- uninstall(bundle1);
+ bundle1.uninstall();
}
}
finally
@@ -162,17 +163,19 @@
}
}
+ @Test
public void testInjectionToMCNamedService() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C",
C.class.getName());
builder.addPropertyMetaData("a", builder.createInject("A"));
BeanMetaData bmd = builder.getBeanMetaData();
- Deployment bean = addBean("beanA", C.class, bmd, A.class);
+ Deployment bean = addBeans("beanA", bmd, C.class, A.class);
try
{
KernelControllerContext kcc = getControllerContext("C", null);
- Bundle bundle1 = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle3"));
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle3");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
bundle1.start();
@@ -212,7 +215,7 @@
}
finally
{
- uninstall(bundle1);
+ bundle1.uninstall();
}
}
finally
@@ -221,16 +224,18 @@
}
}
+ @Test
public void testInvokeDispatch() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C",
C.class.getName());
builder.addPropertyMetaData("msg", builder.createInject("A",
"msg"));
builder.addInstall("calc", "A", int.class.getName(), 123);
BeanMetaData bmd = builder.getBeanMetaData();
- Deployment bean = addBean("beanA", C.class, bmd, A.class);
+ Deployment bean = addBeans("beanA", bmd, C.class, A.class);
try
{
- Bundle bundle1 = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle3"));
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle3");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
bundle1.start();
@@ -259,7 +264,7 @@
}
finally
{
- uninstall(bundle1);
+ bundle1.uninstall();
}
}
finally
@@ -268,22 +273,24 @@
}
}
+ @Test
@SuppressWarnings("rawtypes")
public void testServiceFactoryInjection() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1",
C.class.getName());
builder.addPropertyMetaData("a", builder.createInject("A"));
BeanMetaData bmd = builder.getBeanMetaData();
- Deployment bean1 = addBean("beanA1", C.class, bmd, A.class, D.class);
+ Deployment bean1 = addBeans("beanA1", bmd, C.class, A.class, D.class);
try
{
builder = BeanMetaDataBuilder.createBuilder("C2", C.class.getName());
builder.addPropertyMetaData("a",
builder.createInject("A"));
bmd = builder.getBeanMetaData();
- Deployment bean2 = addBean("beanA2", null, bmd);
+ Deployment bean2 = addBeans("beanA2", bmd, E.class);
try
{
- Bundle bundle1 = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle4"));
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle4");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
bundle1.start();
@@ -326,7 +333,7 @@
}
finally
{
- uninstall(bundle1);
+ bundle1.uninstall();
}
}
finally
@@ -340,68 +347,70 @@
}
}
+ @Test
@SuppressWarnings("rawtypes")
public void testServiceFactoryMix() throws Throwable
{
BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("C1",
C.class.getName());
builder.addPropertyMetaData("a", builder.createInject("A"));
BeanMetaData bmd = builder.getBeanMetaData();
- Deployment bean1 = addBean("beanA1", C.class, bmd, A.class, D.class);
+ Deployment bean1 = addBeans("beanA1", bmd, C.class, A.class, D.class);
try
{
- Bundle bundle1 = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle4"));
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle4");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
+ try
+ {
+ bundle1.start();
+ BundleContext bundleContext1 = bundle1.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> dClass = bundle1.loadClass(D.class.getName());
+ Object d = dClass.newInstance();
+ Hashtable<String, Object> table = new Hashtable<String,
Object>();
+ table.put("service.alias.1", "A");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(),
d, table);
+ assertNotNull(reg1);
+ ServiceReference refA = reg1.getReference();
+ assertNotNull(refA);
+
+ Object a = null;
try
{
- bundle1.start();
- BundleContext bundleContext1 = bundle1.getBundleContext();
- assertNotNull(bundleContext1);
+ checkComplete();
- Class<?> dClass = bundle1.loadClass(D.class.getName());
- Object d = dClass.newInstance();
- Hashtable<String, Object> table = new Hashtable<String,
Object>();
- table.put("service.alias.1", "A");
- ServiceRegistration reg1 =
bundleContext1.registerService(A.class.getName(), d, table);
- assertNotNull(reg1);
- ServiceReference refA = reg1.getReference();
- assertNotNull(refA);
+ Object c1 = getBean("C1");
+ a = getter(c1, "getA", "C1");
- Object a = null;
- try
- {
- checkComplete();
+ ServiceReference refD =
bundleContext1.getServiceReference(C.class.getName());
+ Bundle beanBundle = refD.getBundle();
+ assertNotNull(beanBundle);
+ BundleContext beanBC = beanBundle.getBundleContext();
+ assertNotNull(beanBC);
+ Object service = beanBC.getService(refA);
+ assertSame(a, service);
- Object c1 = getBean("C1");
- a = getter(c1, "getA", "C1");
+ KernelControllerContext cCC = getControllerContext("C1", null);
+ change(cCC, ControllerState.INSTANTIATED);
- ServiceReference refD =
bundleContext1.getServiceReference(C.class.getName());
- Bundle beanBundle = refD.getBundle();
- assertNotNull(beanBundle);
- BundleContext beanBC = beanBundle.getBundleContext();
- assertNotNull(beanBC);
- Object service = beanBC.getService(refA);
- assertSame(a, service);
-
- KernelControllerContext cCC = getControllerContext("C1",
null);
- change(cCC, ControllerState.INSTANTIATED);
-
- List as = assertInstanceOf(getter(d, "getAs", "A"),
List.class);
- assertNotNull(as);
- assertEmpty(as); // SF is still in use
- }
- finally
- {
- reg1.unregister();
- }
-
List as = assertInstanceOf(getter(d, "getAs", "A"),
List.class);
assertNotNull(as);
- assertEquals(1, as.size());
- assertTrue(as.contains(a));
+ assertTrue(as.isEmpty()); // SF is still in use
}
finally
{
- uninstall(bundle1);
+ reg1.unregister();
}
+
+ List as = assertInstanceOf(getter(d, "getAs", "A"),
List.class);
+ assertNotNull(as);
+ assertEquals(1, as.size());
+ assertTrue(as.contains(a));
+ }
+ finally
+ {
+ bundle1.uninstall();
+ }
}
finally
{
@@ -409,6 +418,70 @@
}
}
+ @Test
+ public void testFiltering() throws Throwable
+ {
+ Deployment bean = deployBeans("beanA", A.class);
+ try
+ {
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle1");
+ Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
+ try
+ {
+ bundle1.start();
+ BundleContext bundleContext1 = bundle1.getBundleContext();
+ assertNotNull(bundleContext1);
+
+ Class<?> aClass = bundle1.loadClass(A.class.getName());
+ Object a = aClass.newInstance();
+ Dictionary<String, Object> dictionary = new Hashtable<String,
Object>();
+ dictionary.put("a", "b");
+ ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(),
a, dictionary);
+ assertNotNull(reg1);
+ try
+ {
+ ServiceReference[] refs =
bundleContext1.getServiceReferences(A.class.getName(), "(a=b)");
+ assertNotNull(refs);
+ assertEquals(1, refs.length);
+ ServiceReference osgiRef = refs[0];
+
+ refs = bundleContext1.getServiceReferences(A.class.getName(),
"(bean.name=A)");
+ assertNotNull(refs);
+ assertEquals(1, refs.length);
+ ServiceReference mcRef = refs[0];
+
+ // OSGi service should bubble on top
+ assertEquals("OSGi service has not bubbled on top", osgiRef,
bundleContext1.getServiceReference(A.class.getName()));
+
+ // compare
+ assertTrue(osgiRef.compareTo(mcRef) < 0);
+ assertTrue(0 < mcRef.compareTo(osgiRef));
+
+ // ranking order first
+ refs = bundleContext1.getServiceReferences(A.class.getName(), null);
+ assertNotNull(refs);
+ assertEquals(2, refs.length);
+ assertEquals(osgiRef, refs[0]);
+ assertEquals(mcRef, refs[1]);
+ }
+ finally
+ {
+ reg1.unregister();
+ }
+ }
+ finally
+ {
+ bundle1.uninstall();
+ }
+ }
+ finally
+ {
+ undeploy(bean);
+ }
+ }
+
+ /*
+ @Test
public void testBeansMix() throws Throwable
{
AssembledDirectory mix = createAssembledDirectory("beans1",
"");
@@ -441,9 +514,11 @@
}
}
+ @Test
public void testServiceInjection() throws Throwable
{
- Bundle bundle = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle2", A.class));
+ VirtualFile assembly1 = assembleArchive("simple2",
"/bundles/service/service-bundle2", A.class);
+ Bundle bundle = context.installBundle(assembly1.toURL().toExternalForm());
try
{
bundle.start();
@@ -478,67 +553,8 @@
}
finally
{
- uninstall(bundle);
+ bundle.uninstall();
}
}
-
- public void testFiltering() throws Throwable
- {
- Deployment bean = addBean("beanA", A.class);
- try
- {
- Bundle bundle1 = installBundle(assembleBundle("simple2",
"/bundles/service/service-bundle1"));
- try
- {
- bundle1.start();
- BundleContext bundleContext1 = bundle1.getBundleContext();
- assertNotNull(bundleContext1);
-
- Class<?> aClass = bundle1.loadClass(A.class.getName());
- Object a = aClass.newInstance();
- Dictionary<String, Object> dictionary = new Hashtable<String,
Object>();
- dictionary.put("a", "b");
- ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(),
a, dictionary);
- assertNotNull(reg1);
- try
- {
- ServiceReference[] refs =
bundleContext1.getServiceReferences(A.class.getName(), "(a=b)");
- assertNotNull(refs);
- assertEquals(1, refs.length);
- ServiceReference osgiRef = refs[0];
-
- refs = bundleContext1.getServiceReferences(A.class.getName(),
"(bean.name=A)");
- assertNotNull(refs);
- assertEquals(1, refs.length);
- ServiceReference mcRef = refs[0];
-
- // OSGi service should bubble on top
- assertEquals("OSGi service has not bubbled on top", osgiRef,
bundleContext1.getServiceReference(A.class.getName()));
-
- // compare
- assertTrue(osgiRef.compareTo(mcRef) < 0);
- assertTrue(0 < mcRef.compareTo(osgiRef));
-
- // ranking order first
- refs = bundleContext1.getServiceReferences(A.class.getName(), null);
- assertNotNull(refs);
- assertEquals(2, refs.length);
- assertEquals(osgiRef, refs[0]);
- assertEquals(mcRef, refs[1]);
- }
- finally
- {
- reg1.unregister();
- }
- }
- finally
- {
- uninstall(bundle1);
- }
- }
- finally
- {
- undeploy(bean);
- }
- }
+ */
}
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -31,7 +31,7 @@
import java.util.TreeSet;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.service.support.a.A;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -47,7 +47,7 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ServiceReferenceUnitTestCase extends NativeFrameworkTest
+public class ServiceReferenceUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testGetProperty() throws Exception
@@ -56,7 +56,7 @@
String[] clazzes = new String[] { BundleContext.class.getName() };
Object serviceID = null;
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -155,7 +155,7 @@
{
ServiceReference reference = null;
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -215,7 +215,7 @@
@Test
public void testGetBundle() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -246,7 +246,7 @@
@Test
public void testGetBundleAfterStop() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -277,7 +277,7 @@
@Test
public void testUsingBundles() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly1 = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -293,7 +293,7 @@
assertUsingBundles(reference);
- VirtualFile assembly2 = assembleBundle("simple2",
"/bundles/simple/simple-bundle2");
+ VirtualFile assembly2 = assembleArchive("simple2",
"/bundles/simple/simple-bundle2");
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
@@ -336,7 +336,7 @@
@Test
public void testUsingBundlesAfterStop() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly1 = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -352,7 +352,7 @@
assertUsingBundles(reference);
- VirtualFile assembly2 = assembleBundle("simple2",
"/bundles/simple/simple-bundle2");
+ VirtualFile assembly2 = assembleArchive("simple2",
"/bundles/simple/simple-bundle2");
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
@@ -381,7 +381,7 @@
@Test
public void testIsAssignableToErrors() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1", A.class);
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1", A.class);
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -424,7 +424,7 @@
@Test
public void testNotAssignableTo() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple1",
"/bundles/simple/simple-bundle1", A.class);
+ VirtualFile assembly1 = assembleArchive("simple1",
"/bundles/simple/simple-bundle1", A.class);
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -438,7 +438,7 @@
ServiceReference reference = registration.getReference();
assertNotNull(reference);
- VirtualFile assembly2 = assembleBundle("simple2",
"/bundles/simple/simple-bundle2", A.class);
+ VirtualFile assembly2 = assembleArchive("simple2",
"/bundles/simple/simple-bundle2", A.class);
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
@@ -466,7 +466,7 @@
//Bundle-Name: Service2
//Bundle-SymbolicName: org.jboss.test.osgi.service2
//Export-Package: org.jboss.test.osgi.service.support.a
- VirtualFile assembly2 = assembleBundle("service2",
"/bundles/service/service-bundle2", A.class);
+ VirtualFile assembly2 = assembleArchive("service2",
"/bundles/service/service-bundle2", A.class);
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
@@ -478,7 +478,7 @@
//Bundle-Name: Service1
//Bundle-SymbolicName: org.jboss.test.osgi.service1
//Import-Package: org.jboss.test.osgi.service.support.a
- VirtualFile assembly1 = assembleBundle("service1",
"/bundles/service/service-bundle1");
+ VirtualFile assembly1 = assembleArchive("service1",
"/bundles/service/service-bundle1");
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
@@ -515,7 +515,7 @@
@Test
public void testCompareTo() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -31,7 +31,7 @@
import java.util.Hashtable;
import org.jboss.osgi.vfs.VirtualFile;
-import org.jboss.test.osgi.NativeFrameworkTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -47,13 +47,13 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ServiceRegistrationUnitTestCase extends NativeFrameworkTest
+public class ServiceRegistrationUnitTestCase extends AbstractFrameworkTest
{
@Test
public void testGetReference() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -115,7 +115,7 @@
@Test
public void testSetProperties() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -224,7 +224,7 @@
@Test
public void testSetPropertiesAfterStop() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
@@ -257,7 +257,7 @@
@Test
public void testUnregister() throws Exception
{
- VirtualFile assembly1 = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly1 = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle1 = context.installBundle(assembly1.toURL().toExternalForm());
try
{
@@ -282,7 +282,7 @@
inUse = bundle1.getServicesInUse();
assertArrayEquals(new ServiceReference[] { reference }, inUse);
- VirtualFile assembly2 = assembleBundle("simple2",
"/bundles/simple/simple-bundle2");
+ VirtualFile assembly2 = assembleArchive("simple2",
"/bundles/simple/simple-bundle2");
Bundle bundle2 = context.installBundle(assembly2.toURL().toExternalForm());
try
{
@@ -340,7 +340,7 @@
@Test
public void testUnregisterAfterStop() throws Exception
{
- VirtualFile assembly = assembleBundle("simple1",
"/bundles/simple/simple-bundle1");
+ VirtualFile assembly = assembleArchive("simple1",
"/bundles/simple/simple-bundle1");
Bundle bundle = context.installBundle(assembly.toURL().toExternalForm());
try
{
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServicesTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServicesTest.java 2010-03-10
16:06:33 UTC (rev 102228)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServicesTest.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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;
-
-import java.lang.reflect.Method;
-
-import org.jboss.test.osgi.DeployersTest;
-
-/**
- * Test MC's services.
- *
- * @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
- */
-public abstract class ServicesTest extends DeployersTest
-{
- public ServicesTest(String name)
- {
- super(name);
- }
-
- protected static Object getter(Object target, String getter, String name) throws
Throwable
- {
- assertNotNull("Target " + name + " is not null", target);
- Class<?> clazz = target.getClass();
- Method m = clazz.getDeclaredMethod(getter);
- return m.invoke(target);
- }
-
- protected static Object setter(Object target, String setter, Object value, String
name) throws Throwable
- {
- assertNotNull("Target " + name + " is not null", target);
- assertNotNull("Value is not null", value);
- Class<?> clazz = target.getClass();
- Method m = clazz.getDeclaredMethod(setter, value.getClass());
- return m.invoke(target, value);
- }
-}
\ No newline at end of file
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/e/E.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/e/E.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/e/E.java 2010-03-10
16:12:51 UTC (rev 102229)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.support.e;
+
+public class E
+{
+}
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/JMXServicesUnitTestCase#testAtJmx.xml
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/JMXServicesUnitTestCase#testAtJmx.xml
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/JMXServicesUnitTestCase#testAtJmx.xml 2010-03-10
16:12:51 UTC (rev 102229)
@@ -0,0 +1,7 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Invoker"
class="org.jboss.test.osgi.service.support.MockInvoker">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=invoker,type=unified",exposedInterface=org.jboss.test.osgi.service.support.MockInvokerMBean.class,registerDirectly=true)</annotation>
+ </bean>
+
+</deployment>
\ No newline at end of file
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/jmx-services.xml
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/jmx-services.xml
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/service/jmx-services.xml 2010-03-10
16:12:51 UTC (rev 102229)
@@ -0,0 +1,61 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- JMX Deployment -->
+
+ <bean name="JMXKernel"
class="org.jboss.test.osgi.service.support.JBossJMXKernel" />
+
+ <bean name="ServiceMetaDataICF"
class="org.jboss.system.deployers.managed.ServiceMetaDataICF">
+ <property name="mbeanServer">
+ <inject bean="JMXKernel" property="mbeanServer" />
+ </property>
+ </bean>
+ <bean name="SARDeployer"
class="org.jboss.system.deployers.SARDeployer" />
+ <bean name="ServiceClassLoaderDeployer"
class="org.jboss.system.deployers.ServiceClassLoaderDeployer" />
+ <bean name="ServiceDeploymentDeployer"
class="org.jboss.system.deployers.ServiceDeploymentDeployer" />
+ <bean name="ServiceDeployer"
class="org.jboss.system.deployers.ServiceDeployer">
+ <constructor>
+ <parameter>
+ <inject bean="JMXKernel" property="serviceController"
/>
+ </parameter>
+ </constructor>
+ </bean>
+
+ <!-- Intercept all annotation plugings -->
+
+ <bean name="BeanAnnotationAdapterFactory"
class="org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory">
+ <constructor factoryMethod="getInstance" />
+ </bean>
+
+ <bean name="BeanAnnotationAdapter">
+ <constructor factoryMethod="getBeanAnnotationAdapter">
+ <factory bean="BeanAnnotationAdapterFactory" />
+ </constructor>
+ <incallback method="addAnnotationPlugin" />
+ <uncallback method="removeAnnotationPlugin" />
+ </bean>
+
+ <!-- Support for @JMX -->
+ <lifecycle-configure xmlns="urn:jboss:aop-beans:1.0"
name="JMXRegistrationAdvice"
class="org.jboss.system.microcontainer.jmx.ServiceControllerRegistrationLifecycleCallback"
+ classes="(a)org.jboss.aop.microcontainer.aspects.jmx.JMX">
+ <property name="serviceController">
+ <inject bean="JMXKernel" property="serviceController" />
+ </property>
+ </lifecycle-configure>
+ <lifecycle-create xmlns="urn:jboss:aop-beans:1.0"
name="JMXCreateDestroyAdvice"
class="org.jboss.system.microcontainer.jmx.ServiceControllerCreateDestroyLifecycleCallback"
+ classes="(a)org.jboss.aop.microcontainer.aspects.jmx.JMX">
+ <property name="serviceController">
+ <inject bean="JMXKernel" property="serviceController" />
+ </property>
+ </lifecycle-create>
+ <lifecycle-install xmlns="urn:jboss:aop-beans:1.0"
name="JMXStartStopAdvice"
class="org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback"
+ classes="(a)org.jboss.aop.microcontainer.aspects.jmx.JMX">
+ <property name="serviceController">
+ <inject bean="JMXKernel" property="serviceController" />
+ </property>
+ </lifecycle-install>
+
+ <bean name="Invoker"
class="org.jboss.test.osgi.service.support.MockInvoker">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss:service=invoker,type=unified",exposedInterface=org.jboss.test.osgi.service.support.MockInvokerMBean.class,registerDirectly=true)</annotation>
+ </bean>
+
+</deployment>
\ No newline at end of file