Author: thomas.diesler(a)jboss.com
Date: 2009-11-11 02:10:01 -0500 (Wed, 11 Nov 2009)
New Revision: 96251
Modified:
projects/jboss-osgi/trunk/reactor/framework/pom.xml
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
Log:
More work on rule based resolver
Revert back to jboss-vfs-2.1.3.SP1
Modified: projects/jboss-osgi/trunk/reactor/framework/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-11 07:05:34 UTC (rev
96250)
+++ projects/jboss-osgi/trunk/reactor/framework/pom.xml 2009-11-11 07:10:01 UTC (rev
96251)
@@ -38,7 +38,6 @@
<properties>
<version.drools>5.0.1</version.drools>
<version.jboss.aop>2.1.0.CR3</version.jboss.aop>
- <version.jboss.vfs>2.2.0-SNAPSHOT</version.jboss.vfs>
<version.jboss.classloading>2.0.8-SNAPSHOT</version.jboss.classloading>
<version.jboss.deployers>2.0.9-SNAPSHOT</version.jboss.deployers>
<version.jboss.microcontainer>2.0.9.GA</version.jboss.microcontainer>
@@ -113,11 +112,6 @@
<version>${version.jboss.classloading}</version>
</dependency>
<dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-vfs</artifactId>
- <version>${version.jboss.vfs}</version>
- </dependency>
- <dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading</artifactId>
<version>${version.jboss.classloading}</version>
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -43,6 +43,7 @@
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.util.collection.ConcurrentSet;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -586,7 +587,7 @@
checkValidBundleContext();
checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
- AbstractBundleState bundleState = getBundleManager().install(location, input);
+ AbstractBundleState bundleState = getBundleManager().installBundle(location,
input);
return bundleState.getBundleInternal();
}
@@ -595,6 +596,15 @@
return installBundle(location, null);
}
+ public Bundle installBundle(VirtualFile root) throws BundleException
+ {
+ checkValidBundleContext();
+ checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
+
+ AbstractBundleState bundleState = getBundleManager().installBundle(root);
+ return bundleState.getBundleInternal();
+ }
+
@Override
public String toString()
{
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleContextWrapper.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -25,6 +25,7 @@
import java.io.InputStream;
import java.util.Dictionary;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -140,6 +141,11 @@
return bundleState.installBundle(location);
}
+ public Bundle install(VirtualFile root) throws BundleException
+ {
+ return bundleState.installBundle(root);
+ }
+
@SuppressWarnings("unchecked")
public ServiceRegistration registerService(String clazz, Object service, Dictionary
properties)
{
@@ -167,14 +173,14 @@
bundleState.removeServiceListener(listener);
}
+ public boolean ungetService(ServiceReference reference)
+ {
+ return bundleState.ungetService(reference);
+ }
+
@Override
public String toString()
{
return bundleState.toString();
}
-
- public boolean ungetService(ServiceReference reference)
- {
- return bundleState.ungetService(reference);
- }
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -386,12 +386,12 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public AbstractBundleState install(URL url) throws BundleException
+ public AbstractBundleState installBundle(URL url) throws BundleException
{
if (url == null)
throw new BundleException("Null url");
- return install(url.toExternalForm(), null);
+ return installBundle(url.toExternalForm(), null);
}
/**
@@ -402,7 +402,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public AbstractBundleState install(String location, InputStream input) throws
BundleException
+ public AbstractBundleState installBundle(String location, InputStream input) throws
BundleException
{
if (location == null)
throw new BundleException("Null location");
@@ -456,7 +456,7 @@
* @return the bundle state
* @throws BundleException for any error
*/
- public AbstractBundleState install(VirtualFile root) throws BundleException
+ public AbstractBundleState installBundle(VirtualFile root) throws BundleException
{
return install(root, null);
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/launch/OSGiFramework.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -29,6 +29,8 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.launch.Framework;
@@ -120,6 +122,14 @@
}
/**
+ * Install a bundle from a virtual file
+ */
+ public Bundle installBundle(VirtualFile root) throws BundleException
+ {
+ return bundleManager.installBundle(root).getBundleInternal();
+ }
+
+ /**
* The Framework cannot be uninstalled.
* <p>
* This method always throws a BundleException.
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/plugins/internal/AutoInstallPluginImpl.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -78,7 +78,7 @@
for (URL bundleURL : autoInstall)
{
- Bundle bundle = bundleManager.install(bundleURL);
+ Bundle bundle = bundleManager.installBundle(bundleURL);
autoBundles.put(bundleURL, bundle);
}
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/RuleBasedResolverImpl.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -44,7 +44,7 @@
import org.osgi.framework.Bundle;
/**
- * The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
+ * A Resolver that is based on the Drools rule engine.
*
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/resources/META-INF/resolver-rules.drl 2009-11-11
07:10:01 UTC (rev 96251)
@@ -1,7 +1,6 @@
package org.jboss.osgi.framework.resolver
declare WireCandidate
- name : String
importPackage : ImportPackage
exportPackage : ExportPackage
end
@@ -28,7 +27,6 @@
$import : ImportPackage( name == $export.name, exporter == null )
then
WireCandidate wc = new WireCandidate();
- wc.setName( $import.getName() + "-" + $export.getVersion());
wc.setImportPackage( $import );
wc.setExportPackage( $export );
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -158,7 +158,7 @@
if (resourceRoot == null)
throw new AssertionFailedError("Resource not found: " + root);
URL childResource = new URL(resourceRoot, child);
- AbstractBundleState bundleState = getBundleManager().install(childResource);
+ AbstractBundleState bundleState = getBundleManager().installBundle(childResource);
return bundleState.getBundleInternal();
}
@@ -171,7 +171,7 @@
*/
public Bundle addBundle(VirtualFile file) throws Exception
{
- AbstractBundleState bundleState = getBundleManager().install(file);
+ AbstractBundleState bundleState = getBundleManager().installBundle(file);
return bundleState.getBundleInternal();
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractResolverTest.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -23,9 +23,17 @@
// $Id$
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.launch.OSGiFramework;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.Resolver;
-import org.jboss.test.osgi.FrameworkTestCase;
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.jboss.virtual.VirtualFile;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.osgi.framework.BundleException;
/**
* An abstract {@link Resolver} test.
@@ -33,16 +41,41 @@
* @author thomas.diesler(a)jboss.com
* @since 09-Nov-2009
*/
-abstract class AbstractResolverTest extends FrameworkTestCase
+public abstract class AbstractResolverTest
{
- public AbstractResolverTest(String name)
+ protected static OSGiFramework framework;
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
{
- super(name);
+ OSGiBootstrapProvider bootProvider = OSGiBootstrap.getBootstrapProvider();
+ framework = (OSGiFramework)bootProvider.getFramework();
+ framework.start();
}
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ if (framework != null)
+ {
+ framework.stop();
+ framework = null;
+ }
+ }
+
protected Resolver getResolver()
{
- Resolver resolver = getBundleManager().getPlugin(ResolverPlugin.class);
- return resolver;
+ OSGiBundleManager bundleManager = framework.getBundleManager();
+ return bundleManager.getPlugin(ResolverPlugin.class);
}
+
+ public VirtualFile assembleBundle(String name, String resource, Class<?>...
packages) throws Exception
+ {
+ return new OSGiTestHelper().assembleBundle(name, resource, packages);
+ }
+
+ public VirtualFile assembleBundle(String name, String[] resources, Class<?>...
packages) throws Exception
+ {
+ return new OSGiTestHelper().assembleBundle(name, resources, packages);
+ }
}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -23,6 +23,12 @@
// $Id$
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
import org.jboss.osgi.framework.resolver.ExportPackage;
@@ -30,6 +36,7 @@
import org.jboss.osgi.framework.resolver.Resolvable;
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.test.osgi.classloader.support.a.A;
+import org.jboss.virtual.VirtualFile;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
@@ -42,54 +49,56 @@
*/
public class ResolverMetadataTest extends AbstractResolverTest
{
- public ResolverMetadataTest(String name)
- {
- super(name);
- }
-
@Test
public void testSimpleExport() throws Exception
{
// Bundle-SymbolicName: resolver-simpleexport
// Export-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
-
- Resolver resolver = getResolver();
- assertEquals(1, resolver.getBundles().size());
-
- Resolvable resolvableA = resolver.getBundle(bundleA.getSymbolicName(), null);
- assertNotNull("Resolvable not null", resolvableA);
-
- resolvableA = resolver.getBundle(bundleA.getSymbolicName(), bundleA.getVersion());
- assertNotNull("Resolvable not null", resolvableA);
-
- resolvableA = resolver.getBundle(bundleA);
- assertNotNull("Resolvable not null", resolvableA);
-
- assertNotNull(resolvableA.getBundle());
- assertEquals("resolver-simpleexport", resolvableA.getSymbolicName());
- assertEquals(Version.emptyVersion, resolvableA.getVersion());
-
- List<ExportPackage> exportPackages = resolvableA.getExportPackages();
- assertNotNull("ExportPackages not null", exportPackages);
- assertEquals(1, exportPackages.size());
-
- ExportPackage exportPackage =
resolvableA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- assertNotNull("ExportPackage not null", exportPackage);
- assertEquals("org.jboss.test.osgi.classloader.support.a",
exportPackage.getName());
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Resolver resolver = getResolver();
+ assertEquals(1, resolver.getBundles().size());
+
+ Resolvable resolvableA = resolver.getBundle(bundleA.getSymbolicName(), null);
+ assertNotNull("Resolvable not null", resolvableA);
+
+ resolvableA = resolver.getBundle(bundleA.getSymbolicName(),
bundleA.getVersion());
+ assertNotNull("Resolvable not null", resolvableA);
+
+ resolvableA = resolver.getBundle(bundleA);
+ assertNotNull("Resolvable not null", resolvableA);
+
+ assertNotNull(resolvableA.getBundle());
+ assertEquals("resolver-simpleexport", resolvableA.getSymbolicName());
+ assertEquals(Version.emptyVersion, resolvableA.getVersion());
+
+ List<ExportPackage> exportPackages = resolvableA.getExportPackages();
+ assertNotNull("ExportPackages not null", exportPackages);
+ assertEquals(1, exportPackages.size());
+
+ ExportPackage exportPackage =
resolvableA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertNotNull("ExportPackage not null", exportPackage);
+ assertEquals("org.jboss.test.osgi.classloader.support.a",
exportPackage.getName());
- assertEquals(Version.emptyVersion, exportPackage.getVersion());
- assertEquals(0, exportPackage.getUses().size());
- assertEquals(0, exportPackage.getMandatoryAttributes().size());
- assertNull("Null includes", exportPackage.getIncludes());
- assertNull("Null excludes", exportPackage.getExcludes());
-
- List<ImportPackage> importPackages = resolvableA.getImportPackages();
- assertNotNull("ImportPackages not null", importPackages);
- assertEquals(0, importPackages.size());
-
- assertFalse("No sigleton", resolvableA.isSingleton());
- assertFalse("Not resolved", resolvableA.isResolved());
+ assertEquals(Version.emptyVersion, exportPackage.getVersion());
+ assertEquals(0, exportPackage.getUses().size());
+ assertEquals(0, exportPackage.getMandatoryAttributes().size());
+ assertNull("Null includes", exportPackage.getIncludes());
+ assertNull("Null excludes", exportPackage.getExcludes());
+
+ List<ImportPackage> importPackages = resolvableA.getImportPackages();
+ assertNotNull("ImportPackages not null", importPackages);
+ assertEquals(0, importPackages.size());
+
+ assertFalse("No sigleton", resolvableA.isSingleton());
+ assertFalse("Not resolved", resolvableA.isResolved());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
}
@Test
@@ -97,21 +106,28 @@
{
// Bundle-SymbolicName: resolver-simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
-
- Resolvable resolvableA = getResolver().getBundle(bundleA);
-
- List<ImportPackage> importPackages = resolvableA.getImportPackages();
- assertNotNull("ImportPackages not null", importPackages);
- assertEquals(1, importPackages.size());
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Resolvable resolvableA = getResolver().getBundle(bundleA);
+
+ List<ImportPackage> importPackages = resolvableA.getImportPackages();
+ assertNotNull("ImportPackages not null", importPackages);
+ assertEquals(1, importPackages.size());
- ImportPackage importPackage =
resolvableA.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- assertNotNull("ImportPackage not null", importPackage);
- assertEquals("org.jboss.test.osgi.classloader.support.a",
importPackage.getName());
+ ImportPackage importPackage =
resolvableA.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertNotNull("ImportPackage not null", importPackage);
+ assertEquals("org.jboss.test.osgi.classloader.support.a",
importPackage.getName());
- assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
- assertNull("Null bundle-symbolic-name",
importPackage.getBundleSymbolicName());
- assertEquals("[0.0.0,?)", importPackage.getBundleVersion().toString());
+ assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
+ assertNull("Null bundle-symbolic-name",
importPackage.getBundleSymbolicName());
+ assertEquals("[0.0.0,?)",
importPackage.getBundleVersion().toString());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
}
@Test
@@ -119,9 +135,16 @@
{
// Bundle-SymbolicName: resolver-singleton;singleton:=true
// Export-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA",
"/bundles/resolver/singleton", A.class);
-
- Resolvable resolvableA = getResolver().getBundle(bundleA);
- assertTrue("Sigleton", resolvableA.isSingleton());
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/singleton", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Resolvable resolvableA = getResolver().getBundle(bundleA);
+ assertTrue("Sigleton", resolvableA.isSingleton());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
}
}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java 2009-11-11
07:05:34 UTC (rev 96250)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/RuleBasedResolverTest.java 2009-11-11
07:10:01 UTC (rev 96251)
@@ -23,6 +23,8 @@
// $Id$
+import static org.junit.Assert.*;
+
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.resolver.ExportPackage;
@@ -31,6 +33,9 @@
import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.framework.resolver.internal.drools.RuleBasedResolverImpl;
import org.jboss.test.osgi.classloader.support.a.A;
+import org.jboss.virtual.VirtualFile;
+import org.junit.Before;
+import org.junit.Test;
import org.osgi.framework.Bundle;
/**
@@ -41,17 +46,10 @@
*/
public class RuleBasedResolverTest extends AbstractResolverTest
{
- public RuleBasedResolverTest(String name)
+ @Before
+ public void setUp() throws Exception
{
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- OSGiBundleManager bundleManager = getBundleManager();
+ OSGiBundleManager bundleManager = framework.getBundleManager();
ResolverPlugin resolver = bundleManager.getPlugin(ResolverPlugin.class);
if ((resolver instanceof RuleBasedResolverImpl) == false)
{
@@ -60,25 +58,31 @@
}
}
+ @Test
public void testSimpleImport() throws Exception
{
// Bundle-SymbolicName: resolver-simpleimport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
-
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+
// Bundle-SymbolicName: resolver-simpleexport
// Import-Package: org.jboss.test.osgi.classloader.support.a
- Bundle bundleB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
-
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+
Resolver resolver = getResolver();
Resolvable resolvableA = resolver.getBundle(bundleA);
assertTrue("BundleA resolved", resolvableA.isResolved());
ImportPackage importPackage =
resolvableA.getImportPackage(A.class.getPackage().getName());
assertNotNull("Exporter not null", importPackage.getExporter());
-
+
Resolvable resolvableB = resolver.getBundle(bundleB);
assertTrue("BundleB resolved", resolvableB.isResolved());
ExportPackage exportPackage =
resolvableB.getExportPackage(A.class.getPackage().getName());
assertEquals("Importers not null", 1,
exportPackage.getImporters().size());
+
+ bundleB.uninstall();
+ bundleA.uninstall();
}
}
\ No newline at end of file