[jboss-cvs] JBossAS SVN: r70304 - in projects/microcontainer/trunk/osgi-int: src/main/org/jboss/osgi/plugins/facade and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 2 23:24:02 EST 2008


Author: johnbailey
Date: 2008-03-02 23:24:02 -0500 (Sun, 02 Mar 2008)
New Revision: 70304

Added:
   projects/microcontainer/trunk/osgi-int/src/resources/tests/bootstrap/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml
   projects/microcontainer/trunk/osgi-int/src/resources/tests/bundle/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/bundle/simple.jar
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestDelegate.java
Removed:
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestActivator.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestControllerContext.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestVFSDeploymentUnit.java
Modified:
   projects/microcontainer/trunk/osgi-int/.classpath
   projects/microcontainer/trunk/osgi-int/pom.xml
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java
Log:
Removed Mock components and created OSGiTestCase to bootstrap MC with OSGi deployers.

Modified: projects/microcontainer/trunk/osgi-int/.classpath
===================================================================
--- projects/microcontainer/trunk/osgi-int/.classpath	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/.classpath	2008-03-03 04:24:02 UTC (rev 70304)
@@ -19,7 +19,7 @@
 	<classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
 	<classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.0.0.Beta7/jboss-vfs-2.0.0.Beta7.jar"/>
 	<classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
-   <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR6/jbossxb-2.0.0.CR6.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR6/jbossxb-2.0.0.CR6.jar"/>
 	<classpathentry kind="src" path="/jboss-container"/>
 	<classpathentry kind="var" path="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA.jar" sourcepath="M2_REPO/org/jboss/javassist/3.6.0.GA/javassist-3.6.0.GA-sources.jar"/>
 	<classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.7.1/xercesImpl-2.7.1.jar"/>
@@ -42,5 +42,8 @@
 	<classpathentry kind="src" path="/jboss-kernel"/>
 	<classpathentry kind="var" path="M2_REPO/org/osgi/osgi_R4_core/1.0/osgi_R4_core-1.0.jar"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/jboss-classloading"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-impl"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/jboss-deployers-vfs"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/jboss-classloading-vfs"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: projects/microcontainer/trunk/osgi-int/pom.xml
===================================================================
--- projects/microcontainer/trunk/osgi-int/pom.xml	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/pom.xml	2008-03-03 04:24:02 UTC (rev 70304)
@@ -81,10 +81,6 @@
       <artifactId>jboss-kernel</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.jboss.microcontainer</groupId>
-      <artifactId>jboss-deployers-impl</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.jboss</groupId>
       <artifactId>jboss-vfs</artifactId>
     </dependency>
@@ -157,6 +153,16 @@
         </exclusion>
       </exclusions>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-deployers-impl</artifactId>
+       <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.microcontainer</groupId>
+      <artifactId>jboss-deployers-vfs</artifactId>
+       <scope>test</scope>
+    </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -82,8 +82,7 @@
    {
       try
       {
-         return DeploymentStage2BundleStateMapper.mapBundleState(
-               unit.getMainDeployer().getDeploymentStage(unit.getName())).getState();
+         return DeploymentStage2BundleStateMapper.mapBundleState(unit.getMainDeployer().getDeploymentStage(unit.getName())).getState();
       }
       catch (DeploymentException e)
       {
@@ -136,6 +135,15 @@
    public void uninstall() throws BundleException
    {
       checkPermission(AdminPermission.LIFECYCLE);
+      try
+      {
+         DeployerClient main = unit.getMainDeployer();
+         main.change(unit.getName(), DeploymentStages.NOT_INSTALLED);
+      }
+      catch (DeploymentException e)
+      {
+         throw new BundleException("Failed to uninstall Bundle", e);
+      }
    }
 
    public long getBundleId()
@@ -153,7 +161,7 @@
          VirtualFile file = vfsUnit.getRoot();
          return file.getPathName();
       }
-      return null;
+      return null;  // TODO What if the DeploymentUnit is not VFS
    }
 
    public ServiceReference[] getRegisteredServices()
@@ -219,18 +227,16 @@
     * 
     * @param name a class name
     * @return the class
+    * @throws ClassNotFoundException If the class can not be loaded by DeploymentUnit ClassLoader
+    * @throws IllegalStateException If the DeploymentUnit is NOT_INSTALLED
+    * @throws IllegalStateException If the DeploymentUnit classloader is not set
     */
    public Class<?> loadClass(String name) throws ClassNotFoundException
    {
       checkPermission(AdminPermission.CLASS);
-      try
-      {
-         return unit.getClassLoader().loadClass(name);
-      }
-      catch (IllegalStateException exception) // ClassLoader not set on context
-      {
-         throw new ClassNotFoundException("No classloader found for class: " + name, exception);
-      }
+      checkForUninstalledDeploymentUnit();
+      return unit.getClassLoader().loadClass(name);
+
    }
 
    /**
@@ -242,6 +248,7 @@
    public URL getResource(String name)
    {
       checkPermission(AdminPermission.RESOURCE);
+      checkForUninstalledDeploymentUnit();
       return unit.getClassLoader().getResource(name); // TODO Should it propagate the IllegalStateException or trap and return null?
    }
 
@@ -255,6 +262,7 @@
    public Enumeration getResources(String name) throws IOException
    {
       checkPermission(AdminPermission.RESOURCE);
+      checkForUninstalledDeploymentUnit();
       return unit.getClassLoader().getResources(name); // TODO Should it propagate the IllegalStateException or trap and return null?
    }
 
@@ -325,4 +333,25 @@
          System.getSecurityManager().checkPermission(new AdminPermission(this, adminPermission));
       }
    }
+
+   /**
+    * Checks to see if the DeploymentUnit has been uninstalled.  
+    *
+    * @throws IllegalStateException If there is a problem determining the DeploymentUnitState
+    */
+   private void checkForUninstalledDeploymentUnit()
+   {
+      try
+      {
+         if (DeploymentStages.NOT_INSTALLED.equals(unit.getMainDeployer().getDeploymentStage(unit.getName())))
+         {
+            throw new IllegalStateException("Bundle has been uninstalled");
+         }
+      }
+      catch (DeploymentException e)
+      {
+         throw new IllegalStateException("Failed to determine current DeploymentStage for Deployment: "
+               + unit.getName(), e);
+      }
+   }
 }

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -72,7 +72,10 @@
          }
          catch (IOException e)
          {
-            log.error("Failed to get entry paths", e);
+            if (log.isTraceEnabled())
+            {
+               log.trace("Error getting entry paths", e);
+            }
          }
       }
       return null;
@@ -93,7 +96,10 @@
       }
       catch (Exception e)
       {
-         log.error("Unable to get entry " + path + " from " + unit.getName(), e);
+         if (log.isTraceEnabled())
+         {
+            log.trace("Error getting entry", e);
+         }
       }
       return null;
    }
@@ -125,13 +131,15 @@
          }
          catch (IOException e)
          {
-            log.error("Failed to find entries for path " + path + " with filepattern " + filePattern
-                  + " DeploymentUnit" + unit.getName(), e);
+            if(log.isTraceEnabled())
+            {            
+               log.trace("Error finding entries", e);
+            }
          }
       }
       return null;
    }
-   
+
    /**
     * Get the root VirtualFile from the DeploymentUnit
     * 

Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml	2008-03-03 04:24:02 UTC (rev 70304)
@@ -0,0 +1,134 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- The MainDeployer -->
+   <bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
+      <property name="structuralDeployers"><inject bean="StructuralDeployers"/></property>
+      <property name="deployers"><inject bean="Deployers"/></property>
+      <property name="mgtDeploymentCreator"><inject bean="ManagedDeploymentCreator"/></property>
+   </bean>
+
+   <!-- The ManagedDeploymentCreator implementation -->
+   <bean name="ManagedDeploymentCreator" class="org.jboss.deployers.plugins.managed.DefaultManagedDeploymentCreator" />
+
+   <!-- The holder for deployers that determine structure -->
+   <bean name="StructuralDeployers" class="org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl">
+      <property name="structureBuilder">
+         <!-- The consolidator of the structure information -->
+         <bean name="StructureBuilder" class="org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder"/>
+      </property>
+      <!-- Accept any implementor of structure deployer -->
+      <incallback method="addDeployer"/>
+      <uncallback method="removeDeployer"/>
+   </bean>
+
+   <!-- The holder for deployers that do real deployment -->
+   <bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
+      <constructor><parameter><inject bean="jboss.kernel:service=KernelController"/></parameter></constructor>
+      <!-- Accept any implementor of deployer -->
+      <incallback method="addDeployer"/>
+      <uncallback method="removeDeployer"/>
+   </bean>
+
+   <!-- A declared structure descriptor deployer -->
+   <bean name="DeclaredStructure" class="org.jboss.deployers.vfs.plugins.structure.explicit.DeclaredStructure"></bean>
+
+    <!-- JAR Structure -->
+    <bean name="JARStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure">
+       <!-- Unless specified the default list of suffixes is .zip, .ear, .jar, ,.rar, .war, .sar, .har, .aop -->
+       <constructor>
+          <parameter>
+             <set elementClass="java.lang.String">
+                <value>.zip</value>
+                <value>.ear</value>
+                <value>.jar</value>
+                <value>.rar</value>
+                <value>.war</value>
+                <value>.sar</value>
+                <value>.har</value>
+                <value>.aop</value>
+                <value>.deployer</value>
+                <value>.beans</value>
+             </set>
+          </parameter>
+       </constructor>
+       <property name="candidateStructureVisitorFactory">
+          <!-- Any file that is not an ordinary directory is a candidate -->
+          <bean name="JARStructureCandidates" class="org.jboss.deployers.vfs.spi.structure.helpers.DefaultCandidateStructureVisitorFactory">
+             <!-- A filter to exclude some obvious non-subdeployments -->
+             <property name="filter">
+                <bean name="JARFilter" class="org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter">
+                   <constructor><parameter>
+                      <list elementClass="java.lang.String">
+                         <!-- Exclude class files as subdeployments -->
+                         <value>.class</value>
+                      </list>
+                   </parameter></constructor>
+                </bean>
+             </property>
+          </bean>
+       </property>
+    </bean>
+
+    <!-- File Structure -->
+    <bean name="FileStructure" class="org.jboss.deployers.vfs.plugins.structure.file.FileStructure">
+       <!-- Unless specified the default list of suffixes is -service.xml, -beans.xml, -ds.xml, -aop.xml -->
+       <constructor>
+          <parameter>
+             <set elementClass="java.lang.String">
+                <value>-service.xml</value>
+                <value>-beans.xml</value>
+                <value>-ds.xml</value>
+                <value>-aop.xml</value>
+             </set>
+          </parameter>
+       </constructor>
+    </bean>
+
+   <!-- POJO Deployment -->
+   <bean name="BeanDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanDeployer">
+      <property name="type">beans</property>
+   </bean>
+   <bean name="KernelDeploymentDeployer" class="org.jboss.deployers.vfs.deployer.kernel.KernelDeploymentDeployer">
+      <property name="type">beans</property>
+   </bean>
+   <bean name="BeanMetaDataDeployer" class="org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer">
+      <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
+      <property name="type">beans</property>
+   </bean>
+   
+   <!-- OSGI Deployment -->
+   <bean name="BundleActivatorDeployer" class="org.jboss.osgi.plugins.deployers.BundleActivatorDeployer">
+   	  <constructor><parameter><inject bean="jboss.kernel:service=Kernel"/></parameter></constructor>
+   </bean>
+   <bean name="OSGIMetaDataDeployer" class="org.jboss.osgi.plugins.deployers.OSGiMetaDataDeployer">
+      <constructor><parameter>org.jboss.osgi.spi.metadata.OSGiMetaData</parameter></constructor>
+   </bean>
+
+   <!-- VFS ClassLoader -->
+   <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+      <constructor factoryClass="org.jboss.classloader.spi.ClassLoaderSystem" factoryMethod="getInstance"/>
+   </bean>
+   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+      <incallback method="addModule" state="Configured"/>
+      <uncallback method="removeModule" state="Configured"/>
+   </bean>
+   <bean name="ClassLoadingMetaDataParser" class="org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer">
+      <constructor>
+         <parameter>org.jboss.classloading.spi.metadata.ClassLoadingMetaData</parameter>
+      </constructor>
+      <property name="name">jboss-classloading.xml</property>
+      <property name="buildManagedObject">true</property>
+   </bean>
+   <bean name="ClassLoadingDefaultDeployer" class="org.jboss.deployers.plugins.classloading.ClassLoadingDefaultDeployer">
+      <property name="defaultMetaData">
+         <classloading xmlns="urn:jboss:classloading:1.0" export-all="NON_EMPTY" import-all="true"/>
+      </property>
+   </bean>
+   <bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
+      <property name="classLoading"><inject bean="ClassLoading"/></property>
+   </bean>
+   <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
+      <property name="classLoading"><inject bean="ClassLoading"/></property>
+      <property name="system"><inject bean="ClassLoaderSystem"/></property>
+   </bean>
+</deployment>


Property changes on: projects/microcontainer/trunk/osgi-int/src/resources/tests/bootstrap/bootstrap.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/bundle/simple.jar
===================================================================
(Binary files differ)


Property changes on: projects/microcontainer/trunk/osgi-int/src/resources/tests/bundle/simple.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestCase.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test;
+
+import java.net.URL;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * OSGiTestCase - Parent Test Case for OSGi tests.  
+ * 
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class OSGiTestCase extends MicrocontainerTest
+{
+
+   /**
+    * Create a new OSGiTestCase.
+    * 
+    * @param name
+    */
+   public OSGiTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * Get the AbstractTestDelegate
+    * 
+    * @param clazz
+    * @return The AbstractTestDelegate
+    * @throws Exception
+    */
+   public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+   {
+      return new OSGiTestDelegate(clazz);
+   }
+
+   /**
+    * Get OSGiTestDelegate
+    */
+   protected OSGiTestDelegate getDelegate()
+   {
+      return (OSGiTestDelegate) super.getDelegate();
+   }
+
+   /**
+    * Get DeployerClient from Delegate
+    * 
+    * @return The DeployerClient
+    */
+   protected DeployerClient getDeployerClient()
+   {
+      return getDelegate().getMainDeployer();
+   }
+
+   /**
+    * Assert the given DeploymentUnit is in the specified DeployemntStage
+    * 
+    * @param unit A DeploymentUnit
+    * @param stage A DeploymentStage
+    * @throws DeploymentException If the DeployerClient is unable to determine the current stage
+    */
+   protected void assertStage(DeploymentUnit unit, DeploymentStage stage) throws DeploymentException
+   {
+      assertEquals(stage, getDeployerClient().getDeploymentStage(unit.getName()));
+   }
+
+   /**
+    * Create a VFSDeployment
+    * 
+    * @param root the root location of the deployment
+    * @param child the child to deploy
+    * @return VFSDeployment
+    * @throws Exception
+    */
+   protected VFSDeployment createVFSDeployment(String root, String child) throws Exception
+   {
+      URL resourceRoot = getClass().getResource(root);
+      if (resourceRoot == null)
+         fail("Resource not found: " + root);
+      VirtualFile deployment = VFS.getVirtualFile(resourceRoot, child);
+      if (deployment == null)
+         fail("Child not found " + child + " from " + resourceRoot);
+      return createVFSDeployment(deployment);
+   }
+
+   /**
+    * Create a VFSDeployment
+    * 
+    * @param root the VirtualFile to deploy
+    * @return VFSDeployment
+    * @throws Exception
+    */
+   protected VFSDeployment createVFSDeployment(VirtualFile root) throws Exception
+   {
+      VFSDeploymentFactory factory = VFSDeploymentFactory.getInstance();
+      return factory.createVFSDeployment(root);
+   }
+
+   /**
+    * Create a VFSDeployment and add the Deployment to the DeployerClient, and return the DeploymentUnit 
+    * 
+    * @param root the location of the VirtualFile to deploy
+    * @param child the child to deploy
+    * @return VFSDeploymentUnit for the deployment
+    * @throws Exception
+    */
+   protected VFSDeploymentUnit addDeployment(String root, String child) throws Exception
+   {
+      VFSDeployment deployment = createVFSDeployment(root, child);
+      getDeployerClient().addDeployment(deployment);
+      getDeployerClient().process();
+      return (VFSDeploymentUnit) getMainDeployerStructure().getDeploymentUnit(deployment.getName(), true);
+   }
+
+   /**
+    * Get MainDeployerStructure from Delegate
+    * 
+    * @return MainDeployerStructure
+    */
+   protected MainDeployerStructure getMainDeployerStructure()
+   {
+      return getDelegate().getMainDeployer();
+   }
+}


Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestCase.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestDelegate.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestDelegate.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test;
+
+import java.net.URL;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData10;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.plugins.main.MainDeployerImpl;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * A OSGiTestDelegate
+ * 
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class OSGiTestDelegate extends MicrocontainerTestDelegate
+{
+   private MainDeployerImpl mainDeployer;
+
+   static
+   {
+      DefaultSchemaResolver resolver = (DefaultSchemaResolver) SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+      resolver.addClassBinding("urn:jboss:classloader:1.0", VFSClassLoaderFactory10.class);
+      resolver.addClassBinding("urn:jboss:classloading:1.0", ClassLoadingMetaData10.class);
+   }
+
+   /**
+    * Create a new OSGiTestDelegate.
+    * 
+    * @param clazz
+    * @throws Exception
+    */
+   public OSGiTestDelegate(Class<?> clazz) throws Exception
+   {
+      super(clazz);
+   }
+   
+   /**
+    * Deploys the bootstrap.xml bean descriptor to setup OSGi deployers
+    */
+   protected void deploy() throws Exception
+   {
+      String common = "/bootstrap/bootstrap.xml";
+      URL url = getClass().getResource(common);
+      if (url == null)
+         throw new IllegalStateException(common + " not found");
+      deploy(url);
+
+      super.deploy();
+   }
+   
+   /**
+    * Get the MainDeployer bean from the MC
+    * 
+    * @return MainDeployerImpl
+    */
+   protected MainDeployerImpl getMainDeployer()
+   {
+      if (mainDeployer == null)
+         mainDeployer = getBean("MainDeployer", ControllerState.INSTALLED, MainDeployerImpl.class);
+      return mainDeployer;
+   }
+}


Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/OSGiTestDelegate.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -26,18 +26,10 @@
 
 import junit.framework.Test;
 
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.deployer.DeploymentStage;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.structure.spi.DeploymentContext;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentContext;
-import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
 import org.jboss.osgi.plugins.facade.BundleImpl;
-import org.jboss.test.BaseTestCase;
-import org.jboss.test.bundle.support.TestControllerContext;
-import org.jboss.test.bundle.support.TestMainDeployer;
+import org.jboss.test.OSGiTestCase;
 import org.osgi.framework.Bundle;
 
 /**
@@ -46,18 +38,12 @@
  * @author <a href="baileyje at gmail.com">John Bailey</a>
  * @version $Revision: 1.1 $
  */
-public class BundleImplTestCase extends BaseTestCase
+public class BundleImplTestCase extends OSGiTestCase
 {
    private Bundle bundle;
    
-   private DeploymentContext deploymentContext;
-
    private DeploymentUnit deploymentUnit;
 
-   private ControllerContext controllerContext;
-
-   private TestMainDeployer mainDeployer;
-
    /**
     * 
     * Create a new BundleImplTestCase.
@@ -87,13 +73,7 @@
    {
       super.setUp();
 
-      deploymentContext = new AbstractDeploymentContext("UniqueName", "/simple.jar");
-      deploymentContext.setClassLoader(BundleImplTestCase.class.getClassLoader());
-      deploymentUnit = new AbstractDeploymentUnit(deploymentContext);
-      controllerContext = new TestControllerContext(deploymentContext);
-      deploymentUnit.addAttachment(ControllerContext.class.getName(), controllerContext);
-      mainDeployer = new TestMainDeployer();
-      deploymentUnit.addAttachment(MainDeployer.class.getName(), mainDeployer);
+      deploymentUnit = addDeployment("/bundle", "simple.jar");
       bundle = new BundleImpl(deploymentUnit);
    }
 
@@ -104,16 +84,16 @@
     */
    public void testGetBundleState() throws Exception
    {
-      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
       assertEquals(Bundle.UNINSTALLED, bundle.getState());
 
-      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.CLASSLOADER);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.CLASSLOADER);
       assertEquals(Bundle.RESOLVED, bundle.getState());
 
-      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.REAL);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.REAL);
       assertEquals(Bundle.STARTING, bundle.getState());
 
-      mainDeployer.change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
       assertEquals(Bundle.ACTIVE, bundle.getState());
    }
 
@@ -124,7 +104,7 @@
     */
    public void testGetSymbolicName() throws Exception
    {
-      assertEquals("UniqueName", bundle.getSymbolicName());
+      assertEquals(deploymentUnit.getName(), bundle.getSymbolicName());
    }
 
    /**
@@ -134,7 +114,7 @@
     */
    public void testGetBundleId() throws Exception
    {
-      assertEquals("UniqueName".hashCode(), bundle.getBundleId());
+      assertEquals(deploymentUnit.getName().hashCode(), bundle.getBundleId());
    }
 
    /**
@@ -144,8 +124,10 @@
     */
    public void testStartBundle() throws Exception
    {
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+      assertStage(deploymentUnit, DeploymentStages.NOT_INSTALLED); // Sanity Check...
       bundle.start();
-      assertChangeRequested(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+      assertStage(deploymentUnit, DeploymentStages.INSTALLED);
    }
 
    /**
@@ -155,9 +137,24 @@
     */
    public void testStopBundle() throws Exception
    {
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+      assertStage(deploymentUnit, DeploymentStages.INSTALLED); // Sanity Check...
       bundle.stop();
-      assertChangeRequested(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
+      assertStage(deploymentUnit, DeploymentStages.DESCRIBE);
    }
+   
+   /**
+    * Verifies the Bundle.uninstall method calls the MainDeployer.change method with the NOT_INSTALLED DeploymentStage
+    * 
+    * @throws Exception
+    */
+   public void testUninstallBundle() throws Exception
+   {
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.INSTALLED);
+      assertStage(deploymentUnit, DeploymentStages.INSTALLED); // Sanity Check...
+      bundle.uninstall();
+      assertStage(deploymentUnit, DeploymentStages.NOT_INSTALLED);
+   }
 
    /**
     * Test the Bundle.loadClass method with valid class
@@ -193,21 +190,40 @@
     * 
     * @throws Exception
     */
-   public void testLoadClassNoClassLoader() throws Exception
+   public void testLoadClassNoClassLoaderForDeployment() throws Exception
    {
-      deploymentContext.setClassLoader(null);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
       try
       {
          bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
          fail("Should have thrown ClassNotFoundException");
       }
-      catch (ClassNotFoundException expectedException)
+      catch (IllegalStateException expectedException)
       {
-         assertEquals("No classloader found for class: org.jboss.test.bundle.support.MissingClass", expectedException.getMessage());
+         assertEquals("ClassLoader has not been set", expectedException.getMessage());
       }
    }
    
    /**
+    * Test Bundle.loadClass with a DeploymentUnit that is in the NOT_INSTALLED stage, should throw IllegalStateException.
+    * 
+    * @throws Exception
+    */
+   public void testLoadClassBundleUninstalled() throws Exception
+   {
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+      try
+      {
+         bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
+         fail("Should have thrown ClassNotFoundException");
+      }
+      catch (IllegalStateException expectedException)
+      {
+         assertEquals("Bundle has been uninstalled", expectedException.getMessage());
+      }
+   }
+   
+   /**
     * Test the Bundle.getResource method with valid resource
     * 
     * @throws Exception
@@ -234,9 +250,9 @@
     * 
     * @throws Exception
     */
-   public void testGetResourceMissingClassLoader() throws Exception
+   public void testGetResourceNoClassLoaderForDeploymentUnit() throws Exception
    {
-      deploymentContext.setClassLoader(null);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
       try {
          bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
          fail("Should have thrown IllegalStateException");
@@ -244,6 +260,22 @@
          assertEquals("ClassLoader has not been set", expectedException.getMessage());
       }
    }
+   
+   /**
+    * Test the Bundle.getResource method for an uninstalled Bundle
+    * 
+    * @throws Exception
+    */
+   public void testGetResourceBundleUnintalled() throws Exception
+   {
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+      try {
+         bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
+         fail("Should have thrown IllegalStateException");
+      } catch (IllegalStateException expectedException) {
+         assertEquals("Bundle has been uninstalled", expectedException.getMessage());
+      }
+   }
 
    /**
     * Test the Bundle.getResources method with valid resource
@@ -276,9 +308,9 @@
     * 
     * @throws Exception
     */
-   public void testGetResourcesMissingClassLoader() throws Exception
+   public void testGetResourcesNoClassLoaderForDeploymentUnit() throws Exception
    {
-      deploymentContext.setClassLoader(null);
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
       try {
          bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
          fail("Should have thrown IllegalStateException");
@@ -287,16 +319,19 @@
       }
    }
    
-   
    /**
-    * Assert the correct change was requested of the MainDeployer
+    * Test the Bundle.getResources method with missing DeploymentUnit ClassLoader
     * 
-    * @param deploymentName
-    * @param stage
+    * @throws Exception
     */
-   public void assertChangeRequested(String deploymentName, DeploymentStage stage)
+   public void testGetResourcesUninstalled() throws Exception
    {
-      assertTrue(mainDeployer.changeCalled(deploymentName, stage));
+      getDeployerClient().change(deploymentUnit.getName(), DeploymentStages.NOT_INSTALLED);
+      try {
+         bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
+         fail("Should have thrown IllegalStateException");
+      } catch (IllegalStateException expectedException) {
+         assertEquals("Bundle has been uninstalled", expectedException.getMessage());
+      }
    }
-
 }

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -29,8 +29,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.jboss.test.BaseTestCase;
-import org.jboss.virtual.VFS;
+import org.jboss.test.OSGiTestCase;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -39,7 +38,7 @@
  * @author <a href="baileyje at gmail.com">John Bailey</a>
  * @version $Revision: 1.1 $
  */
-public abstract class AbstractBundleEntryTestCase extends BaseTestCase
+public abstract class AbstractBundleEntryTestCase extends OSGiTestCase
 {
 
    /**
@@ -58,20 +57,6 @@
    }
 
    /**
-    * Get virtual file instance
-    * 
-    * @param root
-    * @param path
-    * @return Virtual file instance
-    * @throws Exception
-    */
-   protected VirtualFile getVirtualFile(String root, String path) throws Exception
-   {
-      URL url = getResource(root);
-      return VFS.getVirtualFile(url, path);
-   }
-
-   /**
     * Assert a returned entry is the expected virtual file based on the root VirtualFile and path
     * 
     * @param root Root VirtualFile to get path

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -21,15 +21,14 @@
 */
 package org.jboss.test.bundle.helper;
 
-import java.io.FileNotFoundException;
 import java.net.URL;
 import java.util.Enumeration;
 
 import junit.framework.Test;
 
 import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.osgi.plugins.facade.helpers.BundleEntryHelper;
-import org.jboss.test.bundle.support.TestVFSDeploymentUnit;
 import org.jboss.virtual.VirtualFile;
 
 /**
@@ -70,8 +69,8 @@
    protected void setUp() throws Exception
    {
       super.setUp();
-      root = getVirtualFile("/org/jboss/test/bundle/helper", "simple.jar");
-      deploymentUnit = new TestVFSDeploymentUnit(root);
+      deploymentUnit = addDeployment("/bundle", "simple.jar");
+      root = VFSDeploymentUnit.class.cast(deploymentUnit).getRoot();
    }
 
    /**
@@ -81,9 +80,9 @@
     */
    public void testGetEntry() throws Exception
    {
-      URL entry = BundleEntryHelper.getEntry(deploymentUnit, "META-INF/manifest.mf");
+      URL entry = BundleEntryHelper.getEntry(deploymentUnit, "META-INF/Manifest.mf");
       assertNotNull(entry);
-      assertEntry(root, "META-INF/manifest.mf", entry);
+      assertEntry(root, "META-INF/Manifest.mf", entry);
    }
 
    /**
@@ -110,8 +109,9 @@
       assertTrue(entries.hasMoreElements());
       assertEquals("simple.jar/META-INF/jboss-service.xml", entries.nextElement());
       assertTrue(entries.hasMoreElements());
-      assertEquals("simple.jar/META-INF/manifest.mf", entries.nextElement());
+      assertEquals("simple.jar/META-INF/Manifest.mf", entries.nextElement());
       assertFalse(entries.hasMoreElements());
+      
    }
 
    /**
@@ -122,15 +122,8 @@
    @SuppressWarnings("unchecked")
    public void testGetEntryPathsNoResult() throws Exception
    {
-      try
-      {
-         BundleEntryHelper.getEntryPaths(deploymentUnit, "org/jboss/osgi/empty");
-         fail("Should have throw FileNotFoundException");
-      }
-      catch (RuntimeException expectedException)
-      {
-         assertTrue(expectedException.getCause() instanceof FileNotFoundException);
-      }
+         // TODO MAKE WORK WITH MAVEN
+         assertNull(BundleEntryHelper.getEntryPaths(deploymentUnit, "org/jboss/osgi/empty"));
    }
 
    /**
@@ -140,15 +133,7 @@
     */
    public void testGetEntryPathsMissingDirPath() throws Exception
    {
-      try
-      {
-         BundleEntryHelper.getEntryPaths(deploymentUnit, "mising/path");
-         fail("Should have throw FileNotFoundException");
-      }
-      catch (RuntimeException expectedException)
-      {
-         assertTrue(expectedException.getCause() instanceof FileNotFoundException);
-      }
+         assertNull(BundleEntryHelper.getEntryPaths(deploymentUnit, "mising/path"));
    }
 
    /**
@@ -159,9 +144,9 @@
    @SuppressWarnings("unchecked")
    public void testFindEntriesNoWildCard() throws Exception
    {
-      Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "manifest.mf", true);
+      Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "Manifest.mf", true);
       assertTrue(entries.hasMoreElements());
-      assertEntry(root, "/META-INF/manifest.mf", entries.nextElement());
+      assertEntry(root, "/META-INF/Manifest.mf", entries.nextElement());
 
       entries = BundleEntryHelper.findEntries(deploymentUnit, "/org", "custom.properties", true);
       assertTrue(entries.hasMoreElements());
@@ -189,7 +174,7 @@
    @SuppressWarnings("unchecked")
    public void testFindEntriesNoWildCardOrRecurse() throws Exception
    {
-      Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "manifest.mf", false);
+      Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "Manifest.mf", false);
       assertNull(entries);
 
       entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "fromroot.xml", false);
@@ -208,7 +193,7 @@
       // starts with wildcard
       Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "*.mf", true);
       assertTrue(entries.hasMoreElements());
-      assertEntry(root, "/META-INF/manifest.mf", entries.nextElement());
+      assertEntry(root, "/META-INF/Manifest.mf", entries.nextElement());
 
       entries = BundleEntryHelper.findEntries(deploymentUnit, "/org/jboss", "*.properties", true);
       assertTrue(entries.hasMoreElements());
@@ -217,10 +202,10 @@
       // starts with wildcard and matches multiple
       entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "*.xml", true);
       assertTrue(entries.hasMoreElements());
-      assertEntry(root, "/fromroot.xml", entries.nextElement());
-      assertTrue(entries.hasMoreElements());
       assertEntry(root, "/META-INF/jboss-service.xml", entries.nextElement());
       assertTrue(entries.hasMoreElements());
+      assertEntry(root, "/fromroot.xml", entries.nextElement());
+      assertTrue(entries.hasMoreElements());
       assertEntry(root, "/org/jboss/osgi/custom.xml", entries.nextElement());
       assertTrue(entries.hasMoreElements());
       assertEntry(root, "/org/jboss/osgi/test/custom.xml", entries.nextElement());

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -23,6 +23,8 @@
 
 import junit.framework.Test;
 
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.osgi.plugins.facade.helpers.BundleEntryVisitor;
 import org.jboss.virtual.VirtualFile;
 
@@ -63,7 +65,8 @@
    protected void setUp() throws Exception
    {
       super.setUp();
-      root = getVirtualFile("/org/jboss/test/bundle/helper", "simple.jar");
+      DeploymentUnit deploymentUnit = addDeployment("/bundle", "simple.jar");
+      root = VFSDeploymentUnit.class.cast(deploymentUnit).getRoot();
    }
 
    /**
@@ -74,11 +77,11 @@
    public void testFindEntriesNoWildCard() throws Exception
    {
 
-      BundleEntryVisitor visitor = new BundleEntryVisitor("manifest.mf", true);
+      BundleEntryVisitor visitor = new BundleEntryVisitor("Manifest.mf", true);
       root.visit(visitor);
       assertEquals(1, visitor.getEntries().size());
 
-      assertEntry(root, "/META-INF/manifest.mf", visitor.getEntries().get(0));
+      assertEntry(root, "/META-INF/Manifest.mf", visitor.getEntries().get(0));
 
       visitor = new BundleEntryVisitor("custom.properties", true);
       root.visit(visitor);
@@ -112,7 +115,7 @@
    public void testFindEntriesNoWildCardOrRecurse() throws Exception
    {
 
-      BundleEntryVisitor visitor = new BundleEntryVisitor("manifest.mf", false);
+      BundleEntryVisitor visitor = new BundleEntryVisitor("Manifest.mf", false);
       root.visit(visitor);
       assertEquals(0, visitor.getEntries().size());
 
@@ -138,7 +141,7 @@
       BundleEntryVisitor visitor = new BundleEntryVisitor("*.mf", true);
       root.visit(visitor);
       assertEquals(1, visitor.getEntries().size());
-      assertEntry(root, "/META-INF/manifest.mf", visitor.getEntries().get(0));
+      assertEntry(root, "/META-INF/Manifest.mf", visitor.getEntries().get(0));
 
       visitor = new BundleEntryVisitor("*.properties", true);
       root.visit(visitor);
@@ -149,8 +152,8 @@
       visitor = new BundleEntryVisitor("*.xml", true);
       root.visit(visitor);
       assertEquals(4, visitor.getEntries().size());
-      assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
-      assertEntry(root, "/META-INF/jboss-service.xml", visitor.getEntries().get(1));
+      assertEntry(root, "/META-INF/jboss-service.xml", visitor.getEntries().get(0));
+      assertEntry(root, "/fromroot.xml", visitor.getEntries().get(1));
       assertEntry(root, "/org/jboss/osgi/custom.xml", visitor.getEntries().get(2));
       assertEntry(root, "/org/jboss/osgi/test/custom.xml", visitor.getEntries().get(3));
 
@@ -166,8 +169,8 @@
       visitor = new BundleEntryVisitor("*xml*", true);
       root.visit(visitor);
       assertEquals(5, visitor.getEntries().size());
-      assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
-      assertEntry(root, "/META-INF/jboss-service.xml", visitor.getEntries().get(1));
+      assertEntry(root, "/META-INF/jboss-service.xml", visitor.getEntries().get(0));
+      assertEntry(root, "/fromroot.xml", visitor.getEntries().get(1));
       assertEntry(root, "/org/jboss/osgi/custom.xml", visitor.getEntries().get(2));
       assertEntry(root, "/org/jboss/osgi/notanxmlfile.txt", visitor.getEntries().get(3));
       assertEntry(root, "/org/jboss/osgi/test/custom.xml", visitor.getEntries().get(4));

Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestActivator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestActivator.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestActivator.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -1,35 +0,0 @@
-package org.jboss.test.bundle.support;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * 
- * A TestActivator.
- * 
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @version $Revision: 1.1 $
- */
-public class TestActivator implements BundleActivator
-{
-
-   /**
-    * Start Bundle
-    * 
-    * @param context BundleContext
-    */
-   public void start(BundleContext context) throws Exception
-   {
-      System.out.println("STARTING - " + context);
-   }
-
-   /**
-    * Start Bundle
-    * 
-    * @param context BundleContext
-    */
-   public void stop(BundleContext context) throws Exception
-   {
-      System.out.println("STOPPING");
-   }
-}

Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestControllerContext.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestControllerContext.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestControllerContext.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -1,126 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- * 
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.bundle.support;
-
-import java.util.Set;
-
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerMode;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.ScopeInfo;
-import org.jboss.deployers.structure.spi.DeploymentContext;
-import org.jboss.util.JBossStringBuilder;
-
-public class TestControllerContext implements ControllerContext
-{
-   private ControllerState state;
-
-   private DeploymentContext context;
-
-   public TestControllerContext(DeploymentContext context)
-   {
-      this.context = context;
-   }
-
-   public String toShortString()
-   {
-      return null;
-   }
-
-   public void toShortString(JBossStringBuilder arg0)
-   {
-
-   }
-
-   @Override
-   public Object clone()
-   {
-      return null;
-   }
-
-   public Set<Object> getAliases()
-   {
-      return null;
-   }
-
-   public Controller getController()
-   {
-      return null;
-   }
-
-   public DependencyInfo getDependencyInfo()
-   {
-      return null;
-   }
-
-   public Throwable getError()
-   {
-      return null;
-   }
-
-   public ControllerMode getMode()
-   {
-      return null;
-   }
-
-   public Object getName()
-   {
-      return context.getName();
-   }
-
-   public ControllerState getRequiredState()
-   {
-      return null;
-   }
-
-   public ScopeInfo getScopeInfo()
-   {
-      return null;
-   }
-
-   public ControllerState getState()
-   {
-      return state;
-   }
-
-   public Object getTarget()
-   {
-      return null;
-   }
-
-   public void install(ControllerState fromState, ControllerState toState) throws Throwable
-   {
-   }
-
-   public void setController(Controller controller)
-   {
-   }
-
-   public void setError(Throwable error)
-   {
-   }
-
-   public void setMode(ControllerMode mode)
-   {
-   }
-
-   public void setRequiredState(ControllerState state)
-   {
-   }
-
-   public void setState(ControllerState state)
-   {
-      this.state = state;
-   }
-
-   public void uninstall(ControllerState fromState, ControllerState toState)
-   {
-   }
-
-}
\ No newline at end of file

Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestMainDeployer.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -1,176 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.bundle.support;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.DeploymentState;
-import org.jboss.deployers.spi.deployer.DeploymentStage;
-import org.jboss.managed.api.ManagedDeployment;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.util.graph.Graph;
-
-/**
- * TestMainDeployer.
- * 
- * @author johnbailey
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class TestMainDeployer implements MainDeployer
-{
-   private DeploymentStage currentStage;
-   private Map<String, DeploymentStage> changesRequested = new HashMap<String, DeploymentStage>();
-
-   /** Create a new TestMainDeployer.
-    */
-   public TestMainDeployer() 
-   {
-      
-   }
-
-   public void shutdown()
-   {
-
-   }
-
-   public void addDeployment(Deployment deployment) throws DeploymentException
-   {
-
-   }
-
-   /** 
-    * Add requested stage to map, and hold on as the current stage 
-    */
-   public void change(String deploymentName, DeploymentStage stage) throws DeploymentException
-   {
-      currentStage = stage;
-      changesRequested.put(deploymentName, stage);
-   }
-
-   public DeploymentStage getDeploymentStage(String deploymentName) throws DeploymentException
-   {
-      return currentStage;
-   }
-
-   public void checkComplete() throws DeploymentException
-   {
-
-   }
-
-   public void checkComplete(Deployment... deployment) throws DeploymentException
-   {
-
-   }
-
-   public void checkComplete(String... names) throws DeploymentException
-   {
-
-   }
-
-   public void checkStructureComplete(Deployment... deployments) throws DeploymentException
-   {
-
-   }
-
-   public void checkStructureComplete(String... names) throws DeploymentException
-   {
-
-   }
-
-   public void deploy(Deployment... deployments) throws DeploymentException
-   {
-
-   }
-
-   public Graph<Map<String, ManagedObject>> getDeepManagedObjects(String name) throws DeploymentException
-   {
-      return null;
-   }
-
-   public Deployment getDeployment(String name)
-   {
-      return null;
-   }
-
-   public DeploymentState getDeploymentState(String name)
-   {
-      return null;
-   }
-
-   public ManagedDeployment getManagedDeployment(String name) throws DeploymentException
-   {
-      return null;
-   }
-
-   public Map<String, ManagedObject> getManagedObjects(String name) throws DeploymentException
-   {
-      return null;
-   }
-
-   public Collection<Deployment> getTopLevel()
-   {
-      return null;
-   }
-
-   public void process()
-   {
-
-   }
-
-   public boolean removeDeployment(Deployment deployment) throws DeploymentException
-   {
-      return false;
-   }
-
-   public boolean removeDeployment(String name) throws DeploymentException
-   {
-      return false;
-   }
-
-   public void undeploy(Deployment... deployments) throws DeploymentException
-   {
-
-   }
-
-   public void undeploy(String... names) throws DeploymentException
-   {
-   }
-
-   public boolean changeCalled(String deploymentName, DeploymentStage stage)
-   {
-      DeploymentStage requestedChange = changesRequested.get(deploymentName);
-      if (requestedChange != null)
-      {
-         return requestedChange.equals(stage);
-      }
-      return false;
-   }
-   
-   
-
-}
\ No newline at end of file

Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestVFSDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestVFSDeploymentUnit.java	2008-03-03 02:25:46 UTC (rev 70303)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestVFSDeploymentUnit.java	2008-03-03 04:24:02 UTC (rev 70304)
@@ -1,424 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.bundle.support;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.deployers.structure.spi.ClassLoaderFactory;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.DeploymentUnitVisitor;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentResourceLoader;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.MutableMetaData;
-import org.jboss.metadata.spi.scope.ScopeKey;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * A TestVFSDeploymentUnit.
- * 
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @version $Revision: 1.1 $
- */
-public class TestVFSDeploymentUnit implements VFSDeploymentUnit
-{
-   private static final long serialVersionUID = 1L;
-
-   private final VirtualFile root;
-
-   public TestVFSDeploymentUnit(VirtualFile root)
-   {
-      this.root = root;
-   }
-
-   public void addClassPath(List<VirtualFile> files)
-   {
-      // FIXME addClassPath
-
-   }
-
-   public void addClassPath(VirtualFile... files)
-   {
-      // FIXME addClassPath
-
-   }
-
-   public List<VirtualFile> getClassPath()
-   {
-      // FIXME getClassPath
-      return null;
-   }
-
-   public VirtualFile getFile(String path)
-   {
-      try
-      {
-         return root.getChild(path);
-      }
-      catch (IOException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public VirtualFile getMetaDataFile(String name)
-   {
-      return null;
-   }
-
-   public List<VirtualFile> getMetaDataFiles(String name, String suffix)
-   {
-      // FIXME getMetaDataFiles
-      return null;
-   }
-
-   public VFSDeploymentUnit getParent()
-   {
-      // FIXME getParent
-      return null;
-   }
-
-   public VFSDeploymentResourceLoader getResourceLoader()
-   {
-      // FIXME getResourceLoader
-      return null;
-   }
-
-   public VirtualFile getRoot()
-   {
-      return root;
-   }
-
-   public VFSDeploymentUnit getTopLevel()
-   {
-      // FIXME getTopLevel
-      return null;
-   }
-
-   public List<VFSDeploymentUnit> getVFSChildren()
-   {
-      // FIXME getVFSChildren
-      return null;
-   }
-
-   public void setClassPath(List<VirtualFile> classPath)
-   {
-      // FIXME setClassPath
-
-   }
-
-   public DeploymentUnit addComponent(String name)
-   {
-      // FIXME addComponent
-      return null;
-   }
-
-   public void addControllerContextName(Object name)
-   {
-      // FIXME addControllerContextName
-
-   }
-
-   public void addIDependOn(DependencyItem dependency)
-   {
-      // FIXME addIDependOn
-
-   }
-
-   public boolean createClassLoader(ClassLoaderFactory factory) throws DeploymentException
-   {
-      // FIXME createClassLoader
-      return false;
-   }
-
-   public <T> Set<? extends T> getAllMetaData(Class<T> type)
-   {
-      // FIXME getAllMetaData
-      return null;
-   }
-
-   public List<DeploymentUnit> getChildren()
-   {
-      // FIXME getChildren
-      return null;
-   }
-
-   public ClassLoader getClassLoader()
-   {
-      // FIXME getClassLoader
-      return null;
-   }
-
-   public List<DeploymentUnit> getComponents()
-   {
-      // FIXME getComponents
-      return null;
-   }
-
-   public Set<Object> getControllerContextNames()
-   {
-      // FIXME getControllerContextNames
-      return null;
-   }
-
-   public DependencyInfo getDependencyInfo()
-   {
-      // FIXME getDependencyInfo
-      return null;
-   }
-
-   public MainDeployer getMainDeployer()
-   {
-      // FIXME getMainDeployer
-      return null;
-   }
-
-   public MetaData getMetaData()
-   {
-      // FIXME getMetaData
-      return null;
-   }
-
-   public MutableMetaData getMutableMetaData()
-   {
-      // FIXME getMutableMetaData
-      return null;
-   }
-
-   public ScopeKey getMutableScope()
-   {
-      // FIXME getMutableScope
-      return null;
-   }
-
-   public String getName()
-   {
-      // FIXME getName
-      return null;
-   }
-
-   public String getRelativePath()
-   {
-      // FIXME getRelativePath
-      return null;
-   }
-
-   public ClassLoader getResourceClassLoader()
-   {
-      // FIXME getResourceClassLoader
-      return null;
-   }
-
-   public ScopeKey getScope()
-   {
-      // FIXME getScope
-      return null;
-   }
-
-   public String getSimpleName()
-   {
-      // FIXME getSimpleName
-      return null;
-   }
-
-   public MutableAttachments getTransientManagedObjects()
-   {
-      // FIXME getTransientManagedObjects
-      return null;
-   }
-
-   public Set<String> getTypes()
-   {
-      // FIXME getTypes
-      return null;
-   }
-
-   public boolean isComponent()
-   {
-      // FIXME isComponent
-      return false;
-   }
-
-   public boolean isTopLevel()
-   {
-      // FIXME isTopLevel
-      return false;
-   }
-
-   public void removeClassLoader(ClassLoaderFactory factory)
-   {
-      // FIXME removeClassLoader
-
-   }
-
-   public boolean removeComponent(String name)
-   {
-      // FIXME removeComponent
-      return false;
-   }
-
-   public void removeControllerContextName(Object name)
-   {
-      // FIXME removeControllerContextName
-
-   }
-
-   public void removeIDependOn(DependencyItem dependency)
-   {
-      // FIXME removeIDependOn
-
-   }
-
-   public void setMutableScope(ScopeKey key)
-   {
-      // FIXME setMutableScope
-
-   }
-
-   public void setScope(ScopeKey key)
-   {
-      // FIXME setScope
-
-   }
-
-   public void visit(DeploymentUnitVisitor visitor) throws DeploymentException
-   {
-      // FIXME visit
-
-   }
-
-   public <T> T addAttachment(Class<T> type, T attachment)
-   {
-      // FIXME addAttachment
-      return null;
-   }
-
-   public Object addAttachment(String name, Object attachment)
-   {
-      // FIXME addAttachment
-      return null;
-   }
-
-   public <T> T addAttachment(String name, T attachment, Class<T> expectedType)
-   {
-      // FIXME addAttachment
-      return null;
-   }
-
-   public void clear()
-   {
-      // FIXME clear
-
-   }
-
-   public void clearChangeCount()
-   {
-      // FIXME clearChangeCount
-
-   }
-
-   public int getChangeCount()
-   {
-      // FIXME getChangeCount
-      return 0;
-   }
-
-   public <T> T removeAttachment(Class<T> type)
-   {
-      // FIXME removeAttachment
-      return null;
-   }
-
-   public <T> T removeAttachment(String name, Class<T> expectedType)
-   {
-      // FIXME removeAttachment
-      return null;
-   }
-
-   public Object removeAttachment(String name)
-   {
-      // FIXME removeAttachment
-      return null;
-   }
-
-   public void setAttachments(Map<String, Object> map)
-   {
-      // FIXME setAttachments
-
-   }
-
-   public <T> T getAttachment(Class<T> type)
-   {
-      // FIXME getAttachment
-      return null;
-   }
-
-   public <T> T getAttachment(String name, Class<T> expectedType)
-   {
-      // FIXME getAttachment
-      return null;
-   }
-
-   public Object getAttachment(String name)
-   {
-      // FIXME getAttachment
-      return null;
-   }
-
-   public Map<String, Object> getAttachments()
-   {
-      // FIXME getAttachments
-      return null;
-   }
-
-   public boolean hasAttachments()
-   {
-      // FIXME hasAttachments
-      return false;
-   }
-
-   public boolean isAttachmentPresent(Class<?> type)
-   {
-      return false;
-   }
-
-   public boolean isAttachmentPresent(String name, Class<?> expectedType)
-   {
-      // FIXME isAttachmentPresent
-      return false;
-   }
-
-   public boolean isAttachmentPresent(String name)
-   {
-      // FIXME isAttachmentPresent
-      return false;
-   }
-
-}




More information about the jboss-cvs-commits mailing list