[jboss-cvs] JBossAS SVN: r93374 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src: main/java/org/jboss/osgi/plugins/facade/classloading and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 11 04:45:14 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-11 04:45:13 -0400 (Fri, 11 Sep 2009)
New Revision: 93374

Removed:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestSuite.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/ClassLoaderTestSuite.java
Modified:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageRequirement.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java
Log:
Add Require-Bundle handling to BundleResolver

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -676,7 +676,6 @@
       
       try
       {
-         log.info("Resolve: " + bundleState.getCanonicalName());
          deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
          deployerClient.checkComplete(unit.getName());
          bundleState.changeState(Bundle.RESOLVED);

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -166,18 +166,19 @@
          return false;
       
       OSGiMetaData metaData = bundleState.getOSGiMetaData();
-      PackageAttribute ourParameters = exportPackage;
-      PackageAttribute otherParameters = packageRequirement.getRequirePackage();
+      PackageAttribute capParameters = exportPackage;
+      PackageAttribute reqParameters = packageRequirement.getRequirePackage();
+      
       boolean validMatch = true;
 
       // Check all the manadatory attributes are present
       if (validMatch == true && mandatoryAttributes != null)
       {
-         if (otherParameters != null)
+         if (reqParameters != null)
          {
             for (String mand : mandatoryAttributes)
             {
-               if (otherParameters.getParameter(mand) == null)
+               if (reqParameters.getParameter(mand) == null)
                {
                   validMatch = false;
                   break;
@@ -186,15 +187,15 @@
          }
       }
 
-      if (validMatch == true && otherParameters != null)
+      if (validMatch == true && reqParameters != null)
       {
-         Map<String, Parameter> params = otherParameters.getParameters();
+         Map<String, Parameter> params = reqParameters.getParameters();
          if (params != null && params.isEmpty() == false)
          {
             for (String name : params.keySet())
             {
-               String otherValue = otherParameters.getParameterValue(name, String.class);
-               String ourValue = ourParameters.getParameterValue(name, String.class);
+               String otherValue = reqParameters.getParameterValue(name, String.class);
+               String ourValue = capParameters.getParameterValue(name, String.class);
 
                // todo we shouldn't mix attributes and directives in the metadata
                if (Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE.equals(name))

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageRequirement.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageRequirement.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageRequirement.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -93,13 +93,13 @@
    public OSGiPackageRequirement(String name, VersionRange versionRange, PackageAttribute requirePackage)
    {
       super(name, versionRange);
-      if (requirePackage == null)
-         throw new IllegalArgumentException("Null requirePackage");
-      this.requirePackage = requirePackage;
-
-      String resolution = requirePackage.getParameterValue(Constants.RESOLUTION_DIRECTIVE, String.class);
-      if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
-         setOptional(true);
+      if (requirePackage != null)
+      {
+         this.requirePackage = requirePackage;
+         String resolution = requirePackage.getParameterValue(Constants.RESOLUTION_DIRECTIVE, String.class);
+         if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
+            setOptional(true);
+      }
    }
 
    /**
@@ -129,16 +129,19 @@
    protected void toString(StringBuffer buffer)
    {
       super.toString(buffer);
-      Map<String, Parameter> parameters = requirePackage.getParameters();
-      if (parameters != null)
+      if (requirePackage != null)
       {
-         Map<String, Object> keyValueMap = new LinkedHashMap<String, Object>();
-         for (String key : parameters.keySet())
+         Map<String, Parameter> parameters = requirePackage.getParameters();
+         if (parameters != null)
          {
-            Object value = parameters.get(key).getValue();
-            keyValueMap.put(key, value);
+            Map<String, Object> keyValueMap = new LinkedHashMap<String, Object>();
+            for (String key : parameters.keySet())
+            {
+               Object value = parameters.get(key).getValue();
+               keyValueMap.put(key, value);
+            }
+            buffer.append(" ").append(keyValueMap);
          }
-         buffer.append(" ").append(keyValueMap);
       }
    }
 }

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -222,7 +222,7 @@
          }
       }
       
-      return allResolved;
+      return allResolved && resolvedBundles.isEmpty();
    }
 
    private OSGiBundleState assertBundleState(Bundle bundle)

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -33,21 +33,23 @@
 import org.jboss.classloading.spi.metadata.Capability;
 import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
 import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.version.VersionRange;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.logging.Logger;
 import org.jboss.osgi.plugins.facade.bundle.AbstractBundleState;
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleWrapper;
+import org.jboss.osgi.plugins.facade.classloading.OSGiPackageRequirement;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+import org.jboss.osgi.spi.metadata.Parameter;
+import org.jboss.osgi.spi.metadata.ParameterizedAttribute;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
 
 /**
- * The bundle resolver.
+ * The BundleResolver wires BundleRequirements to their corresponding BundleCapability.
  * 
- * The BundleResolver has the notion of bundle islands, which maintain sets of bundles that are wired together.
- * 
- * [TODO] versions [TODO] import/export properties
- * 
  * @author thomas.diesler at jboss.com
  * @since 10-Sep-2009
  */
@@ -66,6 +68,14 @@
       this.bundleManager = bundleManager;
    }
 
+   /**
+    * Resolve the given list of bundles.
+    * 
+    * This is an iterative process that tries to wire BundleRequirements
+    * to BundleCapabilities.
+    * 
+    * @return The list of resolved bundles in the resolve order or an empty list
+    */
    public List<Bundle> resolveBundles(List<Bundle> unresolvedBundles)
    {
       if (unresolvedBundles == null)
@@ -84,7 +94,7 @@
 
       List<Bundle> resolvedBundles = new ArrayList<Bundle>();
       unresolvedBundles = new ArrayList<Bundle>(unresolvedBundles);
-      while (resolved > 0)
+      while (resolved > 0 && unresolvedBundles.isEmpty() == false)
       {
          resolveRounds++;
 
@@ -104,12 +114,29 @@
                resolved++;
             }
          }
-         if (unresolvedBundles.isEmpty())
-            break;
       }
 
       log.info("END *****************************************************************");
-      log.info("Unresolved bundles: " + unresolvedBundles);
+      
+      // Log the unresolved bundles
+      if (unresolvedBundles.isEmpty() == false)
+      {
+         for (Bundle bundle : unresolvedBundles)
+         {
+            StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
+            List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
+            for (BundleRequirement requirement : bundleRequirements)
+            {
+               PackageRequirement packreq = requirement.getPackageRequirement();
+               BundleCapability bestMatch = findBestMatch(allCapabilities, requirement);
+               if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
+               {
+                  message.append("\n" + packreq);
+               }
+            }
+            log.info(message);
+         }
+      }
 
       return resolvedBundles;
    }
@@ -122,11 +149,9 @@
       List<BundleCapability> futureCapabilities = new ArrayList<BundleCapability>(allCapabilities);
       futureCapabilities.addAll(bundleCapabilities);
       
-      int nameLengthMax = 0;
       for (BundleRequirement requirement : bundleRequirements)
       {
          PackageRequirement packreq = requirement.getPackageRequirement();
-         nameLengthMax = Math.max(nameLengthMax, packreq.getName().length());
          
          BundleCapability bestMatch = findBestMatch(futureCapabilities, requirement);
          if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
@@ -143,22 +168,55 @@
             it.remove();
       }
       
+      if (processRequiredBundle(bundle, bundleCapabilities, bundleRequirements) == false)
+         return false;
+      
       allCapabilities.addAll(bundleCapabilities);
       bundleCapabilitiesMap.put(bundle, bundleCapabilities);
       bundleRequirementsMap.put(bundle, bundleRequirements);
       
+      // Get the max length of all packages
+      int nameLengthMax = 0;
+      for (BundleCapability capability : bundleCapabilities)
+      {
+         PackageCapability packcap = capability.getPackageCapability();
+         nameLengthMax = Math.max(nameLengthMax, packcap.getName().length());
+      }
+      for (BundleRequirement requirement : bundleRequirements)
+      {
+         PackageRequirement packreq = requirement.getPackageRequirement();
+         nameLengthMax = Math.max(nameLengthMax, packreq.getName().length());
+      }
+      
       // Log the package wiring information
       StringBuffer message = new StringBuffer("Resolved: " + bundle);
-      for (BundleRequirement requirement : bundleRequirements)
+      if (bundleCapabilities.isEmpty() == false)
       {
-         String packageName = requirement.getPackageRequirement().getName();
-         message.append("\n  " + packageName + " ");
-         for (int i = 0; i < (nameLengthMax - packageName.length()); i++)
-            message.append(" ");
-         
-         BundleCapability wire = requirement.getWire();
-         message.append(wire != null ? wire.getExportingBundle() : "null");
+         message.append("\n  Exports");
+         for (BundleCapability capability : bundleCapabilities)
+         {
+            PackageCapability packcap = capability.getPackageCapability();
+            
+            String packageName = packcap.getName();
+            message.append("\n    " + packageName);
+         }
       }
+      if (bundleRequirements.isEmpty() == false)
+      {
+         message.append("\n  Imports");
+         for (BundleRequirement requirement : bundleRequirements)
+         {
+            PackageRequirement packreq = requirement.getPackageRequirement();
+            
+            String packageName = packreq.getName();
+            message.append("\n    " + packageName + " <== ");
+            for (int i = 0; i < (nameLengthMax - packageName.length()); i++)
+               message.append(" ");
+            
+            BundleCapability wire = requirement.getWire();
+            message.append(wire != null ? wire.getExportingBundle() : "null");
+         }
+      }
       log.info(message);
       
       return true;
@@ -257,9 +315,9 @@
 
       OSGiBundleState bundleState = assertBundleState(bundle);
       DeploymentUnit unit = bundleState.getDeploymentUnit();
-      ClassLoadingMetaData metadata = unit.getAttachment(ClassLoadingMetaData.class);
+      ClassLoadingMetaData classloadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
       
-      List<Requirement> requirements = metadata.getRequirements().getRequirements();
+      List<Requirement> requirements = classloadingMetaData.getRequirements().getRequirements();
       if (requirements != null)
       {
          for (Requirement requirement : requirements)
@@ -271,9 +329,90 @@
             }
          }
       }
+      
       return result;
    }
 
+   private boolean processRequiredBundle(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
+   {
+      // The Require-Bundle header specifies that all exported packages from
+      // another bundle must be imported, effectively requiring the public interface
+      // of another bundle
+      OSGiMetaData osgiMetaData = bundle.getOSGiMetaData();
+      List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
+      if (requireBundles != null)
+      {
+         for (ParameterizedAttribute attr : requireBundles)
+         {
+            String requiredBundleName = attr.getAttribute();
+            if (requiredBundleName == null)
+               throw new IllegalStateException("Cannot obtain value for: " + Constants.REQUIRE_BUNDLE);
+            
+            String visibility = Constants.VISIBILITY_PRIVATE;
+            Parameter param = attr.getParameter(Constants.VISIBILITY_DIRECTIVE);
+            if (param != null)
+               visibility = (String)param.getValue();
+            
+            String resolution = Constants.RESOLUTION_MANDATORY;
+            param = attr.getParameter(Constants.RESOLUTION_DIRECTIVE);
+            if (param != null)
+               resolution = (String)param.getValue();
+            
+            // [TODO] bundle-version
+            //String bundleVersion = null;
+            //param = attr.getParameter(Constants.BUNDLE_VERSION_ATTRIBUTE);
+            //if (param != null)
+            //   bundleVersion = (String)param.getValue();
+            
+            if (Constants.RESOLUTION_MANDATORY.equals(resolution))
+            {
+               Bundle requiredBundle = getRequiredBundle(requiredBundleName);
+               if (requiredBundle == null)
+               {
+                  log.info("Cannot find " + resolution + " required bundle: " + requiredBundleName);
+                  return false;
+               }
+               
+               List<BundleCapability> otherCapabilities = bundleCapabilitiesMap.get(requiredBundle);
+               for (BundleCapability otherCapability : otherCapabilities)
+               {
+                  PackageCapability otherPackage = otherCapability.getPackageCapability();
+                  String packageName = otherPackage.getName();
+                  Object version = otherPackage.getVersion();
+                  VersionRange versionRange = new VersionRange(version, true, version, true);
+                  
+                  OSGiPackageRequirement newPackageRequirement = new OSGiPackageRequirement(packageName, versionRange, null);
+                  BundleRequirement newBundleRequirement = new BundleRequirement(bundle, newPackageRequirement);
+                  newBundleRequirement.setWire(otherCapability);
+                  bundleRequirements.add(newBundleRequirement);
+                  
+                  if (Constants.VISIBILITY_REEXPORT.equals(visibility))
+                  {
+                     BundleCapability newBundleCapability = new BundleCapability(bundle, otherPackage);
+                     bundleCapabilities.add(newBundleCapability);
+                  }
+               }
+            }
+            else if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
+            {
+               // [TODO] resolution=optional
+            }
+         }
+      }
+      
+      return true;
+   }
+
+   private Bundle getRequiredBundle(String requiredBundle)
+   {
+      for (Bundle bundle : bundleCapabilitiesMap.keySet())
+      {
+         if (bundle.getSymbolicName().equals(requiredBundle))
+            return bundle;
+      }
+      return null;
+   }
+
    static OSGiBundleState assertBundleState(Bundle bundle)
    {
       if (bundle instanceof OSGiBundleWrapper)

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestCase.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -261,17 +261,17 @@
       return result;
    }
    
-   protected Class<?> assertLoadClass(String name, Bundle start, Bundle expected)
+   protected Class<?> assertLoadClass(String name, Bundle bundle, Bundle expected)
    {
       Class<?> result = null;
       try
       {
-         result = start.loadClass(name);
-         getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + start);
+         result = bundle.loadClass(name);
+         getLog().debug("Got class: " + ClassLoaderUtils.classToString(result) + " for " + name + " from " + bundle);
       }
       catch (ClassNotFoundException e)
       {
-         failure("Did not expect CNFE for " + name + " from " + start, e);
+         failure("Did not expect CNFE for " + name + " from " + bundle, e);
       }
       assertClassLoader(result, expected);
       return result;

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestSuite.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestSuite.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -1,61 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.osgi;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.jboss.test.bundle.metadata.MetaDataTestSuite;
-import org.jboss.test.osgi.bundle.BundleTestSuite;
-import org.jboss.test.osgi.classloader.ClassLoaderTestSuite;
-import org.jboss.test.osgi.filter.FilterTestSuite;
-import org.jboss.test.osgi.service.ServiceTestSuite;
-import org.jboss.test.osgi.smoke.SmokeTestSuite;
-
-/**
- * OSGiTestSuite.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class OSGiTestSuite extends TestSuite
-{
-   public static void main(String[] args)
-   {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite()
-   {
-      TestSuite suite = new TestSuite("OSGi Tests");
-
-      suite.addTest(MetaDataTestSuite.suite());
-      suite.addTest(SmokeTestSuite.suite());
-      suite.addTest(FilterTestSuite.suite());
-      suite.addTest(BundleTestSuite.suite());
-      suite.addTest(ServiceTestSuite.suite());
-      suite.addTest(ClassLoaderTestSuite.suite());
-
-      return suite;
-   }
-}

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/ClassLoaderTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/ClassLoaderTestSuite.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/ClassLoaderTestSuite.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -1,53 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.osgi.classloader;
-
-import org.jboss.test.osgi.classloader.test.ExportImportPackageUnitTestCase;
-import org.jboss.test.osgi.classloader.test.RequireBundleUnitTestCase;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * BundleTestSuite.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ClassLoaderTestSuite extends TestSuite
-{
-   public static void main(String[] args)
-   {
-      TestRunner.run(suite());
-   }
-
-   public static Test suite()
-   {
-      TestSuite suite = new TestSuite("ClassLoader Tests");
-
-      suite.addTest(RequireBundleUnitTestCase.suite());
-      suite.addTest(ExportImportPackageUnitTestCase.suite());
-
-      return suite;
-   }
-}

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -27,6 +27,7 @@
 import org.jboss.test.osgi.OSGiTestCase;
 import org.jboss.test.osgi.classloader.support.a.A;
 import org.jboss.test.osgi.classloader.support.b.B;
+import org.junit.Ignore;
 import org.osgi.framework.Bundle;
 
 /**
@@ -47,11 +48,6 @@
       super(name);
    }
 
-   public static Test suite()
-   {
-      return suite(ExportImportPackageUnitTestCase.class);
-   }
-
    public void testSimpleImportPackage() throws Exception
    {
       Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
@@ -212,21 +208,41 @@
 
    public void testBundleNameImportPackage() throws Exception
    {
+      //Bundle-Name: NotBundleA
+      //Bundle-Version: 1.0.0
+      //Bundle-SymbolicName: org.jboss.test.osgi.classloader.notbundleA
+      //Export-Package: org.jboss.test.osgi.classloader.support.a
       Bundle bundle0 = assembleBundle("notbundleA", "/bundles/classloader/notbundleA", A.class);
+      
       try
       {
          bundle0.start();
          assertLoadClass(bundle0, A.class);
+         assertLoadClass(bundle0, A.class, bundle0);
+         
+         //Bundle-Name: BundleA
+         //Bundle-Version: 1.0.0
+         //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
          Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+         
          try
          {
             bundle1.start();
             assertLoadClass(bundle1, A.class);
+            assertLoadClass(bundle1, A.class, bundle1);
+            
+            //Bundle-Name: BundleB
+            //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
+            //Import-Package: org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=org.jboss.test.osgi.classloader.bundleA
             Bundle bundle2 = assembleBundle("bundlenameimportpackageA", "/bundles/classloader/bundlenameimportpackageA", B.class);
+            
             try
             {
                bundle2.start();
-               System.out.println("FIXME assertLoadClass(bundle2, A.class, bundle1)");
+               System.out.println(" FIXME [JBOSGI-153] Cannot parse Import-Package parameters");
+               //assertLoadClass(bundle2, A.class, bundle1);
+               
                assertLoadClass(bundle2, B.class, bundle2);
             }
             finally

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -21,8 +21,6 @@
 */
 package org.jboss.test.osgi.classloader.test;
 
-import junit.framework.Test;
-
 import org.jboss.deployers.client.spi.IncompleteDeploymentException;
 import org.jboss.test.osgi.OSGiTestCase;
 import org.jboss.test.osgi.classloader.support.a.A;
@@ -43,11 +41,6 @@
       super(name);
    }
 
-   public static Test suite()
-   {
-      return suite(RequireBundleUnitTestCase.class);
-   }
-   
    public void testSimpleRequireBundle() throws Exception
    {
       Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
@@ -206,24 +199,40 @@
    
    public void testReExportRequireBundle() throws Exception
    {
+      //Bundle-Name: BundleA
+      //Bundle-Version: 1.0.0
+      //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
       Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+      
       try
       {
          bundle1.start();
          assertLoadClass(bundle1, A.class);
+         
+         //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
          Bundle bundle2 = assembleBundle("reexportrequirebundleA", "/bundles/classloader/reexportrequirebundleA", B.class);
+         
          try
          {
             bundle2.start();
             assertLoadClass(bundle2, A.class, bundle1);
             assertLoadClass(bundle2, B.class, bundle2);
+            
+            //Bundle-Name: BundleC
+            //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleC
+            //Require-Bundle: org.jboss.test.osgi.classloader.bundleB
             Bundle bundle3 = assembleBundle("reexportrequirebundleB", "/bundles/classloader/reexportrequirebundleB");
+            
             try
             {
-               System.out.println("FIXME assertLoadClass(bundle3, A.class, bundle1)");
-               // assertLoadClass(bundle3, A.class, bundle1);
-               System.out.println("FIXME assertLoadClass(bundle3, B.class, bundle2)");
-               // assertLoadClass(bundle3, B.class, bundle2)
+               System.out.println(" FIXME assertLoadClass(bundle3, A.class, bundle1)");
+               //assertLoadClass(bundle3, A.class, bundle1);
+               System.out.println(" FIXME assertLoadClass(bundle3, B.class, bundle2)");
+               //assertLoadClass(bundle3, B.class, bundle2);
             }
             finally
             {

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java	2009-09-11 06:01:56 UTC (rev 93373)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java	2009-09-11 08:45:13 UTC (rev 93374)
@@ -85,7 +85,7 @@
       assertInvalid("(<=b)");
       assertInvalid("(>=b)");
       assertInvalid("(~=b)");
-      System.out.println("FIXME [JBOSGI-129] - Invalid (*=b)");
+      System.out.println(" FIXME [JBOSGI-129] - Invalid (*=b)");
       assertNoMatch("(*=b)", properties);
       assertInvalid("(a=\\)");
       
@@ -94,7 +94,7 @@
       assertMatch("(a =b)", properties);
       assertMatch("(c= d)", properties);
       assertMatch("(e=f )", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a=)");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a=)");
       assertInvalid("(a=)");
       assertNoMatch("(a=c)", properties);
       assertNoMatch("(x=c)", properties);
@@ -123,16 +123,16 @@
       assertMatch("(a<=2)", properties);
       assertMatch("( a<=2)", properties);
       assertMatch("(a <=2)", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a<= 2)");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a<= 2)");
       assertMatch("(a<= 2)", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a<=2 )");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a<=2 )");
       assertMatch("(a<=2 )", properties);
       assertNoMatch("(a<=0)", properties);
       assertNoMatch("( a<=0)", properties);
       assertNoMatch("(a <=0)", properties);
       assertNoMatch("(a<= 0)", properties);
       assertNoMatch("(a<=0 )", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a<= )");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a<= )");
       try
       {
          assertNoMatch("(a<= )", properties);
@@ -165,16 +165,16 @@
       assertMatch("(a>=0)", properties);
       assertMatch("( a>=0)", properties);
       assertMatch("(a >=0)", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a>= 0)");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a>= 0)");
       assertMatch("(a>= 0)", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a>=0 )");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a>=0 )");
       assertMatch("(a>=0 )", properties);
       assertNoMatch("(a>=2)", properties);
       assertNoMatch("( a>=2)", properties);
       assertNoMatch("(a >=2)", properties);
       assertNoMatch("(a>= 2)", properties);
       assertNoMatch("(a>=2 )", properties);
-      System.out.println("FIXME [JBOSGI-129] - NoMatch (a>= )");
+      System.out.println(" FIXME [JBOSGI-129] - NoMatch (a>= )");
       try
       {
          assertNoMatch("(a>= )", properties);




More information about the jboss-cvs-commits mailing list