[jboss-osgi-commits] 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.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Sun Mar 21 14:41:30 EDT 2010
Author: thomas.diesler at 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 at 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 at 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 at 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 at 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 at 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
More information about the jboss-osgi-commits
mailing list