JBoss-OSGI SVN: r102773 - in projects/jboss-osgi/projects/runtime/framework/trunk/bundle: src/test/java/org/jboss/test/osgi and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-23 07:38:05 -0400 (Tue, 23 Mar 2010)
New Revision: 102773
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple-logservice.bnd
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple.bnd
Log:
Move integration.simple to simple
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml 2010-03-23 11:25:18 UTC (rev 102772)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml 2010-03-23 11:38:05 UTC (rev 102773)
@@ -82,8 +82,8 @@
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-nativecode.jar" files="${tests.resources.dir}/nativecode/simple-nativecode.bnd" />
<!-- simple -->
- <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/integration/simple/simple.bnd" />
- <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-logservice-bundle.jar" files="${tests.resources.dir}/integration/simple/simple-logservice.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/simple/simple.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-logservice-bundle.jar" files="${tests.resources.dir}/simple/simple-logservice.bnd" />
<!-- Please add alphabetically -->
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.simple;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.jboss.test.osgi.simple.bundleA.SimpleService;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class SimpleBundleTestCase
+{
+ @Test
+ public void testBundleInstallLauchAPI() throws Exception
+ {
+ // Uses the OSGi Framework launch API
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ Framework framework = factory.newFramework(null);
+ framework.start();
+
+ OSGiRuntimeHelper helper = new OSGiRuntimeHelper();
+
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(helper.getTestArchivePath("simple-bundle.jar"));
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ BundleContext bndContext = bundle.getBundleContext();
+ assertNotNull("BundleContext not null", bndContext);
+
+ // getServiceReference from bundle context
+ ServiceReference sref = bndContext.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+
+ // getServiceReference from system context
+ sref = sysContext.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ framework.stop();
+ }
+
+ @Test
+ public void testBundleInstallRuntimeAPI() throws Exception
+ {
+ // Uses the JBossOSGi SPI provided runtime abstraction
+ OSGiRuntime runtime = new OSGiRuntimeHelper().getEmbeddedRuntime();
+ OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ runtime.shutdown();
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java (from rev 102752, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.simple;
+
+//$Id$
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.jboss.osgi.testing.OSGiFrameworkTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class SimpleLogServiceTestCase extends OSGiFrameworkTest
+{
+ @Before
+ public void setUp()
+ {
+ System.clearProperty("simple-logservice-bundle");
+ }
+
+ @Test
+ public void testNoLogService() throws Exception
+ {
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
+ fail("Unresolved package contstraint on [org.osgi.service.log] expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+
+ @Test
+ public void testLogServiceFromThirdParty() throws Exception
+ {
+ Bundle logBundle = context.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar"));
+ try
+ {
+ logBundle.start();
+
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ try
+ {
+ bundle.start();
+ fail("Expected UNRESOLVED OSGiPackageRequirement{org.osgi.util.tracker [0.0.0,?)}");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ logBundle.uninstall();
+ }
+ }
+
+ @Test
+ public void testLogServiceFromCompendium() throws Exception
+ {
+ Bundle cmpnBundle = context.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ try
+ {
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
+
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
+
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+ assertFalse("getService", result.indexOf("getService") > 0);
+ assertFalse("addingService", result.indexOf("addingService") > 0);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ cmpnBundle.uninstall();
+ }
+ }
+
+ @Test
+ public void testLogServiceFromTwoExporters() throws Exception
+ {
+ Bundle cmpnBundle = context.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ try
+ {
+ Bundle logBundle = context.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar"));
+ try
+ {
+ logBundle.start();
+
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
+
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
+
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+ assertTrue("getService", result.indexOf("getService") > 0);
+ assertTrue("addingService", result.indexOf("addingService") > 0);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ logBundle.uninstall();
+ }
+ }
+ finally
+ {
+ cmpnBundle.uninstall();
+ }
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleActivator.java 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleActivator.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -19,7 +19,7 @@
* 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.integration.simple.bundleA;
+package org.jboss.test.osgi.simple.bundleA;
//$Id$
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.integration.simple.bundleA;
-
-//$Id$
-
-import org.osgi.framework.BundleContext;
-
-/**
- * A SimpleService
- *
- * @author thomas.diesler(a)jboss.com
- * @since 24-Apr-2009
- */
-public class SimpleService
-{
- public SimpleService(BundleContext context)
- {
- }
-
- public String echo(String msg)
- {
- return msg;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.simple.bundleA;
+
+//$Id$
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A SimpleService
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleService
+{
+ public SimpleService(BundleContext context)
+ {
+ }
+
+ public String echo(String msg)
+ {
+ return msg;
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB)
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.integration.simple.bundleB;
-
-//$Id$
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler(a)jboss.com
- * @since 24-Apr-2009
- */
-public class SimpleLogServiceActivator implements BundleActivator
-{
- public void start(BundleContext context)
- {
- final String symName = context.getBundle().getSymbolicName();
- addMessage(symName, "startBundleActivator");
-
- ServiceReference sref = context.getServiceReference(LogService.class.getName());
- if (sref != null)
- {
- LogService service = (LogService)context.getService(sref);
- String message = "getService: " + service.getClass().getName();
- addMessage(symName, message);
- }
-
- ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
- {
- @Override
- public Object addingService(ServiceReference reference)
- {
- LogService service = (LogService)super.addingService(reference);
- String message = "addingService: " + service.getClass().getName();
- addMessage(symName, message);
- return service;
- }
- };
- tracker.open();
- }
-
- public void stop(BundleContext context)
- {
- String symName = context.getBundle().getSymbolicName();
- addMessage(symName, "stopBundleActivator");
- }
-
- private void addMessage(String propName, String message)
- {
- String previous = System.getProperty(propName, ":");
- System.setProperty(propName, previous + message + ":");
- //System.out.println(message);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.simple.bundleB;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleLogServiceActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ final String symName = context.getBundle().getSymbolicName();
+ addMessage(symName, "startBundleActivator");
+
+ ServiceReference sref = context.getServiceReference(LogService.class.getName());
+ if (sref != null)
+ {
+ LogService service = (LogService)context.getService(sref);
+ String message = "getService: " + service.getClass().getName();
+ addMessage(symName, message);
+ }
+
+ ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ LogService service = (LogService)super.addingService(reference);
+ String message = "addingService: " + service.getClass().getName();
+ addMessage(symName, message);
+ return service;
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ String symName = context.getBundle().getSymbolicName();
+ addMessage(symName, "stopBundleActivator");
+ }
+
+ private void addMessage(String propName, String message)
+ {
+ String previous = System.getProperty(propName, ":");
+ System.setProperty(propName, previous + message + ":");
+ //System.out.println(message);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/simple)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple-logservice.bnd
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/simple/simple-logservice.bnd 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple-logservice.bnd 2010-03-23 11:38:05 UTC (rev 102773)
@@ -2,5 +2,5 @@
Bundle-SymbolicName: simple-logservice-bundle
-Bundle-Activator: org.jboss.test.osgi.integration.simple.bundleB.SimpleLogServiceActivator
-Private-Package: org.jboss.test.osgi.integration.simple.bundleB
+Bundle-Activator: org.jboss.test.osgi.simple.bundleB.SimpleLogServiceActivator
+Private-Package: org.jboss.test.osgi.simple.bundleB
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple.bnd
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/simple/simple.bnd 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple.bnd 2010-03-23 11:38:05 UTC (rev 102773)
@@ -2,5 +2,5 @@
Bundle-SymbolicName: simple-bundle
-Bundle-Activator: org.jboss.test.osgi.integration.simple.bundleA.SimpleActivator
-Export-Package: org.jboss.test.osgi.integration.simple.bundleA
+Bundle-Activator: org.jboss.test.osgi.simple.bundleA.SimpleActivator
+Export-Package: org.jboss.test.osgi.simple.bundleA
14 years, 3 months
JBoss-OSGI SVN: r102772 - in projects/jboss-osgi/projects/runtime/framework/trunk: bundle/scripts and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-23 07:25:18 -0400 (Tue, 23 Mar 2010)
New Revision: 102772
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContext.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
Log:
[TCK] ServiceExceptions pass
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-23 11:25:18 UTC (rev 102772)
@@ -45,11 +45,27 @@
<artifactId>bnd</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-jmx-aop-mc-int</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.kernel</groupId>
+ <artifactId>jboss-jmx-mc-int</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Test bundles dependencies -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.felix</groupId>
@@ -64,7 +80,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.log</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.felix</groupId>
@@ -79,7 +95,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.metatype</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.felix</groupId>
@@ -94,52 +110,52 @@
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-apache-xerces</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-common</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-common-core</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-husky</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-jaxb</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.jmx</groupId>
<artifactId>jboss-osgi-jmx</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.jndi</groupId>
<artifactId>jboss-osgi-jndi</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-reflect</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-xml-binding</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.web</groupId>
<artifactId>pax-web-jetty-bundle</artifactId>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
@@ -158,21 +174,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-jmx-aop-mc-int</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-jmx-mc-int</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-all.xml 2010-03-23 11:25:18 UTC (rev 102772)
@@ -35,11 +35,14 @@
<include>*:jboss-managed:jar</include>
<include>*:jboss-mdr:jar</include>
<include>*:jboss-metatype:jar</include>
+ <include>*:jboss-osgi-deployers-vfs30:jar</include>
<include>*:jboss-osgi-deployment:jar</include>
<include>*:jboss-osgi-framework-core:jar</include>
<include>*:jboss-osgi-framework-metadata:jar</include>
+ <include>*:jboss-osgi-framework-vfs30:jar</include>
<include>*:jboss-osgi-spi:jar</include>
<include>*:jboss-osgi-vfs:jar</include>
+ <include>*:jboss-osgi-vfs30:jar</include>
<include>*:jboss-reflect:jar</include>
<include>*:jboss-vfs:jar</include>
<include>*:jbossxb:jar</include>
@@ -48,16 +51,13 @@
<include>*:org.osgi.compendium:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
- <scope>compile</scope>
+ <scope>provided</scope>
<unpack>true</unpack>
</dependencySet>
<dependencySet>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>*:jboss-logging-log4j:jar</include>
- <include>*:jboss-osgi-deployers-vfs30:jar</include>
- <include>*:jboss-osgi-framework-vfs30:jar</include>
- <include>*:jboss-osgi-vfs30:jar</include>
<include>*:log4j:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml 2010-03-23 11:25:18 UTC (rev 102772)
@@ -30,7 +30,7 @@
<include>*:pax-web-jetty-bundle:jar</include>
</includes>
<useStrictFiltering>true</useStrictFiltering>
- <scope>test</scope>
+ <scope>provided</scope>
<unpack>false</unpack>
</dependencySet>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java 2010-03-23 11:25:18 UTC (rev 102772)
@@ -112,8 +112,6 @@
@Test
public void testGetServiceFactory() throws Exception
{
- String OBJCLASS = BundleContext.class.getName();
-
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
try
@@ -137,7 +135,7 @@
sreg.unregister();
actual = context.getService(sref);
- assertNull("" + actual, actual);
+ assertNull("Service null", actual);
}
finally
{
@@ -184,6 +182,7 @@
@Test
public void testGetWrongInterfacesForServiceFactory() throws Exception
{
+ String[] OBJCLASS = { String.class.getName() };
String[] OBJCLASSES = { String.class.getName(), BundleContext.class.getName() };
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
@@ -196,17 +195,23 @@
context.addFrameworkListener(this);
- ServiceRegistration sreg = context.registerService(String.class.getName(), new SimpleServiceFactory(context), null);
+ SimpleServiceFactory factory = new SimpleServiceFactory(context);
+ ServiceRegistration sreg = context.registerService(OBJCLASS, factory, null);
ServiceReference sref = sreg.getReference();
Object actual = context.getService(sref);
- assertNull("" + actual, actual);
+ assertNull("Service null", actual);
+ assertFalse(context.ungetService(sref));
+ assertEquals("ungetService() not called", 0, factory.ungetCount);
assertFrameworkEvent(FrameworkEvent.ERROR, bundle, ServiceException.class);
- sreg = context.registerService(OBJCLASSES, new SimpleServiceFactory(context), null);
+ factory = new SimpleServiceFactory(context);
+ sreg = context.registerService(OBJCLASSES, factory, null);
sref = sreg.getReference();
actual = context.getService(sref);
- assertNull("" + actual, actual);
+ assertNull("Service null", actual);
+ assertFalse(context.ungetService(sref));
+ assertEquals("ungetService() not called", 0, factory.ungetCount);
assertFrameworkEvent(FrameworkEvent.ERROR, bundle, ServiceException.class);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java 2010-03-23 11:25:18 UTC (rev 102772)
@@ -33,7 +33,7 @@
*/
public class SimpleServiceFactory implements ServiceFactory
{
- public Object service;
+ Object service;
public Bundle getBundle;
public int getCount;
@@ -55,11 +55,11 @@
return service;
}
- public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object unget)
{
ungetBundle = bundle;
ungetRegistration = registration;
- ungetService = service;
+ ungetService = unget;
ungetCount++;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContext.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContext.java 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiControllerContext.java 2010-03-23 11:25:18 UTC (rev 102772)
@@ -57,17 +57,29 @@
// The reason is that the OSGi {@link ServiceFactory} getService() method
// is called with a {@link ServiceReference} that expects the given tracker
// (i.e. the using bundle) already be included in getUsingBundles.
-
+
if (tracker != null)
{
ContextTracker myTracker = getContextTracker();
if (myTracker != null && myTracker != tracker)
myTracker.incrementUsedBy(this, tracker);
-
+
tracker.incrementUsedBy(this, tracker);
}
+
+ // Get the service object
+ Object result = getTargetForActualUser(tracker);
- Object result = getTargetForActualUser(tracker);
+ // In case the ServiceFactory.getService() returns null decrement the usage count again
+ if (result == null)
+ {
+ ContextTracker myTracker = getContextTracker();
+ if (myTracker != null && myTracker != tracker)
+ myTracker.decrementUsedBy(this, tracker);
+
+ tracker.decrementUsedBy(this, tracker);
+ }
+
return result;
}
@@ -81,7 +93,7 @@
// The reason is that the OSGi {@link ServiceFactory} ungetService() method
// is called with a {@link ServiceReference} that expects the given tracker
// (i.e. the using bundle) already be included in getUsingBundles.
-
+
Object result = ungetTargetForActualUser(tracker);
if (tracker != null)
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-03-23 10:59:55 UTC (rev 102771)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-03-23 11:25:18 UTC (rev 102772)
@@ -377,7 +377,6 @@
if (service == null)
{
ServiceFactory serviceFactory = (ServiceFactory)serviceOrFactory;
- boolean gotService = false;
// If the service object returned by the ServiceFactory object is not an instanceof all the classes named when
// the service was registered or the ServiceFactory object throws an exception, null is returned and a Framework
@@ -385,22 +384,26 @@
try
{
service = serviceFactory.getService(bundleState.getBundle(), getRegistration());
- gotService = true;
-
+ }
+ catch (Throwable t)
+ {
+ String msg = "Cannot get service from: " + serviceFactory;
+ ServiceException serviceException = new ServiceException(msg, ServiceException.FACTORY_EXCEPTION, t);
+ log.error("Exception in ServiceFactory.getService()", serviceException);
+ FrameworkEventsPlugin plugin = bundleState.getBundleManager().getPlugin(FrameworkEventsPlugin.class);
+ plugin.fireFrameworkEvent(bundleState, FrameworkEvent.ERROR, serviceException);
+ return null;
+ }
+ try
+ {
service = checkObjClass(service);
serviceCache.put(bundleState, service);
}
catch (Throwable t)
{
- Throwable cause = t;
- String message = "Cannot get service from: " + serviceFactory;
- if (gotService == true)
- {
- message += "." + t.getMessage();
- cause = null;
- }
- ServiceException serviceException = new ServiceException(message, cause);
- log.error("Cannot getService from ServiceFactory", serviceException);
+ String msg = "Cannot get service from: " + serviceFactory;
+ ServiceException serviceException = new ServiceException(msg, ServiceException.FACTORY_ERROR);
+ log.error("Invalid type from ServiceFactory.getService()", serviceException);
FrameworkEventsPlugin plugin = bundleState.getBundleManager().getPlugin(FrameworkEventsPlugin.class);
plugin.fireFrameworkEvent(bundleState, FrameworkEvent.ERROR, serviceException);
return null;
14 years, 3 months
JBoss-OSGI SVN: r102763 - projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-23 02:34:45 -0400 (Tue, 23 Mar 2010)
New Revision: 102763
Modified:
projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
Log:
Expand Bundle-ClassPath test case.
Allow sigle framework tests to run on felix/equinox
Modified: projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
===================================================================
--- projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java 2010-03-23 06:34:09 UTC (rev 102762)
+++ projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java 2010-03-23 06:34:45 UTC (rev 102763)
@@ -23,7 +23,6 @@
// $Id$
-import java.io.IOException;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
14 years, 3 months
JBoss-OSGI SVN: r102762 - in projects/jboss-osgi/projects: deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-23 02:34:09 -0400 (Tue, 23 Mar 2010)
New Revision: 102762
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium-equinox.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/equinox-debug.properties
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-equinox.properties
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-felix.properties
Modified:
projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
Log:
Expand Bundle-ClassPath test case.
Allow sigle framework tests to run on felix/equinox
Modified: projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
===================================================================
--- projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/deployers/trunk/vfs21/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java 2010-03-23 06:34:09 UTC (rev 102762)
@@ -53,13 +53,7 @@
setRelativeOrder(500);
}
- /**
- * Determine the structure of a bundle deployment
- *
- * @param context the structure context
- * @return true when it recognised the context
- * @throws DeploymentException for an error
- */
+ @Override
public boolean determineStructure(StructureContext structureContext) throws DeploymentException
{
ContextInfo context = null;
@@ -91,33 +85,35 @@
}
else
{
- String[] classPathArr = classPath.split("[,\\s]");
+ String[] classPathArr = classPath.split(",");
for (String path : classPathArr)
{
- if (path.equals("."))
+ path = path.trim();
+ if (path.length() > 0)
{
- // Add the root
- addClassPath(structureContext, root, true, false, context);
- }
- else
- {
- // [TODO] publish a Framework Event of type INFO
- // [TODO] locate the class path entry in attached fragments
- try
+ // The Framework must ignore any unrecognized parameters
+ int semicolon = path.indexOf(';');
+ if (semicolon > 0)
+ path = path.substring(0, semicolon);
+
+ if (path.equals("."))
{
+ // Add the root
+ addClassPath(structureContext, root, true, false, context);
+ }
+ else
+ {
+ // [TODO] publish a Framework Event of type INFO
+ // [TODO] locate the class path entry in attached fragments
VirtualFile child = root.getChild(path);
addClassPath(structureContext, child, true, false, context);
}
- catch (IOException ex)
- {
- log.info("Cannot find class path '" + path + "' in: " + root);
- }
}
}
}
-
+
// We don't process children as potential subdeployments
-
+
return true;
}
catch (Exception e)
Modified: projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java
===================================================================
--- projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/deployers/trunk/vfs30/src/main/java/org/jboss/osgi/deployer/BundleStructureDeployer.java 2010-03-23 06:34:09 UTC (rev 102762)
@@ -85,21 +85,30 @@
}
else
{
- String[] classPathArr = classPath.split("[,\\s]");
+ String[] classPathArr = classPath.split(",");
for (String path : classPathArr)
{
- if (path.equals("."))
+ path = path.trim();
+ if (path.length() > 0)
{
- // Add the root
- addClassPath(structureContext, root, true, false, context);
+ // The Framework must ignore any unrecognized parameters
+ int semicolon = path.indexOf(';');
+ if (semicolon > 0)
+ path = path.substring(0, semicolon);
+
+ if (path.equals("."))
+ {
+ // Add the root
+ addClassPath(structureContext, root, true, false, context);
+ }
+ else
+ {
+ // [TODO] publish a Framework Event of type INFO
+ // [TODO] locate the class path entry in attached fragments
+ VirtualFile child = root.getChild(path);
+ addClassPath(structureContext, child, true, false, context);
+ }
}
- else
- {
- // [TODO] publish a Framework Event of type INFO
- // [TODO] locate the class path entry in attached fragments
- VirtualFile child = root.getChild(path);
- addClassPath(structureContext, child, true, false, context);
- }
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/pom.xml 2010-03-23 06:34:09 UTC (rev 102762)
@@ -32,16 +32,18 @@
<version>1.0.0.Alpha4-SNAPSHOT</version>
</parent>
+ <!-- Properties -->
+ <properties>
+ <surefire.jpda.args></surefire.jpda.args>
+ <surefire.system.args>-Xmx512m ${surefire.jpda.args}</surefire.system.args>
+ </properties>
+
+ <!-- Dependencies -->
<dependencies>
<dependency>
<groupId>biz.aQute</groupId>
<artifactId>bnd</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-core</artifactId>
- <version>${version}</version>
- </dependency>
<!-- Test bundles dependencies -->
<dependency>
@@ -167,12 +169,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-vfs30</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-log4j</artifactId>
<scope>test</scope>
@@ -237,7 +233,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Xmx512m</argLine>
+ <argLine>${surefire.system.args}</argLine>
<systemProperties>
<property>
<name>log4j.output.dir</name>
@@ -266,6 +262,7 @@
</build>
<profiles>
+
<!--
Name: all
Desc: Build the aggregated framework jar
@@ -298,5 +295,179 @@
</plugins>
</build>
</profile>
+
+ <!--
+ Name: framework-equinox
+ Descr: Setup for Equinox framework integration testing
+ -->
+ <profile>
+ <id>framework-equinox</id>
+ <activation>
+ <property>
+ <name>fmwk</name>
+ <value>equinox</value>
+ </property>
+ </activation>
+ <properties>
+ <jboss.osgi.framework.properties>jboss-osgi-equinox.properties</jboss.osgi.framework.properties>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.equinox</groupId>
+ <artifactId>jboss-osgi-equinox</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs30</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>compendium</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ <configuration>
+ <finalName>test-libs</finalName>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>scripts/assembly-compendium-equinox.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
+ Name: framework-felix
+ Descr: Setup for Felix framework integration testing
+ -->
+ <profile>
+ <id>framework-felix</id>
+ <activation>
+ <property>
+ <name>fmwk</name>
+ <value>felix</value>
+ </property>
+ </activation>
+ <properties>
+ <jboss.osgi.framework.properties>jboss-osgi-felix.properties</jboss.osgi.framework.properties>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.felix</groupId>
+ <artifactId>jboss-osgi-felix</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs30</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>compendium</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ <configuration>
+ <finalName>test-libs</finalName>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>scripts/assembly-compendium.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
+ Name: framework-native
+ Descr: Setup for Native Framework integration testing
+ -->
+ <profile>
+ <id>framework-jbossmc-default</id>
+ <activation>
+ <property>
+ <name>!fmwk</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-core</artifactId>
+ <version>${version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs30</artifactId>
+ <version>${version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>compendium</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ <configuration>
+ <finalName>test-libs</finalName>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>scripts/assembly-compendium.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!--
+ Name: jpda
+ Descr: Enable JPDA remote debuging
+ -->
+ <profile>
+ <id>jpda</id>
+ <activation>
+ <property>
+ <name>jpda</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.jpda.args>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</surefire.jpda.args>
+ </properties>
+ </profile>
+
</profiles>
</project>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml 2010-03-23 06:34:09 UTC (rev 102762)
@@ -43,15 +43,31 @@
<!-- Please add alphabetically -->
<!-- bundle-classpath -->
+ <jar destfile="${tests.output.dir}/test-libs/bundle-classpath-b.jar">
+ <fileset dir="${tests.classes.dir}">
+ <include name="**/classloader/support/b/B.class"/>
+ </fileset>
+ </jar>
+ <jar destfile="${tests.output.dir}/test-libs/bundle-classpath-c.jar">
+ <fileset dir="${tests.classes.dir}">
+ <include name="**/classloader/support/c/CA.class"/>
+ </fileset>
+ </jar>
<war destfile="${tests.output.dir}/test-libs/bundle-classpath.war"
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="**/classloader/support/a/A.class"/>
</classes>
+ <lib dir="${tests.output.dir}/test-libs">
+ <include name="bundle-classpath-b.jar"/>
+ </lib>
<fileset dir="${tests.resources.dir}/bundles/classloader/bundleclasspath">
<include name="message.txt"/>
</fileset>
+ <fileset dir="${tests.output.dir}/test-libs">
+ <include name="bundle-classpath-c.jar"/>
+ </fileset>
</war>
<!-- fragments/simple -->
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-bundles.xml 2010-03-23 06:34:09 UTC (rev 102762)
@@ -15,17 +15,6 @@
<outputDirectory>bundles</outputDirectory>
<outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>*:org.osgi.compendium:jar</include>
- <include>*:org.osgi.core:jar</include>
- </includes>
- <useStrictFiltering>true</useStrictFiltering>
- <scope>compile</scope>
- <unpack>false</unpack>
- </dependencySet>
- <dependencySet>
- <outputDirectory>bundles</outputDirectory>
- <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
<include>*:jboss-osgi-apache-xerces:jar</include>
<include>*:jboss-osgi-common:jar</include>
<include>*:jboss-osgi-common-core:jar</include>
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium-equinox.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium-equinox.xml (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium-equinox.xml 2010-03-23 06:34:09 UTC (rev 102762)
@@ -0,0 +1,26 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <!-- Dependency Sets -->
+ <dependencySets>
+
+ <!-- bundles -->
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>org.eclipse.equinox:org.eclipse.osgi.services:jar</include>
+ <include>org.eclipse.equinox:org.eclipse.osgi.util:jar</include>
+ </includes>
+ <useStrictFiltering>false</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+
+ </dependencySets>
+</assembly>
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium.xml (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/assembly-compendium.xml 2010-03-23 06:34:09 UTC (rev 102762)
@@ -0,0 +1,26 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+ <id>compendium</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <!-- Dependency Sets -->
+ <dependencySets>
+
+ <!-- bundles -->
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>org.osgi:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>false</useStrictFiltering>
+ <scope>provided</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+
+ </dependencySets>
+</assembly>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java 2010-03-23 06:34:09 UTC (rev 102762)
@@ -22,13 +22,15 @@
package org.jboss.test.osgi.classloader;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import java.net.URL;
+
import org.jboss.osgi.testing.OSGiFrameworkTest;
import org.jboss.test.osgi.classloader.support.a.A;
+import org.jboss.test.osgi.classloader.support.b.B;
+import org.jboss.test.osgi.classloader.support.c.CA;
import org.junit.Test;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
/**
* BundleClassPathTest.
@@ -41,14 +43,15 @@
@Test
public void testBundleClassPath() throws Exception
{
- BundleContext sysContext = framework.getBundleContext();
- Bundle bundle = sysContext.installBundle(getTestArchivePath("bundle-classpath.war"));
+ URL bundleURL = getTestArchiveURL("bundle-classpath.war");
+ Bundle bundle = context.installBundle(bundleURL.toExternalForm());
bundle.start();
assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
- Class<?> clazz = bundle.loadClass(A.class.getName());
- assertNotNull("Loaded class", clazz);
+ assertLoadClass(bundle, A.class.getName(), bundle);
+ assertLoadClass(bundle, B.class.getName(), bundle);
+ assertLoadClass(bundle, CA.class.getName(), bundle);
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/CA.java 2010-03-23 06:34:09 UTC (rev 102762)
@@ -26,7 +26,7 @@
/**
* CA.
*
- * @authorthomas.diesler(a)jboss.com
+ * @author thomas.diesler(a)jboss.com
* @version $Revision$
*/
public class CA
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF 2010-03-23 06:34:09 UTC (rev 102762)
@@ -1,5 +1,4 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bundle-classpath
-Bundle-ClassPath: .,WEB-INF/classes
-
+Bundle-ClassPath: .,bundle-classpath-c.jar,WEB-INF/classes,WEB-INF/lib/bundle-classpath-b.jar
\ No newline at end of file
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/equinox-debug.properties
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/equinox-debug.properties (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/equinox-debug.properties 2010-03-23 06:34:09 UTC (rev 102762)
@@ -0,0 +1,9 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id: equinox-debug.properties 96951 2009-11-25 14:28:07Z thomas.diesler(a)jboss.com $
+#
+
+# Equinox debug properties
+org.eclipse.osgi/debug=true
+org.eclipse.osgi/debug/loader=true
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-equinox.properties
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-equinox.properties (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-equinox.properties 2010-03-23 06:34:09 UTC (rev 102762)
@@ -0,0 +1,32 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id: jboss-osgi-equinox.properties 102237 2010-03-10 17:16:48Z thomas.diesler(a)jboss.com $
+#
+
+# Equinox properties
+osgi.debug=target/test-classes/equinox-debug.properties
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${basedir}/target/osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=\
+ org.apache.log4j;version=1.2, \
+ org.jboss.logging;version=2.1, \
+ org.jboss.net.protocol, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
+ org.jboss.osgi.deployment.interceptor;version=1.0, \
+ org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.capability;version=1.0, \
+ org.jboss.osgi.spi.framework;version=1.0, \
+ org.jboss.osgi.spi.management;version=1.0, \
+ org.jboss.osgi.spi.service;version=1.0, \
+ org.jboss.osgi.spi.util;version=1.0, \
+ org.jboss.osgi.testing;version=1.0, \
+ org.jboss.osgi.vfs;version=1.0, \
+ org.jboss.vfs;version=3.0, \
+ org.osgi.framework;version=1.5
+
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-felix.properties (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/jboss-osgi-felix.properties 2010-03-23 06:34:09 UTC (rev 102762)
@@ -0,0 +1,35 @@
+#
+# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+#
+# $Id: jboss-osgi-felix.properties 102237 2010-03-10 17:16:48Z thomas.diesler(a)jboss.com $
+#
+
+# Felix config properties
+felix.bootdelegation.implicit=false
+
+# Properties to configure the Framework
+org.osgi.framework.storage=${basedir}/target/osgi-store
+org.osgi.framework.storage.clean=onFirstInit
+
+# Framework bootdelegation
+org.osgi.framework.bootdelegation=sun.reflect
+
+# Extra System Packages
+org.osgi.framework.system.packages.extra=\
+ org.apache.log4j;version=1.2, \
+ org.jboss.logging;version=2.1, \
+ org.jboss.net.protocol, \
+ org.jboss.osgi.deployment.common;version=1.0, \
+ org.jboss.osgi.deployment.deployer;version=1.0, \
+ org.jboss.osgi.deployment.interceptor;version=1.0, \
+ org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.capability;version=1.0, \
+ org.jboss.osgi.spi.framework;version=1.0, \
+ org.jboss.osgi.spi.management;version=1.0, \
+ org.jboss.osgi.spi.service;version=1.0, \
+ org.jboss.osgi.spi.util;version=1.0, \
+ org.jboss.osgi.testing;version=1.0, \
+ org.jboss.osgi.vfs;version=1.0, \
+ org.jboss.vfs;version=3.0, \
+ org.osgi.framework;version=1.5
+
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-23 06:05:22 UTC (rev 102761)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-23 06:34:09 UTC (rev 102762)
@@ -65,6 +65,8 @@
<version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>
<version.jboss.osgi.deployers>1.0.5-SNAPSHOT</version.jboss.osgi.deployers>
<version.jboss.osgi.deployment>1.0.2-SNAPSHOT</version.jboss.osgi.deployment>
+ <version.jboss.osgi.equinox>3.5.2-SNAPSHOT</version.jboss.osgi.equinox>
+ <version.jboss.osgi.felix>2.0.4-SNAPSHOT</version.jboss.osgi.felix>
<version.jboss.osgi.husky>1.0.4-SNAPSHOT</version.jboss.osgi.husky>
<version.jboss.osgi.jaxb>2.1.10.SP3</version.jboss.osgi.jaxb>
<version.jboss.osgi.jmx>1.0.4-SNAPSHOT</version.jboss.osgi.jmx>
@@ -148,6 +150,16 @@
<artifactId>jboss-osgi-deployment</artifactId>
<version>${version.jboss.osgi.deployment}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.equinox</groupId>
+ <artifactId>jboss-osgi-equinox</artifactId>
+ <version>${version.jboss.osgi.equinox}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.felix</groupId>
+ <artifactId>jboss-osgi-felix</artifactId>
+ <version>${version.jboss.osgi.felix}</version>
+ </dependency>
<!-- OSGi Dependencies -->
<dependency>
14 years, 3 months
JBoss-OSGI SVN: r102752 - in projects/jboss-osgi/projects/runtime/framework/trunk: bundle/src/test/java/org/jboss/test/osgi/classloader and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-23 00:19:34 -0400 (Tue, 23 Mar 2010)
New Revision: 102752
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.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/AbstractResolverTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
Log:
REmove dependency on OSGiRuntimeTest
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -24,14 +24,11 @@
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.OSGiRuntimeTest;
+import org.jboss.osgi.testing.OSGiFrameworkTest;
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.
@@ -39,15 +36,11 @@
* @author thomas.diesler(a)jboss.com
* @since 07-Oct-2009
*/
-public class BundleClassPathTestCase extends OSGiRuntimeTest
+public class BundleClassPathTestCase extends OSGiFrameworkTest
{
@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"));
@@ -59,7 +52,5 @@
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
-
- framework.stop();
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -27,17 +27,12 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
-import org.jboss.osgi.spi.util.ServiceLoader;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
+import org.jboss.osgi.testing.OSGiFrameworkTest;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
/**
* A test that deployes a bundle and verifies its state
@@ -45,7 +40,7 @@
* @author thomas.diesler(a)jboss.com
* @since 18-Aug-2009
*/
-public class SimpleLogServiceTestCase extends OSGiRuntimeTest
+public class SimpleLogServiceTestCase extends OSGiFrameworkTest
{
@Before
public void setUp()
@@ -56,13 +51,7 @@
@Test
public void testNoLogService() throws Exception
{
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- Framework framework = factory.newFramework(null);
- framework.start();
-
- BundleContext sysContext = framework.getBundleContext();
- Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
-
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
try
{
bundle.start();
@@ -72,89 +61,111 @@
{
// expected
}
-
- framework.stop();
+ finally
+ {
+ bundle.uninstall();
+ }
}
@Test
public void testLogServiceFromThirdParty() throws Exception
{
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- Framework framework = factory.newFramework(null);
- framework.start();
-
- BundleContext sysContext = framework.getBundleContext();
- sysContext.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar")).start();
-
- Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ Bundle logBundle = context.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar"));
try
{
- bundle.start();
+ logBundle.start();
+
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ try
+ {
+ bundle.start();
+ fail("Expected UNRESOLVED OSGiPackageRequirement{org.osgi.util.tracker [0.0.0,?)}");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
}
- catch (BundleException ex)
+ finally
{
- // Expected UNRESOLVED OSGiPackageRequirement{org.osgi.util.tracker [0.0.0,?)} with MC Framework
+ logBundle.uninstall();
}
-
- assumeTrue(bundle.getState() == Bundle.ACTIVE);
-
- // The bundle activator is expected to set this property
- String result = System.getProperty(bundle.getSymbolicName());
- assertNotNull("Result property not null", result);
-
- assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
- assertFalse("getService", result.indexOf("getService") > 0);
- assertFalse("addingService", result.indexOf("addingService") > 0);
-
- framework.stop();
}
@Test
public void testLogServiceFromCompendium() throws Exception
{
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- Framework framework = factory.newFramework(null);
- framework.start();
+ Bundle cmpnBundle = context.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ try
+ {
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
- BundleContext sysContext = framework.getBundleContext();
- sysContext.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
- Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
- bundle.start();
-
- // The bundle activator is expected to set this property
- String result = System.getProperty(bundle.getSymbolicName());
- assertNotNull("Result property not null", result);
-
- assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
- assertFalse("getService", result.indexOf("getService") > 0);
- assertFalse("addingService", result.indexOf("addingService") > 0);
-
- framework.stop();
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+ assertFalse("getService", result.indexOf("getService") > 0);
+ assertFalse("addingService", result.indexOf("addingService") > 0);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ cmpnBundle.uninstall();
+ }
}
@Test
public void testLogServiceFromTwoExporters() throws Exception
{
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- Framework framework = factory.newFramework(null);
- framework.start();
+ Bundle cmpnBundle = context.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ try
+ {
+ Bundle logBundle = context.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar"));
+ try
+ {
+ logBundle.start();
- BundleContext sysContext = framework.getBundleContext();
- sysContext.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar")).start();
- sysContext.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar")).start();
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
- Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
- bundle.start();
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
- // The bundle activator is expected to set this property
- String result = System.getProperty(bundle.getSymbolicName());
- assertNotNull("Result property not null", result);
-
- assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
- assertTrue("getService", result.indexOf("getService") > 0);
- assertTrue("addingService", result.indexOf("addingService") > 0);
-
- framework.stop();
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+ assertTrue("getService", result.indexOf("getService") > 0);
+ assertTrue("addingService", result.indexOf("addingService") > 0);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ logBundle.uninstall();
+ }
+ }
+ finally
+ {
+ cmpnBundle.uninstall();
+ }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -23,15 +23,10 @@
//$Id: FragmentTestCase.java 99648 2010-01-20 09:27:43Z thomas.diesler(a)jboss.com $
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.jboss.osgi.testing.OSGiFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.launch.Framework;
/**
* Test NativeCode-Library functionality
@@ -39,28 +34,8 @@
* @author thomas.diesler(a)jboss.com
* @since 21-Jan-2010
*/
-public class NativeCodeTestCase extends OSGiRuntimeTest
+public class NativeCodeTestCase extends OSGiFrameworkTest
{
- private static Framework framework;
-
- @BeforeClass
- public static void beforeClass() throws Exception
- {
- OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
- framework = bootProvider.getFramework();
- framework.start();
- }
-
- @AfterClass
- public static void afterClass() throws Exception
- {
- if (framework != null)
- {
- framework.stop();
- framework = null;
- }
- }
-
@Test
public void testNativeCode() throws Exception
{
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-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -47,13 +47,13 @@
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -86,7 +86,7 @@
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -112,13 +112,13 @@
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Only resolve BundleB
@@ -155,7 +155,7 @@
// Export-Package: org.jboss.test.osgi.classloader.support.a
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/selfimport", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -181,13 +181,13 @@
//Bundle-SymbolicName: packageimportversion
//Import-Package: org.jboss.test.osgi.classloader.support.a;version="[0.0.0,1.0.0]"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageimportversion");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: packageexportversion100
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/packageexportversion100", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -220,13 +220,13 @@
//Bundle-SymbolicName: packageimportversionfails
//Import-Package: org.jboss.test.osgi.classloader.support.a;version="[3.0,4.0)"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageimportversionfails");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: packageexportversion100
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/packageexportversion100", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -259,7 +259,7 @@
//Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageimportoptional");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -285,13 +285,13 @@
//Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageimportoptional");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -324,7 +324,7 @@
//Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageimportoptional");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -335,7 +335,7 @@
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -368,13 +368,13 @@
//Bundle-SymbolicName: bundlenameimport
//Import-Package: org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/bundlenameimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: simpleexport
//Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -407,13 +407,13 @@
//Bundle-SymbolicName: bundlenameimport
//Import-Package: org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/bundlenameimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: sigleton;singleton:=true
//Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/singleton", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -446,13 +446,13 @@
//Bundle-SymbolicName: bundleversionimport
//Import-Package: org.jboss.test.osgi.classloader.support.a;bundle-version="[0.0.0,1.0.0)"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/bundleversionimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -485,13 +485,13 @@
//Bundle-SymbolicName: bundleversionimportfails
//Import-Package: org.jboss.test.osgi.classloader.support.a;bundle-version="[1.0.0,2.0.0)"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/bundleversionimportfails");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -526,13 +526,13 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundle");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -565,7 +565,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundle");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -591,7 +591,7 @@
//Bundle-SymbolicName: requirebundleoptional
//Require-Bundle: simpleexport;resolution:=optional
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleoptional");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -614,13 +614,13 @@
//Bundle-SymbolicName: requirebundleversion
//Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleversion");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -653,13 +653,13 @@
//Bundle-SymbolicName: versionrequirebundlefails
//Require-Bundle: simpleexport;bundle-version="[1.0.0,2.0.0)"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleversionfails");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -701,7 +701,7 @@
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileC = assembleArchive("bundleC", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
@@ -712,10 +712,10 @@
// Verify bundle states
assertEquals("BundleA RESOLVED", Bundle.RESOLVED, bundleA.getState());
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
- Bundle bundleC = framework.installBundle(fileC);
+ Bundle bundleC = installBundle(fileC);
try
{
allResolved = packageAdmin.resolveBundles(null);
@@ -761,7 +761,7 @@
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileC = assembleArchive("bundleC", "/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -772,10 +772,10 @@
// Verify bundle states
assertEquals("BundleB RESOLVED", Bundle.RESOLVED, bundleB.getState());
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
- Bundle bundleC = framework.installBundle(fileC);
+ Bundle bundleC = installBundle(fileC);
try
{
allResolved = packageAdmin.resolveBundles(null);
@@ -821,13 +821,13 @@
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileC = assembleArchive("bundleC", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
- Bundle bundleC = framework.installBundle(fileC);
+ Bundle bundleC = installBundle(fileC);
try
{
// Resolve the installed bundles
@@ -876,13 +876,13 @@
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileC = assembleArchive("bundleC", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
- Bundle bundleC = framework.installBundle(fileC);
+ Bundle bundleC = installBundle(fileC);
try
{
// Resolve the installed bundles
@@ -931,10 +931,10 @@
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileC = assembleArchive("bundleC", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -946,7 +946,7 @@
assertEquals("BundleA RESOLVED", Bundle.RESOLVED, bundleA.getState());
assertEquals("BundleB RESOLVED", Bundle.RESOLVED, bundleB.getState());
- Bundle bundleC = framework.installBundle(fileC);
+ Bundle bundleC = installBundle(fileC);
try
{
allResolved = packageAdmin.resolveBundles(null);
@@ -991,10 +991,10 @@
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileC = assembleArchive("bundleC", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -1006,7 +1006,7 @@
assertEquals("BundleA RESOLVED", Bundle.RESOLVED, bundleA.getState());
assertEquals("BundleB RESOLVED", Bundle.RESOLVED, bundleB.getState());
- Bundle bundleC = framework.installBundle(fileC);
+ Bundle bundleC = installBundle(fileC);
try
{
allResolved = packageAdmin.resolveBundles(null);
@@ -1042,13 +1042,13 @@
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattribute", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -1072,7 +1072,7 @@
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattribute");
- bundleB = framework.installBundle(fileB);
+ bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -1105,13 +1105,13 @@
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattribute", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: packageimportattributefails
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattributefails");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -1144,13 +1144,13 @@
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattributemandatory", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattribute");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -1183,13 +1183,13 @@
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattributemandatory", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
// Resolve the installed bundles
@@ -1222,7 +1222,7 @@
//Bundle-SymbolicName: systempackageimport
//Import-Package: org.osgi.framework;version=1.4
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/systempackageimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
// Resolve the installed bundles
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -27,20 +27,13 @@
import static org.junit.Assert.fail;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.launch.OSGiFramework;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.osgi.framework.plugins.Plugin;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.Resolver;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.junit.AfterClass;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
import org.osgi.service.packageadmin.PackageAdmin;
/**
@@ -49,28 +42,8 @@
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
*/
-public abstract class AbstractResolverTest extends OSGiRuntimeTest
+public abstract class AbstractResolverTest extends AbstractFrameworkTest
{
- protected static OSGiFramework framework;
-
- @BeforeClass
- public static void beforeClass() throws BundleException
- {
- OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
- framework = (OSGiFramework)bootProvider.getFramework();
- framework.start();
- }
-
- @AfterClass
- public static void afterClass() throws BundleException
- {
- if (framework != null)
- {
- framework.stop();
- framework = null;
- }
- }
-
@Before
public void setUp() throws Exception
{
@@ -78,7 +51,7 @@
Resolver testResolver = getTestResolver();
if (installedResolver != testResolver)
{
- OSGiBundleManager bundleManager = framework.getBundleManager();
+ OSGiBundleManager bundleManager = getBundleManager();
if (installedResolver != null)
bundleManager.removePlugin((Plugin)installedResolver);
if (testResolver != null)
@@ -94,22 +67,16 @@
protected Resolver getInstalledResolver()
{
- OSGiBundleManager bundleManager = framework.getBundleManager();
+ OSGiBundleManager bundleManager = getBundleManager();
return bundleManager.getOptionalPlugin(ResolverPlugin.class);
}
protected PackageAdmin getPackageAdmin()
{
- OSGiBundleManager bundleManager = framework.getBundleManager();
+ OSGiBundleManager bundleManager = getBundleManager();
return bundleManager.getPlugin(PackageAdminPlugin.class);
}
- protected BundleContext getSystemContext()
- {
- BundleContext sysContext = framework.getBundleContext();
- return sysContext;
- }
-
protected void assertLoaderBundle(Bundle expLoader, Bundle srcLoader, Class<?> clazz) throws ClassNotFoundException
{
Class<?> classA = srcLoader.loadClass(clazz.getName());
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTestCase.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/BasicResolverTestCase.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -42,7 +42,7 @@
Resolver resolver = getInstalledResolver();
if (resolver == null || resolver.getClass() != BasicResolverImpl.class)
{
- OSGiBundleManager bundleManager = framework.getBundleManager();
+ OSGiBundleManager bundleManager = getBundleManager();
resolver = new BasicResolverImpl(bundleManager);
resolver.addBundle(bundleManager.getSystemBundle());
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -61,7 +61,7 @@
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleexport", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
assertEquals(1, resolver.getBundles().size());
@@ -116,7 +116,7 @@
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -149,7 +149,7 @@
// Bundle-SymbolicName: singleton;singleton:=true
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/singleton", A.class);
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -171,7 +171,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundle");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -198,7 +198,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport;resolution:=optional
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleoptional");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -225,7 +225,7 @@
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleversion");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -252,7 +252,7 @@
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattribute");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -264,7 +264,7 @@
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
@@ -279,7 +279,7 @@
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattribute");
- bundleB = framework.installBundle(fileB);
+ bundleB = installBundle(fileB);
try
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
@@ -310,7 +310,7 @@
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattribute");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -322,7 +322,7 @@
//Bundle-SymbolicName: packageimportattributefails
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattributefails");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
@@ -353,7 +353,7 @@
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattributemandatory");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -367,7 +367,7 @@
//Bundle-SymbolicName: packageimportattribute
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattribute");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
@@ -398,7 +398,7 @@
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattributemandatory");
- Bundle bundleA = framework.installBundle(fileA);
+ Bundle bundleA = installBundle(fileA);
try
{
ResolverBundle resBundleA = resolver.getBundle(bundleA);
@@ -412,7 +412,7 @@
//Bundle-SymbolicName: simpleimport
//Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileB = assembleArchive("bundleB", "/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
+ Bundle bundleB = installBundle(fileB);
try
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
@@ -427,7 +427,7 @@
//Bundle-SymbolicName: packageimportattributefails
//Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
fileB = assembleArchive("bundleB", "/bundles/resolver/packageimportattributefails");
- bundleB = framework.installBundle(fileB);
+ bundleB = installBundle(fileB);
try
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java 2010-03-23 04:19:34 UTC (rev 102752)
@@ -30,16 +30,12 @@
import java.util.List;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.launch.OSGiFramework;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.framework.resolver.ResolverBundle;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
+import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
/**
@@ -48,62 +44,50 @@
* @author thomas.diesler(a)jboss.com
* @since 27-Jul-2009
*/
-public class ResolverSmokeTestCase extends OSGiRuntimeTest
+public class ResolverSmokeTestCase extends AbstractFrameworkTest
{
@Test
public void testRandomBundleResolution() throws BundleException
{
- OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
- OSGiFramework framework = (OSGiFramework)bootProvider.getFramework();
- framework.start();
+ List<String> bundlePaths = new ArrayList<String>();
+ bundlePaths.add("bundles/jboss-osgi-apache-xerces.jar");
+ bundlePaths.add("bundles/jboss-osgi-common.jar");
+ bundlePaths.add("bundles/jboss-osgi-common-core.jar");
+ bundlePaths.add("bundles/jboss-osgi-husky.jar");
+ bundlePaths.add("bundles/jboss-osgi-jaxb.jar");
+ bundlePaths.add("bundles/jboss-osgi-jmx.jar");
+ bundlePaths.add("bundles/jboss-osgi-jndi.jar");
+ bundlePaths.add("bundles/jboss-osgi-reflect.jar");
+ bundlePaths.add("bundles/jboss-osgi-xml-binding.jar");
+ bundlePaths.add("bundles/org.apache.felix.configadmin.jar");
+ bundlePaths.add("bundles/org.apache.felix.log.jar");
+ bundlePaths.add("bundles/org.apache.felix.metatype.jar");
+ bundlePaths.add("bundles/org.osgi.compendium.jar");
+ bundlePaths.add("bundles/pax-web-jetty-bundle.jar");
- try
+ Collections.shuffle(bundlePaths);
+
+ List<Bundle> unresolved = new ArrayList<Bundle>();
+ for (String path : bundlePaths)
{
- List<String> bundlePaths = new ArrayList<String>();
- bundlePaths.add("bundles/jboss-osgi-apache-xerces.jar");
- bundlePaths.add("bundles/jboss-osgi-common.jar");
- bundlePaths.add("bundles/jboss-osgi-common-core.jar");
- bundlePaths.add("bundles/jboss-osgi-husky.jar");
- bundlePaths.add("bundles/jboss-osgi-jaxb.jar");
- bundlePaths.add("bundles/jboss-osgi-jmx.jar");
- bundlePaths.add("bundles/jboss-osgi-jndi.jar");
- bundlePaths.add("bundles/jboss-osgi-reflect.jar");
- bundlePaths.add("bundles/jboss-osgi-xml-binding.jar");
- bundlePaths.add("bundles/org.apache.felix.configadmin.jar");
- bundlePaths.add("bundles/org.apache.felix.log.jar");
- bundlePaths.add("bundles/org.apache.felix.metatype.jar");
- bundlePaths.add("bundles/org.osgi.compendium.jar");
- bundlePaths.add("bundles/pax-web-jetty-bundle.jar");
+ Bundle bundle = context.installBundle(getTestArchivePath(path));
+ unresolved.add(bundle);
+ }
- Collections.shuffle(bundlePaths);
+ OSGiBundleManager bundleManager = getBundleManager();
+ Resolver resolver = bundleManager.getOptionalPlugin(ResolverPlugin.class);
+ if (resolver != null)
+ {
+ List<ResolverBundle> installedBundles = resolver.getBundles();
+ assertEquals("All bundles installed", bundlePaths.size(), installedBundles.size());
- List<Bundle> unresolved = new ArrayList<Bundle>();
- BundleContext sysContext = framework.getBundleContext();
- for (String path : bundlePaths)
- {
- Bundle bundle = sysContext.installBundle(getTestArchivePath(path));
- unresolved.add(bundle);
- }
-
- OSGiBundleManager bundleManager = framework.getBundleManager();
- Resolver resolver = bundleManager.getOptionalPlugin(ResolverPlugin.class);
- if (resolver != null)
- {
- List<ResolverBundle> installedBundles = resolver.getBundles();
- assertEquals("All bundles installed", bundlePaths.size(), installedBundles.size());
-
- List<ResolverBundle> resolved = resolver.resolve(unresolved);
- assertEquals("All bundles resolved", unresolved.size(), resolved.size());
- }
-
- System.out.println("FIXME [JBKERNEL-54] Cannot resolve circular dependencies");
- //PackageAdminPlugin packageAdmin = bundleManager.getPlugin(PackageAdminPlugin.class);
- //boolean allResolved = packageAdmin.resolveBundles(null);
- //assertTrue("All bundles resolved", allResolved);
+ List<ResolverBundle> resolved = resolver.resolve(unresolved);
+ assertEquals("All bundles resolved", unresolved.size(), resolved.size());
}
- finally
- {
- framework.stop();
- }
+
+ System.out.println("FIXME [JBKERNEL-54] Cannot resolve circular dependencies");
+ //PackageAdminPlugin packageAdmin = bundleManager.getPlugin(PackageAdminPlugin.class);
+ //boolean allResolved = packageAdmin.resolveBundles(null);
+ //assertTrue("All bundles resolved", allResolved);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-23 03:55:01 UTC (rev 102751)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-23 04:19:34 UTC (rev 102752)
@@ -44,11 +44,9 @@
<!-- Modules -->
<modules>
<module>core</module>
- <!--
<module>metadata</module>
<module>vfs21</module>
<module>vfs30</module>
- -->
<module>bundle</module>
</modules>
14 years, 3 months
JBoss-OSGI SVN: r102734 - projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-22 16:24:44 -0400 (Mon, 22 Mar 2010)
New Revision: 102734
Modified:
projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
Log:
unchecked
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java 2010-03-22 19:30:38 UTC (rev 102733)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java 2010-03-22 20:24:44 UTC (rev 102734)
@@ -181,6 +181,7 @@
}
@Test
+ @SuppressWarnings("unchecked")
public void getComponentIds() throws Exception
{
if (context == null)
@@ -200,6 +201,7 @@
}
@Test
+ @SuppressWarnings("unchecked")
public void testBeanMetadata() throws Exception
{
if (context == null)
@@ -219,6 +221,7 @@
}
@Test
+ @SuppressWarnings("unchecked")
public void testServiceMetadata() throws Exception
{
if (context == null)
@@ -251,6 +254,7 @@
}
@Test
+ @SuppressWarnings("unchecked")
public void testServiceReferenceMetadata() throws Exception
{
if (context == null)
14 years, 3 months
JBoss-OSGI SVN: r102729 - in projects/jboss-osgi: projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service and 9 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-22 14:12:49 -0400 (Mon, 22 Mar 2010)
New Revision: 102729
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFindHookTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleFrameworkTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleRuntimeTestCase.java
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/FrameworkEventsPlugin.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGi142TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi143/OSGi143TestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/services/ServiceRegistrationTestCase.java
Log:
[JBOSGI-302] Add support for service hooks
[TCK] various other service related issues
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -59,42 +59,42 @@
try
{
bundle.start();
- BundleContext bundleContext1 = bundle.getBundleContext();
- assertNotNull(bundleContext1);
+ BundleContext context1 = bundle.getBundleContext();
+ assertNotNull(context1);
- assertNoGetReference(bundleContext1, A.class.getName());
- assertNoReferences(bundleContext1, A.class.getName());
- assertNoAllReferences(bundleContext1, A.class.getName());
- assertNoGetReference(bundleContext1, B.class.getName());
- assertNoReferences(bundleContext1, B.class.getName());
- assertNoAllReferences(bundleContext1, B.class.getName());
+ assertNoGetReference(context1, A.class.getName());
+ assertNoReferences(context1, A.class.getName());
+ assertNoAllReferences(context1, A.class.getName());
+ assertNoGetReference(context1, B.class.getName());
+ assertNoReferences(context1, B.class.getName());
+ assertNoAllReferences(context1, B.class.getName());
Class<?> clazz = bundle.loadClass(A.class.getName());
Object service1 = clazz.newInstance();
- ServiceRegistration registration1 = bundleContext1.registerService(A.class.getName(), service1, null);
- assertNotNull(registration1);
- ServiceReference reference1 = registration1.getReference();
- assertNotNull(reference1);
+ ServiceRegistration sreg1 = context1.registerService(A.class.getName(), service1, null);
+ assertNotNull(sreg1);
+ ServiceReference sref1 = sreg1.getReference();
+ assertNotNull(sref1);
- assertGetReference(bundleContext1, A.class.getName(), reference1);
- assertReferences(bundleContext1, A.class.getName(), reference1);
- assertAllReferences(bundleContext1, A.class.getName(), reference1);
- assertNoGetReference(bundleContext1, B.class.getName());
- assertNoReferences(bundleContext1, B.class.getName());
- assertNoAllReferences(bundleContext1, B.class.getName());
+ assertGetReference(context1, A.class.getName(), sref1);
+ assertReferences(context1, A.class.getName(), sref1);
+ assertAllReferences(context1, A.class.getName(), sref1);
+ assertNoGetReference(context1, B.class.getName());
+ assertNoReferences(context1, B.class.getName());
+ assertNoAllReferences(context1, B.class.getName());
- registration1.unregister();
+ sreg1.unregister();
- assertNoGetReference(bundleContext1, A.class.getName());
- assertNoReferences(bundleContext1, A.class.getName());
- assertNoAllReferences(bundleContext1, A.class.getName());
- assertNoGetReference(bundleContext1, B.class.getName());
- assertNoReferences(bundleContext1, B.class.getName());
- assertNoAllReferences(bundleContext1, B.class.getName());
+ assertNoGetReference(context1, A.class.getName());
+ assertNoReferences(context1, A.class.getName());
+ assertNoAllReferences(context1, A.class.getName());
+ assertNoGetReference(context1, B.class.getName());
+ assertNoReferences(context1, B.class.getName());
+ assertNoAllReferences(context1, B.class.getName());
try
{
- bundleContext1.getServiceReference(null);
+ context1.getServiceReference(null);
fail("Should not be here!");
}
catch (IllegalArgumentException t)
@@ -104,7 +104,7 @@
try
{
- bundleContext1.getServiceReferences(null, "invalid");
+ context1.getServiceReferences(null, "invalid");
fail("Should not be here!");
}
catch (InvalidSyntaxException t)
@@ -114,7 +114,7 @@
try
{
- bundleContext1.getAllServiceReferences(null, "invalid");
+ context1.getAllServiceReferences(null, "invalid");
fail("Should not be here!");
}
catch (InvalidSyntaxException t)
@@ -126,7 +126,7 @@
try
{
- bundleContext1.getServiceReference(A.class.getName());
+ context1.getServiceReference(A.class.getName());
fail("Should not be here!");
}
catch (IllegalStateException t)
@@ -136,7 +136,7 @@
try
{
- bundleContext1.getServiceReferences(null, null);
+ context1.getServiceReferences(null, null);
fail("Should not be here!");
}
catch (IllegalStateException t)
@@ -146,7 +146,7 @@
try
{
- bundleContext1.getAllServiceReferences(null, null);
+ context1.getAllServiceReferences(null, null);
fail("Should not be here!");
}
catch (IllegalStateException t)
@@ -179,77 +179,77 @@
try
{
bundleA.start();
- BundleContext bundleContext1 = bundleA.getBundleContext();
- assertNotNull(bundleContext1);
+ BundleContext context1 = bundleA.getBundleContext();
+ assertNotNull(context1);
if (className != null)
- assertNoGetReference(bundleContext1, className);
+ assertNoGetReference(context1, className);
Class<?> clazz = bundleA.loadClass(A.class.getName());
Object service1 = clazz.newInstance();
- ServiceRegistration registration1 = bundleContext1.registerService(A.class.getName(), service1, null);
- assertNotNull(registration1);
- ServiceReference reference1 = registration1.getReference();
- assertNotNull(reference1);
+ ServiceRegistration sreg1 = context1.registerService(A.class.getName(), service1, null);
+ assertNotNull(sreg1);
+ ServiceReference sref1 = sreg1.getReference();
+ assertNotNull(sref1);
VirtualFile assemblyB = assembleArchive("simple2", "/bundles/simple/simple-bundle2", A.class);
Bundle bundleB = installBundle(assemblyB);
try
{
bundleB.start();
- BundleContext bundleContext2 = bundleB.getBundleContext();
- assertNotNull(bundleContext2);
+ BundleContext context2 = bundleB.getBundleContext();
+ assertNotNull(context2);
if (className != null)
- assertNoGetReference(bundleContext2, className);
+ assertNoGetReference(context2, className);
clazz = bundleB.loadClass(A.class.getName());
Object service2 = clazz.newInstance();
- ServiceRegistration registration2 = bundleContext2.registerService(A.class.getName(), service2, null);
- assertNotNull(registration2);
- ServiceReference reference2 = registration2.getReference();
- assertNotNull(reference2);
+ ServiceRegistration sreg2 = context2.registerService(A.class.getName(), service2, null);
+ assertNotNull(sreg2);
+ ServiceReference sref2 = sreg2.getReference();
+ assertNotNull(sref2);
if (className != null)
- assertGetReference(bundleContext1, className, reference1);
+ assertGetReference(context1, className, sref1);
if (className != null)
- assertGetReference(bundleContext2, className, reference2);
+ assertGetReference(context2, className, sref2);
- registration1.unregister();
+ sreg1.unregister();
if (className != null)
- assertNoGetReference(bundleContext1, className);
+ assertNoGetReference(context1, className);
if (className != null)
- assertGetReference(bundleContext2, className, reference2);
+ assertGetReference(context2, className, sref2);
- registration1 = bundleContext1.registerService(A.class.getName(), service1, null);
- assertNotNull(registration1);
- reference1 = registration1.getReference();
- assertNotNull(reference1);
+ sreg1 = context1.registerService(A.class.getName(), service1, null);
+ assertNotNull(sreg1);
+ sref1 = sreg1.getReference();
+ assertNotNull(sref1);
if (className != null)
- assertGetReference(bundleContext1, className, reference1);
+ assertGetReference(context1, className, sref1);
if (className != null)
- assertGetReference(bundleContext2, className, reference2);
+ assertGetReference(context2, className, sref2);
- registration2.unregister();
+ sreg2.unregister();
if (className != null)
- assertGetReference(bundleContext1, className, reference1);
+ assertGetReference(context1, className, sref1);
if (className != null)
- assertNoGetReference(bundleContext2, className);
+ assertNoGetReference(context2, className);
- registration1.unregister();
+ sreg1.unregister();
if (className != null)
- assertNoGetReference(bundleContext1, className);
+ assertNoGetReference(context1, className);
if (className != null)
- assertNoGetReference(bundleContext2, className);
+ assertNoGetReference(context2, className);
}
finally
{
@@ -276,82 +276,88 @@
private void assertGetServiceReferencesAssignable(String className) throws Exception
{
+ // Bundle-ManifestVersion: 2
+ // Bundle-SymbolicName: org.jboss.test.osgi.service2
+ // Export-Package: org.jboss.test.osgi.service.support.a
VirtualFile assemblyA = assembleArchive("service2", "/bundles/service/service-bundle2", A.class);
Bundle bundleA = installBundle(assemblyA);
try
{
bundleA.start();
- BundleContext bundleContext1 = bundleA.getBundleContext();
- assertNotNull(bundleContext1);
+ BundleContext context1 = bundleA.getBundleContext();
+ assertNotNull(context1);
if (className != null)
- assertNoGetReference(bundleContext1, className);
+ assertNoGetReference(context1, className);
Class<?> clazz = bundleA.loadClass(A.class.getName());
Object service1 = clazz.newInstance();
- ServiceRegistration registration1 = bundleContext1.registerService(A.class.getName(), service1, null);
- assertNotNull(registration1);
- ServiceReference reference1 = registration1.getReference();
- assertNotNull(reference1);
+ ServiceRegistration sreg1 = context1.registerService(A.class.getName(), service1, null);
+ assertNotNull(sreg1);
+ ServiceReference sref1 = sreg1.getReference();
+ assertNotNull(sref1);
+ // Bundle-ManifestVersion: 2
+ // Bundle-SymbolicName: org.jboss.test.osgi.service1
+ // Import-Package: org.jboss.test.osgi.service.support.a
VirtualFile assemblyB = assembleArchive("service1", "/bundles/service/service-bundle1");
Bundle bundleB = installBundle(assemblyB);
try
{
bundleB.start();
- BundleContext bundleContext2 = bundleB.getBundleContext();
- assertNotNull(bundleContext2);
+ BundleContext context2 = bundleB.getBundleContext();
+ assertNotNull(context2);
if (className != null)
- assertGetReference(bundleContext2, className, reference1);
+ assertGetReference(context2, className, sref1);
clazz = bundleB.loadClass(A.class.getName());
Object service2 = clazz.newInstance();
- ServiceRegistration registration2 = bundleContext2.registerService(A.class.getName(), service2, null);
- assertNotNull(registration2);
- ServiceReference reference2 = registration2.getReference();
- assertNotNull(reference2);
+ ServiceRegistration sreg2 = context2.registerService(A.class.getName(), service2, null);
+ assertNotNull(sreg2);
+ ServiceReference sref2 = sreg2.getReference();
+ assertNotNull(sref2);
if (className != null)
- assertGetReference(bundleContext1, className, reference1);
+ assertGetReference(context1, className, sref1);
if (className != null)
- assertGetReference(bundleContext2, className, reference1);
+ assertGetReference(context2, className, sref1);
- registration1.unregister();
+ sreg1.unregister();
if (className != null)
- assertGetReference(bundleContext1, className, reference2);
+ assertGetReference(context1, className, sref2);
if (className != null)
- assertGetReference(bundleContext2, className, reference2);
+ assertGetReference(context2, className, sref2);
- registration1 = bundleContext1.registerService(A.class.getName(), service1, null);
- assertNotNull(registration1);
- reference1 = registration1.getReference();
- assertNotNull(reference1);
+ sreg1 = context1.registerService(A.class.getName(), service1, null);
+ assertNotNull(sreg1);
+ sref1 = sreg1.getReference();
+ assertNotNull(sref1);
if (className != null)
- assertGetReference(bundleContext1, className, reference2);
+ assertGetReference(context1, className, sref2);
if (className != null)
- assertGetReference(bundleContext2, className, reference2);
+ assertGetReference(context2, className, sref2);
- registration2.unregister();
+ sreg2.unregister();
if (className != null)
- assertGetReference(bundleContext1, className, reference1);
+ assertGetReference(context1, className, sref1);
if (className != null)
- assertGetReference(bundleContext2, className, reference1);
+ assertGetReference(context2, className, sref1);
- registration1.unregister();
+ sreg1.unregister();
if (className != null)
- assertNoGetReference(bundleContext1, className);
+ assertNoGetReference(context1, className);
if (className != null)
- assertNoGetReference(bundleContext2, className);
+ assertNoGetReference(context2, className);
}
finally
{
@@ -369,99 +375,105 @@
{
String className = A.class.getName();
+ // Bundle-ManifestVersion: 2
+ // Bundle-SymbolicName: org.jboss.test.osgi.service2
+ // Export-Package: org.jboss.test.osgi.service.support.a
VirtualFile assemblyA = assembleArchive("service2", "/bundles/service/service-bundle2", A.class);
Bundle bundleA = installBundle(assemblyA);
try
{
bundleA.start();
- BundleContext bundleContext1 = bundleA.getBundleContext();
- assertNotNull(bundleContext1);
+ BundleContext context1 = bundleA.getBundleContext();
+ assertNotNull(context1);
- assertNoGetReference(bundleContext1, className);
- assertNoReferences(bundleContext1, className);
- assertNoAllReferences(bundleContext1, className);
+ assertNoGetReference(context1, className);
+ assertNoReferences(context1, className);
+ assertNoAllReferences(context1, className);
Dictionary<String, Object> properties1 = new Hashtable<String, Object>();
- properties1.put(Constants.SERVICE_RANKING, 1);
+ properties1.put(Constants.SERVICE_RANKING, new Integer(1));
Class<?> clazz = bundleA.loadClass(className);
Object service1 = clazz.newInstance();
- ServiceRegistration registration1 = bundleContext1.registerService(className, service1, properties1);
- assertNotNull(registration1);
- ServiceReference reference1 = registration1.getReference();
- assertNotNull(reference1);
+ ServiceRegistration sreg1 = context1.registerService(className, service1, properties1);
+ assertNotNull(sreg1);
+ ServiceReference sref1 = sreg1.getReference();
+ assertNotNull(sref1);
+ // Bundle-ManifestVersion: 2
+ // Bundle-SymbolicName: org.jboss.test.osgi.service1
+ // Import-Package: org.jboss.test.osgi.service.support.a
VirtualFile assemblyB = assembleArchive("service1", "/bundles/service/service-bundle1");
Bundle bundleB = installBundle(assemblyB);
try
{
bundleB.start();
- BundleContext bundleContext2 = bundleB.getBundleContext();
- assertNotNull(bundleContext2);
+ BundleContext context2 = bundleB.getBundleContext();
+ assertNotNull(context2);
- assertGetReference(bundleContext2, className, reference1);
- assertReferences(bundleContext2, className, reference1);
- assertAllReferences(bundleContext2, className, reference1);
+ assertGetReference(context2, className, sref1);
+ assertReferences(context2, className, sref1);
+ assertAllReferences(context2, className, sref1);
Dictionary<String, Object> properties2 = new Hashtable<String, Object>();
- properties2.put(Constants.SERVICE_RANKING, 2);
+ properties2.put(Constants.SERVICE_RANKING, new Integer(2));
clazz = bundleB.loadClass(className);
Object service2 = clazz.newInstance();
- ServiceRegistration registration2 = bundleContext2.registerService(className, service2, properties2);
- assertNotNull(registration2);
- ServiceReference reference2 = registration2.getReference();
- assertNotNull(reference2);
+ ServiceRegistration sreg2 = context2.registerService(className, service2, properties2);
+ assertNotNull(sreg2);
+ ServiceReference sref2 = sreg2.getReference();
+ assertNotNull(sref2);
- assertGetReference(bundleContext1, className, reference2);
- assertReferences(bundleContext1, className, reference2, reference1);
- assertAllReferences(bundleContext1, className, reference2, reference1);
+ assertGetReference(context1, className, sref2);
+ assertReferences(context1, className, sref1, sref2);
+ assertAllReferences(context1, className, sref1, sref2);
- assertGetReference(bundleContext2, className, reference2);
- assertReferences(bundleContext2, className, reference2, reference1);
- assertAllReferences(bundleContext2, className, reference2, reference1);
+ assertGetReference(context2, className, sref2);
+ assertReferences(context2, className, sref1, sref2);
+ assertAllReferences(context2, className, sref1, sref2);
- registration1.unregister();
+ sreg1.unregister();
- assertGetReference(bundleContext1, className, reference2);
- assertReferences(bundleContext1, className, reference2);
- assertAllReferences(bundleContext1, className, reference2);
+ assertGetReference(context1, className, sref2);
+ assertReferences(context1, className, sref2);
+ assertAllReferences(context1, className, sref2);
- assertGetReference(bundleContext2, className, reference2);
- assertReferences(bundleContext2, className, reference2);
- assertAllReferences(bundleContext2, className, reference2);
+ assertGetReference(context2, className, sref2);
+ assertReferences(context2, className, sref2);
+ assertAllReferences(context2, className, sref2);
- registration1 = bundleContext1.registerService(className, service1, properties1);
- assertNotNull(registration1);
- reference1 = registration1.getReference();
- assertNotNull(reference1);
+ sreg1 = context1.registerService(className, service1, properties1);
+ assertNotNull(sreg1);
+ sref1 = sreg1.getReference();
+ assertNotNull(sref1);
- assertGetReference(bundleContext1, className, reference2);
- assertReferences(bundleContext1, className, reference2, reference1);
- assertAllReferences(bundleContext1, className, reference2, reference1);
+ assertGetReference(context1, className, sref2);
+ assertReferences(context1, className, sref1, sref2);
+ assertAllReferences(context1, className, sref1, sref2);
- assertGetReference(bundleContext2, className, reference2);
- assertReferences(bundleContext2, className, reference2, reference1);
- assertAllReferences(bundleContext2, className, reference2, reference1);
+ assertGetReference(context2, className, sref2);
+ assertReferences(context2, className, sref1, sref2);
+ assertAllReferences(context2, className, sref1, sref2);
- registration2.unregister();
+ sreg2.unregister();
- assertGetReference(bundleContext1, className, reference1);
- assertReferences(bundleContext1, className, reference1);
- assertAllReferences(bundleContext1, className, reference1);
+ assertGetReference(context1, className, sref1);
+ assertReferences(context1, className, sref1);
+ assertAllReferences(context1, className, sref1);
- assertGetReference(bundleContext2, className, reference1);
- assertReferences(bundleContext2, className, reference1);
- assertAllReferences(bundleContext2, className, reference1);
+ assertGetReference(context2, className, sref1);
+ assertReferences(context2, className, sref1);
+ assertAllReferences(context2, className, sref1);
- registration1.unregister();
+ sreg1.unregister();
- assertNoGetReference(bundleContext1, className);
- assertNoReferences(bundleContext1, className);
- assertNoAllReferences(bundleContext1, className);
+ assertNoGetReference(context1, className);
+ assertNoReferences(context1, className);
+ assertNoAllReferences(context1, className);
if (className != null)
- assertNoGetReference(bundleContext2, className);
- assertNoReferences(bundleContext2, className);
- assertNoAllReferences(bundleContext2, className);
+ assertNoGetReference(context2, className);
+ assertNoReferences(context2, className);
+ assertNoAllReferences(context2, className);
}
finally
{
@@ -485,34 +497,34 @@
try
{
bundle.start();
- BundleContext bundleContext1 = bundle.getBundleContext();
- assertNotNull(bundleContext1);
+ BundleContext context1 = bundle.getBundleContext();
+ assertNotNull(context1);
- assertNoGetReference(bundleContext1, A.class.getName());
- assertNoReferences(bundleContext1, null, "(a=b)");
- assertNoAllReferences(bundleContext1, null, "(a=b)");
- assertNoReferences(bundleContext1, className, "(a=b)");
- assertNoAllReferences(bundleContext1, className, "(a=b)");
- assertNoReferences(bundleContext1, wrongClassName, "(a=b)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(a=b)");
- assertNoReferences(bundleContext1, null, "(c=d)");
- assertNoAllReferences(bundleContext1, null, "(c=d)");
- assertNoReferences(bundleContext1, className, "(c=d)");
- assertNoAllReferences(bundleContext1, className, "(c=d)");
- assertNoReferences(bundleContext1, wrongClassName, "(c=d)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(c=d)");
- assertNoReferences(bundleContext1, null, "(c=x)");
- assertNoAllReferences(bundleContext1, null, "(c=x)");
- assertNoReferences(bundleContext1, className, "(c=x)");
- assertNoAllReferences(bundleContext1, className, "(c=x)");
- assertNoReferences(bundleContext1, wrongClassName, "(c=x)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(c=x)");
- assertNoReferences(bundleContext1, null, "(x=d)");
- assertNoAllReferences(bundleContext1, null, "(x=d)");
- assertNoReferences(bundleContext1, className, "(x=d)");
- assertNoAllReferences(bundleContext1, className, "(x=d)");
- assertNoReferences(bundleContext1, wrongClassName, "(x=d)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(x=d)");
+ assertNoGetReference(context1, A.class.getName());
+ assertNoReferences(context1, null, "(a=b)");
+ assertNoAllReferences(context1, null, "(a=b)");
+ assertNoReferences(context1, className, "(a=b)");
+ assertNoAllReferences(context1, className, "(a=b)");
+ assertNoReferences(context1, wrongClassName, "(a=b)");
+ assertNoAllReferences(context1, wrongClassName, "(a=b)");
+ assertNoReferences(context1, null, "(c=d)");
+ assertNoAllReferences(context1, null, "(c=d)");
+ assertNoReferences(context1, className, "(c=d)");
+ assertNoAllReferences(context1, className, "(c=d)");
+ assertNoReferences(context1, wrongClassName, "(c=d)");
+ assertNoAllReferences(context1, wrongClassName, "(c=d)");
+ assertNoReferences(context1, null, "(c=x)");
+ assertNoAllReferences(context1, null, "(c=x)");
+ assertNoReferences(context1, className, "(c=x)");
+ assertNoAllReferences(context1, className, "(c=x)");
+ assertNoReferences(context1, wrongClassName, "(c=x)");
+ assertNoAllReferences(context1, wrongClassName, "(c=x)");
+ assertNoReferences(context1, null, "(x=d)");
+ assertNoAllReferences(context1, null, "(x=d)");
+ assertNoReferences(context1, className, "(x=d)");
+ assertNoAllReferences(context1, className, "(x=d)");
+ assertNoReferences(context1, wrongClassName, "(x=d)");
+ assertNoAllReferences(context1, wrongClassName, "(x=d)");
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("a", "b");
@@ -520,64 +532,64 @@
Class<?> clazz = bundle.loadClass(A.class.getName());
Object service1 = clazz.newInstance();
- ServiceRegistration registration1 = bundleContext1.registerService(A.class.getName(), service1, properties);
- assertNotNull(registration1);
- ServiceReference reference1 = registration1.getReference();
- assertNotNull(reference1);
+ ServiceRegistration sreg1 = context1.registerService(A.class.getName(), service1, properties);
+ assertNotNull(sreg1);
+ ServiceReference sref1 = sreg1.getReference();
+ assertNotNull(sref1);
- assertGetReference(bundleContext1, A.class.getName(), reference1);
- assertReferences(bundleContext1, null, "(a=b)", reference1);
- assertAllReferences(bundleContext1, null, "(a=b)", reference1);
- assertReferences(bundleContext1, className, "(a=b)", reference1);
- assertAllReferences(bundleContext1, className, "(a=b)", reference1);
- assertNoReferences(bundleContext1, wrongClassName, "(a=b)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(a=b)");
- assertReferences(bundleContext1, null, "(c=d)", reference1);
- assertAllReferences(bundleContext1, null, "(c=d)", reference1);
- assertReferences(bundleContext1, className, "(c=d)", reference1);
- assertAllReferences(bundleContext1, className, "(c=d)", reference1);
- assertNoReferences(bundleContext1, wrongClassName, "(c=d)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(c=d)");
- assertNoReferences(bundleContext1, null, "(c=x)");
- assertNoAllReferences(bundleContext1, null, "(c=x)");
- assertNoReferences(bundleContext1, className, "(c=x)");
- assertNoAllReferences(bundleContext1, className, "(c=x)");
- assertNoReferences(bundleContext1, wrongClassName, "(c=x)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(c=x)");
- assertNoReferences(bundleContext1, null, "(x=d)");
- assertNoAllReferences(bundleContext1, null, "(x=d)");
- assertNoReferences(bundleContext1, className, "(x=d)");
- assertNoAllReferences(bundleContext1, className, "(x=d)");
- assertNoReferences(bundleContext1, wrongClassName, "(x=d)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(x=d)");
+ assertGetReference(context1, A.class.getName(), sref1);
+ assertReferences(context1, null, "(a=b)", sref1);
+ assertAllReferences(context1, null, "(a=b)", sref1);
+ assertReferences(context1, className, "(a=b)", sref1);
+ assertAllReferences(context1, className, "(a=b)", sref1);
+ assertNoReferences(context1, wrongClassName, "(a=b)");
+ assertNoAllReferences(context1, wrongClassName, "(a=b)");
+ assertReferences(context1, null, "(c=d)", sref1);
+ assertAllReferences(context1, null, "(c=d)", sref1);
+ assertReferences(context1, className, "(c=d)", sref1);
+ assertAllReferences(context1, className, "(c=d)", sref1);
+ assertNoReferences(context1, wrongClassName, "(c=d)");
+ assertNoAllReferences(context1, wrongClassName, "(c=d)");
+ assertNoReferences(context1, null, "(c=x)");
+ assertNoAllReferences(context1, null, "(c=x)");
+ assertNoReferences(context1, className, "(c=x)");
+ assertNoAllReferences(context1, className, "(c=x)");
+ assertNoReferences(context1, wrongClassName, "(c=x)");
+ assertNoAllReferences(context1, wrongClassName, "(c=x)");
+ assertNoReferences(context1, null, "(x=d)");
+ assertNoAllReferences(context1, null, "(x=d)");
+ assertNoReferences(context1, className, "(x=d)");
+ assertNoAllReferences(context1, className, "(x=d)");
+ assertNoReferences(context1, wrongClassName, "(x=d)");
+ assertNoAllReferences(context1, wrongClassName, "(x=d)");
- registration1.unregister();
+ sreg1.unregister();
- assertNoGetReference(bundleContext1, A.class.getName());
- assertNoReferences(bundleContext1, null, "(a=b)");
- assertNoAllReferences(bundleContext1, null, "(a=b)");
- assertNoReferences(bundleContext1, className, "(a=b)");
- assertNoAllReferences(bundleContext1, className, "(a=b)");
- assertNoReferences(bundleContext1, wrongClassName, "(a=b)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(a=b)");
- assertNoReferences(bundleContext1, null, "(c=d)");
- assertNoAllReferences(bundleContext1, null, "(c=d)");
- assertNoReferences(bundleContext1, className, "(c=d)");
- assertNoAllReferences(bundleContext1, className, "(c=d)");
- assertNoReferences(bundleContext1, wrongClassName, "(c=d)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(c=d)");
- assertNoReferences(bundleContext1, null, "(c=x)");
- assertNoAllReferences(bundleContext1, null, "(c=x)");
- assertNoReferences(bundleContext1, className, "(c=x)");
- assertNoAllReferences(bundleContext1, className, "(c=x)");
- assertNoReferences(bundleContext1, wrongClassName, "(c=x)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(c=x)");
- assertNoReferences(bundleContext1, null, "(x=d)");
- assertNoAllReferences(bundleContext1, null, "(x=d)");
- assertNoReferences(bundleContext1, className, "(x=d)");
- assertNoAllReferences(bundleContext1, className, "(x=d)");
- assertNoReferences(bundleContext1, wrongClassName, "(x=d)");
- assertNoAllReferences(bundleContext1, wrongClassName, "(x=d)");
+ assertNoGetReference(context1, A.class.getName());
+ assertNoReferences(context1, null, "(a=b)");
+ assertNoAllReferences(context1, null, "(a=b)");
+ assertNoReferences(context1, className, "(a=b)");
+ assertNoAllReferences(context1, className, "(a=b)");
+ assertNoReferences(context1, wrongClassName, "(a=b)");
+ assertNoAllReferences(context1, wrongClassName, "(a=b)");
+ assertNoReferences(context1, null, "(c=d)");
+ assertNoAllReferences(context1, null, "(c=d)");
+ assertNoReferences(context1, className, "(c=d)");
+ assertNoAllReferences(context1, className, "(c=d)");
+ assertNoReferences(context1, wrongClassName, "(c=d)");
+ assertNoAllReferences(context1, wrongClassName, "(c=d)");
+ assertNoReferences(context1, null, "(c=x)");
+ assertNoAllReferences(context1, null, "(c=x)");
+ assertNoReferences(context1, className, "(c=x)");
+ assertNoAllReferences(context1, className, "(c=x)");
+ assertNoReferences(context1, wrongClassName, "(c=x)");
+ assertNoAllReferences(context1, wrongClassName, "(c=x)");
+ assertNoReferences(context1, null, "(x=d)");
+ assertNoAllReferences(context1, null, "(x=d)");
+ assertNoReferences(context1, className, "(x=d)");
+ assertNoAllReferences(context1, className, "(x=d)");
+ assertNoReferences(context1, wrongClassName, "(x=d)");
+ assertNoAllReferences(context1, wrongClassName, "(x=d)");
}
finally
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -60,14 +60,14 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- bundleContext.registerService(OBJCLASS, bundleContext, null);
+ context.registerService(OBJCLASS, context, null);
try
{
- bundleContext.getService(null);
+ context.getService(null);
fail("Should not be here!");
}
catch (IllegalArgumentException t)
@@ -77,7 +77,7 @@
try
{
- bundleContext.ungetService(null);
+ context.ungetService(null);
fail("Should not be here!");
}
catch (IllegalArgumentException t)
@@ -99,17 +99,17 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, bundleContext, null);
- ServiceReference reference = registration.getReference();
+ ServiceRegistration sreg = context.registerService(OBJCLASS, context, null);
+ ServiceReference sref = sreg.getReference();
- Object actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
+ Object actual = context.getService(sref);
+ assertEquals(context, actual);
- registration.unregister();
- actual = bundleContext.getService(reference);
+ sreg.unregister();
+ actual = context.getService(sref);
assertNull("" + actual, actual);
}
finally
@@ -126,19 +126,19 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, bundleContext, null);
- ServiceReference reference = registration.getReference();
+ ServiceRegistration sreg = context.registerService(OBJCLASS, context, null);
+ ServiceReference sref = sreg.getReference();
- Object actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
+ Object actual = context.getService(sref);
+ assertEquals(context, actual);
bundle.stop();
try
{
- bundleContext.getService(reference);
+ context.getService(sref);
fail("Should not be here!");
}
catch (IllegalStateException t)
@@ -160,14 +160,14 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- bundleContext.addFrameworkListener(this);
+ context.addFrameworkListener(this);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, new BrokenServiceFactory(bundleContext, true), null);
- ServiceReference reference = registration.getReference();
- Object actual = bundleContext.getService(reference);
+ ServiceRegistration sreg = context.registerService(OBJCLASS, new BrokenServiceFactory(context, true), null);
+ ServiceReference sref = sreg.getReference();
+ Object actual = context.getService(sref);
assertNull("" + actual, actual);
assertFrameworkEvent(FrameworkEvent.ERROR, bundle, ServiceException.class);
@@ -186,18 +186,18 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- bundleContext.addFrameworkListener(this);
+ context.addFrameworkListener(this);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, new BrokenServiceFactory(bundleContext, false), null);
- ServiceReference reference = registration.getReference();
- Object actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
+ ServiceRegistration sreg = context.registerService(OBJCLASS, new BrokenServiceFactory(context, false), null);
+ ServiceReference sref = sreg.getReference();
+ Object actual = context.getService(sref);
+ assertEquals(context, actual);
assertNoFrameworkEvent();
- registration.unregister();
+ sreg.unregister();
assertFrameworkEvent(FrameworkEvent.WARNING, bundle, BundleException.class);
}
@@ -215,34 +215,36 @@
try
{
bundle1.start();
- BundleContext bundleContext = bundle1.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context1 = bundle1.getBundleContext();
+ assertNotNull(context1);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, bundleContext, null);
- ServiceReference reference = registration.getReference();
- Object actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
- assertFalse(bundleContext.ungetService(reference));
+ ServiceRegistration sreg = context1.registerService(OBJCLASS, context1, null);
+ ServiceReference sref = sreg.getReference();
+ Object actual = context1.getService(sref);
+ assertEquals(context1, actual);
+ assertTrue(context1.ungetService(sref));
+ assertFalse(context1.ungetService(sref));
- bundleContext.getService(reference);
- bundleContext.getService(reference);
- assertTrue(bundleContext.ungetService(reference));
- assertFalse(bundleContext.ungetService(reference));
+ context1.getService(sref);
+ context1.getService(sref);
+ assertTrue(context1.ungetService(sref));
+ assertTrue(context1.ungetService(sref));
+ assertFalse(context1.ungetService(sref));
VirtualFile assembly2 = assembleArchive("simple-bundle2", "/bundles/simple/simple-bundle2");
Bundle bundle2 = installBundle(assembly2);
try
{
bundle2.start();
- BundleContext bundleContext2 = bundle2.getBundleContext();
- assertNotNull(bundleContext2);
+ BundleContext context2 = bundle2.getBundleContext();
+ assertNotNull(context2);
- bundleContext2.getService(reference);
-
- bundleContext.getService(reference);
- assertFalse(bundleContext.ungetService(reference));
-
- assertFalse(bundleContext2.ungetService(reference));
+ context2.getService(sref);
+ context1.getService(sref);
+ assertTrue(context1.ungetService(sref));
+ assertFalse(context1.ungetService(sref));
+ assertTrue(context2.ungetService(sref));
+ assertFalse(context2.ungetService(sref));
}
finally
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -22,6 +22,7 @@
package org.jboss.test.osgi.service;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -118,20 +119,24 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, new SimpleServiceFactory(bundleContext), null);
- ServiceReference reference = registration.getReference();
+ ServiceRegistration sreg = context.registerService(OBJCLASS, new SimpleServiceFactory(context), null);
+ ServiceReference sref = sreg.getReference();
- Object actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
+ Object actual = context.getService(sref);
+ assertEquals(context, actual);
- actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
+ actual = context.getService(sref);
+ assertEquals(context, actual);
+
+ assertTrue(context.ungetService(sref));
+ assertTrue(context.ungetService(sref));
+ assertFalse(context.ungetService(sref));
- registration.unregister();
- actual = bundleContext.getService(reference);
+ sreg.unregister();
+ actual = context.getService(sref);
assertNull("" + actual, actual);
}
finally
@@ -150,19 +155,19 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- ServiceRegistration registration = bundleContext.registerService(OBJCLASS, new SimpleServiceFactory(bundleContext), null);
- ServiceReference reference = registration.getReference();
+ ServiceRegistration sreg = context.registerService(OBJCLASS, new SimpleServiceFactory(context), null);
+ ServiceReference sref = sreg.getReference();
- Object actual = bundleContext.getService(reference);
- assertEquals(bundleContext, actual);
+ Object actual = context.getService(sref);
+ assertEquals(context, actual);
bundle.stop();
try
{
- bundleContext.getService(reference);
+ context.getService(sref);
fail("Should not be here!");
}
catch (IllegalStateException t)
@@ -186,21 +191,21 @@
try
{
bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext context = bundle.getBundleContext();
+ assertNotNull(context);
- bundleContext.addFrameworkListener(this);
+ context.addFrameworkListener(this);
- ServiceRegistration registration = bundleContext.registerService(String.class.getName(), new SimpleServiceFactory(bundleContext), null);
- ServiceReference reference = registration.getReference();
- Object actual = bundleContext.getService(reference);
+ ServiceRegistration sreg = context.registerService(String.class.getName(), new SimpleServiceFactory(context), null);
+ ServiceReference sref = sreg.getReference();
+ Object actual = context.getService(sref);
assertNull("" + actual, actual);
assertFrameworkEvent(FrameworkEvent.ERROR, bundle, ServiceException.class);
- registration = bundleContext.registerService(OBJCLASSES, new SimpleServiceFactory(bundleContext), null);
- reference = registration.getReference();
- actual = bundleContext.getService(reference);
+ sreg = context.registerService(OBJCLASSES, new SimpleServiceFactory(context), null);
+ sref = sreg.getReference();
+ actual = context.getService(sref);
assertNull("" + actual, actual);
assertFrameworkEvent(FrameworkEvent.ERROR, bundle, ServiceException.class);
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFindHookTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFindHookTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFindHookTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -0,0 +1,120 @@
+/*
+* 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.service;
+
+// Id: $
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.test.osgi.AbstractFrameworkTest;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.hooks.service.FindHook;
+
+/**
+ * Test {@link FindHook} functionality.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 20-Mar-2010
+ */
+public class ServiceFindHookTestCase extends AbstractFrameworkTest
+{
+ @Test
+ public void testFindHook() throws Exception
+ {
+ final BundleContext context = framework.getBundleContext();
+
+ final boolean[] allServices = new boolean[4];
+ final boolean[] allGood = new boolean[4];
+ final int[] callIndex = new int[1];
+ FindHook hook = new FindHook()
+ {
+ @Override
+ @SuppressWarnings("rawtypes")
+ public void find(BundleContext context, String name, String filter, boolean all, Collection references)
+ {
+ assertNotNull("BundleContext not null", context);
+ assertNotNull("Service name not null", name);
+ assertNull("Filter null", filter);
+ allServices[callIndex[0]] = all;
+ assertEquals(2, references.size());
+ if (callIndex[0] == 2)
+ {
+ Iterator it = references.iterator();
+ it.next();
+ it.remove();
+ }
+ allGood[callIndex[0]] = true;
+ }
+ };
+
+ Runnable service = new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+
+ context.registerService(FindHook.class.getName(), hook, null);
+ ServiceReference sref1 = context.registerService(Runnable.class.getName(), service, null).getReference();
+ ServiceReference sref2= context.registerService(Runnable.class.getName(), service, null).getReference();
+
+ ServiceReference sref = context.getServiceReference(Runnable.class.getName());
+ assertNotNull("Reference not null", sref);
+ assertFalse("All services false", allServices[0]);
+ assertEquals(sref1, sref);
+ assertTrue("All good", allGood[0]);
+
+ callIndex[0] = 1;
+ ServiceReference[] srefs = context.getServiceReferences(Runnable.class.getName(), null);
+ assertNotNull("References not null", srefs);
+ assertEquals(2, srefs.length);
+ assertEquals(sref2, srefs[0]);
+ assertEquals(sref1, srefs[1]);
+ assertFalse("All services false", allServices[1]);
+ assertTrue("All good", allGood[1]);
+
+ callIndex[0] = 2;
+ srefs = context.getServiceReferences(Runnable.class.getName(), null);
+ assertNotNull("References not null", srefs);
+ assertEquals(1, srefs.length);
+ assertEquals(sref1, srefs[0]);
+ assertFalse("All services false", allServices[2]);
+ assertTrue("All good", allGood[2]);
+
+ callIndex[0] = 3;
+ srefs = context.getAllServiceReferences(Runnable.class.getName(), null);
+ assertEquals(2, srefs.length);
+ assertEquals(sref2, srefs[0]);
+ assertEquals(sref1, srefs[1]);
+ assertTrue("All services true", allServices[3]);
+ assertTrue("All good", allGood[3]);
+ }
+}
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -1,109 +0,0 @@
-/*
-* 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.service;
-
-// Id: $
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.test.osgi.AbstractFrameworkTest;
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.hooks.service.ListenerHook;
-import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
-
-/**
- * Test {@link ListenerHook} functionality.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 20-Mar-2010
- */
-public class ServiceListenerHookTestCase extends AbstractFrameworkTest
-{
- @Test
- public void testListenerHook() throws Exception
- {
- final Collection<ListenerInfo> added = new ArrayList<ListenerInfo>();
- final Collection<ListenerInfo> removed = new ArrayList<ListenerInfo>();
- ListenerHook hook = new ListenerHook()
- {
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void added(Collection infos)
- {
- added.addAll(infos);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void removed(Collection infos)
- {
- added.removeAll(infos);
- removed.addAll(infos);
- }
- };
-
- Runnable service = new Runnable()
- {
- public void run()
- {
- }
- };
-
- final List<String> events = new ArrayList<String>();
- ServiceListener listener = new ServiceListener()
- {
- public void serviceChanged(ServiceEvent event)
- {
- int eventType = event.getType();
- events.add(ConstantsHelper.serviceEvent(eventType));
- }
- };
-
- BundleContext context = framework.getBundleContext();
- context.addServiceListener(listener, "(foo=bar)");
-
- Hashtable<String, String> props = new Hashtable<String, String>();
- props.put("foo", "bar");
- context.registerService(Runnable.class.getName(), service, props);
- assertEquals(1, events.size());
- assertEquals("REGISTERED", events.get(0));
-
- context.registerService(ListenerHook.class.getName(), hook, null);
- assertTrue("Hook added called", added.size() > 0);
- assertTrue("Hook removed not called", removed.isEmpty());
-
- int size = added.size();
-
- // Register the same listener with a different filter
- context.addServiceListener(listener, "(bar=foo)");
- assertTrue("Hook removed called", removed.size() > 0);
- assertEquals("Hook added called", size, added.size());
- }
-}
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -0,0 +1,111 @@
+/*
+* 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.service;
+
+// Id: $
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.test.osgi.AbstractFrameworkTest;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.hooks.service.EventHook;
+import org.osgi.framework.hooks.service.FindHook;
+import org.osgi.framework.hooks.service.ListenerHook;
+import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
+
+/**
+ * Test {@link ListenerHook}, {@link EventHook}, {@link FindHook} functionality.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 20-Mar-2010
+ */
+public class ServiceListenerHookTestCase extends AbstractFrameworkTest
+{
+ @Test
+ public void testListenerHook() throws Exception
+ {
+ final Collection<ListenerInfo> added = new ArrayList<ListenerInfo>();
+ final Collection<ListenerInfo> removed = new ArrayList<ListenerInfo>();
+ ListenerHook hook = new ListenerHook()
+ {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void added(Collection infos)
+ {
+ added.addAll(infos);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void removed(Collection infos)
+ {
+ added.removeAll(infos);
+ removed.addAll(infos);
+ }
+ };
+
+ Runnable service = new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+
+ final List<String> events = new ArrayList<String>();
+ ServiceListener listener = new ServiceListener()
+ {
+ public void serviceChanged(ServiceEvent event)
+ {
+ int eventType = event.getType();
+ events.add(ConstantsHelper.serviceEvent(eventType));
+ }
+ };
+
+ BundleContext context = framework.getBundleContext();
+ context.addServiceListener(listener, "(foo=bar)");
+
+ Hashtable<String, String> props = new Hashtable<String, String>();
+ props.put("foo", "bar");
+ context.registerService(Runnable.class.getName(), service, props);
+ assertEquals(1, events.size());
+ assertEquals("REGISTERED", events.get(0));
+
+ context.registerService(ListenerHook.class.getName(), hook, null);
+ assertTrue("Hook added called", added.size() > 0);
+ assertTrue("Hook removed not called", removed.isEmpty());
+
+ int size = added.size();
+
+ // Register the same listener with a different filter
+ context.addServiceListener(listener, "(bar=foo)");
+ assertTrue("Hook removed called", removed.size() > 0);
+ assertEquals("Hook added called", size, added.size());
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -25,6 +25,8 @@
import static org.junit.Assert.assertNotNull;
+import java.util.Hashtable;
+
import org.jboss.osgi.vfs.VirtualFile;
import org.jboss.test.osgi.AbstractFrameworkTest;
import org.junit.Test;
@@ -94,6 +96,15 @@
sreg.unregister();
assertServiceEvent(ServiceEvent.UNREGISTERING, sref);
+
+ filter = "(objectClass=dummy)";
+ context.addServiceListener(this, filter);
+
+ sreg = context.registerService(BundleContext.class.getName(), context, null);
+ assertNoServiceEvent();
+
+ sreg.unregister();
+ assertNoServiceEvent();
}
finally
{
@@ -102,7 +113,7 @@
}
@Test
- public void testObjectClassFilterNegative() throws Exception
+ public void testModifyServiceProperties() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -113,14 +124,30 @@
assertNotNull(context);
assertNoServiceEvent();
- String filter = "(objectClass=dummy)";
+ String filter = "(&(objectClass=org.osgi.framework.BundleContext)(foo=bar))";
context.addServiceListener(this, filter);
- ServiceRegistration sreg = context.registerService(BundleContext.class.getName(), context, null);
- assertNoServiceEvent();
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put("foo", "bar");
+ ServiceRegistration sreg = context.registerService(BundleContext.class.getName(), context, props);
+ ServiceReference sref = sreg.getReference();
+ assertServiceEvent(ServiceEvent.REGISTERED, sref);
+
+ props.put("xxx", "yyy");
+ sreg.setProperties(props);
+ assertServiceEvent(ServiceEvent.MODIFIED, sref);
+
+ props.put("foo", "notbar");
+ sreg.setProperties(props);
+ assertServiceEvent(ServiceEvent.MODIFIED_ENDMATCH, sref);
+
+ props.put("foo", "bar");
+ sreg.setProperties(props);
+ assertServiceEvent(ServiceEvent.MODIFIED, sref);
+
sreg.unregister();
- assertNoServiceEvent();
+ assertServiceEvent(ServiceEvent.UNREGISTERING, sref);
}
finally
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -466,15 +466,17 @@
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));
+
+ System.out.println("FIXME: document, explain and verify ServiceMix ordering");
+ // assertTrue(osgiRef.compareTo(mcRef) < 0);
- // ranking order first
+ // lowest ranking first
refs = bundleContext1.getServiceReferences(A.class.getName(), null);
assertNotNull(refs);
assertEquals(2, refs.length);
- assertEquals(osgiRef, refs[0]);
- assertEquals(mcRef, refs[1]);
+ assertEquals(mcRef, refs[0]);
+ assertEquals(osgiRef, refs[1]);
}
finally
{
@@ -515,6 +517,7 @@
Object service = bc.getService(ref);
assertInstanceOf(service, aClass, false);
assertSame(service, getBean("A"));
+ assertTrue(bc.ungetService(ref));
assertFalse(bc.ungetService(ref));
}
finally
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -21,7 +21,13 @@
*/
package org.jboss.test.osgi.service;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.Dictionary;
import java.util.HashSet;
@@ -53,7 +59,7 @@
@Test
public void testGetProperty() throws Exception
{
- ServiceReference reference = null;
+ ServiceReference sref = null;
String[] clazzes = new String[] { BundleContext.class.getName() };
Object serviceID = null;
@@ -69,92 +75,92 @@
properties.put("testA", "a");
properties.put("testB", "b");
properties.put("MiXeD", "Case");
- ServiceRegistration registration = bundleContext.registerService(clazzes, bundleContext, properties);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(clazzes, bundleContext, properties);
+ assertNotNull(sreg);
- reference = registration.getReference();
- assertNotNull(reference);
+ sref = sreg.getReference();
+ assertNotNull(sref);
- serviceID = reference.getProperty(Constants.SERVICE_ID);
+ serviceID = sref.getProperty(Constants.SERVICE_ID);
assertNotNull(serviceID);
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID.toLowerCase()));
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID.toUpperCase()));
- assertArrayEquals(clazzes, (String[])reference.getProperty(Constants.OBJECTCLASS));
- assertArrayEquals(clazzes, (String[])reference.getProperty(Constants.OBJECTCLASS.toLowerCase()));
- assertArrayEquals(clazzes, (String[])reference.getProperty(Constants.OBJECTCLASS.toUpperCase()));
- assertEquals("a", reference.getProperty("testA"));
- assertEquals("b", reference.getProperty("testB"));
- assertEquals("Case", reference.getProperty("MiXeD"));
- assertEquals("Case", reference.getProperty("mixed"));
- assertEquals("Case", reference.getProperty("MIXED"));
- assertNull(reference.getProperty(null));
- assertNull(reference.getProperty("doesNotExist"));
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID.toLowerCase()));
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID.toUpperCase()));
+ assertArrayEquals(clazzes, (String[])sref.getProperty(Constants.OBJECTCLASS));
+ assertArrayEquals(clazzes, (String[])sref.getProperty(Constants.OBJECTCLASS.toLowerCase()));
+ assertArrayEquals(clazzes, (String[])sref.getProperty(Constants.OBJECTCLASS.toUpperCase()));
+ assertEquals("a", sref.getProperty("testA"));
+ assertEquals("b", sref.getProperty("testB"));
+ assertEquals("Case", sref.getProperty("MiXeD"));
+ assertEquals("Case", sref.getProperty("mixed"));
+ assertEquals("Case", sref.getProperty("MIXED"));
+ assertNull(sref.getProperty(null));
+ assertNull(sref.getProperty("doesNotExist"));
properties.put("testA", "notA");
- assertEquals("a", reference.getProperty("testA"));
+ assertEquals("a", sref.getProperty("testA"));
properties.put(Constants.SERVICE_ID, "rubbish");
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID));
properties.put(Constants.OBJECTCLASS, "rubbish");
- assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
+ assertEquals(clazzes, sref.getProperty(Constants.OBJECTCLASS));
- registration.setProperties(properties);
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
- assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
- assertEquals("notA", reference.getProperty("testA"));
- assertEquals("b", reference.getProperty("testB"));
- assertEquals("Case", reference.getProperty("MiXeD"));
- assertEquals("Case", reference.getProperty("mixed"));
- assertEquals("Case", reference.getProperty("MIXED"));
+ sreg.setProperties(properties);
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID));
+ assertEquals(clazzes, sref.getProperty(Constants.OBJECTCLASS));
+ assertEquals("notA", sref.getProperty("testA"));
+ assertEquals("b", sref.getProperty("testB"));
+ assertEquals("Case", sref.getProperty("MiXeD"));
+ assertEquals("Case", sref.getProperty("mixed"));
+ assertEquals("Case", sref.getProperty("MIXED"));
- registration.setProperties(null);
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
- assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
- assertNull(reference.getProperty("testA"));
- assertNull(reference.getProperty("testB"));
- assertNull(reference.getProperty("MiXeD"));
- assertNull(reference.getProperty("mixed"));
- assertNull(reference.getProperty("MIXED"));
- assertNull(reference.getProperty(null));
+ sreg.setProperties(null);
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID));
+ assertEquals(clazzes, sref.getProperty(Constants.OBJECTCLASS));
+ assertNull(sref.getProperty("testA"));
+ assertNull(sref.getProperty("testB"));
+ assertNull(sref.getProperty("MiXeD"));
+ assertNull(sref.getProperty("mixed"));
+ assertNull(sref.getProperty("MIXED"));
+ assertNull(sref.getProperty(null));
- registration.setProperties(properties);
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
- assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
- assertEquals("notA", reference.getProperty("testA"));
- assertEquals("b", reference.getProperty("testB"));
- assertEquals("Case", reference.getProperty("MiXeD"));
- assertEquals("Case", reference.getProperty("mixed"));
- assertEquals("Case", reference.getProperty("MIXED"));
- assertNull(reference.getProperty(null));
+ sreg.setProperties(properties);
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID));
+ assertEquals(clazzes, sref.getProperty(Constants.OBJECTCLASS));
+ assertEquals("notA", sref.getProperty("testA"));
+ assertEquals("b", sref.getProperty("testB"));
+ assertEquals("Case", sref.getProperty("MiXeD"));
+ assertEquals("Case", sref.getProperty("mixed"));
+ assertEquals("Case", sref.getProperty("MIXED"));
+ assertNull(sref.getProperty(null));
- registration.unregister();
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
- assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
- assertEquals("notA", reference.getProperty("testA"));
- assertEquals("b", reference.getProperty("testB"));
- assertEquals("Case", reference.getProperty("MiXeD"));
- assertEquals("Case", reference.getProperty("mixed"));
- assertEquals("Case", reference.getProperty("MIXED"));
- assertNull(reference.getProperty(null));
+ sreg.unregister();
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID));
+ assertEquals(clazzes, sref.getProperty(Constants.OBJECTCLASS));
+ assertEquals("notA", sref.getProperty("testA"));
+ assertEquals("b", sref.getProperty("testB"));
+ assertEquals("Case", sref.getProperty("MiXeD"));
+ assertEquals("Case", sref.getProperty("mixed"));
+ assertEquals("Case", sref.getProperty("MIXED"));
+ assertNull(sref.getProperty(null));
}
finally
{
bundle.uninstall();
}
- assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
- assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
- assertEquals("notA", reference.getProperty("testA"));
- assertEquals("b", reference.getProperty("testB"));
- assertEquals("Case", reference.getProperty("MiXeD"));
- assertEquals("Case", reference.getProperty("mixed"));
- assertEquals("Case", reference.getProperty("MIXED"));
- assertNull(reference.getProperty(null));
+ assertEquals(serviceID, sref.getProperty(Constants.SERVICE_ID));
+ assertEquals(clazzes, sref.getProperty(Constants.OBJECTCLASS));
+ assertEquals("notA", sref.getProperty("testA"));
+ assertEquals("b", sref.getProperty("testB"));
+ assertEquals("Case", sref.getProperty("MiXeD"));
+ assertEquals("Case", sref.getProperty("mixed"));
+ assertEquals("Case", sref.getProperty("MIXED"));
+ assertNull(sref.getProperty(null));
}
@Test
public void testGetPropertyKeys() throws Exception
{
- ServiceReference reference = null;
+ ServiceReference sref = null;
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -168,37 +174,37 @@
properties.put("testA", "a");
properties.put("testB", "b");
properties.put("MiXeD", "Case");
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
+ assertNotNull(sreg);
- reference = registration.getReference();
- assertNotNull(reference);
+ sref = sreg.getReference();
+ assertNotNull(sref);
- assertPropertyKeys(reference, "testA", "testB", "MiXeD");
+ assertPropertyKeys(sref, "testA", "testB", "MiXeD");
properties.put("testC", "c");
- assertPropertyKeys(reference, "testA", "testB", "MiXeD");
+ assertPropertyKeys(sref, "testA", "testB", "MiXeD");
- registration.setProperties(properties);
- assertPropertyKeys(reference, "testA", "testB", "testC", "MiXeD");
+ sreg.setProperties(properties);
+ assertPropertyKeys(sref, "testA", "testB", "testC", "MiXeD");
- registration.setProperties(null);
- assertPropertyKeys(reference);
+ sreg.setProperties(null);
+ assertPropertyKeys(sref);
- registration.setProperties(properties);
- assertPropertyKeys(reference, "testA", "testB", "testC", "MiXeD");
+ sreg.setProperties(properties);
+ assertPropertyKeys(sref, "testA", "testB", "testC", "MiXeD");
- registration.unregister();
- assertPropertyKeys(reference, "testA", "testB", "testC", "MiXeD");
+ sreg.unregister();
+ assertPropertyKeys(sref, "testA", "testB", "testC", "MiXeD");
}
finally
{
bundle.uninstall();
}
- assertPropertyKeys(reference, "testA", "testB", "testC", "MiXeD");
+ assertPropertyKeys(sref, "testA", "testB", "testC", "MiXeD");
}
- private void assertPropertyKeys(ServiceReference reference, String... expectedKeys)
+ private void assertPropertyKeys(ServiceReference sref, String... expectedKeys)
{
Set<String> expected = new HashSet<String>();
expected.add(Constants.SERVICE_ID);
@@ -207,7 +213,7 @@
expected.add(key);
Set<String> actual = new HashSet<String>();
- for (String key : reference.getPropertyKeys())
+ for (String key : sref.getPropertyKeys())
actual.add(key);
assertEquals(expected, actual);
@@ -224,18 +230,18 @@
BundleContext bundleContext = bundle.getBundleContext();
assertNotNull(bundleContext);
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
- Bundle other = reference.getBundle();
+ Bundle other = sref.getBundle();
assertEquals(bundle, other);
- registration.unregister();
+ sreg.unregister();
- other = reference.getBundle();
+ other = sref.getBundle();
assertNull("" + other, other);
}
finally
@@ -255,18 +261,18 @@
BundleContext bundleContext = bundle.getBundleContext();
assertNotNull(bundleContext);
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
- Bundle other = reference.getBundle();
+ Bundle other = sref.getBundle();
assertEquals(bundle, other);
bundle.stop();
- other = reference.getBundle();
+ other = sref.getBundle();
assertNull("" + other, other);
}
finally
@@ -286,13 +292,13 @@
BundleContext bundleContext = bundle1.getBundleContext();
assertNotNull(bundleContext);
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
- assertUsingBundles(reference);
+ assertUsingBundles(sref);
VirtualFile assembly2 = assembleArchive("simple2", "/bundles/simple/simple-bundle2");
Bundle bundle2 = installBundle(assembly2);
@@ -302,26 +308,26 @@
BundleContext bundleContext2 = bundle2.getBundleContext();
assertNotNull(bundleContext2);
- bundleContext2.getService(reference);
- assertUsingBundles(reference, bundle2);
+ bundleContext2.getService(sref);
+ assertUsingBundles(sref, bundle2);
- bundleContext2.ungetService(reference);
- assertUsingBundles(reference);
+ bundleContext2.ungetService(sref);
+ assertUsingBundles(sref);
- bundleContext2.getService(reference);
- bundleContext2.getService(reference);
- assertUsingBundles(reference, bundle2);
- bundleContext2.ungetService(reference);
- assertUsingBundles(reference, bundle2);
- bundleContext2.ungetService(reference);
- assertUsingBundles(reference);
+ bundleContext2.getService(sref);
+ bundleContext2.getService(sref);
+ assertUsingBundles(sref, bundle2);
+ bundleContext2.ungetService(sref);
+ assertUsingBundles(sref, bundle2);
+ bundleContext2.ungetService(sref);
+ assertUsingBundles(sref);
- bundleContext.getService(reference);
- bundleContext2.getService(reference);
- assertUsingBundles(reference, bundle1, bundle2);
+ bundleContext.getService(sref);
+ bundleContext2.getService(sref);
+ assertUsingBundles(sref, bundle1, bundle2);
- registration.unregister();
- assertUsingBundles(reference);
+ sreg.unregister();
+ assertUsingBundles(sref);
}
finally
{
@@ -345,13 +351,13 @@
BundleContext bundleContext = bundle1.getBundleContext();
assertNotNull(bundleContext);
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
- assertUsingBundles(reference);
+ assertUsingBundles(sref);
VirtualFile assembly2 = assembleArchive("simple2", "/bundles/simple/simple-bundle2");
Bundle bundle2 = installBundle(assembly2);
@@ -361,12 +367,12 @@
BundleContext bundleContext2 = bundle2.getBundleContext();
assertNotNull(bundleContext2);
- bundleContext.getService(reference);
- bundleContext2.getService(reference);
- assertUsingBundles(reference, bundle1, bundle2);
+ bundleContext.getService(sref);
+ bundleContext2.getService(sref);
+ assertUsingBundles(sref, bundle1, bundle2);
bundle1.stop();
- assertUsingBundles(reference);
+ assertUsingBundles(sref);
}
finally
{
@@ -390,15 +396,15 @@
BundleContext bundleContext = bundle.getBundleContext();
assertNotNull(bundleContext);
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
try
{
- reference.isAssignableTo(null, A.class.getName());
+ sref.isAssignableTo(null, A.class.getName());
fail("Should not be here!");
}
catch (IllegalArgumentException t)
@@ -408,7 +414,7 @@
try
{
- reference.isAssignableTo(bundle, null);
+ sref.isAssignableTo(bundle, null);
fail("Should not be here!");
}
catch (IllegalArgumentException t)
@@ -433,22 +439,22 @@
BundleContext bundleContext = bundle1.getBundleContext();
assertNotNull(bundleContext);
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
VirtualFile assembly2 = assembleArchive("simple2", "/bundles/simple/simple-bundle2", A.class);
Bundle bundle2 = installBundle(assembly2);
try
{
- assertFalse(reference.isAssignableTo(bundle2, A.class.getName()));
- assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
+ assertFalse(sref.isAssignableTo(bundle2, A.class.getName()));
+ assertTrue(sref.isAssignableTo(bundle2, String.class.getName()));
- registration.unregister();
- assertFalse(reference.isAssignableTo(bundle2, A.class.getName()));
- assertFalse(reference.isAssignableTo(bundle2, String.class.getName())); // review ???
+ sreg.unregister();
+ assertFalse(sref.isAssignableTo(bundle2, A.class.getName()));
+ assertFalse(sref.isAssignableTo(bundle2, String.class.getName())); // review ???
}
finally
{
@@ -485,22 +491,22 @@
try
{
- ServiceRegistration registration = bundleContext2.registerService(BundleContext.class.getName(), bundleContext2, null);
- assertNotNull(registration);
+ ServiceRegistration sreg = bundleContext2.registerService(BundleContext.class.getName(), bundleContext2, null);
+ assertNotNull(sreg);
- ServiceReference reference = registration.getReference();
- assertNotNull(reference);
+ ServiceReference sref = sreg.getReference();
+ assertNotNull(sref);
- assertTrue(reference.isAssignableTo(bundle2, A.class.getName()));
- assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
- assertTrue(reference.isAssignableTo(bundle1, A.class.getName()));
- assertTrue(reference.isAssignableTo(bundle1, String.class.getName()));
+ assertTrue(sref.isAssignableTo(bundle2, A.class.getName()));
+ assertTrue(sref.isAssignableTo(bundle2, String.class.getName()));
+ assertTrue(sref.isAssignableTo(bundle1, A.class.getName()));
+ assertTrue(sref.isAssignableTo(bundle1, String.class.getName()));
- registration.unregister();
- assertTrue(reference.isAssignableTo(bundle2, A.class.getName()));
- assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
- assertFalse(reference.isAssignableTo(bundle1, A.class.getName()));
- assertFalse(reference.isAssignableTo(bundle1, String.class.getName())); // review ???
+ sreg.unregister();
+ assertTrue(sref.isAssignableTo(bundle2, A.class.getName()));
+ assertTrue(sref.isAssignableTo(bundle2, String.class.getName()));
+ assertFalse(sref.isAssignableTo(bundle1, A.class.getName()));
+ assertFalse(sref.isAssignableTo(bundle1, String.class.getName())); // review ???
}
finally
{
@@ -516,114 +522,159 @@
@Test
public void testCompareTo() throws Exception
{
- VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
- Bundle bundle = installBundle(assembly);
- try
- {
- bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ BundleContext bundleContext = framework.getBundleContext();
+ assertNotNull(bundleContext);
- ServiceRegistration registration1 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration1);
+ ServiceRegistration sreg1 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg1);
- ServiceReference reference1 = registration1.getReference();
- assertNotNull(reference1);
+ ServiceReference sref1 = sreg1.getReference();
+ assertNotNull(sref1);
- ServiceRegistration registration2 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
- assertNotNull(registration2);
+ ServiceRegistration sreg2 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ assertNotNull(sreg2);
- ServiceReference reference2 = registration2.getReference();
- assertNotNull(reference2);
+ ServiceReference sref2 = sreg2.getReference();
+ assertNotNull(sref2);
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
- properties.put(Constants.SERVICE_RANKING, 10);
- ServiceRegistration registration3 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
- assertNotNull(registration3);
+ Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ properties.put(Constants.SERVICE_RANKING, 10);
+ ServiceRegistration sreg3 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
+ assertNotNull(sreg3);
- ServiceReference reference3 = registration3.getReference();
- assertNotNull(reference3);
+ ServiceReference sref3 = sreg3.getReference();
+ assertNotNull(sref3);
- properties = new Hashtable<String, Object>();
- properties.put(Constants.SERVICE_RANKING, -10);
- ServiceRegistration registration4 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
- assertNotNull(registration4);
+ properties = new Hashtable<String, Object>();
+ properties.put(Constants.SERVICE_RANKING, -10);
+ ServiceRegistration sreg4 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
+ assertNotNull(sreg4);
- ServiceReference reference4 = registration4.getReference();
- assertNotNull(reference4);
+ ServiceReference sref4 = sreg4.getReference();
+ assertNotNull(sref4);
- assertGreaterRanking(reference1, reference2);
- assertGreaterRanking(reference3, reference1);
- assertGreaterRanking(reference3, reference2);
- assertGreaterRanking(reference1, reference4);
- assertGreaterRanking(reference2, reference4);
- assertGreaterRanking(reference3, reference4);
+ assertGreaterRanking(sref1, sref2);
+ assertGreaterRanking(sref3, sref1);
+ assertGreaterRanking(sref3, sref2);
+ assertGreaterRanking(sref1, sref4);
+ assertGreaterRanking(sref2, sref4);
+ assertGreaterRanking(sref3, sref4);
- try
- {
- reference1.compareTo(null);
- fail("Should not be here!");
- }
- catch (IllegalArgumentException t)
- {
- // expected
- }
+ try
+ {
+ sref1.compareTo(null);
+ fail("Should not be here!");
+ }
+ catch (IllegalArgumentException t)
+ {
+ // expected
+ }
- try
- {
- reference1.compareTo(new Object());
- fail("Should not be here!");
- }
- catch (IllegalArgumentException t)
- {
- // expected
- }
+ try
+ {
+ sref1.compareTo(new Object());
+ fail("Should not be here!");
+ }
+ catch (IllegalArgumentException t)
+ {
+ // expected
+ }
- properties = new Hashtable<String, Object>();
- properties.put(Constants.SERVICE_RANKING, "NotANumber");
- ServiceRegistration registration5 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
- assertNotNull(registration5);
+ properties = new Hashtable<String, Object>();
+ properties.put(Constants.SERVICE_RANKING, "NotANumber");
+ ServiceRegistration sreg5 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
+ assertNotNull(sreg5);
- ServiceReference reference5 = registration5.getReference();
- assertNotNull(reference5);
+ ServiceReference sref5 = sreg5.getReference();
+ assertNotNull(sref5);
- assertGreaterRanking(reference1, reference5); // review ???
+ assertGreaterRanking(sref1, sref5);
- Set<ServiceReference> ordering = new TreeSet<ServiceReference>();
- ordering.add(reference1);
- ordering.add(reference2);
- ordering.add(reference3);
- ordering.add(reference4);
- ordering.add(reference5);
- Iterator<ServiceReference> iterator = ordering.iterator();
- assertEquals(reference4, iterator.next());
- assertEquals(reference5, iterator.next());
- assertEquals(reference2, iterator.next());
- assertEquals(reference1, iterator.next());
- assertEquals(reference3, iterator.next());
+ Set<ServiceReference> ordering = new TreeSet<ServiceReference>();
+ ordering.add(sref1);
+ ordering.add(sref2);
+ ordering.add(sref3);
+ ordering.add(sref4);
+ ordering.add(sref5);
+ Iterator<ServiceReference> iterator = ordering.iterator();
+ assertEquals(sref4, iterator.next());
+ assertEquals(sref5, iterator.next());
+ assertEquals(sref2, iterator.next());
+ assertEquals(sref1, iterator.next());
+ assertEquals(sref3, iterator.next());
- ordering = new TreeSet<ServiceReference>();
- ordering.add(reference5);
- ordering.add(reference4);
- ordering.add(reference3);
- ordering.add(reference2);
- ordering.add(reference1);
- iterator = ordering.iterator();
- assertEquals(reference4, iterator.next());
- assertEquals(reference5, iterator.next());
- assertEquals(reference2, iterator.next());
- assertEquals(reference1, iterator.next());
- assertEquals(reference3, iterator.next());
- }
- finally
+ ordering = new TreeSet<ServiceReference>();
+ ordering.add(sref5);
+ ordering.add(sref4);
+ ordering.add(sref3);
+ ordering.add(sref2);
+ ordering.add(sref1);
+ iterator = ordering.iterator();
+ assertEquals(sref4, iterator.next());
+ assertEquals(sref5, iterator.next());
+ assertEquals(sref2, iterator.next());
+ assertEquals(sref1, iterator.next());
+ assertEquals(sref3, iterator.next());
+ }
+
+ @Test
+ public void testServiceReferenceOrder() throws Exception
+ {
+ Runnable runIt = new Runnable()
{
- bundle.uninstall();
- }
+ public void run()
+ {
+ }
+ };
+
+ BundleContext context = framework.getBundleContext();
+ Hashtable<String, Object> props = new Hashtable<String, Object>();
+ props.put(Constants.SERVICE_DESCRIPTION, "min value");
+ props.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
+ ServiceRegistration sreg1 = context.registerService(Runnable.class.getName(), runIt, props);
+ ServiceReference sref1 = sreg1.getReference();
+
+ props.put(Constants.SERVICE_DESCRIPTION, "max value 1");
+ props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ ServiceRegistration sreg2 = context.registerService(Runnable.class.getName(), runIt, props);
+ ServiceReference sref2 = sreg2.getReference();
+
+ props.put(Constants.SERVICE_DESCRIPTION, "max value 2");
+ props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ ServiceRegistration sreg3 = context.registerService(Runnable.class.getName(), runIt, props);
+ ServiceReference sref3 = sreg3.getReference();
+
+ props.put(Constants.SERVICE_DESCRIPTION, "max value 3");
+ props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ ServiceRegistration sreg4 = context.registerService(Runnable.class.getName(), runIt, props);
+ ServiceReference sref4 = sreg4.getReference();
+
+ ServiceReference[] srefs = context.getServiceReferences(Runnable.class.getName(), null);
+ assertEquals(4, srefs.length);
+ assertEquals(sref1, srefs[0]);
+ assertEquals(sref4, srefs[1]);
+ assertEquals(sref3, srefs[2]);
+ assertEquals(sref2, srefs[3]);
+
+ ServiceReference sref = context.getServiceReference(Runnable.class.getName());
+ assertEquals(sref2, sref);
+ sreg2.unregister();
+
+ sref = context.getServiceReference(Runnable.class.getName());
+ assertEquals(sref3, sref);
+ sreg3.unregister();
+
+ sref = context.getServiceReference(Runnable.class.getName());
+ assertEquals(sref4, sref);
+ sreg4.unregister();
+
+ sref = context.getServiceReference(Runnable.class.getName());
+ assertEquals(sref1, sref);
}
- protected void assertGreaterRanking(ServiceReference reference1, ServiceReference reference2) throws Exception
+ protected void assertGreaterRanking(ServiceReference sref1, ServiceReference sref2) throws Exception
{
- assertTrue(reference1 + " > " + reference2, reference1.compareTo(reference2) > 0);
- assertTrue(reference2 + " < " + reference1, reference2.compareTo(reference1) < 0);
+ assertTrue(sref1 + " > " + sref2, sref1.compareTo(sref2) > 0);
+ assertTrue(sref2 + " < " + sref1, sref2.compareTo(sref1) < 0);
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -465,12 +465,13 @@
*/
boolean removeContextInUse(ControllerContext context)
{
+ int usedByCount = getUsedByCount(context, this);
if (context instanceof ContextTracking)
{
ContextTracking ct = (ContextTracking)context;
ct.ungetTarget(this);
}
- return getUsedByCount(context, this) > 0;
+ return usedByCount > 0;
}
public ServiceReference[] getServicesInUse()
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -1,57 +0,0 @@
-/*
-* 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.osgi.framework.bundle;
-
-import java.util.Comparator;
-
-import org.jboss.dependency.spi.ControllerContext;
-
-/**
- * Compare controller contexts.
- *
- * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
- */
-class ContextComparator implements Comparator<ControllerContext>
-{
- public static final Comparator<ControllerContext> INSTANCE = new ContextComparator();
-
- public int compare(ControllerContext c1, ControllerContext c2)
- {
- Integer ranking1 = MDRUtils.getRanking(c1);
- Integer ranking2 = MDRUtils.getRanking(c2);
- int diff = ranking2 - ranking1;
- if (diff == 0)
- {
- Long id1 = MDRUtils.getId(c1);
- Long id2 = MDRUtils.getId(c2);
- if (id1 == null && id2 == null)
- return 0;
- if (id1 != null && id2 == null)
- return -1;
- if (id2 != null && id1 == null)
- return 1;
-
- return (id2 > id1) ? -1 : 1;
- }
- return diff;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ContextComparator.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -0,0 +1,71 @@
+/*
+* 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.osgi.framework.bundle;
+
+// $Id: $
+
+import java.util.Comparator;
+
+import org.jboss.dependency.spi.ControllerContext;
+
+/**
+ * If this ServiceReference and the specified ServiceReference have the same service id they are equal.
+ * This ServiceReference is less than the specified ServiceReference if it has a lower service ranking
+ * and greater if it has a higher service ranking.
+ *
+ * Otherwise, if this ServiceReference and the specified ServiceReference have the same service ranking,
+ * this ServiceReference is less than the specified ServiceReference if it has a higher service id and
+ * greater if it has a lower service id.
+ *
+ * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Mar-2010
+ */
+class ContextComparator implements Comparator<ControllerContext>
+{
+ private static final Comparator<ControllerContext> INSTANCE = new ContextComparator();
+
+ static Comparator<ControllerContext> getInstance()
+ {
+ return INSTANCE;
+ }
+
+ public int compare(ControllerContext c1, ControllerContext c2)
+ {
+ if (c1.equals(c2))
+ return 0;
+
+ Long id1 = MDRUtils.getId(c1);
+ Long id2 = MDRUtils.getId(c2);
+ if (id1 != null && id1.equals(id2))
+ throw new IllegalStateException("Compare not consistent with equals: " + c1 + " != " + c2);
+
+ Integer ranking1 = MDRUtils.getRanking(c1);
+ Integer ranking2 = MDRUtils.getRanking(c2);
+ if (ranking1.equals(ranking2) == false)
+ return (ranking1 < ranking2 ? -1 : 1);
+
+ id1 = (id1 != null ? id1 : Long.MAX_VALUE);
+ id2 = (id2 != null ? id2 : Long.MAX_VALUE);
+ return (id1 > id2 ? -1 : 1);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -21,6 +21,8 @@
*/
package org.jboss.osgi.framework.bundle;
+// $Id: $
+
import org.jboss.dependency.spi.ControllerContext;
import org.osgi.framework.Bundle;
@@ -29,51 +31,63 @@
*
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
+ * @author thomas.diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
-public class OSGiServiceReferenceWrapper extends ControllerContextHandle
+class OSGiServiceReferenceWrapper extends ControllerContextHandle
{
/** The service state */
private OSGiServiceState serviceState;
- /**
- * Create a new OSGiServiceReferenceWrapper.
- *
- * @param serviceState the service state
- * @throws IllegalArgumentException for a null parameter
- */
- public OSGiServiceReferenceWrapper(OSGiServiceState serviceState)
+ OSGiServiceReferenceWrapper(OSGiServiceState serviceState)
{
if (serviceState == null)
throw new IllegalArgumentException("Null service state");
this.serviceState = serviceState;
}
+ @Override
public Bundle getBundle()
{
return serviceState.getBundle();
}
+ @Override
public Object getProperty(String key)
{
return serviceState.getProperty(key);
}
+ @Override
public String[] getPropertyKeys()
{
return serviceState.getPropertyKeys();
}
+ @Override
public Bundle[] getUsingBundles()
{
return serviceState.getUsingBundles();
}
+ @Override
public boolean isAssignableTo(Bundle bundle, String className)
{
return serviceState.isAssignableTo(bundle, className);
}
+ OSGiServiceState getServiceState()
+ {
+ return serviceState;
+ }
+
+ @Override
+ ControllerContext getContext()
+ {
+ return getServiceState();
+ }
+
+ @Override
public int compareTo(Object reference)
{
return serviceState.compareTo(reference);
@@ -96,14 +110,4 @@
{
return serviceState.toString();
}
-
- OSGiServiceState getServiceState()
- {
- return serviceState;
- }
-
- ControllerContext getContext()
- {
- return getServiceState();
- }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -27,8 +27,10 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Comparator;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -101,7 +103,8 @@
private Map<AbstractBundleState, Object> serviceCache;
/** The properties */
- private CaseInsensitiveDictionary properties;
+ private CaseInsensitiveDictionary prevProperties;
+ private CaseInsensitiveDictionary currProperties;
/** The bean info */
private BeanInfo beanInfo;
@@ -115,7 +118,7 @@
* @param properties the properties
* @throws IllegalArgumentException for a null parameter
*/
- @SuppressWarnings({ "rawtypes" })
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public OSGiServiceState(AbstractBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
{
super(service, properties);
@@ -141,8 +144,12 @@
if (isServiceFactory == false)
checkObjClass(service);
- if (properties != null)
- this.properties = new CaseInsensitiveDictionary(properties);
+ if (properties == null)
+ properties = new Hashtable();
+
+ properties.put(Constants.SERVICE_ID, getServiceId());
+ properties.put(Constants.OBJECTCLASS, getClasses());
+ this.currProperties = new CaseInsensitiveDictionary(properties);
serviceRegistration = new OSGiServiceRegistrationWrapper(this);
@@ -370,20 +377,32 @@
if (service == null)
{
ServiceFactory serviceFactory = (ServiceFactory)serviceOrFactory;
+ boolean gotService = false;
+
+ // If the service object returned by the ServiceFactory object is not an instanceof all the classes named when
+ // the service was registered or the ServiceFactory object throws an exception, null is returned and a Framework
+ // event of type FrameworkEvent.ERROR containing a ServiceException describing the error is fired.
try
{
service = serviceFactory.getService(bundleState.getBundle(), getRegistration());
+ gotService = true;
+
service = checkObjClass(service);
serviceCache.put(bundleState, service);
}
catch (Throwable t)
{
- // If the service object returned by the ServiceFactory object is not an instanceof all the classes named when
- // the service was registered or the ServiceFactory object throws an exception, null is returned and a Framework
- // event of type FrameworkEvent.ERROR containing a ServiceException describing the error is fired.
- log.error("Error from getService for " + this, t);
+ Throwable cause = t;
+ String message = "Cannot get service from: " + serviceFactory;
+ if (gotService == true)
+ {
+ message += "." + t.getMessage();
+ cause = null;
+ }
+ ServiceException serviceException = new ServiceException(message, cause);
+ log.error("Cannot getService from ServiceFactory", serviceException);
FrameworkEventsPlugin plugin = bundleState.getBundleManager().getPlugin(FrameworkEventsPlugin.class);
- plugin.fireFrameworkEvent(bundleState, FrameworkEvent.ERROR, new ServiceException("Error using service factory:" + serviceFactory, t));
+ plugin.fireFrameworkEvent(bundleState, FrameworkEvent.ERROR, serviceException);
return null;
}
}
@@ -468,51 +487,56 @@
return bundleState;
}
- @Override
+ @Override
public Object getProperty(String key)
{
if (key == null)
return null;
- if (Constants.SERVICE_ID.equalsIgnoreCase(key))
- return getServiceId();
- if (Constants.OBJECTCLASS.equalsIgnoreCase(key))
- return getClasses();
- if (properties == null)
- return null;
- return properties.get(key);
+ return currProperties.get(key);
}
@Override
public String[] getPropertyKeys()
{
ArrayList<String> result = new ArrayList<String>();
- if (properties != null)
+ if (currProperties != null)
{
- Enumeration<String> keys = properties.keys();
+ Enumeration<String> keys = currProperties.keys();
while (keys.hasMoreElements())
result.add(keys.nextElement());
}
- result.add(Constants.SERVICE_ID);
- result.add(Constants.OBJECTCLASS);
return result.toArray(new String[result.size()]);
}
@Override
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public void setProperties(Dictionary properties)
{
checkUnregistered();
+ // Remember the previous properties for a potential
+ // delivery of the MODIFIED_ENDMATCH event
+ prevProperties = currProperties;
+
if (properties == null)
- this.properties = null;
- else
- this.properties = new CaseInsensitiveDictionary(properties);
+ properties = new Hashtable();
+
+ properties.put(Constants.SERVICE_ID, getServiceId());
+ properties.put(Constants.OBJECTCLASS, getClasses());
+ currProperties = new CaseInsensitiveDictionary(properties);
// This event is synchronously delivered after the service properties have been modified.
FrameworkEventsPlugin plugin = bundleState.getBundleManager().getPlugin(FrameworkEventsPlugin.class);
plugin.fireServiceEvent(bundleState, ServiceEvent.MODIFIED, this);
}
+
+ @SuppressWarnings("rawtypes")
+ public Dictionary getPreviousProperties()
+ {
+ return prevProperties;
+ }
+
@Override
public Bundle[] getUsingBundles()
{
@@ -524,7 +548,7 @@
return bundles.toArray(new Bundle[bundles.size()]);
}
-
+
@Override
public boolean isAssignableTo(Bundle bundle, String className)
{
@@ -549,6 +573,15 @@
}
}
+ /*
+ * If this ServiceReference and the specified ServiceReference have the same service id they are equal.
+ * This ServiceReference is less than the specified ServiceReference if it has a lower service ranking
+ * and greater if it has a higher service ranking.
+ *
+ * Otherwise, if this ServiceReference and the specified ServiceReference have the same service ranking,
+ * this ServiceReference is less than the specified ServiceReference if it has a higher service id and
+ * greater if it has a lower service id.
+ */
@Override
public int compareTo(Object reference)
{
@@ -563,70 +596,25 @@
else
throw new IllegalArgumentException(reference + " is not a service reference");
- Long otherServiceId = MDRUtils.getId(other);
- if (otherServiceId == null)
- return -1; // TODO?
-
- long thisServiceId = getServiceId();
- if (thisServiceId == otherServiceId)
- return 0;
-
- Integer otherRanking = MDRUtils.getRanking(other);
- int thisRanking = getServiceRanking();
- int ranking = thisRanking - otherRanking;
- if (ranking != 0)
- return ranking;
-
- return (thisServiceId > otherServiceId) ? -1 : 1;
+ Comparator<ControllerContext> comparator = ContextComparator.getInstance();
+ return comparator.compare(this, other);
}
- @Override
- public boolean equals(Object obj)
+ String toLongString()
{
- if (obj == null)
- return false;
-
- OSGiServiceState other;
- if (obj instanceof OSGiServiceState)
- other = (OSGiServiceState)obj;
- else if (obj instanceof OSGiServiceReferenceWrapper)
- other = ((OSGiServiceReferenceWrapper)obj).getServiceState();
- else
- return false;
- return this == other;
- }
-
- @Override
- public int hashCode()
- {
- return toString().hashCode();
- }
-
- @Override
- public String toString()
- {
StringBuilder builder = new StringBuilder();
+ String desc = (String)getProperty(Constants.SERVICE_DESCRIPTION);
builder.append("Service{");
builder.append("id=").append(getServiceId());
- builder.append(" classes=").append(Arrays.asList(getClasses()));
+ builder.append(desc != null ? ",desc=" + desc : "");
+ builder.append(",bundle=").append(getBundleState().getCanonicalName());
+ builder.append(",classes=").append(Arrays.asList(getClasses()));
+ builder.append(isServiceFactory ? ",factory=" : ",service=").append(serviceOrFactory);
+ builder.append(",props=").append(currProperties);
builder.append("}");
return builder.toString();
}
- public String toLongString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("Service{");
- builder.append("id=").append(getServiceId());
- builder.append(" bundle=").append(getBundleState().getCanonicalName());
- builder.append(" classes=").append(Arrays.asList(getClasses()));
- builder.append(isServiceFactory ? " factory=" : " service=").append(serviceOrFactory);
- if (properties != null)
- builder.append(" properties=").append(properties);
- builder.append("}");
- return builder.toString();
- }
-
/**
* Register the service
*/
@@ -786,4 +774,41 @@
{
return serviceRegistration == null;
}
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ OSGiServiceState other;
+ if (obj instanceof OSGiServiceState)
+ other = (OSGiServiceState)obj;
+ else if (obj instanceof OSGiServiceReferenceWrapper)
+ other = ((OSGiServiceReferenceWrapper)obj).getServiceState();
+ else
+ return false;
+ return this == other;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ Object desc = getProperty(Constants.SERVICE_DESCRIPTION);
+ Object rank = getProperty(Constants.SERVICE_RANKING);
+ builder.append("Service{");
+ builder.append("id=").append(getServiceId());
+ builder.append(rank != null ? ",rank=" + rank : "");
+ builder.append(desc != null ? ",desc=" + desc : "");
+ builder.append(",classes=").append(Arrays.asList(getClasses()));
+ builder.append("}");
+ return builder.toString();
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -208,7 +208,10 @@
if (srefs.isEmpty())
return null;
- return srefs.iterator().next();
+ // If multiple such services exist, the service with the highest ranking is returned.
+ // If there is a tie in ranking, the service with the lowest service ID is returned.
+ ArrayList<ServiceReference> list = new ArrayList<ServiceReference>(srefs);
+ return list.get(list.size() - 1);
}
@Override
@@ -235,25 +238,29 @@
* in which the find hooks are called is the reverse compareTo ordering of
* their Service References.
*/
- @SuppressWarnings("unchecked")
- private Collection<ServiceReference> processFindHooks(AbstractBundleState bundle, String clazz, String filterStr, boolean checkAssignable, Collection<ServiceReference> srefs)
+ private Collection<ServiceReference> processFindHooks(AbstractBundleState bundle, String clazz, String filterStr, boolean checkAssignable,
+ Collection<ServiceReference> srefs)
{
BundleContext context = bundle.getBundleContext();
- if (context == null)
+ Collection<ServiceReference> hookRefs = getServiceReferencesInternal(bundle, FindHook.class.getName(), null, true);
+ if (context == null || hookRefs.isEmpty())
return srefs;
-
- // Get and sort the FindHook refs
- Collection<ServiceReference> hookRefs = getServiceReferencesInternal(bundle, FindHook.class.getName(), null, true);
+
+ // Event and Find Hooks can not be used to hide the services from the framework.
+ if (clazz != null && clazz.startsWith(FindHook.class.getPackage().getName()))
+ return srefs;
+
+ // The order in which the find hooks are called is the reverse compareTo ordering of
+ // their ServiceReferences. That is, the service with the highest ranking number must be called first.
List<ServiceReference> sortedHookRefs = new ArrayList<ServiceReference>(hookRefs);
- Collections.sort(sortedHookRefs);
Collections.reverse(sortedHookRefs);
-
+
srefs = new RemoveOnlyCollection<ServiceReference>(srefs);
-
+
List<FindHook> hooks = new ArrayList<FindHook>();
- for(ServiceReference hookRef : sortedHookRefs)
+ for (ServiceReference hookRef : sortedHookRefs)
hooks.add((FindHook)context.getService(hookRef));
-
+
for (FindHook hook : hooks)
{
try
@@ -453,9 +460,9 @@
return mdrFactory;
}
- private Collection<ServiceReference> getServiceReferencesInternal(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
+ private List<ServiceReference> getServiceReferencesInternal(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
{
- Set<ControllerContext> contexts;
+ Set<ControllerContext> contexts = null;
KernelController controller = kernel.getController();
// Don't check assignabilty for the system bundle
@@ -463,46 +470,50 @@
if (isSystemBundle)
checkAssignable = false;
- // TODO - a bit slow for system bundle
+ // Load the service class from the given bundle
if (clazz != null && isSystemBundle == false)
{
+ // Use all contexts the are of the given service type
Class<?> type = getBundleManager().loadClassFailsafe(bundle, clazz);
- if (type == null)
+ if (type != null)
+ contexts = controller.getContexts(type, ControllerState.INSTALLED);
+
+ // No services found
+ if (contexts == null || contexts.isEmpty())
return Collections.emptyList();
+ }
- contexts = controller.getContexts(type, ControllerState.INSTALLED);
- }
- else
- {
+ // Use all installed contexts
+ if (contexts == null)
contexts = controller.getContextsByState(ControllerState.INSTALLED);
- }
+ // No services found
if (contexts == null || contexts.isEmpty())
return Collections.emptyList();
if (filter == null)
filter = NoFilter.INSTANCE;
+ // Sort by the spec, should bubble up
List<ControllerContext> sorted = new ArrayList<ControllerContext>(contexts);
- Collections.sort(sorted, ContextComparator.INSTANCE); // Sort by the spec, should bubble up
- Collection<ServiceReference> result = new ArrayList<ServiceReference>();
+ Collections.sort(sorted, ContextComparator.getInstance());
+
+ List<ServiceReference> result = new ArrayList<ServiceReference>();
for (ControllerContext context : sorted)
{
- // re-check?? -- we already only get INSTALLED
- if (KernelUtils.isUnregistered(context) == false)
+ ServiceReference sref = getServiceReferenceForContext(context);
+ if (filter.match(sref) && hasPermission(context))
{
- ServiceReference ref = getServiceReferenceForContext(context);
- if (filter.match(ref) && hasPermission(context))
+ // True if the context contains the given class name
+ if (clazz == null || MDRUtils.matchClass(context, clazz))
{
- if (clazz == null || isSystemBundle == false || MDRUtils.matchClass(context, clazz))
- {
- // Check the assignability
- if (checkAssignable == false || MDRUtils.isAssignableTo(context, bundle))
- result.add(ref);
- }
+ // Check the assignability
+ if (checkAssignable == false || MDRUtils.isAssignableTo(context, bundle))
+ result.add(sref);
}
}
}
+ //Collections.sort(result, ServiceReferenceComparator.getInstance());
return result;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/FrameworkEventsPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/FrameworkEventsPlugin.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/FrameworkEventsPlugin.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -69,6 +69,5 @@
void fireFrameworkEvent(Bundle bundle, int type, Throwable throwable);
- // [TODO] remove dependecy on propriatary API
void fireServiceEvent(Bundle bundle, int type, OSGiServiceState service);
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -541,8 +541,8 @@
}
// Expose the wrapper not the state itself
- final ServiceEvent event = new OSGiServiceEvent(type, service.getReferenceInternal());
- final String typeName = ConstantsHelper.serviceEvent(event.getType());
+ ServiceEvent event = new OSGiServiceEvent(type, service.getReferenceInternal());
+ String typeName = ConstantsHelper.serviceEvent(event.getType());
log.info("Service " + typeName + ": " + service);
@@ -558,21 +558,31 @@
return;
// Call the listeners. All service events are synchronously delivered
- for (ServiceListenerRegistration registration : listeners)
+ for (ServiceListenerRegistration listener : listeners)
{
try
{
- // [TODO] MODIFIED_ENDMATCH
- // This event is synchronously delivered after the service properties have been modified.
+ String filterstr = listener.filter.toString();
+ if (listener.filter.match(service))
+ {
+ AccessControlContext accessControlContext = listener.accessControlContext;
+ if (accessControlContext == null || service.hasPermission(accessControlContext))
+ listener.listener.serviceChanged(event);
+ }
+
+ // The MODIFIED_ENDMATCH event is synchronously delivered after the service properties have been modified.
// This event is only delivered to listeners which were added with a non-null filter where
// the filter matched the service properties prior to the modification but the filter does
// not match the modified service properties.
-
- if (registration.filter.match(service))
+ else if (filterstr != null && ServiceEvent.MODIFIED == event.getType())
{
- AccessControlContext accessControlContext = registration.accessControlContext;
- if (accessControlContext == null || service.hasPermission(accessControlContext))
- registration.listener.serviceChanged(event);
+ if (listener.filter.match(service.getPreviousProperties()))
+ {
+ event = new OSGiServiceEvent(ServiceEvent.MODIFIED_ENDMATCH, service.getReferenceInternal());
+ AccessControlContext accessControlContext = listener.accessControlContext;
+ if (accessControlContext == null || service.hasPermission(accessControlContext))
+ listener.listener.serviceChanged(event);
+ }
}
}
catch (Throwable t)
@@ -622,7 +632,6 @@
return listeners;
}
- @SuppressWarnings("unchecked")
private List<EventHook> getEventHooks()
{
List<EventHook> hooks = new ArrayList<EventHook>();
@@ -641,7 +650,6 @@
// The calling order of the hooks is defined by the reversed compareTo ordering of their Service
// Reference objects. That is, the service with the highest ranking number is called first.
List<ServiceReference> sortedRefs = new ArrayList<ServiceReference>(Arrays.asList(srefs));
- Collections.sort(sortedRefs);
Collections.reverse(sortedRefs);
for (ServiceReference sref : sortedRefs)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -39,6 +39,8 @@
public RemoveOnlyCollection(Collection<T> delegate)
{
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate");
this.delegate = delegate;
}
@@ -120,4 +122,22 @@
{
delegate.clear();
}
+
+ @Override
+ public int hashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate.equals(obj);
+ }
+
+ @Override
+ public String toString()
+ {
+ return delegate.toString();
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-22 18:12:49 UTC (rev 102729)
@@ -41,6 +41,17 @@
<url>http://fisheye.jboss.com/qsearch/JBossOSGi</url>
</scm>
+ <!-- Modules -->
+ <modules>
+ <module>core</module>
+ <!--
+ <module>metadata</module>
+ <module>vfs21</module>
+ <module>vfs30</module>
+ -->
+ <module>bundle</module>
+ </modules>
+
<!-- Properties -->
<properties>
<version.apache.felix.configadmin>1.0.10</version.apache.felix.configadmin>
@@ -69,15 +80,6 @@
<version.osgi>4.2.0</version.osgi>
</properties>
- <!-- Modules -->
- <modules>
- <module>core</module>
- <module>metadata</module>
- <module>vfs21</module>
- <module>vfs30</module>
- <module>bundle</module>
- </modules>
-
<!-- Dependency Management -->
<dependencyManagement>
<dependencies>
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleFrameworkTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleFrameworkTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleFrameworkTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.example.simple;
+
+//$Id: SimpleTestCase.java 102343 2010-03-12 09:23:57Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.net.URL;
+
+import org.jboss.osgi.testing.OSGiFrameworkTest;
+import org.jboss.test.osgi.example.simple.bundle.SimpleService;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 12-Feb-2009
+ */
+public class SimpleFrameworkTestCase extends OSGiFrameworkTest
+{
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Get the bundle location
+ URL url = getTestArchiveURL("example-simple.jar");
+
+ // Install the Bundle
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(url.toExternalForm());
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
+
+ // Check that the BundleContext is still null
+ BundleContext context = bundle.getBundleContext();
+ assertNull("BundleContext null", context);
+
+ // Start the bundle
+ bundle.start();
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
+
+ // Check that the BundleContext is not null
+ context = bundle.getBundleContext();
+ assertNotNull("BundleContext not null", context);
+
+ // Get a service from the bundle's context
+ ServiceReference sref = context.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+ Object service = context.getService(sref);
+ assertNotNull("Service not null", service);
+
+ // Get a service from the system context
+ sref = sysContext.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+ service = context.getService(sref);
+ assertNotNull("Service not null", service);
+
+ // Stop the bundle
+ bundle.stop();
+ assertBundleState(Bundle.RESOLVED, bundle.getState());
+
+ try
+ {
+ context.getServiceReference(SimpleService.class.getName());
+ fail("Invalid BundleContext expected");
+ }
+ catch (IllegalStateException ex)
+ {
+ // expected
+ }
+
+ // Get a service from the system context
+ sref = sysContext.getServiceReference(SimpleService.class.getName());
+ assertNull("ServiceReference null", sref);
+
+ // Uninstall the bundle
+ bundle.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleRuntimeTestCase.java (from rev 102377, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleRuntimeTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleRuntimeTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.example.simple;
+
+//$Id$
+
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeTest;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 12-Feb-2009
+ */
+public class SimpleRuntimeTestCase extends OSGiRuntimeTest
+{
+ @Test
+ public void testSimpleBundle() throws Exception
+ {
+ // Get the default runtime
+ OSGiRuntime runtime = getDefaultRuntime();
+ try
+ {
+ // Install the bundle
+ OSGiBundle bundle = runtime.installBundle("example-simple.jar");
+ assertBundleState(Bundle.INSTALLED, bundle.getState());
+
+ // Start the bundle
+ bundle.start();
+ assertBundleState(Bundle.ACTIVE, bundle.getState());
+
+ // Uninstall the bundle
+ bundle.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundle.getState());
+ }
+ finally
+ {
+ // Shutdown the runtime
+ runtime.shutdown();
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/simple/SimpleTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.example.simple;
-
-//$Id$
-
-import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiRuntime;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- * A test that deployes a bundle and verifies its state
- *
- * @author thomas.diesler(a)jboss.com
- * @since 12-Feb-2009
- */
-public class SimpleTestCase extends OSGiRuntimeTest
-{
- @Test
- public void testSimpleBundle() throws Exception
- {
- // Get the default runtime
- OSGiRuntime runtime = getDefaultRuntime();
- try
- {
- // Install the bundle
- OSGiBundle bundle = runtime.installBundle("example-simple.jar");
- assertBundleState(Bundle.INSTALLED, bundle.getState());
-
- // Start the bundle
- bundle.start();
- assertBundleState(Bundle.ACTIVE, bundle.getState());
-
- // Uninstall the bundle
- bundle.uninstall();
- assertBundleState(Bundle.UNINSTALLED, bundle.getState());
- }
- finally
- {
- // Shutdown the runtime
- runtime.shutdown();
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/trunk/testsuite/functional/scripts/antrun-test-jars.xml 2010-03-22 18:12:49 UTC (rev 102729)
@@ -28,6 +28,7 @@
[JBOSGI-284] Investigate version numbering scheme
[JBOSGI-286] Investigate classloading of javax.* classes
[JBOSGI-287] Optional import loaded from system classloader
+ [JBOSGI-298] InstanceAlreadyExistsException: osgi.core:type=framework,version=1.5
-->
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGi142TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGi142TestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi142/OSGi142TestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -23,17 +23,13 @@
//$Id: OSGI142TestCase.java 87103 2009-04-09 22:18:31Z thomas.diesler(a)jboss.com $
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.testing.OSGiFrameworkTest;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.test.osgi.jbosgi142.bundleA.BeanA;
import org.jboss.test.osgi.jbosgi142.bundleB.BeanB;
import org.jboss.test.osgi.jbosgi142.bundleX.BeanX;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.launch.Framework;
/**
* [JBOSGI-142] Investigate classloading space
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi143/OSGi143TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi143/OSGi143TestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi143/OSGi143TestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -26,16 +26,12 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.testing.OSGiFrameworkTest;
-import org.jboss.osgi.testing.OSGiRuntimeTest;
import org.jboss.test.osgi.jbosgi143.bundleA.BeanA;
import org.jboss.test.osgi.jbosgi143.bundleX.BeanX;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.launch.Framework;
/**
* [JBOSGI-143] Add initial support for DynamicImport-Package
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/services/ServiceRegistrationTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/services/ServiceRegistrationTestCase.java 2010-03-22 17:35:30 UTC (rev 102728)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/services/ServiceRegistrationTestCase.java 2010-03-22 18:12:49 UTC (rev 102729)
@@ -105,9 +105,12 @@
Bundle[] users = sref.getUsingBundles();
System.out.println("FIXME [JBOSGI-305] Clarify ServiceReference.getUsingBundles() in ServiceFactory.ungetService()");
- //assertNotNull("Users not null", users);
- //assertEquals(1, users.length);
- //assertEquals(bundle, users[0]);
+ if ("equinox".equals(getFrameworkName()) == false)
+ {
+ assertNotNull("Users not null", users);
+ assertEquals(1, users.length);
+ assertEquals(bundle, users[0]);
+ }
allGood[1] = true;
}
14 years, 3 months
JBoss-OSGI SVN: r102691 - in projects/jboss-osgi/projects/runtime/framework/trunk: core/src/main/java/org/jboss/osgi/framework/bundle and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-21 15:48:04 -0400 (Sun, 21 Mar 2010)
New Revision: 102691
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
Log:
Add FindHook support - first cut
[TCK] EventHook pass
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java 2010-03-21 19:48:04 UTC (rev 102691)
@@ -74,7 +74,7 @@
contexts.add(context);
fail("Cannot add a context");
}
- catch (RuntimeException ex)
+ catch (UnsupportedOperationException ex)
{
// expected
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-03-21 18:41:27 UTC (rev 102690)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-03-21 19:48:04 UTC (rev 102691)
@@ -484,7 +484,7 @@
{
checkValidBundleContext();
ServiceManagerPlugin plugin = getBundleManager().getPlugin(ServiceManagerPlugin.class);
- return plugin.getAllServiceReferences(this, clazz, filter);
+ return plugin.getServiceReferences(this, clazz, filter, false);
}
public Object getService(ServiceReference reference)
@@ -505,7 +505,7 @@
{
checkValidBundleContext();
ServiceManagerPlugin plugin = getBundleManager().getPlugin(ServiceManagerPlugin.class);
- return plugin.getServiceReferences(this, clazz, filter);
+ return plugin.getServiceReferences(this, clazz, filter, true);
}
@SuppressWarnings({ "rawtypes" })
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-03-21 18:41:27 UTC (rev 102690)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-03-21 19:48:04 UTC (rev 102691)
@@ -55,13 +55,16 @@
import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
import org.jboss.osgi.framework.util.KernelUtils;
import org.jboss.osgi.framework.util.NoFilter;
+import org.jboss.osgi.framework.util.RemoveOnlyCollection;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.service.FindHook;
import org.osgi.framework.hooks.service.ListenerHook;
import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
@@ -90,11 +93,11 @@
/** Enable MDR usage */
private boolean enableMDRUsage = true;
-
+
public ServiceManagerPluginImpl(OSGiBundleManager bundleManager, DeploymentRegistry registry)
{
super(bundleManager);
-
+
if (registry == null)
throw new IllegalArgumentException("Null deployment registry");
@@ -135,7 +138,7 @@
}
if (result.isEmpty())
return null;
-
+
return result.toArray(new ServiceReference[result.size()]);
}
@@ -156,25 +159,11 @@
if (references.isEmpty())
return null;
-
+
return references.toArray(new ServiceReference[references.size()]);
}
@Override
- public ServiceReference[] getAllServiceReferences(AbstractBundleState bundle, String clazz, String filterStr) throws InvalidSyntaxException
- {
- Filter filter = NoFilter.INSTANCE;
- if (filterStr != null)
- filter = FrameworkUtil.createFilter(filterStr);
-
- Collection<ServiceReference> services = getServices(bundle, clazz, filter, false);
- if (services == null || services.isEmpty())
- return null;
-
- return services.toArray(new ServiceReference[services.size()]);
- }
-
- @Override
public Set<Bundle> getUsingBundles(OSGiServiceState serviceState)
{
AbstractBundleState bundleState = serviceState.getBundleState();
@@ -191,13 +180,13 @@
}
return bundles;
}
-
+
@Override
public Object getService(AbstractBundleState bundleState, ServiceReference reference)
{
if (reference == null)
throw new IllegalArgumentException("Null reference");
-
+
ControllerContextHandle handle = (ControllerContextHandle)reference;
ControllerContext context = handle.getContext();
if (KernelUtils.isUnregistered(context)) // we're probably not installed anymore
@@ -213,28 +202,72 @@
{
if (clazz == null)
throw new IllegalArgumentException("Null clazz");
-
- Collection<ServiceReference> services = getServices(bundle, clazz, null, true);
- if (services == null || services.isEmpty())
+
+ Collection<ServiceReference> srefs = getServiceReferencesInternal(bundle, clazz, null, true);
+ srefs = processFindHooks(bundle, clazz, null, true, srefs);
+ if (srefs.isEmpty())
return null;
- return services.iterator().next();
+ return srefs.iterator().next();
}
@Override
- public ServiceReference[] getServiceReferences(AbstractBundleState bundle, String clazz, String filterStr) throws InvalidSyntaxException
+ public ServiceReference[] getServiceReferences(AbstractBundleState bundle, String clazz, String filterStr, boolean checkAssignable)
+ throws InvalidSyntaxException
{
- Filter filter = NoFilter.INSTANCE;
+ Filter filter = null;
if (filterStr != null)
filter = FrameworkUtil.createFilter(filterStr);
- Collection<ServiceReference> services = getServices(bundle, clazz, filter, true);
- if (services == null || services.isEmpty())
+ Collection<ServiceReference> srefs = getServiceReferencesInternal(bundle, clazz, filter, checkAssignable);
+ srefs = processFindHooks(bundle, clazz, filterStr, checkAssignable, srefs);
+ if (srefs.isEmpty())
return null;
- return services.toArray(new ServiceReference[services.size()]);
+ return srefs.toArray(new ServiceReference[srefs.size()]);
}
+ /*
+ * The FindHook is called when a target bundle searches the service registry
+ * with the getServiceReference or getServiceReferences methods. A registered
+ * FindHook service gets a chance to inspect the returned set of service
+ * references and can optionally shrink the set of returned services. The order
+ * in which the find hooks are called is the reverse compareTo ordering of
+ * their Service References.
+ */
+ @SuppressWarnings("unchecked")
+ private Collection<ServiceReference> processFindHooks(AbstractBundleState bundle, String clazz, String filterStr, boolean checkAssignable, Collection<ServiceReference> srefs)
+ {
+ BundleContext context = bundle.getBundleContext();
+ if (context == null)
+ return srefs;
+
+ // Get and sort the FindHook refs
+ Collection<ServiceReference> hookRefs = getServiceReferencesInternal(bundle, FindHook.class.getName(), null, true);
+ List<ServiceReference> sortedHookRefs = new ArrayList<ServiceReference>(hookRefs);
+ Collections.sort(sortedHookRefs);
+ Collections.reverse(sortedHookRefs);
+
+ srefs = new RemoveOnlyCollection<ServiceReference>(srefs);
+
+ List<FindHook> hooks = new ArrayList<FindHook>();
+ for(ServiceReference hookRef : sortedHookRefs)
+ hooks.add((FindHook)context.getService(hookRef));
+
+ for (FindHook hook : hooks)
+ {
+ try
+ {
+ hook.find(context, clazz, filterStr, !checkAssignable, srefs);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Error while calling FindHook: " + hook, ex);
+ }
+ }
+ return srefs;
+ }
+
@Override
@SuppressWarnings("rawtypes")
public OSGiServiceState registerService(AbstractBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
@@ -247,7 +280,7 @@
FrameworkEventsPlugin eventsPlugin = getPlugin(FrameworkEventsPlugin.class);
listenerInfos = eventsPlugin.getServiceListenerInfos(null);
}
-
+
OSGiServiceState result = new OSGiServiceState(bundleState, clazzes, service, properties);
result.internalRegister();
try
@@ -272,11 +305,11 @@
ListenerHook listenerHook = (ListenerHook)service;
listenerHook.added(listenerInfos);
}
-
+
// This event is synchronously delivered after the service has been registered with the Framework.
FrameworkEventsPlugin eventsPlugin = getPlugin(FrameworkEventsPlugin.class);
eventsPlugin.fireServiceEvent(bundleState, ServiceEvent.REGISTERED, result);
-
+
return result;
}
@@ -284,15 +317,15 @@
public void unregisterService(OSGiServiceState serviceState)
{
AbstractBundleState bundleState = serviceState.getBundleState();
-
+
// This event is synchronously delivered before the service has completed unregistering.
FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
plugin.fireServiceEvent(bundleState, ServiceEvent.UNREGISTERING, serviceState);
-
+
internalUnregister(serviceState);
if (bundleState instanceof OSGiBundleState)
removeContext(serviceState, ((OSGiBundleState)bundleState).getDeploymentUnit());
-
+
Controller controller = kernel.getController();
controller.uninstall(serviceState.getName());
}
@@ -309,17 +342,17 @@
Set<AbstractBundleState> used = new HashSet<AbstractBundleState>();
OSGiBundleManager manager = bundleState.getBundleManager();
ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
-
+
for (Object user : users)
{
AbstractBundleState using = plugin.getBundleForUser(user);
- if (used.add(using) == true)
+ if (used.add(using) == true)
{
// ungetService will cleanup service cache
int count = ct.getUsedByCount(serviceState, using);
while (count > 0)
{
- using.ungetContext(serviceState);
+ using.ungetContext(serviceState);
count--;
}
}
@@ -328,7 +361,7 @@
}
serviceState.clearTarget();
}
-
+
@Override
public boolean ungetService(AbstractBundleState bundleState, ServiceReference reference)
{
@@ -339,7 +372,7 @@
ControllerContext context = serviceReference.getContext();
if (KernelUtils.isUnregistered(context))
return false;
-
+
return bundleState.removeContextInUse(context);
}
@@ -420,7 +453,7 @@
return mdrFactory;
}
- private Collection<ServiceReference> getServices(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
+ private Collection<ServiceReference> getServiceReferencesInternal(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
{
Set<ControllerContext> contexts;
KernelController controller = kernel.getController();
@@ -435,7 +468,7 @@
{
Class<?> type = getBundleManager().loadClassFailsafe(bundle, clazz);
if (type == null)
- return null; // or check all?
+ return Collections.emptyList();
contexts = controller.getContexts(type, ControllerState.INSTALLED);
}
@@ -445,7 +478,7 @@
}
if (contexts == null || contexts.isEmpty())
- return null;
+ return Collections.emptyList();
if (filter == null)
filter = NoFilter.INSTANCE;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java 2010-03-21 18:41:27 UTC (rev 102690)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java 2010-03-21 19:48:04 UTC (rev 102691)
@@ -63,21 +63,10 @@
/**
* Returns an array of <code>ServiceReference</code> objects. The returned
* array of <code>ServiceReference</code> objects contains services that
- * were registered under the specified class and match the specified filter
+ * were registered under the specified class, match the specified filter
* expression.
*
- * @param clazz The class name with which the service was registered or <code>null</code> for all services.
- * @param filter The filter expression or <code>null</code> for all services.
- * @return An array of <code>ServiceReference</code> objects or <code>null</code>
- * if no services are registered which satisfy the search.
- */
- ServiceReference[] getAllServiceReferences(AbstractBundleState bundleState, String clazz, String filter) throws InvalidSyntaxException;
-
- /**
- * Returns an array of <code>ServiceReference</code> objects. The returned
- * array of <code>ServiceReference</code> objects contains services that
- * were registered under the specified class, match the specified filter
- * expression, and the packages for the class names under which the services
+ * If checkAssignable is true, the packages for the class names under which the services
* were registered match the context bundle's packages as defined in
* {@link ServiceReference#isAssignableTo(Bundle, String)}.
*
@@ -85,7 +74,7 @@
* @param clazz The class name with which the service was registered or <code>null</code> for all services.
* @param filter The filter expression or <code>null</code> for all services.
*/
- ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, String filter) throws InvalidSyntaxException;
+ ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, String filter, boolean checkAssignable) throws InvalidSyntaxException;
/**
* Returns a <code>ServiceReference</code> object for a service that
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2010-03-21 18:41:27 UTC (rev 102690)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2010-03-21 19:48:04 UTC (rev 102691)
@@ -46,6 +46,7 @@
import org.jboss.osgi.framework.bundle.OSGiServiceState;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.util.NoFilter;
+import org.jboss.osgi.framework.util.RemoveOnlyCollection;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -57,7 +58,6 @@
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceException;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.SynchronousBundleListener;
@@ -66,7 +66,8 @@
import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
/**
- * A plugin that installs/starts bundles on framework startup.
+ * A plugin that manages {@link FrameworkListener}, {@link BundleListener}, {@link ServiceListener} and their
+ * associated {@link FrameworkEvent}, {@link BundleEvent}, {@link ServiceEvent}.
*
* @author thomas.diesler(a)jboss.com
* @since 18-Aug-2009
@@ -526,7 +527,6 @@
{
// Get a snapshot of the current listeners
List<ServiceListenerRegistration> listeners = new ArrayList<ServiceListenerRegistration>();
- Collection<BundleContext> contexts = new HashSet<BundleContext>();
synchronized (serviceListeners)
{
for (Entry<Bundle, List<ServiceListenerRegistration>> entry : serviceListeners.entrySet())
@@ -535,13 +535,9 @@
{
BundleContext context = listener.getBundleContext();
if (context != null)
- {
listeners.add(listener);
- contexts.add(context);
- }
}
}
- contexts = new RemoveOnlyCollection<BundleContext>(contexts);
}
// Expose the wrapper not the state itself
@@ -555,31 +551,8 @@
return;
// Call the registered event hooks
- List<EventHook> eventHooks = getEventHooks();
- for (EventHook hook : eventHooks)
- {
- try
- {
- hook.event(event, contexts);
- }
- catch (Exception ex)
- {
- log.warn("Error while calling EventHook: " + hook, ex);
- }
- }
+ listeners = processEventHooks(listeners, event);
- // Remove the listeners that have been filtered by the EventHooks
- if (contexts.size() != listeners.size())
- {
- Iterator<ServiceListenerRegistration> it = listeners.iterator();
- while (it.hasNext())
- {
- ServiceListenerRegistration slreg = it.next();
- if (contexts.contains(slreg.getBundleContext()) == false)
- it.remove();
- }
- }
-
// Nobody is interested
if (listeners.isEmpty())
return;
@@ -609,6 +582,46 @@
}
}
+ private List<ServiceListenerRegistration> processEventHooks(List<ServiceListenerRegistration> listeners, final ServiceEvent event)
+ {
+ // Collect the BundleContexts
+ Collection<BundleContext> contexts = new HashSet<BundleContext>();
+ for (ServiceListenerRegistration listener : listeners)
+ {
+ BundleContext context = listener.getBundleContext();
+ if (context != null)
+ contexts.add(context);
+ }
+ contexts = new RemoveOnlyCollection<BundleContext>(contexts);
+
+ // Call the registered event hooks
+ List<EventHook> eventHooks = getEventHooks();
+ for (EventHook hook : eventHooks)
+ {
+ try
+ {
+ hook.event(event, contexts);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Error while calling EventHook: " + hook, ex);
+ }
+ }
+
+ // Remove the listeners that have been filtered by the EventHooks
+ if (contexts.size() != listeners.size())
+ {
+ Iterator<ServiceListenerRegistration> it = listeners.iterator();
+ while (it.hasNext())
+ {
+ ServiceListenerRegistration slreg = it.next();
+ if (contexts.contains(slreg.getBundleContext()) == false)
+ it.remove();
+ }
+ }
+ return listeners;
+ }
+
@SuppressWarnings("unchecked")
private List<EventHook> getEventHooks()
{
@@ -833,97 +846,4 @@
return "ServiceEvent[type=" + ConstantsHelper.serviceEvent(getType()) + ",source=" + getSource() + "]";
}
}
-
- /**
- * A Collection that does not allow add operations.
- */
- @SuppressWarnings("rawtypes")
- static class RemoveOnlyCollection<T> implements Collection<T>
- {
- Collection<T> delegate;
-
- RemoveOnlyCollection(Collection<T> delegate)
- {
- this.delegate = delegate;
- }
-
- @Override
- public int size()
- {
- return delegate.size();
- }
-
- @Override
- public boolean isEmpty()
- {
- return delegate.isEmpty();
- }
-
- @Override
- public boolean contains(Object o)
- {
- return delegate.contains(o);
- }
-
- @Override
- public Iterator<T> iterator()
- {
- return delegate.iterator();
- }
-
- @Override
- public Object[] toArray()
- {
- return delegate.toArray();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Object[] toArray(Object[] a)
- {
- return delegate.toArray(a);
- }
-
- @Override
- public boolean add(Object e)
- {
- throw new ServiceException("Add not supported");
- }
-
- @Override
- public boolean remove(Object o)
- {
- return delegate.remove(o);
- }
-
- @Override
- public boolean containsAll(Collection c)
- {
- return delegate.containsAll(c);
- }
-
- @Override
- public boolean addAll(Collection c)
- {
- throw new ServiceException("Add not supported");
- }
-
- @Override
- public boolean removeAll(Collection c)
- {
- return delegate.removeAll(c);
- }
-
- @Override
- public boolean retainAll(Collection c)
- {
- return delegate.removeAll(c);
- }
-
- @Override
- public void clear()
- {
- delegate.clear();
- }
- }
}
\ No newline at end of file
Added: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/util/RemoveOnlyCollection.java 2010-03-21 19:48:04 UTC (rev 102691)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.framework.util;
+
+//$Id: SystemPackagesPluginImpl.java 92858 2009-08-27 10:58:32Z thomas.diesler(a)jboss.com $
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * A Collection that does not allow add operations.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-MAr-2010
+ */
+@SuppressWarnings("rawtypes")
+public class RemoveOnlyCollection<T> implements Collection<T>
+{
+ Collection<T> delegate;
+
+ public RemoveOnlyCollection(Collection<T> delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o)
+ {
+ return delegate.contains(o);
+ }
+
+ @Override
+ public Iterator<T> iterator()
+ {
+ return delegate.iterator();
+ }
+
+ @Override
+ public Object[] toArray()
+ {
+ return delegate.toArray();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Object[] toArray(Object[] a)
+ {
+ return delegate.toArray(a);
+ }
+
+ @Override
+ public boolean add(Object e)
+ {
+ throw new UnsupportedOperationException("Add not supported");
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ return delegate.remove(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection c)
+ {
+ return delegate.containsAll(c);
+ }
+
+ @Override
+ public boolean addAll(Collection c)
+ {
+ throw new UnsupportedOperationException("Add not supported");
+ }
+
+ @Override
+ public boolean removeAll(Collection c)
+ {
+ return delegate.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection c)
+ {
+ return delegate.removeAll(c);
+ }
+
+ @Override
+ public void clear()
+ {
+ delegate.clear();
+ }
+}
\ No newline at end of file
14 years, 3 months
JBoss-OSGI SVN: r102690 - in projects/jboss-osgi/projects/runtime/framework/trunk: bundle/src/test/java/org/jboss/test/osgi/bundle/support/b and 15 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-21 14:41:27 -0400 (Sun, 21 Mar 2010)
New Revision: 102690
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesTestCase.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/SystemBundleTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleService.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleServiceActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleTestCase.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/fragments/fragA/FragBeanA.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.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/ResolverMetadataTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/BrokenServiceFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java
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/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
Log:
Add EventHook support - first cut
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleEntriesTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -50,7 +50,8 @@
*/
public class BundleEntriesTestCase extends AbstractFrameworkTest
{
- @Test public void testEntriesNotInstalled() throws Exception
+ @Test
+ public void testEntriesNotInstalled() throws Exception
{
Bundle bundle = installBundle(assembleArchive("entries-simple", "/bundles/entries/entries-simple"));
bundle.uninstall();
@@ -73,8 +74,9 @@
// expected
}
}
-
- @Test public void testFindEntriesNoPath() throws Exception
+
+ @Test
+ public void testFindEntriesNoPath() throws Exception
{
Bundle bundle = installBundle(assembleArchive("entries-simple", "/bundles/entries/entries-simple"));
try
@@ -91,8 +93,9 @@
bundle.uninstall();
}
}
-
- @Test public void testEntries() throws Exception
+
+ @Test
+ public void testEntries() throws Exception
{
Bundle bundle = installBundle(assembleArchive("entries-simple", "/bundles/entries/entries-simple"));
try
@@ -100,26 +103,11 @@
assertEntry(bundle, "");
assertNoEntries(bundle, "", "", false);
assertNoEntries(bundle, "", "", true);
- assertEntryPaths("", bundle,
- "root.xml",
- "root-no-suffix",
- "entry1.xml",
- "META-INF/",
- "META-INF/MANIFEST.MF",
- "org/",
- "org/jboss/",
- "org/jboss/test/",
- "org/jboss/test/osgi/",
- "org/jboss/test/osgi/bundle/",
- "org/jboss/test/osgi/bundle/entries/",
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
+ assertEntryPaths("", bundle, "root.xml", "root-no-suffix", "entry1.xml", "META-INF/", "META-INF/MANIFEST.MF", "org/", "org/jboss/", "org/jboss/test/",
+ "org/jboss/test/osgi/", "org/jboss/test/osgi/bundle/", "org/jboss/test/osgi/bundle/entries/", "org/jboss/test/osgi/bundle/entries/notxml.suffix",
+ "org/jboss/test/osgi/bundle/entries/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml", "org/jboss/test/osgi/bundle/entries/sub/",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
assertNoEntry(bundle, "DoesNotExist");
assertNoEntries(bundle, "", "DoesNotExist", false);
assertNoEntries(bundle, "", "DoesNotExist", true);
@@ -137,21 +125,15 @@
assertEntry(bundle, "entry1.xml");
assertEntries(bundle, "", "entry1.xml", false, "entry1.xml");
- assertEntries(bundle, "", "entry1.xml", true,
- "entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml"
- );
+ assertEntries(bundle, "", "entry1.xml", true, "entry1.xml", "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
assertEntryPaths(bundle, "entry1.xml");
assertEntry(bundle, "META-INF");
assertNoEntries(bundle, "", "META-INF", false);
assertNoEntries(bundle, "", "META-INF", true);
- assertEntryPaths("META-INF", bundle,
- "META-INF/",
- "META-INF/MANIFEST.MF"
- );
-
+ assertEntryPaths("META-INF", bundle, "META-INF/", "META-INF/MANIFEST.MF");
+
assertNoEntry(bundle, "META-INF/DoesNotExist");
assertNoEntries(bundle, "META-INF", "DoesNotExist", false);
assertNoEntries(bundle, "META-INF", "DoesNotExist", true);
@@ -165,21 +147,11 @@
assertEntry(bundle, "org");
assertNoEntries(bundle, "", "org", false);
assertNoEntries(bundle, "", "org", true);
- assertEntryPaths("org", bundle,
- "org/",
- "org/jboss/",
- "org/jboss/test/",
- "org/jboss/test/osgi/",
- "org/jboss/test/osgi/bundle/",
- "org/jboss/test/osgi/bundle/entries/",
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
+ assertEntryPaths("org", bundle, "org/", "org/jboss/", "org/jboss/test/", "org/jboss/test/osgi/", "org/jboss/test/osgi/bundle/",
+ "org/jboss/test/osgi/bundle/entries/", "org/jboss/test/osgi/bundle/entries/notxml.suffix", "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/entry2.xml", "org/jboss/test/osgi/bundle/entries/sub/", "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
assertNoEntry(bundle, "org/DoesNotExist");
assertNoEntries(bundle, "org", "DoesNotExist", false);
assertNoEntries(bundle, "org", "DoesNotExist", true);
@@ -188,179 +160,94 @@
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries");
assertEntries(bundle, "", "org/jboss/test/osgi/bundle/entries", false);
assertEntries(bundle, "", "org/jboss/test/osgi/bundle/entries", true);
- assertEntryPaths("org/jboss/test/osgi/bundle/entries", bundle,
- "org/jboss/test/osgi/bundle/entries/",
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
+ assertEntryPaths("org/jboss/test/osgi/bundle/entries", bundle, "org/jboss/test/osgi/bundle/entries/", "org/jboss/test/osgi/bundle/entries/notxml.suffix",
+ "org/jboss/test/osgi/bundle/entries/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml", "org/jboss/test/osgi/bundle/entries/sub/",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
assertNoEntry(bundle, "org/jboss/test/osgi/bundle/DoesNotExist");
assertNoEntries(bundle, "org/jboss/test/osgi/bundle", "DoesNotExist", false);
assertNoEntries(bundle, "org/jboss/test/osgi/bundle", "DoesNotExist", true);
assertNoEntryPaths(bundle, "org/jboss/test/osgi/bundle/DoesNotExist");
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries/notxml.suffix");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "notxml.suffix", false,
- "org/jboss/test/osgi/bundle/entries/notxml.suffix");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "notxml.suffix", true,
- "org/jboss/test/osgi/bundle/entries/notxml.suffix"
- );
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "notxml.suffix", false, "org/jboss/test/osgi/bundle/entries/notxml.suffix");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "notxml.suffix", true, "org/jboss/test/osgi/bundle/entries/notxml.suffix");
assertEntryPaths(bundle, "org/jboss/test/osgi/bundle/entries/notxml.suffix");
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries/entry1.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry1.xml", false,
- "org/jboss/test/osgi/bundle/entries/entry1.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry1.xml", true,
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml"
- );
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry1.xml", false, "org/jboss/test/osgi/bundle/entries/entry1.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry1.xml", true, "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
assertEntryPaths(bundle, "org/jboss/test/osgi/bundle/entries/entry1.xml");
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries/entry2.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry2.xml", false,
- "org/jboss/test/osgi/bundle/entries/entry2.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry2.xml", true,
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry2.xml", false, "org/jboss/test/osgi/bundle/entries/entry2.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry2.xml", true, "org/jboss/test/osgi/bundle/entries/entry2.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
assertEntryPaths(bundle, "org/jboss/test/osgi/bundle/entries/entry2.xml");
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries/sub");
assertEntries(bundle, "", "org/jboss/test/osgi/bundle/entries/sub", false);
assertEntries(bundle, "", "org/jboss/test/osgi/bundle/entries/sub", true);
- assertEntryPaths("org/jboss/test/osgi/bundle/entries/sub", bundle,
- "org/jboss/test/osgi/bundle/entries/sub/",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
+ assertEntryPaths("org/jboss/test/osgi/bundle/entries/sub", bundle, "org/jboss/test/osgi/bundle/entries/sub/",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
assertNoEntry(bundle, "org/jboss/test/osgi/bundle/DoesNotExist/sub");
assertNoEntries(bundle, "org/jboss/test/osgi/bundle/sub", "DoesNotExist", false);
assertNoEntries(bundle, "org/jboss/test/osgi/bundle/sub", "DoesNotExist", true);
assertNoEntryPaths(bundle, "org/jboss/test/osgi/bundle/DoesNotExist/sub");
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry1.xml", false,
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry1.xml", true,
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry1.xml", false, "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry1.xml", true, "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
assertEntryPaths(bundle, "org/jboss/test/osgi/bundle/entries/sub/entry1.xml");
assertEntry(bundle, "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry2.xml", false,
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry2.xml", false, "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry2.xml", true, "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+ assertEntryPaths(bundle, "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
+ assertEntries(bundle, "", "*", false, "root.xml", "root-no-suffix", "entry1.xml");
+ assertEntries(bundle, "", "*", true, "root.xml", "root-no-suffix", "entry1.xml", "META-INF/MANIFEST.MF",
+ "org/jboss/test/osgi/bundle/entries/notxml.suffix", "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml",
"org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries/sub", "entry2.xml", true,
+
+ assertEntries(bundle, "", null, false, "root.xml", "root-no-suffix", "entry1.xml");
+ assertEntries(bundle, "", null, true, "root.xml", "root-no-suffix", "entry1.xml", "META-INF/MANIFEST.MF",
+ "org/jboss/test/osgi/bundle/entries/notxml.suffix", "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml",
"org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
- assertEntryPaths(bundle, "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
- assertEntries(bundle, "", "*", false,
- "root.xml",
- "root-no-suffix",
- "entry1.xml"
- );
- assertEntries(bundle, "", "*", true,
- "root.xml",
- "root-no-suffix",
- "entry1.xml",
- "META-INF/MANIFEST.MF",
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
+ assertEntries(bundle, "", "root*", false, "root-no-suffix", "root.xml");
+ assertEntries(bundle, "", "root*", true, "root-no-suffix", "root.xml");
- assertEntries(bundle, "", null, false,
- "root.xml",
- "root-no-suffix",
- "entry1.xml"
- );
- assertEntries(bundle, "", null, true,
- "root.xml",
- "root-no-suffix",
- "entry1.xml",
- "META-INF/MANIFEST.MF",
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
- assertEntries(bundle, "", "root*", false,
- "root-no-suffix",
- "root.xml"
- );
- assertEntries(bundle, "", "root*", true,
- "root-no-suffix",
- "root.xml"
- );
-
- assertEntries(bundle, "", "entry*", false,
- "entry1.xml"
- );
- assertEntries(bundle, "", "entry*", true,
- "entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry*", false,
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml"
- );
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry*", true,
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
- assertEntries(bundle, "", "*.xml", false,
- "root.xml",
- "entry1.xml"
- );
- assertEntries(bundle, "", "*.xml", true,
- "root.xml",
- "entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
- assertEntries(bundle, "", "*xml*", false,
- "root.xml",
- "entry1.xml"
- );
- assertEntries(bundle, "", "*xml*", true,
- "root.xml",
- "entry1.xml",
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
-
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "*xml*", false,
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml"
- );
- assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "*xml*", true,
- "org/jboss/test/osgi/bundle/entries/notxml.suffix",
- "org/jboss/test/osgi/bundle/entries/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
- "org/jboss/test/osgi/bundle/entries/entry2.xml",
- "org/jboss/test/osgi/bundle/entries/sub/entry2.xml"
- );
+ assertEntries(bundle, "", "entry*", false, "entry1.xml");
+ assertEntries(bundle, "", "entry*", true, "entry1.xml", "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry*", false, "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/entry2.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "entry*", true, "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
+ assertEntries(bundle, "", "*.xml", false, "root.xml", "entry1.xml");
+ assertEntries(bundle, "", "*.xml", true, "root.xml", "entry1.xml", "org/jboss/test/osgi/bundle/entries/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml",
+ "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
+ assertEntries(bundle, "", "*xml*", false, "root.xml", "entry1.xml");
+ assertEntries(bundle, "", "*xml*", true, "root.xml", "entry1.xml", "org/jboss/test/osgi/bundle/entries/notxml.suffix",
+ "org/jboss/test/osgi/bundle/entries/entry1.xml", "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/entry2.xml", "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
+
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "*xml*", false, "org/jboss/test/osgi/bundle/entries/notxml.suffix",
+ "org/jboss/test/osgi/bundle/entries/entry1.xml", "org/jboss/test/osgi/bundle/entries/entry2.xml");
+ assertEntries(bundle, "org/jboss/test/osgi/bundle/entries", "*xml*", true, "org/jboss/test/osgi/bundle/entries/notxml.suffix",
+ "org/jboss/test/osgi/bundle/entries/entry1.xml", "org/jboss/test/osgi/bundle/entries/sub/entry1.xml",
+ "org/jboss/test/osgi/bundle/entries/entry2.xml", "org/jboss/test/osgi/bundle/entries/sub/entry2.xml");
}
finally
{
@@ -379,7 +266,7 @@
URL actual = bundle.getEntry(path);
assertNull("Did not expect entry: " + actual + " for path: " + path, actual);
}
-
+
@SuppressWarnings("unchecked")
protected void assertEntries(Bundle bundle, String path, String filePattern, boolean recurse, String... entries) throws Exception
{
@@ -387,7 +274,7 @@
Enumeration<URL> enumeration = bundle.findEntries(path, filePattern, recurse);
while (enumeration != null && enumeration.hasMoreElements())
actual.add(enumeration.nextElement());
-
+
URL baseurl = bundle.getEntry("/");
Set<URL> expected = new HashSet<URL>();
for (String entry : entries)
@@ -400,7 +287,7 @@
{
assertEntries(bundle, path, filePattern, recurse);
}
-
+
protected void assertEntryPaths(Bundle bundle, String path) throws Exception
{
Set<String> expected = Collections.singleton(path);
@@ -408,7 +295,7 @@
assertEntryPaths(bundle, path, expected);
assertEntryPaths(bundle, "/" + path, expected);
}
-
+
protected void assertEntryPaths(String path, Bundle bundle, String... entries) throws Exception
{
Set<String> expected = new HashSet<String>();
@@ -417,7 +304,7 @@
assertEntryPaths(bundle, path, expected);
assertEntryPaths(bundle, "/" + path, expected);
}
-
+
@SuppressWarnings("unchecked")
protected void assertEntryPaths(Bundle bundle, String path, Set<String> expected) throws Exception
{
@@ -425,10 +312,10 @@
Enumeration<String> enumeration = bundle.getEntryPaths(path);
while (enumeration != null && enumeration.hasMoreElements())
actual.add(enumeration.nextElement());
-
+
assertEquals(expected, actual);
}
-
+
@SuppressWarnings("unchecked")
protected void assertNoEntryPaths(Bundle bundle, String path) throws Exception
{
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-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -48,7 +48,8 @@
/**
* Verifies that the service bundle can get started
*/
- @Test public void testSimpleStart() throws Exception
+ @Test
+ public void testSimpleStart() throws Exception
{
VirtualFile assemblyA = assembleArchive("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = installBundle(assemblyA);
@@ -72,7 +73,8 @@
/**
* Verifies that the bundle state is RESOLVED after a failure in BundleActivator.start()
*/
- @Test public void testDependencyNotAvailable() throws Exception
+ @Test
+ public void testDependencyNotAvailable() throws Exception
{
VirtualFile assemblyA = assembleArchive("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = installBundle(assemblyA);
@@ -113,7 +115,8 @@
/**
* Verifies that BundleB can get started when the service is available
*/
- @Test public void testDependencyAvailable() throws Exception
+ @Test
+ public void testDependencyAvailable() throws Exception
{
VirtualFile assemblyA = assembleArchive("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = installBundle(assemblyA);
@@ -145,7 +148,8 @@
/**
* Verifies that BundleB can get started when the service is made available
*/
- @Test public void testStartRetry() throws Exception
+ @Test
+ public void testStartRetry() throws Exception
{
VirtualFile assemblyA = assembleArchive("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class);
Bundle bundleA = installBundle(assemblyA);
@@ -193,7 +197,8 @@
/**
* Verifies that BundleB is still INSTALLED after a failure in PackageAdmin.resolve()
*/
- @Test public void testFailToResolve() throws Exception
+ @Test
+ public void testFailToResolve() throws Exception
{
VirtualFile assemblyA = assembleArchive("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class);
Bundle bundleB = installBundle(assemblyA);
@@ -204,11 +209,11 @@
// Get the PackageAdmin service
ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin packageAdmin = (PackageAdmin)context.getService(sref);
-
+
// Attempt to explicitly resolve a bundle with missing dependency
boolean allResolved = packageAdmin.resolveBundles(new Bundle[] { bundleB });
assertFalse("Resolve fails", allResolved);
-
+
// Verify that the bundkle is still in state INSTALLED
assertBundleState(Bundle.INSTALLED, bundleB.getState());
}
@@ -222,7 +227,8 @@
/**
* Verifies that we get a BundleException when an invalid bundle is installed
*/
- @Test public void testInstallInvalid() throws Exception
+ @Test
+ public void testInstallInvalid() throws Exception
{
try
{
@@ -233,7 +239,7 @@
{
// expected
}
-
+
try
{
installBundle(assembleArchive("invalid-export", "/bundles/lifecycle/invalid02"));
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/SystemBundleTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -44,32 +44,38 @@
*/
public class SystemBundleTestCase extends AbstractFrameworkTest
{
- @Test public void testBundleId() throws Exception
+ @Test
+ public void testBundleId() throws Exception
{
assertEquals(0, framework.getBundleId());
}
-
- @Test public void testSymbolicName() throws Exception
+
+ @Test
+ public void testSymbolicName() throws Exception
{
assertEquals(Constants.SYSTEM_BUNDLE_SYMBOLICNAME, framework.getSymbolicName());
}
-
- @Test public void testState() throws Exception
+
+ @Test
+ public void testState() throws Exception
{
assertEquals(Bundle.ACTIVE, framework.getState());
}
-
- @Test public void testStartStop() throws Exception
+
+ @Test
+ public void testStartStop() throws Exception
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testUpdate() throws Exception
+
+ @Test
+ public void testUpdate() throws Exception
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testUninstall() throws Exception
+
+ @Test
+ public void testUninstall() throws Exception
{
try
{
@@ -81,7 +87,7 @@
// expected
}
}
-
+
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testGetHeaders() throws Exception
@@ -91,42 +97,49 @@
// todo expected.put(Attributes.Name.IMPLEMENTATION_TITLE.toString(), "JBoss OSGi");
// todo expected.put(Attributes.Name.IMPLEMENTATION_VENDOR.toString(), "jboss.org");
// todo expected.put(Attributes.Name.IMPLEMENTATION_VERSION.toString(), "r4v41");
-
+
Dictionary dictionary = framework.getHeaders();
assertEquals(expected, dictionary);
}
-
- @Test public void testLocation() throws Exception
+
+ @Test
+ public void testLocation() throws Exception
{
assertEquals(Constants.SYSTEM_BUNDLE_LOCATION, framework.getLocation());
}
-
- @Test public void testGetEntry()
+
+ @Test
+ public void testGetEntry()
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testGetEntryPath()
+
+ @Test
+ public void testGetEntryPath()
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testFindEntries()
+
+ @Test
+ public void testFindEntries()
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testLoadClass()
+
+ @Test
+ public void testLoadClass()
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testGetResource()
+
+ @Test
+ public void testGetResource()
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
-
- @Test public void testGetResources()
+
+ @Test
+ public void testGetResources()
{
System.out.println("FIXME [JBOSGI-138] Proper system BundleContext implementation");
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleService.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleService.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.osgi.bundle.support.b;
-
/**
* A marker service.
*
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleServiceActivator.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/bundle/support/b/LifecycleServiceActivator.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -35,7 +35,9 @@
public void start(BundleContext context) throws Exception
{
- context.registerService(LifecycleService.class.getName(), new LifecycleService(){}, null);
+ context.registerService(LifecycleService.class.getName(), new LifecycleService()
+ {
+ }, null);
}
public void stop(BundleContext context) throws Exception
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/BundleClassPathTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -41,7 +41,8 @@
*/
public class BundleClassPathTestCase extends OSGiRuntimeTest
{
- @Test public void testBundleClassPath() throws Exception
+ @Test
+ public void testBundleClassPath() throws Exception
{
OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
Framework framework = bootProvider.getFramework();
@@ -55,7 +56,7 @@
Class<?> clazz = bundle.loadClass(A.class.getName());
assertNotNull("Loaded class", clazz);
-
+
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/RequireBundleTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -43,7 +43,8 @@
*/
public class RequireBundleTestCase extends AbstractFrameworkTest
{
- @Test public void testSimpleRequireBundle() throws Exception
+ @Test
+ public void testSimpleRequireBundle() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -69,8 +70,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testSimpleRequireBundleFails() throws Exception
+
+ @Test
+ public void testSimpleRequireBundleFails() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -99,8 +101,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testVersionRequireBundle() throws Exception
+
+ @Test
+ public void testVersionRequireBundle() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -126,8 +129,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testVersionRequireBundleFails() throws Exception
+
+ @Test
+ public void testVersionRequireBundleFails() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -156,8 +160,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testOptionalRequireBundle() throws Exception
+
+ @Test
+ public void testOptionalRequireBundle() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -183,8 +188,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testOptionalRequireBundleFails() throws Exception
+
+ @Test
+ public void testOptionalRequireBundleFails() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -210,8 +216,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testReExportRequireBundle() throws Exception
+
+ @Test
+ public void testReExportRequireBundle() throws Exception
{
//Bundle-Name: BundleA
//Bundle-Version: 1.0.0
@@ -219,31 +226,31 @@
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
-
+
try
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
-
+
//Bundle-Name: BundleB
//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 = assembleArchive("reexportrequirebundleA", "/bundles/classloader/reexportrequirebundleA", B.class);
Bundle bundleB = installBundle(assemblyB);
-
+
try
{
bundleB.start();
assertLoadClass(bundleB, A.class.getName(), bundleA);
assertLoadClass(bundleB, B.class.getName(), bundleB);
-
+
//Bundle-Name: BundleC
//Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleC
//Require-Bundle: org.jboss.test.osgi.classloader.bundleB
VirtualFile assemblyC = assembleArchive("reexportrequirebundleB", "/bundles/classloader/reexportrequirebundleB");
Bundle bundleC = installBundle(assemblyC);
-
+
try
{
assertLoadClass(bundleC, A.class.getName(), bundleA);
@@ -264,8 +271,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testNoReExportRequireBundle() throws Exception
+
+ @Test
+ public void testNoReExportRequireBundle() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -302,8 +310,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testAttributeRequireBundle() throws Exception
+
+ @Test
+ public void testAttributeRequireBundle() throws Exception
{
VirtualFile assemblyA = assembleArchive("bundleA", "/bundles/classloader/bundleA", A.class);
Bundle bundleA = installBundle(assemblyA);
@@ -329,8 +338,9 @@
bundleA.uninstall();
}
}
-
- @Test public void testAttributeRequireBundleFails() throws Exception
+
+ @Test
+ public void testAttributeRequireBundleFails() throws Exception
{
// 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
@@ -341,7 +351,7 @@
{
bundleA.start();
assertLoadClass(bundleA, A.class.getName());
-
+
// Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
// Require-Bundle: org.jboss.test.osgi.classloader.bundleA;doesnotexist=true;test=y
VirtualFile assemblyB = assembleArchive("attributerequirebundlefails", "/bundles/classloader/attributerequirebundlefails", B.class);
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-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/compendium/PackageAdminTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -42,7 +42,8 @@
*/
public class PackageAdminTestCase extends AbstractFrameworkTest
{
- @Test public void testGetBudleFromClass() throws Exception
+ @Test
+ public void testGetBudleFromClass() throws Exception
{
VirtualFile assemblyA = assembleArchive("smoke-assembled", "/bundles/smoke/smoke-assembled", PA.class);
Bundle bundleA = installBundle(assemblyA);
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-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/FragmentTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -61,7 +61,7 @@
OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
framework = bootProvider.getFramework();
framework.start();
-
+
context = framework.getBundleContext();
}
@@ -75,7 +75,8 @@
}
}
- @Test public void testHostOnly() throws Exception
+ @Test
+ public void testHostOnly() throws Exception
{
// Bundle-SymbolicName: simple-hostA
// Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
@@ -98,7 +99,8 @@
assertBundleState(Bundle.UNINSTALLED, hostA.getState());
}
- @Test public void testFragmentOnly() throws Exception
+ @Test
+ public void testFragmentOnly() throws Exception
{
// Bundle-SymbolicName: simple-fragA
// Export-Package: org.jboss.test.osgi.fragments.fragA
@@ -127,7 +129,8 @@
assertBundleState(Bundle.UNINSTALLED, fragA.getState());
}
- @Test public void testAttachedFragment() throws Exception
+ @Test
+ public void testAttachedFragment() throws Exception
{
// Bundle-SymbolicName: simple-hostA
// Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
@@ -165,14 +168,15 @@
assertBundleState(Bundle.UNINSTALLED, fragA.getState());
}
- @Test public void testFragmentHidesPrivatePackage() throws Exception
+ @Test
+ public void testFragmentHidesPrivatePackage() throws Exception
{
if (context != null)
{
System.out.println("FIXME [JBCL-137] Add support for OSGi Fragments");
return;
}
-
+
// Bundle-SymbolicName: simple-hostA
// Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
Bundle hostA = context.installBundle(getTestArchivePath("fragments-simple-hostA.jar"));
@@ -209,14 +213,15 @@
assertBundleState(Bundle.UNINSTALLED, fragB.getState());
}
- @Test public void testFragmentExportsPackage() throws Exception
+ @Test
+ public void testFragmentExportsPackage() throws Exception
{
if (context != null)
{
System.out.println("FIXME [JBCL-137] Add support for OSGi Fragments");
return;
}
-
+
// Bundle-SymbolicName: simple-hostA
// Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
Bundle hostA = context.installBundle(getTestArchivePath("fragments-simple-hostA.jar"));
@@ -288,14 +293,15 @@
assertBundleState(Bundle.UNINSTALLED, fragA.getState());
}
- @Test public void testFragmentRequireBundle() throws Exception
+ @Test
+ public void testFragmentRequireBundle() throws Exception
{
if (context != null)
{
System.out.println("FIXME [JBCL-137] Add support for OSGi Fragments");
return;
}
-
+
// Bundle-SymbolicName: simple-hostA
// Private-Package: org.jboss.test.osgi.fragments.hostA, org.jboss.test.osgi.fragments.subA
Bundle hostA = context.installBundle(getTestArchivePath("fragments-simple-hostA.jar"));
@@ -315,7 +321,7 @@
// Clarify error behaviour when fragments fail to attach
// https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1524
-
+
// Equinox: Resolves HostA but does not attach FragA
if (hostA.getState() == Bundle.ACTIVE)
assertBundleState(Bundle.INSTALLED, fragC.getState());
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragA/FragBeanA.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -23,7 +23,6 @@
//$Id$
-
public class FragBeanA
{
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragB/FragBeanB.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -23,7 +23,6 @@
//$Id: FragmentService.java 99106 2010-01-07 11:02:59Z thomas.diesler(a)jboss.com $
-
public class FragBeanB
{
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/fragments/fragC/FragBeanC.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -23,7 +23,6 @@
//$Id: FragmentService.java 99106 2010-01-07 11:02:59Z thomas.diesler(a)jboss.com $
-
public class FragBeanC
{
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -46,51 +46,53 @@
*/
public class SimpleBundleTestCase
{
- @Test public void testBundleInstallLauchAPI() throws Exception
+ @Test
+ public void testBundleInstallLauchAPI() throws Exception
{
// Uses the OSGi Framework launch API
FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
Framework framework = factory.newFramework(null);
framework.start();
-
+
OSGiRuntimeHelper helper = new OSGiRuntimeHelper();
-
+
BundleContext sysContext = framework.getBundleContext();
Bundle bundle = sysContext.installBundle(helper.getTestArchivePath("simple-bundle.jar"));
-
+
assertEquals("simple-bundle", bundle.getSymbolicName());
-
+
bundle.start();
assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
-
+
BundleContext bndContext = bundle.getBundleContext();
assertNotNull("BundleContext not null", bndContext);
-
+
// getServiceReference from bundle context
ServiceReference sref = bndContext.getServiceReference(SimpleService.class.getName());
assertNotNull("ServiceReference not null", sref);
-
+
// getServiceReference from system context
sref = sysContext.getServiceReference(SimpleService.class.getName());
assertNotNull("ServiceReference not null", sref);
-
+
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
framework.stop();
}
- @Test public void testBundleInstallRuntimeAPI() throws Exception
+ @Test
+ public void testBundleInstallRuntimeAPI() throws Exception
{
// Uses the JBossOSGi SPI provided runtime abstraction
OSGiRuntime runtime = new OSGiRuntimeHelper().getEmbeddedRuntime();
OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
assertEquals("simple-bundle", bundle.getSymbolicName());
-
+
bundle.start();
assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
-
+
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -53,7 +53,8 @@
System.clearProperty("simple-logservice-bundle");
}
- @Test public void testNoLogService() throws Exception
+ @Test
+ public void testNoLogService() throws Exception
{
FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
Framework framework = factory.newFramework(null);
@@ -75,7 +76,8 @@
framework.stop();
}
- @Test public void testLogServiceFromThirdParty() throws Exception
+ @Test
+ public void testLogServiceFromThirdParty() throws Exception
{
FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
Framework framework = factory.newFramework(null);
@@ -83,7 +85,7 @@
BundleContext sysContext = framework.getBundleContext();
sysContext.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar")).start();
-
+
Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
try
{
@@ -95,7 +97,7 @@
}
assumeTrue(bundle.getState() == Bundle.ACTIVE);
-
+
// The bundle activator is expected to set this property
String result = System.getProperty(bundle.getSymbolicName());
assertNotNull("Result property not null", result);
@@ -103,11 +105,12 @@
assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
assertFalse("getService", result.indexOf("getService") > 0);
assertFalse("addingService", result.indexOf("addingService") > 0);
-
+
framework.stop();
}
- @Test public void testLogServiceFromCompendium() throws Exception
+ @Test
+ public void testLogServiceFromCompendium() throws Exception
{
FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
Framework framework = factory.newFramework(null);
@@ -115,7 +118,7 @@
BundleContext sysContext = framework.getBundleContext();
sysContext.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
-
+
Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
bundle.start();
@@ -130,7 +133,8 @@
framework.stop();
}
- @Test public void testLogServiceFromTwoExporters() throws Exception
+ @Test
+ public void testLogServiceFromTwoExporters() throws Exception
{
FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
Framework framework = factory.newFramework(null);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -31,7 +31,7 @@
* @author thomas.diesler(a)jboss.com
* @since 24-Apr-2009
*/
-public class SimpleService
+public class SimpleService
{
public SimpleService(BundleContext context)
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -41,7 +41,7 @@
{
final String symName = context.getBundle().getSymbolicName();
addMessage(symName, "startBundleActivator");
-
+
ServiceReference sref = context.getServiceReference(LogService.class.getName());
if (sref != null)
{
@@ -49,7 +49,7 @@
String message = "getService: " + service.getClass().getName();
addMessage(symName, message);
}
-
+
ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
{
@Override
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/nativecode/NativeCodeTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -61,10 +61,11 @@
}
}
- @Test public void testNativeCode() throws Exception
+ @Test
+ public void testNativeCode() throws Exception
{
BundleContext context = framework.getBundleContext();
-
+
Bundle bundleA = context.installBundle(getTestArchivePath("simple-nativecode.jar"));
assertBundleState(Bundle.INSTALLED, bundleA.getState());
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-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -522,7 +522,7 @@
public void testRequireBundle() throws Exception
{
// [TODO] require bundle visibility
-
+
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundle");
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -51,12 +51,13 @@
*/
public class ResolverMetadataTestCase extends AbstractResolverTest
{
- @Test public void testSimpleExport() throws Exception
+ @Test
+ public void testSimpleExport() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
// Bundle-SymbolicName: simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleexport", A.class);
@@ -105,12 +106,13 @@
}
}
- @Test public void testSimpleImport() throws Exception
+ @Test
+ public void testSimpleImport() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
// Bundle-SymbolicName: simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/simpleimport");
@@ -137,12 +139,13 @@
}
}
- @Test public void testSingleton() throws Exception
+ @Test
+ public void testSingleton() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
// Bundle-SymbolicName: singleton;singleton:=true
// Export-Package: org.jboss.test.osgi.classloader.support.a
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/singleton", A.class);
@@ -158,12 +161,13 @@
}
}
- @Test public void testRequireBundle() throws Exception
+ @Test
+ public void testRequireBundle() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundle");
@@ -184,12 +188,13 @@
}
}
- @Test public void testRequireBundleOptional() throws Exception
+ @Test
+ public void testRequireBundleOptional() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport;resolution:=optional
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleoptional");
@@ -210,12 +215,13 @@
}
}
- @Test public void testRequireBundleVersion() throws Exception
+ @Test
+ public void testRequireBundleVersion() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: requirebundle
//Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/requirebundleversion");
@@ -236,12 +242,13 @@
}
}
- @Test public void testPackageAttribute() throws Exception
+ @Test
+ public void testPackageAttribute() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattribute");
@@ -277,7 +284,7 @@
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
ImportPackage importPackage = resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
+ Set<String> importAttributes = importPackage.getAttributes();
assertTrue("Contains attr", importAttributes.contains("test"));
assertEquals("x", importPackage.getAttribute("test"));
assertTrue("Attribute match", exportPackage.matchAttributes(importPackage));
@@ -293,12 +300,13 @@
}
}
- @Test public void testPackageAttributeFails() throws Exception
+ @Test
+ public void testPackageAttributeFails() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: packageexportattribute
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattribute");
@@ -319,7 +327,7 @@
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
ImportPackage importPackage = resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
+ Set<String> importAttributes = importPackage.getAttributes();
assertTrue("Contains attr", importAttributes.contains("test"));
assertEquals("y", importPackage.getAttribute("test"));
assertFalse("Attribute no match", exportPackage.matchAttributes(importPackage));
@@ -335,12 +343,13 @@
}
}
- @Test public void testPackageAttributeMandatory() throws Exception
+ @Test
+ public void testPackageAttributeMandatory() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattributemandatory");
@@ -363,7 +372,7 @@
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
ImportPackage importPackage = resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
+ Set<String> importAttributes = importPackage.getAttributes();
assertTrue("Contains attr", importAttributes.contains("test"));
assertEquals("x", importPackage.getAttribute("test"));
assertTrue("Attribute match", exportPackage.matchAttributes(importPackage));
@@ -379,12 +388,13 @@
}
}
- @Test public void testPackageAttributeMandatoryFails() throws Exception
+ @Test
+ public void testPackageAttributeMandatoryFails() throws Exception
{
Resolver resolver = getTestResolver();
if (resolver == null)
return;
-
+
//Bundle-SymbolicName: packageexportattributemandatory
//Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
VirtualFile fileA = assembleArchive("bundleA", "/bundles/resolver/packageexportattributemandatory");
@@ -422,7 +432,7 @@
{
ResolverBundle resBundleB = resolver.getBundle(bundleB);
ImportPackage importPackage = resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
+ Set<String> importAttributes = importPackage.getAttributes();
assertTrue("Contains attr", importAttributes.contains("test"));
assertEquals("y", importPackage.getAttribute("test"));
assertFalse("Attribute no match", exportPackage.matchAttributes(importPackage));
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/resolver/ResolverSmokeTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -50,12 +50,13 @@
*/
public class ResolverSmokeTestCase extends OSGiRuntimeTest
{
- @Test public void testRandomBundleResolution() throws BundleException
+ @Test
+ public void testRandomBundleResolution() throws BundleException
{
OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
OSGiFramework framework = (OSGiFramework)bootProvider.getFramework();
framework.start();
-
+
try
{
List<String> bundlePaths = new ArrayList<String>();
@@ -94,7 +95,7 @@
List<ResolverBundle> resolved = resolver.resolve(unresolved);
assertEquals("All bundles resolved", unresolved.size(), resolved.size());
}
-
+
System.out.println("FIXME [JBKERNEL-54] Cannot resolve circular dependencies");
//PackageAdminPlugin packageAdmin = bundleManager.getPlugin(PackageAdminPlugin.class);
//boolean allResolved = packageAdmin.resolveBundles(null);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetServiceReferencesTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -51,7 +51,8 @@
public class GetServiceReferencesTestCase extends AbstractFrameworkTest
{
- @Test public void testGetServiceReferences() throws Exception
+ @Test
+ public void testGetServiceReferences() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1", A.class);
Bundle bundle = installBundle(assembly);
@@ -60,7 +61,7 @@
bundle.start();
BundleContext bundleContext1 = bundle.getBundleContext();
assertNotNull(bundleContext1);
-
+
assertNoGetReference(bundleContext1, A.class.getName());
assertNoReferences(bundleContext1, A.class.getName());
assertNoAllReferences(bundleContext1, A.class.getName());
@@ -81,16 +82,16 @@
assertNoGetReference(bundleContext1, B.class.getName());
assertNoReferences(bundleContext1, B.class.getName());
assertNoAllReferences(bundleContext1, B.class.getName());
-
+
registration1.unregister();
-
+
assertNoGetReference(bundleContext1, A.class.getName());
assertNoReferences(bundleContext1, A.class.getName());
assertNoAllReferences(bundleContext1, A.class.getName());
assertNoGetReference(bundleContext1, B.class.getName());
assertNoReferences(bundleContext1, B.class.getName());
assertNoAllReferences(bundleContext1, B.class.getName());
-
+
try
{
bundleContext1.getServiceReference(null);
@@ -100,7 +101,7 @@
{
// expected
}
-
+
try
{
bundleContext1.getServiceReferences(null, "invalid");
@@ -110,7 +111,7 @@
{
// expected
}
-
+
try
{
bundleContext1.getAllServiceReferences(null, "invalid");
@@ -120,9 +121,9 @@
{
// expected
}
-
+
bundle.stop();
-
+
try
{
bundleContext1.getServiceReference(A.class.getName());
@@ -132,7 +133,7 @@
{
// expected
}
-
+
try
{
bundleContext1.getServiceReferences(null, null);
@@ -142,7 +143,7 @@
{
// expected
}
-
+
try
{
bundleContext1.getAllServiceReferences(null, null);
@@ -158,17 +159,19 @@
bundle.uninstall();
}
}
-
- @Test public void testGetServiceReferencesNoClassNotAssignable() throws Exception
+
+ @Test
+ public void testGetServiceReferencesNoClassNotAssignable() throws Exception
{
assertGetServiceReferencesNotAssignable(null);
}
-
- @Test public void testGetServiceReferencesNotAssignable() throws Exception
+
+ @Test
+ public void testGetServiceReferencesNotAssignable() throws Exception
{
assertGetServiceReferencesNotAssignable(A.class.getName());
}
-
+
private void assertGetServiceReferencesNotAssignable(String className) throws Exception
{
VirtualFile assemblyA = assembleArchive("simple1", "/bundles/simple/simple-bundle1", A.class);
@@ -178,7 +181,7 @@
bundleA.start();
BundleContext bundleContext1 = bundleA.getBundleContext();
assertNotNull(bundleContext1);
-
+
if (className != null)
assertNoGetReference(bundleContext1, className);
@@ -206,15 +209,15 @@
assertNotNull(registration2);
ServiceReference reference2 = registration2.getReference();
assertNotNull(reference2);
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference1);
if (className != null)
assertGetReference(bundleContext2, className, reference2);
-
+
registration1.unregister();
-
+
if (className != null)
assertNoGetReference(bundleContext1, className);
@@ -225,23 +228,23 @@
assertNotNull(registration1);
reference1 = registration1.getReference();
assertNotNull(reference1);
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference1);
if (className != null)
assertGetReference(bundleContext2, className, reference2);
-
+
registration2.unregister();
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference1);
if (className != null)
assertNoGetReference(bundleContext2, className);
-
+
registration1.unregister();
-
+
if (className != null)
assertNoGetReference(bundleContext1, className);
@@ -259,12 +262,14 @@
}
}
- @Test public void testGetServiceReferencesNoClassAssignable() throws Exception
+ @Test
+ public void testGetServiceReferencesNoClassAssignable() throws Exception
{
assertGetServiceReferencesAssignable(null);
}
- @Test public void testGetServiceReferencesClassAssignable() throws Exception
+ @Test
+ public void testGetServiceReferencesClassAssignable() throws Exception
{
assertGetServiceReferencesAssignable(A.class.getName());
}
@@ -306,15 +311,15 @@
assertNotNull(registration2);
ServiceReference reference2 = registration2.getReference();
assertNotNull(reference2);
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference1);
if (className != null)
assertGetReference(bundleContext2, className, reference1);
-
+
registration1.unregister();
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference2);
@@ -325,23 +330,23 @@
assertNotNull(registration1);
reference1 = registration1.getReference();
assertNotNull(reference1);
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference2);
if (className != null)
assertGetReference(bundleContext2, className, reference2);
-
+
registration2.unregister();
-
+
if (className != null)
assertGetReference(bundleContext1, className, reference1);
if (className != null)
assertGetReference(bundleContext2, className, reference1);
-
+
registration1.unregister();
-
+
if (className != null)
assertNoGetReference(bundleContext1, className);
@@ -359,10 +364,11 @@
}
}
- @Test public void testGetServiceReferencesRankings() throws Exception
+ @Test
+ public void testGetServiceReferencesRankings() throws Exception
{
String className = A.class.getName();
-
+
VirtualFile assemblyA = assembleArchive("service2", "/bundles/service/service-bundle2", A.class);
Bundle bundleA = installBundle(assemblyA);
try
@@ -370,7 +376,7 @@
bundleA.start();
BundleContext bundleContext1 = bundleA.getBundleContext();
assertNotNull(bundleContext1);
-
+
assertNoGetReference(bundleContext1, className);
assertNoReferences(bundleContext1, className);
assertNoAllReferences(bundleContext1, className);
@@ -393,8 +399,8 @@
assertNotNull(bundleContext2);
assertGetReference(bundleContext2, className, reference1);
- assertReferences(bundleContext2, className, reference1);
- assertAllReferences(bundleContext2, className, reference1);
+ assertReferences(bundleContext2, className, reference1);
+ assertAllReferences(bundleContext2, className, reference1);
Dictionary<String, Object> properties2 = new Hashtable<String, Object>();
properties2.put(Constants.SERVICE_RANKING, 2);
@@ -404,50 +410,50 @@
assertNotNull(registration2);
ServiceReference reference2 = registration2.getReference();
assertNotNull(reference2);
-
+
assertGetReference(bundleContext1, className, reference2);
- assertReferences(bundleContext1, className, reference2, reference1);
- assertAllReferences(bundleContext1, className, reference2, reference1);
+ assertReferences(bundleContext1, className, reference2, reference1);
+ assertAllReferences(bundleContext1, className, reference2, reference1);
assertGetReference(bundleContext2, className, reference2);
- assertReferences(bundleContext2, className, reference2, reference1);
- assertAllReferences(bundleContext2, className, reference2, reference1);
-
+ assertReferences(bundleContext2, className, reference2, reference1);
+ assertAllReferences(bundleContext2, className, reference2, reference1);
+
registration1.unregister();
-
+
assertGetReference(bundleContext1, className, reference2);
- assertReferences(bundleContext1, className, reference2);
- assertAllReferences(bundleContext1, className, reference2);
+ assertReferences(bundleContext1, className, reference2);
+ assertAllReferences(bundleContext1, className, reference2);
assertGetReference(bundleContext2, className, reference2);
- assertReferences(bundleContext2, className, reference2);
- assertAllReferences(bundleContext2, className, reference2);
+ assertReferences(bundleContext2, className, reference2);
+ assertAllReferences(bundleContext2, className, reference2);
registration1 = bundleContext1.registerService(className, service1, properties1);
assertNotNull(registration1);
reference1 = registration1.getReference();
assertNotNull(reference1);
-
+
assertGetReference(bundleContext1, className, reference2);
- assertReferences(bundleContext1, className, reference2, reference1);
- assertAllReferences(bundleContext1, className, reference2, reference1);
+ assertReferences(bundleContext1, className, reference2, reference1);
+ assertAllReferences(bundleContext1, className, reference2, reference1);
assertGetReference(bundleContext2, className, reference2);
- assertReferences(bundleContext2, className, reference2, reference1);
- assertAllReferences(bundleContext2, className, reference2, reference1);
-
+ assertReferences(bundleContext2, className, reference2, reference1);
+ assertAllReferences(bundleContext2, className, reference2, reference1);
+
registration2.unregister();
-
+
assertGetReference(bundleContext1, className, reference1);
- assertReferences(bundleContext1, className, reference1);
- assertAllReferences(bundleContext1, className, reference1);
+ assertReferences(bundleContext1, className, reference1);
+ assertAllReferences(bundleContext1, className, reference1);
assertGetReference(bundleContext2, className, reference1);
- assertReferences(bundleContext2, className, reference1);
- assertAllReferences(bundleContext2, className, reference1);
-
+ assertReferences(bundleContext2, className, reference1);
+ assertAllReferences(bundleContext2, className, reference1);
+
registration1.unregister();
-
+
assertNoGetReference(bundleContext1, className);
assertNoReferences(bundleContext1, className);
assertNoAllReferences(bundleContext1, className);
@@ -467,12 +473,13 @@
bundleA.uninstall();
}
}
-
- @Test public void testGetServiceReferencesFilterted() throws Exception
+
+ @Test
+ public void testGetServiceReferencesFilterted() throws Exception
{
String className = A.class.getName();
String wrongClassName = B.class.getName();
-
+
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1", A.class);
Bundle bundle = installBundle(assembly);
try
@@ -480,7 +487,7 @@
bundle.start();
BundleContext bundleContext1 = bundle.getBundleContext();
assertNotNull(bundleContext1);
-
+
assertNoGetReference(bundleContext1, A.class.getName());
assertNoReferences(bundleContext1, null, "(a=b)");
assertNoAllReferences(bundleContext1, null, "(a=b)");
@@ -510,7 +517,7 @@
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put("a", "b");
properties.put("c", "d");
-
+
Class<?> clazz = bundle.loadClass(A.class.getName());
Object service1 = clazz.newInstance();
ServiceRegistration registration1 = bundleContext1.registerService(A.class.getName(), service1, properties);
@@ -543,9 +550,9 @@
assertNoAllReferences(bundleContext1, className, "(x=d)");
assertNoReferences(bundleContext1, wrongClassName, "(x=d)");
assertNoAllReferences(bundleContext1, wrongClassName, "(x=d)");
-
+
registration1.unregister();
-
+
assertNoGetReference(bundleContext1, A.class.getName());
assertNoReferences(bundleContext1, null, "(a=b)");
assertNoAllReferences(bundleContext1, null, "(a=b)");
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/GetUnGetServiceTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -52,7 +52,8 @@
{
static String OBJCLASS = BundleContext.class.getName();
- @Test public void testGetUnServiceErrors() throws Exception
+ @Test
+ public void testGetUnServiceErrors() throws Exception
{
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -63,7 +64,7 @@
assertNotNull(bundleContext);
bundleContext.registerService(OBJCLASS, bundleContext, null);
-
+
try
{
bundleContext.getService(null);
@@ -73,7 +74,7 @@
{
// expected
}
-
+
try
{
bundleContext.ungetService(null);
@@ -89,8 +90,9 @@
bundle.uninstall();
}
}
-
- @Test public void testGetService() throws Exception
+
+ @Test
+ public void testGetService() throws Exception
{
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -105,7 +107,7 @@
Object actual = bundleContext.getService(reference);
assertEquals(bundleContext, actual);
-
+
registration.unregister();
actual = bundleContext.getService(reference);
assertNull("" + actual, actual);
@@ -115,8 +117,9 @@
bundle.uninstall();
}
}
-
- @Test public void testGetServiceAfterStop() throws Exception
+
+ @Test
+ public void testGetServiceAfterStop() throws Exception
{
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -131,7 +134,7 @@
Object actual = bundleContext.getService(reference);
assertEquals(bundleContext, actual);
-
+
bundle.stop();
try
{
@@ -148,8 +151,9 @@
bundle.uninstall();
}
}
-
- @Test public void testErrorInGetService() throws Exception
+
+ @Test
+ public void testErrorInGetService() throws Exception
{
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -160,12 +164,12 @@
assertNotNull(bundleContext);
bundleContext.addFrameworkListener(this);
-
+
ServiceRegistration registration = bundleContext.registerService(OBJCLASS, new BrokenServiceFactory(bundleContext, true), null);
ServiceReference reference = registration.getReference();
Object actual = bundleContext.getService(reference);
assertNull("" + actual, actual);
-
+
assertFrameworkEvent(FrameworkEvent.ERROR, bundle, ServiceException.class);
}
finally
@@ -173,8 +177,9 @@
bundle.uninstall();
}
}
-
- @Test public void testErrorInUnGetService() throws Exception
+
+ @Test
+ public void testErrorInUnGetService() throws Exception
{
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -185,7 +190,7 @@
assertNotNull(bundleContext);
bundleContext.addFrameworkListener(this);
-
+
ServiceRegistration registration = bundleContext.registerService(OBJCLASS, new BrokenServiceFactory(bundleContext, false), null);
ServiceReference reference = registration.getReference();
Object actual = bundleContext.getService(reference);
@@ -193,7 +198,7 @@
assertNoFrameworkEvent();
registration.unregister();
-
+
assertFrameworkEvent(FrameworkEvent.WARNING, bundle, BundleException.class);
}
finally
@@ -202,7 +207,8 @@
}
}
- @Test public void testUnGetServiceResult() throws Exception
+ @Test
+ public void testUnGetServiceResult() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle1 = installBundle(assembly1);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/JMXServicesTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -42,7 +42,8 @@
*/
public class JMXServicesTestCase extends AbstractDeploymentTest
{
- @Test public void testAtJmx() throws Throwable
+ @Test
+ public void testAtJmx() throws Throwable
{
URL beans = getResourceURL("service/jmx-services.xml");
deploy(beans);
@@ -60,7 +61,8 @@
}
}
- @Test public void testMBeans() throws Throwable
+ @Test
+ public void testMBeans() throws Throwable
{
// mix mbean services with bundles -- TODO
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/RegisterServiceTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -49,11 +49,12 @@
static String OBJCLASS = BundleContext.class.getName();
static String[] OBJCLASSES = new String[] { OBJCLASS };
- @Test public void testRegisterServiceErrors() throws Exception
+ @Test
+ public void testRegisterServiceErrors() throws Exception
{
String OBJCLASS = BundleContext.class.getName();
String[] OBJCLASSES = new String[] { OBJCLASS };
-
+
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
try
@@ -61,27 +62,27 @@
bundle.start();
BundleContext bundleContext = bundle.getBundleContext();
assertNotNull(bundleContext);
-
+
try
{
- bundleContext.registerService((String) null, new Object(), null);
+ bundleContext.registerService((String)null, new Object(), null);
fail("Should not be here!");
}
catch (IllegalArgumentException t)
{
// expected
}
-
+
try
{
- bundleContext.registerService((String[]) null, new Object(), null);
+ bundleContext.registerService((String[])null, new Object(), null);
fail("Should not be here!");
}
catch (IllegalArgumentException t)
{
// expected
}
-
+
try
{
bundleContext.registerService(new String[0], new Object(), null);
@@ -91,7 +92,7 @@
{
// expected
}
-
+
try
{
bundleContext.registerService(OBJCLASS, null, null);
@@ -101,7 +102,7 @@
{
// expected
}
-
+
try
{
bundleContext.registerService(OBJCLASSES, null, null);
@@ -111,7 +112,7 @@
{
// expected
}
-
+
try
{
bundleContext.registerService(OBJCLASS, new Object(), null);
@@ -121,7 +122,7 @@
{
// expected
}
-
+
try
{
bundleContext.registerService(OBJCLASSES, new Object(), null);
@@ -144,7 +145,7 @@
{
// expected
}
-
+
try
{
bundleContext.registerService(OBJCLASSES, bundleContext, properties);
@@ -154,7 +155,7 @@
{
// expected
}
-
+
bundle.stop();
try
@@ -166,7 +167,7 @@
{
// expected
}
-
+
try
{
bundleContext.registerService(OBJCLASSES, bundleContext, null);
@@ -182,8 +183,9 @@
bundle.uninstall();
}
}
-
- @Test public void testRegisterServiceOBJCLASS() throws Exception
+
+ @Test
+ public void testRegisterServiceOBJCLASS() throws Exception
{
Dictionary<String, Object> properties = new Hashtable<String, Object>();
properties.put(Constants.OBJECTCLASS, new String[] { "rubbish" });
@@ -215,8 +217,9 @@
bundle.uninstall();
}
}
-
- @Test public void testRegisterService() throws Exception
+
+ @Test
+ public void testRegisterService() throws Exception
{
VirtualFile assembly = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -242,7 +245,8 @@
}
}
- @Test public void testBundleUninstall() throws Exception
+ @Test
+ public void testBundleUninstall() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle1 = installBundle(assembly1);
@@ -282,7 +286,8 @@
}
}
- @Test public void testRegisteredServices() throws Exception
+ @Test
+ public void testRegisteredServices() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple-bundle1", "/bundles/simple/simple-bundle1");
Bundle bundle1 = installBundle(assembly1);
@@ -312,7 +317,7 @@
assertNull(registered);
registered = bundle1.getRegisteredServices();
- assertArrayEquals(new ServiceReference[]{reference}, registered);
+ assertArrayEquals(new ServiceReference[] { reference }, registered);
}
finally
{
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceEventHookTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -0,0 +1,97 @@
+/*
+* 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.service;
+
+// Id: $
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.test.osgi.AbstractFrameworkTest;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.hooks.service.EventHook;
+
+/**
+ * Test {@link EventHook} functionality.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 20-Mar-2010
+ */
+public class ServiceEventHookTestCase extends AbstractFrameworkTest
+{
+ @Test
+ public void testEventHook() throws Exception
+ {
+ final BundleContext context = framework.getBundleContext();
+
+ final List<String> events = new ArrayList<String>();
+ final boolean[] allGood = new boolean[1];
+ EventHook hook = new EventHook()
+ {
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void event(ServiceEvent event, Collection contexts)
+ {
+ assertNotNull("ServiceEvent not null", event);
+ events.add(ConstantsHelper.serviceEvent(event.getType()));
+ assertNotNull("Contexts not null", contexts);
+ assertEquals(1, contexts.size());
+ Iterator it = contexts.iterator();
+ assertEquals(context, it.next());
+ // Can remove a context
+ it.remove();
+ try
+ {
+ contexts.add(context);
+ fail("Cannot add a context");
+ }
+ catch (RuntimeException ex)
+ {
+ // expected
+ }
+ allGood[0] = true;
+ }
+ };
+
+ Runnable service = new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+
+ context.registerService(EventHook.class.getName(), hook, null);
+ context.registerService(Runnable.class.getName(), service, null);
+ assertTrue("Events called", events.size() > 0);
+ assertTrue("Events all good", allGood[0]);
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceFactoryTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -259,9 +259,9 @@
assertEquals(1, users.length);
assertEquals(context.getBundle(), users[0]);
assertTrue("getService good", allGood[0]);
-
+
sreg.unregister();
-
+
was = (Runnable)context.getService(sref);
assertNull("Service null", was);
assertTrue("ungetService good", allGood[1]);
Added: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerHookTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -0,0 +1,109 @@
+/*
+* 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.service;
+
+// Id: $
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.test.osgi.AbstractFrameworkTest;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.hooks.service.ListenerHook;
+import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
+
+/**
+ * Test {@link ListenerHook} functionality.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 20-Mar-2010
+ */
+public class ServiceListenerHookTestCase extends AbstractFrameworkTest
+{
+ @Test
+ public void testListenerHook() throws Exception
+ {
+ final Collection<ListenerInfo> added = new ArrayList<ListenerInfo>();
+ final Collection<ListenerInfo> removed = new ArrayList<ListenerInfo>();
+ ListenerHook hook = new ListenerHook()
+ {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void added(Collection infos)
+ {
+ added.addAll(infos);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void removed(Collection infos)
+ {
+ added.removeAll(infos);
+ removed.addAll(infos);
+ }
+ };
+
+ Runnable service = new Runnable()
+ {
+ public void run()
+ {
+ }
+ };
+
+ final List<String> events = new ArrayList<String>();
+ ServiceListener listener = new ServiceListener()
+ {
+ public void serviceChanged(ServiceEvent event)
+ {
+ int eventType = event.getType();
+ events.add(ConstantsHelper.serviceEvent(eventType));
+ }
+ };
+
+ BundleContext context = framework.getBundleContext();
+ context.addServiceListener(listener, "(foo=bar)");
+
+ Hashtable<String, String> props = new Hashtable<String, String>();
+ props.put("foo", "bar");
+ context.registerService(Runnable.class.getName(), service, props);
+ assertEquals(1, events.size());
+ assertEquals("REGISTERED", events.get(0));
+
+ context.registerService(ListenerHook.class.getName(), hook, null);
+ assertTrue("Hook added called", added.size() > 0);
+ assertTrue("Hook removed not called", removed.isEmpty());
+
+ int size = added.size();
+
+ // Register the same listener with a different filter
+ context.addServiceListener(listener, "(bar=foo)");
+ assertTrue("Hook removed called", removed.size() > 0);
+ assertEquals("Hook added called", size, added.size());
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceListenerTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -44,7 +44,8 @@
*/
public class ServiceListenerTestCase extends AbstractFrameworkTest
{
- @Test public void testServiceListener() throws Exception
+ @Test
+ public void testServiceListener() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -56,12 +57,12 @@
assertNoServiceEvent();
context.addServiceListener(this);
-
+
ServiceRegistration sreg = context.registerService(BundleContext.class.getName(), context, null);
ServiceReference sref = sreg.getReference();
-
+
assertServiceEvent(ServiceEvent.REGISTERED, sref);
-
+
sreg.unregister();
assertServiceEvent(ServiceEvent.UNREGISTERING, sref);
}
@@ -71,7 +72,8 @@
}
}
- @Test public void testObjectClassFilter() throws Exception
+ @Test
+ public void testObjectClassFilter() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -81,15 +83,15 @@
BundleContext context = bundle.getBundleContext();
assertNotNull(context);
assertNoServiceEvent();
-
+
String filter = "(" + Constants.OBJECTCLASS + "=" + BundleContext.class.getName() + ")";
context.addServiceListener(this, filter);
-
+
ServiceRegistration sreg = context.registerService(BundleContext.class.getName(), context, null);
ServiceReference sref = sreg.getReference();
-
+
assertServiceEvent(ServiceEvent.REGISTERED, sref);
-
+
sreg.unregister();
assertServiceEvent(ServiceEvent.UNREGISTERING, sref);
}
@@ -99,7 +101,8 @@
}
}
- @Test public void testObjectClassFilterNegative() throws Exception
+ @Test
+ public void testObjectClassFilterNegative() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -109,13 +112,13 @@
BundleContext context = bundle.getBundleContext();
assertNotNull(context);
assertNoServiceEvent();
-
+
String filter = "(objectClass=dummy)";
context.addServiceListener(this, filter);
-
+
ServiceRegistration sreg = context.registerService(BundleContext.class.getName(), context, null);
assertNoServiceEvent();
-
+
sreg.unregister();
assertNoServiceEvent();
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceMixTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -373,7 +373,7 @@
// Construct the ServiceFactory
Class<?> factoryClass = bundle.loadClass(ServiceMixFactory.class.getName());
Object factory = factoryClass.newInstance();
-
+
// Register the ServiceFactory
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put("service.alias.1", "A");
@@ -403,7 +403,7 @@
List as = assertInstanceOf(getter(factory, "getAs", "A"), List.class);
assertNotNull(as);
-
+
System.out.println("FIXME: Verify ServiceFactory still in use");
//assertTrue(as.isEmpty()); // SF is still in use
}
@@ -414,7 +414,7 @@
List as = assertInstanceOf(getter(factory, "getAs", "A"), List.class);
assertNotNull(as);
-
+
System.out.println("FIXME: Verify ServiceFactory still in use");
//assertEquals(1, as.size());
//assertTrue(as.contains(a));
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceReferenceTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -50,7 +50,8 @@
*/
public class ServiceReferenceTestCase extends AbstractFrameworkTest
{
- @Test public void testGetProperty() throws Exception
+ @Test
+ public void testGetProperty() throws Exception
{
ServiceReference reference = null;
String[] clazzes = new String[] { BundleContext.class.getName() };
@@ -70,17 +71,17 @@
properties.put("MiXeD", "Case");
ServiceRegistration registration = bundleContext.registerService(clazzes, bundleContext, properties);
assertNotNull(registration);
-
+
reference = registration.getReference();
assertNotNull(reference);
-
+
serviceID = reference.getProperty(Constants.SERVICE_ID);
assertNotNull(serviceID);
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID.toLowerCase()));
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID.toUpperCase()));
- assertArrayEquals(clazzes, (String[]) reference.getProperty(Constants.OBJECTCLASS));
- assertArrayEquals(clazzes, (String[]) reference.getProperty(Constants.OBJECTCLASS.toLowerCase()));
- assertArrayEquals(clazzes, (String[]) reference.getProperty(Constants.OBJECTCLASS.toUpperCase()));
+ assertArrayEquals(clazzes, (String[])reference.getProperty(Constants.OBJECTCLASS));
+ assertArrayEquals(clazzes, (String[])reference.getProperty(Constants.OBJECTCLASS.toLowerCase()));
+ assertArrayEquals(clazzes, (String[])reference.getProperty(Constants.OBJECTCLASS.toUpperCase()));
assertEquals("a", reference.getProperty("testA"));
assertEquals("b", reference.getProperty("testB"));
assertEquals("Case", reference.getProperty("MiXeD"));
@@ -88,14 +89,14 @@
assertEquals("Case", reference.getProperty("MIXED"));
assertNull(reference.getProperty(null));
assertNull(reference.getProperty("doesNotExist"));
-
+
properties.put("testA", "notA");
assertEquals("a", reference.getProperty("testA"));
properties.put(Constants.SERVICE_ID, "rubbish");
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
properties.put(Constants.OBJECTCLASS, "rubbish");
assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
-
+
registration.setProperties(properties);
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
@@ -104,7 +105,7 @@
assertEquals("Case", reference.getProperty("MiXeD"));
assertEquals("Case", reference.getProperty("mixed"));
assertEquals("Case", reference.getProperty("MIXED"));
-
+
registration.setProperties(null);
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
@@ -114,7 +115,7 @@
assertNull(reference.getProperty("mixed"));
assertNull(reference.getProperty("MIXED"));
assertNull(reference.getProperty(null));
-
+
registration.setProperties(properties);
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
@@ -124,7 +125,7 @@
assertEquals("Case", reference.getProperty("mixed"));
assertEquals("Case", reference.getProperty("MIXED"));
assertNull(reference.getProperty(null));
-
+
registration.unregister();
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
@@ -139,7 +140,7 @@
{
bundle.uninstall();
}
-
+
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID));
assertEquals(clazzes, reference.getProperty(Constants.OBJECTCLASS));
assertEquals("notA", reference.getProperty("testA"));
@@ -149,11 +150,12 @@
assertEquals("Case", reference.getProperty("MIXED"));
assertNull(reference.getProperty(null));
}
-
- @Test public void testGetPropertyKeys() throws Exception
+
+ @Test
+ public void testGetPropertyKeys() throws Exception
{
ServiceReference reference = null;
-
+
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
try
@@ -168,7 +170,7 @@
properties.put("MiXeD", "Case");
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
assertNotNull(registration);
-
+
reference = registration.getReference();
assertNotNull(reference);
@@ -185,7 +187,7 @@
registration.setProperties(properties);
assertPropertyKeys(reference, "testA", "testB", "testC", "MiXeD");
-
+
registration.unregister();
assertPropertyKeys(reference, "testA", "testB", "testC", "MiXeD");
}
@@ -203,15 +205,16 @@
expected.add(Constants.OBJECTCLASS);
for (String key : expectedKeys)
expected.add(key);
-
+
Set<String> actual = new HashSet<String>();
for (String key : reference.getPropertyKeys())
actual.add(key);
-
+
assertEquals(expected, actual);
}
-
- @Test public void testGetBundle() throws Exception
+
+ @Test
+ public void testGetBundle() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -223,15 +226,15 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
-
+
Bundle other = reference.getBundle();
assertEquals(bundle, other);
-
+
registration.unregister();
-
+
other = reference.getBundle();
assertNull("" + other, other);
}
@@ -240,8 +243,9 @@
bundle.uninstall();
}
}
-
- @Test public void testGetBundleAfterStop() throws Exception
+
+ @Test
+ public void testGetBundleAfterStop() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -253,15 +257,15 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
-
+
Bundle other = reference.getBundle();
assertEquals(bundle, other);
bundle.stop();
-
+
other = reference.getBundle();
assertNull("" + other, other);
}
@@ -270,8 +274,9 @@
bundle.uninstall();
}
}
-
- @Test public void testUsingBundles() throws Exception
+
+ @Test
+ public void testUsingBundles() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle1 = installBundle(assembly1);
@@ -283,12 +288,12 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
-
+
assertUsingBundles(reference);
-
+
VirtualFile assembly2 = assembleArchive("simple2", "/bundles/simple/simple-bundle2");
Bundle bundle2 = installBundle(assembly2);
try
@@ -296,13 +301,13 @@
bundle2.start();
BundleContext bundleContext2 = bundle2.getBundleContext();
assertNotNull(bundleContext2);
-
+
bundleContext2.getService(reference);
assertUsingBundles(reference, bundle2);
-
+
bundleContext2.ungetService(reference);
assertUsingBundles(reference);
-
+
bundleContext2.getService(reference);
bundleContext2.getService(reference);
assertUsingBundles(reference, bundle2);
@@ -314,7 +319,7 @@
bundleContext.getService(reference);
bundleContext2.getService(reference);
assertUsingBundles(reference, bundle1, bundle2);
-
+
registration.unregister();
assertUsingBundles(reference);
}
@@ -328,8 +333,9 @@
bundle1.uninstall();
}
}
-
- @Test public void testUsingBundlesAfterStop() throws Exception
+
+ @Test
+ public void testUsingBundlesAfterStop() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle1 = installBundle(assembly1);
@@ -341,12 +347,12 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
-
+
assertUsingBundles(reference);
-
+
VirtualFile assembly2 = assembleArchive("simple2", "/bundles/simple/simple-bundle2");
Bundle bundle2 = installBundle(assembly2);
try
@@ -358,7 +364,7 @@
bundleContext.getService(reference);
bundleContext2.getService(reference);
assertUsingBundles(reference, bundle1, bundle2);
-
+
bundle1.stop();
assertUsingBundles(reference);
}
@@ -372,8 +378,9 @@
bundle1.uninstall();
}
}
-
- @Test public void testIsAssignableToErrors() throws Exception
+
+ @Test
+ public void testIsAssignableToErrors() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1", A.class);
Bundle bundle = installBundle(assembly);
@@ -385,10 +392,10 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
-
+
try
{
reference.isAssignableTo(null, A.class.getName());
@@ -398,7 +405,7 @@
{
// expected
}
-
+
try
{
reference.isAssignableTo(bundle, null);
@@ -413,9 +420,10 @@
{
bundle.uninstall();
}
- }
+ }
- @Test public void testNotAssignableTo() throws Exception
+ @Test
+ public void testNotAssignableTo() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple1", "/bundles/simple/simple-bundle1", A.class);
Bundle bundle1 = installBundle(assembly1);
@@ -427,7 +435,7 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
@@ -437,7 +445,7 @@
{
assertFalse(reference.isAssignableTo(bundle2, A.class.getName()));
assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
-
+
registration.unregister();
assertFalse(reference.isAssignableTo(bundle2, A.class.getName()));
assertFalse(reference.isAssignableTo(bundle2, String.class.getName())); // review ???
@@ -452,15 +460,16 @@
bundle1.uninstall();
}
}
-
- @Test public void testIsAssignableTo() throws Exception
+
+ @Test
+ public void testIsAssignableTo() throws Exception
{
//Bundle-Name: Service2
//Bundle-SymbolicName: org.jboss.test.osgi.service2
//Export-Package: org.jboss.test.osgi.service.support.a
VirtualFile assembly2 = assembleArchive("service2", "/bundles/service/service-bundle2", A.class);
Bundle bundle2 = installBundle(assembly2);
-
+
try
{
bundle2.start();
@@ -472,13 +481,13 @@
//Import-Package: org.jboss.test.osgi.service.support.a
VirtualFile assembly1 = assembleArchive("service1", "/bundles/service/service-bundle1");
Bundle bundle1 = installBundle(assembly1);
-
+
try
{
ServiceRegistration registration = bundleContext2.registerService(BundleContext.class.getName(), bundleContext2, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
@@ -486,7 +495,7 @@
assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
assertTrue(reference.isAssignableTo(bundle1, A.class.getName()));
assertTrue(reference.isAssignableTo(bundle1, String.class.getName()));
-
+
registration.unregister();
assertTrue(reference.isAssignableTo(bundle2, A.class.getName()));
assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
@@ -503,8 +512,9 @@
bundle2.uninstall();
}
}
-
- @Test public void testCompareTo() throws Exception
+
+ @Test
+ public void testCompareTo() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -516,13 +526,13 @@
ServiceRegistration registration1 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration1);
-
+
ServiceReference reference1 = registration1.getReference();
assertNotNull(reference1);
ServiceRegistration registration2 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration2);
-
+
ServiceReference reference2 = registration2.getReference();
assertNotNull(reference2);
@@ -530,7 +540,7 @@
properties.put(Constants.SERVICE_RANKING, 10);
ServiceRegistration registration3 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
assertNotNull(registration3);
-
+
ServiceReference reference3 = registration3.getReference();
assertNotNull(reference3);
@@ -538,17 +548,17 @@
properties.put(Constants.SERVICE_RANKING, -10);
ServiceRegistration registration4 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
assertNotNull(registration4);
-
+
ServiceReference reference4 = registration4.getReference();
assertNotNull(reference4);
-
+
assertGreaterRanking(reference1, reference2);
assertGreaterRanking(reference3, reference1);
assertGreaterRanking(reference3, reference2);
assertGreaterRanking(reference1, reference4);
assertGreaterRanking(reference2, reference4);
assertGreaterRanking(reference3, reference4);
-
+
try
{
reference1.compareTo(null);
@@ -558,7 +568,7 @@
{
// expected
}
-
+
try
{
reference1.compareTo(new Object());
@@ -573,12 +583,12 @@
properties.put(Constants.SERVICE_RANKING, "NotANumber");
ServiceRegistration registration5 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
assertNotNull(registration5);
-
+
ServiceReference reference5 = registration5.getReference();
assertNotNull(reference5);
assertGreaterRanking(reference1, reference5); // review ???
-
+
Set<ServiceReference> ordering = new TreeSet<ServiceReference>();
ordering.add(reference1);
ordering.add(reference2);
@@ -591,7 +601,7 @@
assertEquals(reference2, iterator.next());
assertEquals(reference1, iterator.next());
assertEquals(reference3, iterator.next());
-
+
ordering = new TreeSet<ServiceReference>();
ordering.add(reference5);
ordering.add(reference4);
@@ -610,7 +620,7 @@
bundle.uninstall();
}
}
-
+
protected void assertGreaterRanking(ServiceReference reference1, ServiceReference reference2) throws Exception
{
assertTrue(reference1 + " > " + reference2, reference1.compareTo(reference2) > 0);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationTestCase.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/ServiceRegistrationTestCase.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -50,7 +50,8 @@
*/
public class ServiceRegistrationTestCase extends AbstractFrameworkTest
{
- @Test public void testGetReference() throws Exception
+ @Test
+ public void testGetReference() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -62,19 +63,19 @@
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
ServiceReference reference2 = bundleContext.getServiceReference(BundleContext.class.getName());
assertEquals(reference, reference2);
-
+
Object object = bundleContext.getService(reference);
assertEquals(bundleContext, object);
reference2 = registration.getReference();
assertEquals(reference, reference2);
-
+
registration.unregister();
try
{
@@ -89,11 +90,11 @@
ServiceRegistration registration2 = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
assertNotNull(registration);
assertNotSame(registration, registration2);
-
+
reference2 = registration2.getReference();
assertNotNull(reference2);
assertNotSame(reference, reference2);
-
+
bundle.stop();
try
{
@@ -110,8 +111,9 @@
bundle.uninstall();
}
}
-
- @Test public void testSetProperties() throws Exception
+
+ @Test
+ public void testSetProperties() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -123,7 +125,7 @@
String propertyA = "org.jboss.osgi.test.PropertyA";
String propertyALower = "org.jboss.osgi.test.propertya";
-
+
Hashtable<String, Object> properties = new Hashtable<String, Object>();
properties.put(propertyA, "testA");
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, properties);
@@ -132,7 +134,7 @@
assertNotNull(reference);
assertEquals("testA", reference.getProperty(propertyA));
assertEquals("testA", reference.getProperty(propertyALower));
-
+
Object serviceID = reference.getProperty(Constants.SERVICE_ID);
Object objectClass = reference.getProperty(Constants.OBJECTCLASS);
@@ -141,7 +143,7 @@
assertAllReferences(bundleContext, null, "(" + Constants.SERVICE_ID + "=" + serviceID + ")", reference);
bundleContext.addServiceListener(this);
-
+
properties = new Hashtable<String, Object>();
properties.put(propertyA, "testAChanged");
registration.setProperties(properties);
@@ -151,7 +153,7 @@
assertNoAllReferences(bundleContext, null, "(" + propertyALower + "=testA)");
assertAllReferences(bundleContext, null, "(" + propertyA + "=testAChanged)", reference);
assertAllReferences(bundleContext, null, "(" + propertyALower + "=testAChanged)", reference);
-
+
registration.setProperties(null);
assertServiceEvent(ServiceEvent.MODIFIED, reference);
assertNull(reference.getProperty(propertyA));
@@ -159,7 +161,7 @@
assertNoAllReferences(bundleContext, null, "(" + propertyALower + "=testA)");
assertNoAllReferences(bundleContext, null, "(" + propertyA + "=testAChanged)");
assertNoAllReferences(bundleContext, null, "(" + propertyALower + "=testAChanged)");
-
+
properties = new Hashtable<String, Object>();
properties.put(propertyA, "testA2");
properties.put(Constants.SERVICE_ID, "rubbish1");
@@ -172,7 +174,7 @@
assertEquals(serviceID, reference.getProperty(Constants.SERVICE_ID.toLowerCase()));
assertEquals(objectClass, reference.getProperty(Constants.OBJECTCLASS));
assertEquals(objectClass, reference.getProperty(Constants.OBJECTCLASS.toLowerCase()));
-
+
try
{
assertNoAllReferences(bundleContext, null, "(" + Constants.SERVICE_ID + "=rubbish1)");
@@ -182,7 +184,7 @@
{
// expected
}
-
+
assertAllReferences(bundleContext, null, "(" + Constants.SERVICE_ID + "=" + serviceID + ")", reference);
properties = new Hashtable<String, Object>();
@@ -198,10 +200,10 @@
// expected
}
assertNoServiceEvent();
-
+
registration.unregister();
assertServiceEvent(ServiceEvent.UNREGISTERING, reference);
-
+
try
{
registration.setProperties(new Hashtable<String, Object>());
@@ -218,8 +220,9 @@
bundle.uninstall();
}
}
-
- @Test public void testSetPropertiesAfterStop() throws Exception
+
+ @Test
+ public void testSetPropertiesAfterStop() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -233,7 +236,7 @@
assertNotNull(registration);
bundle.stop();
-
+
try
{
registration.setProperties(new Hashtable<String, Object>());
@@ -250,8 +253,9 @@
bundle.uninstall();
}
}
-
- @Test public void testUnregister() throws Exception
+
+ @Test
+ public void testUnregister() throws Exception
{
VirtualFile assembly1 = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle1 = installBundle(assembly1);
@@ -264,7 +268,7 @@
SimpleServiceFactory factory = new SimpleServiceFactory(bundleContext);
ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), factory, null);
assertNotNull(registration);
-
+
ServiceReference reference = registration.getReference();
assertNotNull(reference);
@@ -273,7 +277,7 @@
ServiceReference[] inUse = bundle1.getServicesInUse();
assertNull(inUse);
-
+
bundleContext.getService(reference);
inUse = bundle1.getServicesInUse();
assertArrayEquals(new ServiceReference[] { reference }, inUse);
@@ -292,16 +296,16 @@
assertNull(factory.ungetBundle);
assertNull(factory.ungetRegistration);
assertNull(factory.ungetService);
-
+
bundleContext.addServiceListener(this);
registration.unregister();
reference2 = bundleContext.getServiceReference(BundleContext.class.getName());
assertNull("" + reference2, reference2);
-
+
Object actual = bundleContext.getService(reference);
assertNull("" + actual, actual);
-
+
assertServiceEvent(ServiceEvent.UNREGISTERING, reference);
inUse = bundle1.getServicesInUse();
@@ -316,7 +320,7 @@
{
bundle2.uninstall();
}
-
+
try
{
registration.unregister();
@@ -332,8 +336,9 @@
bundle1.uninstall();
}
}
-
- @Test public void testUnregisterAfterStop() throws Exception
+
+ @Test
+ public void testUnregisterAfterStop() throws Exception
{
VirtualFile assembly = assembleArchive("simple1", "/bundles/simple/simple-bundle1");
Bundle bundle = installBundle(assembly);
@@ -347,7 +352,7 @@
assertNotNull(registration);
bundle.stop();
-
+
try
{
registration.unregister();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/BrokenServiceFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/BrokenServiceFactory.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/BrokenServiceFactory.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -41,7 +41,7 @@
this.service = service;
this.inGet = inGet;
}
-
+
public Object getService(Bundle bundle, ServiceRegistration registration)
{
if (inGet)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/LazyBundle.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -36,9 +36,7 @@
{
public static Bundle getBundle(DeploymentUnit unit) throws Exception
{
- return (Bundle)Proxy.newProxyInstance(Bundle.class.getClassLoader(),
- new Class<?>[]{Bundle.class},
- new LazyBundleHandler(unit));
+ return (Bundle)Proxy.newProxyInstance(Bundle.class.getClassLoader(), new Class<?>[] { Bundle.class }, new LazyBundleHandler(unit));
}
private static class LazyBundleHandler implements InvocationHandler
@@ -63,7 +61,7 @@
AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
if (bundle == null)
throw new IllegalArgumentException("No such OSGiBundleState attachment: " + unit);
- this.bundle = bundle.getBundleInternal();
+ this.bundle = bundle.getBundleInternal();
}
return bundle;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/SimpleServiceFactory.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -34,10 +34,10 @@
public class SimpleServiceFactory implements ServiceFactory
{
public Object service;
-
+
public Bundle getBundle;
public int getCount;
-
+
public Bundle ungetBundle;
public ServiceRegistration ungetRegistration;
public Object ungetService;
Modified: 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 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/service/support/e/E.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -21,6 +21,6 @@
*/
package org.jboss.test.osgi.service.support.e;
-public class E
+public class E
{
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2010-03-21 18:23:23 UTC (rev 102689)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2010-03-21 18:41:27 UTC (rev 102690)
@@ -26,9 +26,11 @@
import java.security.AccessControlContext;
import java.security.AccessController;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -55,9 +57,11 @@
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceException;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.SynchronousBundleListener;
+import org.osgi.framework.hooks.service.EventHook;
import org.osgi.framework.hooks.service.ListenerHook;
import org.osgi.framework.hooks.service.ListenerHook.ListenerInfo;
@@ -242,11 +246,11 @@
// If the context bundle's list of listeners already contains a listener l such that (l==listener),
// then this method replaces that listener's filter (which may be null) with the specified one (which may be null).
removeServiceListener(bundle, listener);
-
+
// Create the new listener registration
- Filter filter = (filterstr != null ? FrameworkUtil.createFilter(filterstr) : NoFilter.INSTANCE);
+ Filter filter = (filterstr != null ? FrameworkUtil.createFilter(filterstr) : NoFilter.INSTANCE);
ServiceListenerRegistration slreg = new ServiceListenerRegistration(bundle, listener, filter);
-
+
// The {@link ListenerHook} added method is called to provide the hook implementation with information on newly added service listeners.
// This method will be called as service listeners are added while this hook is registered
for (ListenerHook hook : getServiceListenerHooks())
@@ -521,16 +525,23 @@
public void fireServiceEvent(Bundle bundle, int type, final OSGiServiceState service)
{
// Get a snapshot of the current listeners
- final ArrayList<ServiceListenerRegistration> listeners = new ArrayList<ServiceListenerRegistration>();
+ List<ServiceListenerRegistration> listeners = new ArrayList<ServiceListenerRegistration>();
+ Collection<BundleContext> contexts = new HashSet<BundleContext>();
synchronized (serviceListeners)
{
for (Entry<Bundle, List<ServiceListenerRegistration>> entry : serviceListeners.entrySet())
{
for (ServiceListenerRegistration listener : entry.getValue())
{
- listeners.add(listener);
+ BundleContext context = listener.getBundleContext();
+ if (context != null)
+ {
+ listeners.add(listener);
+ contexts.add(context);
+ }
}
}
+ contexts = new RemoveOnlyCollection<BundleContext>(contexts);
}
// Expose the wrapper not the state itself
@@ -539,14 +550,40 @@
log.info("Service " + typeName + ": " + service);
+ // Do nothing if the Framework is not active
+ if (getBundleManager().isFrameworkActive() == false)
+ return;
+
+ // Call the registered event hooks
+ List<EventHook> eventHooks = getEventHooks();
+ for (EventHook hook : eventHooks)
+ {
+ try
+ {
+ hook.event(event, contexts);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Error while calling EventHook: " + hook, ex);
+ }
+ }
+
+ // Remove the listeners that have been filtered by the EventHooks
+ if (contexts.size() != listeners.size())
+ {
+ Iterator<ServiceListenerRegistration> it = listeners.iterator();
+ while (it.hasNext())
+ {
+ ServiceListenerRegistration slreg = it.next();
+ if (contexts.contains(slreg.getBundleContext()) == false)
+ it.remove();
+ }
+ }
+
// Nobody is interested
if (listeners.isEmpty())
return;
- // Are we active?
- if (getBundleManager().isFrameworkActive() == false)
- return;
-
// Call the listeners. All service events are synchronously delivered
for (ServiceListenerRegistration registration : listeners)
{
@@ -572,6 +609,34 @@
}
}
+ @SuppressWarnings("unchecked")
+ private List<EventHook> getEventHooks()
+ {
+ List<EventHook> hooks = new ArrayList<EventHook>();
+ BundleContext context = getBundleManager().getSystemContext();
+ ServiceReference[] srefs = null;
+ try
+ {
+ srefs = context.getServiceReferences(EventHook.class.getName(), null);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ // ignore
+ }
+ if (srefs != null)
+ {
+ // The calling order of the hooks is defined by the reversed compareTo ordering of their Service
+ // Reference objects. That is, the service with the highest ranking number is called first.
+ List<ServiceReference> sortedRefs = new ArrayList<ServiceReference>(Arrays.asList(srefs));
+ Collections.sort(sortedRefs);
+ Collections.reverse(sortedRefs);
+
+ for (ServiceReference sref : sortedRefs)
+ hooks.add((EventHook)context.getService(sref));
+ }
+ return hooks;
+ }
+
private static Bundle assertBundle(Bundle bundle)
{
if (bundle == null)
@@ -627,6 +692,11 @@
accessControlContext = AccessController.getContext();
}
+ public BundleContext getBundleContext()
+ {
+ return bundle.getBundleContext();
+ }
+
public ListenerInfo getListenerInfo()
{
return info;
@@ -648,6 +718,13 @@
ServiceListenerRegistration other = (ServiceListenerRegistration)obj;
return other.listener.equals(listener);
}
+
+ @Override
+ public String toString()
+ {
+ String className = listener.getClass().getName();
+ return "ServiceListener[" + bundle + "," + className + "," + filter + "]";
+ }
}
static class ListenerInfoImpl implements ListenerInfo
@@ -704,8 +781,8 @@
@Override
public String toString()
{
- String simpleName = listener.getClass().getSimpleName();
- return "ListenerInfo[" + context + "," + simpleName + "," + removed + "]";
+ String className = listener.getClass().getName();
+ return "ListenerInfo[" + context + "," + className + "," + removed + "]";
}
}
@@ -756,4 +833,97 @@
return "ServiceEvent[type=" + ConstantsHelper.serviceEvent(getType()) + ",source=" + getSource() + "]";
}
}
+
+ /**
+ * A Collection that does not allow add operations.
+ */
+ @SuppressWarnings("rawtypes")
+ static class RemoveOnlyCollection<T> implements Collection<T>
+ {
+ Collection<T> delegate;
+
+ RemoveOnlyCollection(Collection<T> delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ @Override
+ public boolean contains(Object o)
+ {
+ return delegate.contains(o);
+ }
+
+ @Override
+ public Iterator<T> iterator()
+ {
+ return delegate.iterator();
+ }
+
+ @Override
+ public Object[] toArray()
+ {
+ return delegate.toArray();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Object[] toArray(Object[] a)
+ {
+ return delegate.toArray(a);
+ }
+
+ @Override
+ public boolean add(Object e)
+ {
+ throw new ServiceException("Add not supported");
+ }
+
+ @Override
+ public boolean remove(Object o)
+ {
+ return delegate.remove(o);
+ }
+
+ @Override
+ public boolean containsAll(Collection c)
+ {
+ return delegate.containsAll(c);
+ }
+
+ @Override
+ public boolean addAll(Collection c)
+ {
+ throw new ServiceException("Add not supported");
+ }
+
+ @Override
+ public boolean removeAll(Collection c)
+ {
+ return delegate.removeAll(c);
+ }
+
+ @Override
+ public boolean retainAll(Collection c)
+ {
+ return delegate.removeAll(c);
+ }
+
+ @Override
+ public void clear()
+ {
+ delegate.clear();
+ }
+ }
}
\ No newline at end of file
14 years, 3 months
JBoss-OSGI SVN: r102686 - in projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework: plugins and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-03-21 11:45:02 -0400 (Sun, 21 Mar 2010)
New Revision: 102686
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java
Log:
Add getUsingBundles() to ServiceManagerPlugin
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-03-21 14:29:03 UTC (rev 102685)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-03-21 15:45:02 UTC (rev 102686)
@@ -29,7 +29,6 @@
import java.util.Collection;
import java.util.Dictionary;
import java.util.Enumeration;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -48,6 +47,7 @@
import org.jboss.osgi.framework.metadata.CaseInsensitiveDictionary;
import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
+import org.jboss.osgi.framework.plugins.ServiceManagerPlugin;
import org.jboss.osgi.spi.util.BundleClassLoader;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -282,11 +282,13 @@
return getTarget();
}
+ @Override
public Object invoke(String name, Object[] parameters, String[] signature) throws Throwable
{
return getBeanInfo().invoke(getTarget(), name, signature, parameters);
}
+ @Override
public ClassLoader getClassLoader() throws Throwable
{
return getClassLoaderInternal();
@@ -301,11 +303,13 @@
return BundleClassLoader.createClassLoader(getBundle());
}
+ @Override
public Object get(String name) throws Throwable
{
return getBeanInfo().getProperty(getTarget(), name);
}
+ @Override
public void set(String name, Object value) throws Throwable
{
getBeanInfo().setProperty(getTarget(), name, value);
@@ -388,7 +392,7 @@
}
/**
- * Unget from cache.
+ * Unget the service from cache.
*
* @param bundleState the bundle state
* @return ungot service
@@ -427,16 +431,12 @@
return service;
}
- /**
- * Get the service registration
- *
- * @return the service registration
- */
- public ServiceRegistration getRegistration()
+ ServiceRegistration getRegistration()
{
return serviceRegistration;
}
+ @Override
public ServiceReference getReference()
{
checkUnregistered();
@@ -450,6 +450,7 @@
return serviceReference;
}
+ @Override
public Bundle getBundle()
{
if (isUnregistered())
@@ -467,6 +468,7 @@
return bundleState;
}
+ @Override
public Object getProperty(String key)
{
if (key == null)
@@ -480,6 +482,7 @@
return properties.get(key);
}
+ @Override
public String[] getPropertyKeys()
{
ArrayList<String> result = new ArrayList<String>();
@@ -494,6 +497,7 @@
return result.toArray(new String[result.size()]);
}
+ @Override
@SuppressWarnings("rawtypes")
public void setProperties(Dictionary properties)
{
@@ -512,33 +516,22 @@
@Override
public Bundle[] getUsingBundles()
{
- Set<Bundle> bundles = getUsingBundleInternal();
+ OSGiBundleManager manager = bundleState.getBundleManager();
+ ServiceManagerPlugin plugin = manager.getPlugin(ServiceManagerPlugin.class);
+ Set<Bundle> bundles = plugin.getUsingBundles(this);
if (bundles.size() == 0)
return null;
return bundles.toArray(new Bundle[bundles.size()]);
}
-
- private Set<Bundle> getUsingBundleInternal()
- {
- OSGiBundleManager manager = bundleState.getBundleManager();
- ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
-
- Set<Object> users = getContextTracker().getUsers(this);
- Set<Bundle> bundles = new HashSet<Bundle>();
- for (Object user : users)
- {
- AbstractBundleState abs = plugin.getBundleForUser(user);
- bundles.add(abs.getBundleInternal());
- }
- return bundles;
- }
-
+
+ @Override
public boolean isAssignableTo(Bundle bundle, String className)
{
return MDRUtils.isAssignableTo(this, bundleState, bundle, className);
}
+ @Override
public void unregister()
{
checkUnregistered();
@@ -556,6 +549,7 @@
}
}
+ @Override
public int compareTo(Object reference)
{
if (reference == null)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-03-21 14:29:03 UTC (rev 102685)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-03-21 15:45:02 UTC (rev 102686)
@@ -55,6 +55,7 @@
import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
import org.jboss.osgi.framework.util.KernelUtils;
import org.jboss.osgi.framework.util.NoFilter;
+import org.osgi.framework.Bundle;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
@@ -118,6 +119,7 @@
applyMDRUsage(false);
}
+ @Override
public ServiceReference[] getRegisteredServices(AbstractBundleState bundleState)
{
Set<ControllerContext> contexts = getRegisteredContexts(bundleState);
@@ -137,6 +139,7 @@
return result.toArray(new ServiceReference[result.size()]);
}
+ @Override
public ServiceReference[] getServicesInUse(AbstractBundleState bundleState)
{
Set<ControllerContext> contexts = bundleState.getUsedContexts(bundleState);
@@ -157,6 +160,7 @@
return references.toArray(new ServiceReference[references.size()]);
}
+ @Override
public ServiceReference[] getAllServiceReferences(AbstractBundleState bundle, String clazz, String filterStr) throws InvalidSyntaxException
{
Filter filter = NoFilter.INSTANCE;
@@ -170,13 +174,25 @@
return services.toArray(new ServiceReference[services.size()]);
}
- /**
- * Get a service
- *
- * @param bundleState the bundle that requests the service
- * @param reference the service reference
- * @return the service
- */
+ @Override
+ public Set<Bundle> getUsingBundles(OSGiServiceState serviceState)
+ {
+ AbstractBundleState bundleState = serviceState.getBundleState();
+ OSGiBundleManager manager = bundleState.getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+
+ ContextTracker contextTracker = serviceState.getContextTracker();
+ Set<Object> users = contextTracker.getUsers(serviceState);
+ Set<Bundle> bundles = new HashSet<Bundle>();
+ for (Object user : users)
+ {
+ AbstractBundleState abs = plugin.getBundleForUser(user);
+ bundles.add(abs.getBundleInternal());
+ }
+ return bundles;
+ }
+
+ @Override
public Object getService(AbstractBundleState bundleState, ServiceReference reference)
{
if (reference == null)
@@ -192,6 +208,7 @@
return target;
}
+ @Override
public ServiceReference getServiceReference(AbstractBundleState bundle, String clazz)
{
if (clazz == null)
@@ -204,6 +221,7 @@
return services.iterator().next();
}
+ @Override
public ServiceReference[] getServiceReferences(AbstractBundleState bundle, String clazz, String filterStr) throws InvalidSyntaxException
{
Filter filter = NoFilter.INSTANCE;
@@ -217,6 +235,7 @@
return services.toArray(new ServiceReference[services.size()]);
}
+ @Override
@SuppressWarnings("rawtypes")
public OSGiServiceState registerService(AbstractBundleState bundleState, String[] clazzes, Object service, Dictionary properties)
{
@@ -261,6 +280,7 @@
return result;
}
+ @Override
public void unregisterService(OSGiServiceState serviceState)
{
AbstractBundleState bundleState = serviceState.getBundleState();
@@ -277,9 +297,6 @@
controller.uninstall(serviceState.getName());
}
- /**
- * Unregister the service
- */
private void internalUnregister(OSGiServiceState serviceState)
{
AbstractBundleState bundleState = serviceState.getBundleState();
@@ -312,6 +329,7 @@
serviceState.clearTarget();
}
+ @Override
public boolean ungetService(AbstractBundleState bundleState, ServiceReference reference)
{
if (reference == null)
@@ -325,6 +343,7 @@
return bundleState.removeContextInUse(context);
}
+ @Override
public void unregisterServices(AbstractBundleState bundleState)
{
unregisterContexts(bundleState);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java 2010-03-21 14:29:03 UTC (rev 102685)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java 2010-03-21 15:45:02 UTC (rev 102686)
@@ -22,6 +22,7 @@
package org.jboss.osgi.framework.plugins;
import java.util.Dictionary;
+import java.util.Set;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiServiceState;
@@ -104,7 +105,14 @@
*/
Object getService(AbstractBundleState bundleState, ServiceReference reference);
+
/**
+ * Returns the bundles that are using the service.
+ * @return A set of bundles or an empty set.
+ */
+ Set<Bundle> getUsingBundles(OSGiServiceState serviceState);
+
+ /**
* Releases the service object referenced by the specified
* <code>ServiceReference</code> object. If the context bundle's use count
* for the service is zero, this method returns <code>false</code>.
14 years, 3 months