Author: thomas.diesler(a)jboss.com
Date: 2010-03-31 18:33:05 -0400 (Wed, 31 Mar 2010)
New Revision: 103365
Added:
projects/jboss-osgi/projects/parent/trunk/.settings/
projects/jboss-osgi/projects/parent/trunk/.settings/org.maven.ide.eclipse.prefs
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/C.java
projects/jboss-osgi/projects/spi/trunk/.gitignore
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/DynamicImportPackageTestCase.java
projects/jboss-osgi/projects/spi/trunk/.settings/org.eclipse.jdt.core.prefs
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java
Log:
[JBCL-131] Add test coverage for DynamicImport-Package: *
Added: projects/jboss-osgi/projects/parent/trunk/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jboss-osgi/projects/parent/trunk/.settings/org.maven.ide.eclipse.prefs
(rev 0)
+++
projects/jboss-osgi/projects/parent/trunk/.settings/org.maven.ide.eclipse.prefs 2010-03-31
22:33:05 UTC (rev 103365)
@@ -0,0 +1,9 @@
+#Wed Mar 31 23:09:39 CEST 2010
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/DynamicImportPackageTestCase.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/DynamicImportPackageTestCase.java 2010-03-31
22:07:24 UTC (rev 103364)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/DynamicImportPackageTestCase.java 2010-03-31
22:33:05 UTC (rev 103365)
@@ -28,6 +28,10 @@
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.test.osgi.classloader.support.a.A;
+import org.jboss.test.osgi.classloader.support.b.B;
+import org.jboss.test.osgi.classloader.support.c.C;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.service.log.LogService;
@@ -40,23 +44,113 @@
*/
public class DynamicImportPackageTestCase extends OSGiFrameworkTest
{
+ private static JavaArchive archiveA, archiveB, archiveC;
+
+ @BeforeClass
+ public static void beforeTestCase()
+ {
+ // Bundle-SymbolicName: dynamic-wildcard-a
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ // Import-Package: org.jboss.test.osgi.classloader.support.b
+ // DynamicImport-Package: *
+ archiveA = Archives.create("dynamic-wildcard-a", JavaArchive.class);
+ archiveA.addClass(A.class);
+ archiveA.setManifest(new Asset()
+ {
+ public InputStream openStream()
+ {
+ OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
+ builder.addBundleManifestVersion(2);
+ builder.addBundleSymbolicName(archiveA.getName());
+ builder.addExportPackages(A.class.getPackage().getName());
+ builder.addImportPackages(B.class.getPackage().getName());
+ builder.addDynamicImportPackages("*");
+ return builder.openStream();
+ }
+ });
+
+ // Bundle-SymbolicName: dynamic-wildcard-bc
+ // Export-Package: org.jboss.test.osgi.classloader.support.b,
org.jboss.test.osgi.classloader.support.c
+ archiveB = Archives.create("dynamic-wildcard-bc", JavaArchive.class);
+ archiveB.addClasses(B.class, C.class);
+ archiveB.setManifest(new Asset()
+ {
+ public InputStream openStream()
+ {
+ OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
+ builder.addBundleManifestVersion(2);
+ builder.addBundleSymbolicName(archiveB.getName());
+ builder.addExportPackages(B.class.getPackage().getName());
+ builder.addExportPackages(C.class.getPackage().getName());
+ return builder.openStream();
+ }
+ });
+
+ // Bundle-SymbolicName: dynamic-log-service
+ // DynamicImport-Package: org.osgi.service.log
+ archiveC = Archives.create("dynamic-log-service", JavaArchive.class);
+ archiveC.setManifest(new Asset()
+ {
+ public InputStream openStream()
+ {
+ OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
+ builder.addBundleManifestVersion(2);
+ builder.addBundleSymbolicName(archiveC.getName());
+ builder.addDynamicImportPackages("org.osgi.service.log");
+ return builder.openStream();
+ }
+ });
+ }
+
@Test
+ public void testDynamicImportWithWildcard() throws Exception
+ {
+ Bundle bundleA = installBundle(archiveA);
+ assertBundleState(Bundle.INSTALLED, bundleA.getState());
+ try
+ {
+ Bundle bundleB = installBundle(archiveB);
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
+ try
+ {
+ assertLoadClass(bundleA, A.class.getName(), bundleA);
+ assertLoadClass(bundleA, B.class.getName(), bundleB);
+
+ System.out.println("FIXME [JBCL-131] Add a notion of on demand
resolution");
+ //assertLoadClass(bundleA, C.class.getName(), bundleB);
+
+ assertBundleState(Bundle.RESOLVED, bundleA.getState());
+ assertBundleState(Bundle.RESOLVED, bundleB.getState());
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
public void testLogServiceAvailableOnInstall() throws Exception
{
Bundle cmpd = installBundle("bundles/org.osgi.compendium.jar");
+ assertBundleState(Bundle.INSTALLED, cmpd.getState());
try
{
- Bundle bundle = installBundle(getBundleArchive());
- assertBundleState(Bundle.INSTALLED, bundle.getState());
+ Bundle bundleC = installBundle(archiveC);
+ assertBundleState(Bundle.INSTALLED, bundleC.getState());
try
{
- bundle.start();
- assertBundleState(Bundle.ACTIVE, bundle.getState());
- assertLoadClass(bundle, LogService.class.getName());
+ bundleC.start();
+ assertBundleState(Bundle.ACTIVE, bundleC.getState());
+ assertLoadClass(bundleC, LogService.class.getName());
}
finally
{
- bundle.uninstall();
+ bundleC.uninstall();
}
}
finally
@@ -68,18 +162,18 @@
@Test
public void testLogServiceNotAvailableOnInstall() throws Exception
{
- Bundle bundle = installBundle(getBundleArchive());
- assertBundleState(Bundle.INSTALLED, bundle.getState());
+ Bundle bundleC = installBundle(archiveC);
+ assertBundleState(Bundle.INSTALLED, bundleC.getState());
try
{
- bundle.start();
- assertBundleState(Bundle.ACTIVE, bundle.getState());
- assertLoadClassFail(bundle, LogService.class.getName());
-
+ bundleC.start();
+ assertBundleState(Bundle.ACTIVE, bundleC.getState());
+ assertLoadClassFail(bundleC, LogService.class.getName());
+
Bundle cmpd = installBundle("bundles/org.osgi.compendium.jar");
try
{
- assertLoadClass(bundle, LogService.class.getName());
+ assertLoadClass(bundleC, LogService.class.getName());
}
finally
{
@@ -88,24 +182,7 @@
}
finally
{
- bundle.uninstall();
+ bundleC.uninstall();
}
}
-
- private JavaArchive getBundleArchive()
- {
- final JavaArchive archive = Archives.create("dynamic-log-service",
JavaArchive.class);
- archive.setManifest(new Asset()
- {
- public InputStream openStream()
- {
- OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
- builder.addBundleManifestVersion(2);
- builder.addBundleSymbolicName(archive.getName());
- builder.addDynamicImportPackages("org.osgi.service.log");
- return builder.openStream();
- }
- });
- return archive;
- }
}
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/C.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/C.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/classloader/support/c/C.java 2010-03-31
22:33:05 UTC (rev 103365)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+package org.jboss.test.osgi.classloader.support.c;
+
+/**
+ * B.
+ *
+ * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class C
+{
+}
Added: projects/jboss-osgi/projects/spi/trunk/.gitignore
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/.gitignore (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/.gitignore 2010-03-31 22:33:05 UTC (rev
103365)
@@ -0,0 +1 @@
+/target
Modified: projects/jboss-osgi/projects/spi/trunk/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/.settings/org.eclipse.jdt.core.prefs 2010-03-31
22:07:24 UTC (rev 103364)
+++ projects/jboss-osgi/projects/spi/trunk/.settings/org.eclipse.jdt.core.prefs 2010-03-31
22:33:05 UTC (rev 103365)
@@ -1,4 +1,4 @@
-#Tue Feb 16 17:08:55 CET 2010
+#Wed Mar 31 23:12:49 CEST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java
===================================================================
---
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java 2010-03-31
22:07:24 UTC (rev 103364)
+++
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/testing/OSGiFrameworkTest.java 2010-03-31
22:33:05 UTC (rev 103365)
@@ -79,7 +79,7 @@
private final List<ServiceEvent> serviceEvents = new
CopyOnWriteArrayList<ServiceEvent>();
@BeforeClass
- public static void beforeClass() throws Exception
+ public static void beforeFrameworkTestClass() throws Exception
{
OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
framework = bootProvider.getFramework();
@@ -90,7 +90,7 @@
}
@AfterClass
- public static void afterClass() throws Exception
+ public static void afterFrameworkTestClass() throws Exception
{
if (framework != null)
{