[jboss-osgi-commits] JBoss-OSGI SVN: r96193 - in projects/jboss-osgi/trunk/reactor/framework: src/test/java/org/jboss/test/osgi and 7 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Mon Nov 9 14:47:53 EST 2009
Author: thomas.diesler at jboss.com
Date: 2009-11-09 14:47:51 -0500 (Mon, 09 Nov 2009)
New Revision: 96193
Added:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloading/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/classloading/
Modified:
projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/web.xml
Log:
Move BundleClassPathTest together with other classloader tests
Rename OSGiTestCase to FrameworkTestCase to reduce confusion with Husky OSGiTest
Modified: projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/scripts/antrun-test-jars.xml 2009-11-09 19:47:51 UTC (rev 96193)
@@ -44,12 +44,12 @@
<!-- bundle-classpath -->
<war destfile="${tests.output.dir}/test-libs/bundle-classpath.war"
- manifest="${tests.resources.dir}/classloading/bundleclasspath/MANIFEST.MF"
- webxml="${tests.resources.dir}/classloading/bundleclasspath/web.xml">
+ manifest="${tests.resources.dir}/bundles/classloader/bundleclasspath/MANIFEST.MF"
+ webxml="${tests.resources.dir}/bundles/classloader/bundleclasspath/web.xml">
<classes dir="${tests.classes.dir}">
- <include name="**/classloading/EndpointServlet.class"/>
+ <include name="**/classloader/support/a/A.class"/>
</classes>
- <fileset dir="${tests.resources.dir}/classloading/bundleclasspath">
+ <fileset dir="${tests.resources.dir}/bundles/classloader/bundleclasspath">
<include name="message.txt"/>
</fileset>
</war>
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java (from rev 96190, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -0,0 +1,572 @@
+/*
+ * 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.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.spi.util.ConstantsHelper;
+import org.jboss.test.AbstractTestDelegate;
+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 at gmail.com">John Bailey</a>
+ * @version $Revision: 87848 $
+ */
+public abstract class FrameworkTestCase extends MicrocontainerTest implements FrameworkListener, SynchronousBundleListener, ServiceListener
+{
+ private List<FrameworkEvent> frameworkEvents = new CopyOnWriteArrayList<FrameworkEvent>();
+ private List<BundleEvent> bundleEvents = new CopyOnWriteArrayList<BundleEvent>();
+ private List<ServiceEvent> serviceEvents = new CopyOnWriteArrayList<ServiceEvent>();
+
+ /**
+ * Create a new OSGiTestCase.
+ *
+ * @param name the test name
+ */
+ public FrameworkTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get the AbstractTestDelegate
+ *
+ * @param clazz the test class
+ * @return The AbstractTestDelegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ FrameworkTestDelegate delegate = new FrameworkTestDelegate(clazz);
+ //delegate.enableSecurity = true;
+ return delegate;
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * 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 Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+ {
+ return getDelegate().assembleBundle(name, new String[] { resources }, packages);
+ }
+
+ protected Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ return getDelegate().assembleBundle(name, 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 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> expected = new HashSet<Bundle>();
+ for (Bundle bundle : bundles)
+ expected.add(bundle);
+
+ Set<Bundle> actual = new HashSet<Bundle>();
+ Bundle[] users = reference.getUsingBundles();
+ if (users != null)
+ for (Bundle bundle : users)
+ actual.add(bundle);
+
+ getLog().debug(reference + " users=" + actual);
+
+ assertEquals(expected, actual);
+ }
+
+ 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("unchecked")
+ 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--;
+ }
+ }
+}
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java (from rev 96190, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -0,0 +1,187 @@
+/*
+ * 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.net.URL;
+import java.util.Enumeration;
+
+import junit.framework.AssertionFailedError;
+
+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.launch.OSGiFramework;
+import org.jboss.osgi.spi.util.ServiceLoader;
+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;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A OSGiTestDelegate
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @author Thomas.Diesler at jboss.com
+ */
+class FrameworkTestDelegate extends MicrocontainerTestDelegate
+{
+ private OSGiBundleManager bundleManager;
+
+ /**
+ * Create a new OSGiTestDelegate.
+ */
+ FrameworkTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ OSGiBundleManager getBundleManager()
+ {
+ if (bundleManager == null)
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ OSGiFramework framework = (OSGiFramework)factory.newFramework(null);
+ try
+ {
+ framework.start();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start framework", ex);
+ }
+ bundleManager = framework.getBundleManager();
+ }
+ return bundleManager;
+ }
+
+ /**
+ * 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
+ */
+ 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().install(childResource);
+ return bundleState.getBundleInternal();
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ Bundle addBundle(VirtualFile file) throws Exception
+ {
+ AbstractBundleState bundleState = getBundleManager().install(file);
+ return bundleState.getBundleInternal();
+ }
+
+ /**
+ * Remove a bundle
+ *
+ * @param bundle the bundle to remove
+ * @throws Exception for any error
+ */
+ void uninstall(Bundle bundle) throws Exception
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ getBundleManager().uninstall(bundle);
+ }
+
+ DeploymentUnit getDeploymentUnit(Bundle bundle)
+ {
+ DeploymentUnit deploymentUnit = getBundleManager().getDeployment(bundle.getBundleId());
+ if (deploymentUnit == null)
+ throw new AssertionFailedError("Bundle not installed: " + bundle);
+ return deploymentUnit;
+ }
+
+ Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
+ {
+ return assembleBundle(name, new String[] { resources }, packages);
+ }
+
+ Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name, "");
+ for (String path : resourcePaths)
+ addPath(assembledDirectory, path, "");
+ for (Class<?> reference : packages)
+ addPackage(assembledDirectory, reference);
+ return addBundle(assembledDirectory);
+ }
+
+ AssembledDirectory createAssembledDirectory(String name) throws Exception
+ {
+ return createAssembledDirectory(name, "");
+ }
+
+ AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
+ {
+ return AssembledDirectory.createAssembledDirectory(name, rootName);
+ }
+
+ void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
+ {
+ String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
+ dir.addResources(reference, new String[] { packagePath + "/*.class" } , new String[0]);
+ }
+
+ 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);
+ }
+
+ URL getBundleResource(Bundle bundle, String path)
+ {
+ return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
+ }
+
+ Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
+ {
+ return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
+ }
+}
Deleted: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -1,572 +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.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.spi.util.ConstantsHelper;
-import org.jboss.test.AbstractTestDelegate;
-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 at gmail.com">John Bailey</a>
- * @version $Revision: 87848 $
- */
-public abstract class OSGiTestCase extends MicrocontainerTest implements FrameworkListener, SynchronousBundleListener, ServiceListener
-{
- private List<FrameworkEvent> frameworkEvents = new CopyOnWriteArrayList<FrameworkEvent>();
- private List<BundleEvent> bundleEvents = new CopyOnWriteArrayList<BundleEvent>();
- private List<ServiceEvent> serviceEvents = new CopyOnWriteArrayList<ServiceEvent>();
-
- /**
- * Create a new OSGiTestCase.
- *
- * @param name the test name
- */
- public OSGiTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Get the AbstractTestDelegate
- *
- * @param clazz the test class
- * @return The AbstractTestDelegate
- * @throws Exception for any error
- */
- public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
- {
- OSGiTestDelegate delegate = new OSGiTestDelegate(clazz);
- //delegate.enableSecurity = true;
- return delegate;
- }
-
- /**
- * Get OSGiTestDelegate
- */
- protected OSGiTestDelegate getDelegate()
- {
- return (OSGiTestDelegate)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);
- }
-
- /**
- * 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 Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
- {
- return getDelegate().assembleBundle(name, new String[] { resources }, packages);
- }
-
- protected Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
- {
- return getDelegate().assembleBundle(name, 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 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> expected = new HashSet<Bundle>();
- for (Bundle bundle : bundles)
- expected.add(bundle);
-
- Set<Bundle> actual = new HashSet<Bundle>();
- Bundle[] users = reference.getUsingBundles();
- if (users != null)
- for (Bundle bundle : users)
- actual.add(bundle);
-
- getLog().debug(reference + " users=" + actual);
-
- assertEquals(expected, actual);
- }
-
- 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("unchecked")
- 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/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -1,187 +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 java.net.URL;
-import java.util.Enumeration;
-
-import junit.framework.AssertionFailedError;
-
-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.launch.OSGiFramework;
-import org.jboss.osgi.spi.util.ServiceLoader;
-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;
-import org.osgi.framework.launch.FrameworkFactory;
-
-/**
- * A OSGiTestDelegate
- *
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @author Thomas.Diesler at jboss.com
- */
-public class OSGiTestDelegate extends MicrocontainerTestDelegate
-{
- private OSGiBundleManager bundleManager;
-
- /**
- * Create a new OSGiTestDelegate.
- */
- public OSGiTestDelegate(Class<?> clazz) throws Exception
- {
- super(clazz);
- }
-
- protected OSGiBundleManager getBundleManager()
- {
- if (bundleManager == null)
- {
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- OSGiFramework framework = (OSGiFramework)factory.newFramework(null);
- try
- {
- framework.start();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start framework", ex);
- }
- bundleManager = framework.getBundleManager();
- }
- return bundleManager;
- }
-
- /**
- * 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().install(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().install(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)
- getBundleManager().uninstall(bundle);
- }
-
- protected DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- DeploymentUnit deploymentUnit = getBundleManager().getDeployment(bundle.getBundleId());
- if (deploymentUnit == null)
- throw new AssertionFailedError("Bundle not installed: " + bundle);
- return deploymentUnit;
- }
-
- public Bundle assembleBundle(String name, String resources, Class<?>... packages) throws Exception
- {
- return assembleBundle(name, new String[] { resources }, packages);
- }
-
- public Bundle assembleBundle(String name, String[] resourcePaths, Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name, "");
- for (String path : resourcePaths)
- addPath(assembledDirectory, path, "");
- for (Class<?> reference : packages)
- addPackage(assembledDirectory, reference);
- return addBundle(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);
- }
-
- protected URL getBundleResource(Bundle bundle, String path)
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
- }
-
- protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws Exception
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
- }
-}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleContextUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -29,7 +29,7 @@
import java.util.Locale;
import java.util.Set;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
@@ -46,7 +46,7 @@
* @author Thomas.Diesler at jboss.com
* @version $Revision: 1.1 $
*/
-public class BundleContextUnitTestCase extends OSGiTestCase
+public class BundleContextUnitTestCase extends FrameworkTestCase
{
public BundleContextUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -28,7 +28,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
/**
@@ -39,7 +39,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class BundleEntriesUnitTestCase extends OSGiTestCase
+public class BundleEntriesUnitTestCase extends FrameworkTestCase
{
public BundleEntriesUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -25,7 +25,7 @@
import java.util.Hashtable;
import java.util.jar.Attributes;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -38,7 +38,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class BundleUnitTestCase extends OSGiTestCase
+public class BundleUnitTestCase extends FrameworkTestCase
{
public BundleUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/bundle/SystemBundleUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -36,7 +36,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class SystemBundleUnitTestCase extends OSGiTestCase
+public class SystemBundleUnitTestCase extends FrameworkTestCase
{
public SystemBundleUnitTestCase(String name)
{
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java (from rev 96188, projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloading/BundleClassPathTest.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTest.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.classloader;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.testing.OSGiTest;
+import org.jboss.test.osgi.classloader.support.a.A;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * BundleClassPathTest.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 07-Oct-2009
+ */
+public class BundleClassPathTest extends OSGiTest
+{
+ @Test
+ public void testBundleClassPath() throws Exception
+ {
+ OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+ Framework framework = bootProvider.getFramework();
+ framework.start();
+
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(getTestArchivePath("bundle-classpath.war"));
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ Class<?> clazz = bundle.loadClass(A.class.getName());
+ assertNotNull("Loaded class", clazz);
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ framework.stop();
+ }
+}
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/ExportImportPackageUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.classloader;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
import org.osgi.framework.Bundle;
@@ -39,7 +39,7 @@
* @author Thomas.Diesler at jboss.com
* @version $Revision: 1.1 $
*/
-public class ExportImportPackageUnitTestCase extends OSGiTestCase
+public class ExportImportPackageUnitTestCase extends FrameworkTestCase
{
public ExportImportPackageUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/classloader/RequireBundleUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.classloader;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
import org.osgi.framework.Bundle;
@@ -34,7 +34,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class RequireBundleUnitTestCase extends OSGiTestCase
+public class RequireBundleUnitTestCase extends FrameworkTestCase
{
public RequireBundleUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.jboss.test.osgi.service.support.b.B;
import org.osgi.framework.Bundle;
@@ -41,7 +41,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class GetServiceReferencesUnitTestCase extends OSGiTestCase
+public class GetServiceReferencesUnitTestCase extends FrameworkTestCase
{
public GetServiceReferencesUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.osgi.service;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.BrokenServiceFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -35,7 +35,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class GetUnGetServiceUnitTestCase extends OSGiTestCase
+public class GetUnGetServiceUnitTestCase extends FrameworkTestCase
{
static String OBJCLASS = BundleContext.class.getName();
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/RegisterServiceUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.util.Dictionary;
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -38,7 +38,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class RegisterServiceUnitTestCase extends OSGiTestCase
+public class RegisterServiceUnitTestCase extends FrameworkTestCase
{
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceFactoryUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -22,7 +22,7 @@
package org.jboss.test.osgi.service;
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -37,7 +37,7 @@
* @author Thomas.Diesler at jboss.com
* @version $Revision$
*/
-public class ServiceFactoryUnitTestCase extends OSGiTestCase
+public class ServiceFactoryUnitTestCase extends FrameworkTestCase
{
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceReferenceUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -28,7 +28,7 @@
import java.util.Set;
import java.util.TreeSet;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -43,7 +43,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ServiceReferenceUnitTestCase extends OSGiTestCase
+public class ServiceReferenceUnitTestCase extends FrameworkTestCase
{
public ServiceReferenceUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationUnitTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -23,7 +23,7 @@
import java.util.Hashtable;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.service.support.SimpleServiceFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -38,7 +38,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class ServiceRegistrationUnitTestCase extends OSGiTestCase
+public class ServiceRegistrationUnitTestCase extends FrameworkTestCase
{
public ServiceRegistrationUnitTestCase(String name)
{
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-09 19:25:59 UTC (rev 96192)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/smoke/OSGiSmokeTestCase.java 2009-11-09 19:47:51 UTC (rev 96193)
@@ -24,7 +24,7 @@
import java.io.InputStream;
import java.net.URL;
-import org.jboss.test.osgi.OSGiTestCase;
+import org.jboss.test.osgi.FrameworkTestCase;
import org.jboss.test.osgi.smoke.support.a.A;
import org.jboss.test.osgi.smoke.support.a.b.B;
import org.jboss.test.osgi.smoke.support.c.C;
@@ -36,7 +36,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class OSGiSmokeTestCase extends OSGiTestCase
+public class OSGiSmokeTestCase extends FrameworkTestCase
{
public OSGiSmokeTestCase(String name)
{
Copied: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath (from rev 96188, projects/jboss-osgi/trunk/reactor/framework/src/test/resources/classloading/bundleclasspath)
Modified: projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/web.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/test/resources/classloading/bundleclasspath/web.xml 2009-11-09 19:04:43 UTC (rev 96188)
+++ projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/classloader/bundleclasspath/web.xml 2009-11-09 19:47:51 UTC (rev 96193)
@@ -2,11 +2,9 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.4">
- <display-name>WebApp Sample</display-name>
-
<servlet>
<servlet-name>servlet</servlet-name>
- <servlet-class>org.jboss.test.osgi.classloading.EndpointServlet</servlet-class>
+ <servlet-class>org.jboss.test.osgi.classloader.some.servlet</servlet-class>
<init-param>
<param-name>initProp</param-name>
<param-value>SomeValue</param-value>
More information about the jboss-osgi-commits
mailing list