[jboss-cvs] JBossAS SVN: r70252 - in projects/microcontainer/trunk/osgi-int/src: main/org/jboss/osgi/plugins/facade/helpers and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 29 02:35:20 EST 2008
Author: johnbailey
Date: 2008-02-29 02:35:20 -0500 (Fri, 29 Feb 2008)
New Revision: 70252
Added:
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/BundleEntryVisitor.java
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/META-INF/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/META-INF/jboss-service.xml
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/META-INF/manifest.mf
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/fromroot.xml
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/custom.xml
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/empty/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/notanxmlfile.txt
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/test/
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/test/custom.properties
projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/test/custom.xml
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/
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
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHeaderTestCase.java
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHelperTestSuite.java
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/TestVFSDeploymentUnit.java
Removed:
projects/microcontainer/trunk/osgi-int/src/resources/tests/OSGI-INF/
projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java
Modified:
projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.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/BundleTestSuite.java
Log:
Added support for finding entries within a Bundle
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-02-29 07:08:34 UTC (rev 70251)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/BundleImpl.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -30,14 +30,16 @@
import java.util.Locale;
import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.DeployerClient;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
+import org.jboss.osgi.plugins.facade.helpers.BundleEntryHelper;
import org.jboss.osgi.plugins.facade.helpers.BundleHeaders;
import org.jboss.osgi.plugins.facade.helpers.DeploymentStage2BundleStateMapper;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -51,7 +53,6 @@
*/
public class BundleImpl implements Bundle
{
-
/** The log */
private static final Logger log = Logger.getLogger(BundleImpl.class);
@@ -59,13 +60,12 @@
protected BundleHeaders bundleHeaders;
- private long lastModified = -1;
+ private long lastModified = System.currentTimeMillis();
/**
- *
* Create a new BundleImpl.
*
- * @param unit
+ * @param unit the DeploymentUnit
*/
public BundleImpl(DeploymentUnit unit)
{
@@ -75,6 +75,8 @@
/**
* Get Bundle state based on the current DeployentStage
+ *
+ * @return the Bundle's state
*/
public int getState()
{
@@ -91,12 +93,11 @@
}
/**
- * Deligate to the MainDeployer to start the Bundle
+ * Start the Bundle
*/
public void start() throws BundleException
{
checkPermission(AdminPermission.EXECUTE);
-
try
{
DeployerClient main = unit.getMainDeployer();
@@ -111,6 +112,15 @@
public void stop() throws BundleException
{
checkPermission(AdminPermission.EXECUTE);
+ try
+ {
+ DeployerClient main = unit.getMainDeployer();
+ main.change(unit.getName(), DeploymentStages.DESCRIBE);
+ }
+ catch (DeploymentException e)
+ {
+ throw new BundleException("Failed to stop Bundle", e);
+ }
}
public void update() throws BundleException
@@ -131,12 +141,18 @@
public long getBundleId()
{
checkPermission(AdminPermission.METADATA);
- return 1L;
+ return unit.getName().hashCode();
}
public String getLocation()
{
checkPermission(AdminPermission.METADATA);
+ if (unit instanceof VFSDeploymentUnit)
+ {
+ VFSDeploymentUnit vfsUnit = VFSDeploymentUnit.class.cast(unit);
+ VirtualFile file = vfsUnit.getRoot();
+ return file.getPathName();
+ }
return null;
}
@@ -166,6 +182,11 @@
return true;
}
+ /**
+ * Get the Bundle's headers
+ *
+ * @return the Bundle's headers
+ */
@SuppressWarnings("unchecked")
public Dictionary getHeaders()
{
@@ -183,92 +204,120 @@
return bundleHeaders.toDictionary();
}
+ /**
+ * Get the Bundle's symbolic name
+ *
+ * @return the Bundle's symbolic name
+ */
public String getSymbolicName()
{
return (String) getControllerContext().getName();
}
+ /**
+ * Load class from Bundles classloader
+ *
+ * @param name a class name
+ * @return the class
+ */
public Class<?> loadClass(String name) throws ClassNotFoundException
{
checkPermission(AdminPermission.CLASS);
- if (getControllerContext() != null)
+ try
{
- // Verify ControllerState required to load CL resources
- if (ControllerState.INSTANTIATED.equals(getControllerContext().getState()))
- {
- return unit.getClassLoader().loadClass(name);
- }
+ return unit.getClassLoader().loadClass(name);
}
- return null;
+ catch (IllegalStateException exception) // ClassLoader not set on context
+ {
+ throw new ClassNotFoundException("No classloader found for class: " + name, exception);
+ }
}
+ /**
+ * Get resource from Bundle classloader
+ *
+ * @param name a resource name
+ * @return URL URL to resource
+ */
public URL getResource(String name)
{
checkPermission(AdminPermission.RESOURCE);
-
- if (getControllerContext() != null)
- {
- // Verify ControllerState required to load CL resources
- if (ControllerState.INSTANTIATED.equals(getControllerContext().getState()))
- {
- return unit.getClassLoader().getResource(name);
- }
- }
- return null;
+ return unit.getClassLoader().getResource(name); // TODO Should it propagate the IllegalStateException or trap and return null?
}
+ /**
+ * Get resources from bundle classloader
+ *
+ * @param name a resource name
+ * @return Enumeration of URLs to resources
+ */
@SuppressWarnings("unchecked")
public Enumeration getResources(String name) throws IOException
{
checkPermission(AdminPermission.RESOURCE);
-
- if (getControllerContext() != null)
- {
- // Verify ControllerState required to load CL resources
- if (ControllerState.INSTANTIATED.equals(getControllerContext().getState()))
- {
- return unit.getClassLoader().getResources(name);
- }
- }
- return null;
+ return unit.getClassLoader().getResources(name); // TODO Should it propagate the IllegalStateException or trap and return null?
}
+ /**
+ * Get paths to entries in Bundle for a given directory
+ *
+ * @param name name of entry
+ * @return Enumeration of URLs to entries in Bundle
+ */
@SuppressWarnings("unchecked")
- public Enumeration getEntryPaths(String string)
+ public Enumeration getEntryPaths(String dirPath)
{
checkPermission(AdminPermission.RESOURCE);
- return null;
+ return BundleEntryHelper.getEntryPaths(unit, dirPath);
}
- public URL getEntry(String string)
+ /**
+ * Get an entry from the bundle
+ *
+ * @param path path to entry
+ * @return URL to entry
+ */
+ public URL getEntry(String path)
{
checkPermission(AdminPermission.RESOURCE);
- return null;
+ return BundleEntryHelper.getEntry(unit, path);
}
public long getLastModified()
{
- // TODO - Get a better scheme for this.. This should be set at INSTALL, UPDATE, UNSTALL
- if (lastModified == -1)
- {
- lastModified = System.currentTimeMillis();
- }
return lastModified;
}
+ /**
+ * Search Bundle for entries
+ *
+ * @param path base path in Bundle
+ * @param filePattern pattern used to select files
+ * @param recurse should search recurse directories
+ * @return Enumeration of URLs to matched entries
+ */
@SuppressWarnings("unchecked")
- public Enumeration findEntries(String string, String string1, boolean b)
+ public Enumeration findEntries(String path, String filePattern, boolean recurse)
{
checkPermission(AdminPermission.RESOURCE);
-
- return null;
+ return BundleEntryHelper.findEntries(unit, path, filePattern, recurse);
}
+ /**
+ * Returns the ControllerContext for the DeploymentUnit
+ *
+ * @return the ControllerContext
+ */
private ControllerContext getControllerContext()
{
return unit.getAttachment(ControllerContext.class.getName(), ControllerContext.class);
}
+ /**
+ * Checks administrative permissions
+ *
+ * @param adminPermission the permission to check
+ */
private void checkPermission(String adminPermission)
{
if (System.getSecurityManager() != null)
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,152 @@
+/*
+ * 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.osgi.plugins.facade.helpers;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A BundleEntryHelper - Helper used to retrieve Bundle Entries from a VirtualFile
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleEntryHelper
+{
+
+ /** The log */
+ private static final Logger log = Logger.getLogger(BundleEntryHelper.class);
+
+ /**
+ * Get paths to entries in DeploymentUnit for a given directory
+ *
+ * @param unit DeploymentUnit
+ * @param name name of entry
+ * @return Enumeration of URLs to entries in Bundle
+ */
+ @SuppressWarnings("unchecked")
+ public static Enumeration getEntryPaths(DeploymentUnit unit, String dirPath)
+ {
+ VirtualFile file = getVirtualFile(unit, dirPath);
+ if (file != null)
+ {
+ List<String> entryPaths = new ArrayList<String>();
+ try
+ {
+ for (VirtualFile entry : file.getChildren())
+ {
+ entryPaths.add(entry.getPathName());
+ }
+ if (entryPaths.isEmpty() == false)
+ {
+ return Collections.enumeration(entryPaths);
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Failed to get entry paths", e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get an entry from the DeploymentUnit
+ *
+ * @param path path to entry
+ * @return URL to entry
+ */
+ public static URL getEntry(DeploymentUnit unit, String path)
+ {
+ try
+ {
+ VirtualFile file = getVirtualFile(unit, path);
+ return file != null ? file.toURL() : null;
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to get entry " + path + " from " + unit.getName(), e);
+ }
+ return null;
+ }
+
+ /**
+ * Search DeploymentUnit for entries
+ *
+ * @param path base path in Bundle
+ * @param filePattern pattern used to select files
+ * @param recurse should search recurse directories
+ * @return Enumeration of URLs to matched entries
+ */
+ @SuppressWarnings("unchecked")
+ public static Enumeration findEntries(DeploymentUnit unit, String path, String filePattern, boolean recurse)
+ {
+ VirtualFile file = getVirtualFile(unit, path);
+ if (file != null)
+ {
+ BundleEntryVisitor bundleEntryVisitor = new BundleEntryVisitor(filePattern, recurse);
+ try
+ {
+ file.visit(bundleEntryVisitor);
+ List<URL> entries = bundleEntryVisitor.getEntries();
+ if (entries.isEmpty() == false)
+ {
+ return Collections.enumeration(entries);
+ }
+ // TODO Consider finding entries from attached fragments (modules?).
+ }
+ catch (IOException e)
+ {
+ log.error("Failed to find entries for path " + path + " with filepattern " + filePattern
+ + " DeploymentUnit" + unit.getName(), e);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the root VirtualFile from the DeploymentUnit
+ *
+ * @param unit DeploymentUnit
+ * @return root VirtualFile from DeploymentUnit
+ */
+ private static VirtualFile getVirtualFile(DeploymentUnit unit, String filePath)
+ {
+ VirtualFile returnFile = null;
+ if (unit instanceof VFSDeploymentUnit)
+ {
+ VFSDeploymentUnit vfsUnit = VFSDeploymentUnit.class.cast(unit);
+ returnFile = vfsUnit.getFile(filePath);
+ }
+ return returnFile;
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,126 @@
+/*
+* 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.osgi.plugins.facade.helpers;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.plugins.facade.BundleImpl;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileVisitor;
+import org.jboss.virtual.VisitorAttributes;
+
+/**
+ * A BundleEntryVisitor - VirtualFile visitor used to find Bundle entries matching a file pattern
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleEntryVisitor implements VirtualFileVisitor
+{
+ private final boolean recurse;
+
+ private final Pattern filePattern;
+
+ private List<URL> entries = new ArrayList<URL>();
+
+ /** The log */
+ private static final Logger log = Logger.getLogger(BundleImpl.class);
+
+ /**
+ * Create a new BundleEntryVisitor.
+ *
+ * @param filePattern The file pattern
+ * @param recurse Should recurse
+ */
+ public BundleEntryVisitor(String filePattern, boolean recurse)
+ {
+ this.filePattern = convertToPattern(filePattern);
+ this.recurse = recurse;
+ }
+
+ /**
+ * Get attributes used to define visitor behavior
+ *
+ * @return visitor attributes
+ */
+ public VisitorAttributes getAttributes()
+ {
+ if (recurse)
+ {
+ return VisitorAttributes.RECURSE_LEAVES_ONLY;
+ }
+ else
+ {
+ return VisitorAttributes.LEAVES_ONLY;
+ }
+ }
+
+ /**
+ * Visit an individual file and match against pattern
+ *
+ * @param file File to compare to pattern
+ */
+ public void visit(VirtualFile file)
+ {
+ Matcher matcher = filePattern.matcher(file.getName());
+ if (matcher.find())
+ {
+ try
+ {
+ entries.add(file.toURL());
+ }
+ catch (Exception e)
+ {
+ // TODO Handle Exception
+ log.error("Failed to get URL for VirtualFile " + file.getName(), e);
+ }
+ }
+ }
+
+ /**
+ * Get entries matching the file pattern
+ *
+ * @return Entry List
+ */
+ public List<URL> getEntries()
+ {
+ return entries;
+ }
+
+ /**
+ * Convert file pattern (RFC 1960-based Filter) into a RegEx pattern
+ *
+ * @param filePattern
+ * @return Regular expressions pattern
+ */
+ private Pattern convertToPattern(String filePattern)
+ {
+ return Pattern.compile(new StringBuilder().append("^").append(filePattern.replace("*", ".*")).append("$")
+ .toString());
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/facade/helpers/BundleEntryVisitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/META-INF/jboss-service.xml
===================================================================
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/META-INF/manifest.mf
===================================================================
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/fromroot.xml
===================================================================
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/custom.xml
===================================================================
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/notanxmlfile.txt
===================================================================
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/test/custom.properties
===================================================================
Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/helper/simple.jar/org/jboss/osgi/test/custom.xml
===================================================================
Deleted: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java 2008-02-29 07:08:34 UTC (rev 70251)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -1,100 +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;
-
-import java.util.Dictionary;
-
-import junit.framework.Test;
-
-import org.jboss.classloading.plugins.metadata.PackageCapability;
-import org.jboss.classloading.plugins.metadata.PackageRequirement;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.version.Version;
-import org.jboss.classloading.spi.version.VersionRange;
-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.helpers.BundleHeaders;
-import org.jboss.test.bundle.metadata.AbstractManifestTestCase;
-import org.osgi.framework.Constants;
-
-/**
- *
- * A BundleHeaderTestCase.
- *
- * @author <a href="baileyje at gmail.com">John Bailey</a>
- * @version $Revision: 1.1 $
- */
-public class BundleHeaderTestCase extends AbstractManifestTestCase
-{
- private BundleHeaders bundleHeaders;
-
- /**
- *
- * Create a new BundleHeaderTestCase.
- *
- * @param name
- */
- public BundleHeaderTestCase(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(BundleHeaderTestCase.class);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- DeploymentContext deploymentContext = new AbstractDeploymentContext("aDeployment", "/test.jar");
-
- DeploymentUnit deploymentUnit = new AbstractDeploymentUnit(deploymentContext);
-
- ClassLoadingMetaData clMetaData = new ClassLoadingMetaData();
- clMetaData.getCapabilities().addCapability(new PackageCapability("org.jboss.test", new Version(1,2,0)));
- clMetaData.getCapabilities().addCapability(new PackageCapability("org.jboss.test.other", new Version(1,5,0)));
-
-
- clMetaData.getRequirements().addRequirement(new PackageRequirement("org.jboss.test", new VersionRange(new Version(1,2,0))));
- clMetaData.getRequirements().addRequirement(new PackageRequirement("org.jboss.test.other", new VersionRange(new Version(1,5,0),new Version(2,0,1))));
- deploymentUnit.addAttachment(ClassLoadingMetaData.class, clMetaData);
-
- bundleHeaders = new BundleHeaders(deploymentUnit);
- }
- /**
- * Test getting BundleHeaders as a Dictionary
- *
- * @throws Exception
- */
- @SuppressWarnings("unchecked")
- public void testToDictionary() throws Exception
- {
- Dictionary<String, Object> headers = bundleHeaders.toDictionary();
- assertNotNull(headers);
- assertEquals("org.jboss.test;version=1.2.0,org.jboss.test.other;version=1.5.0", headers.get(Constants.EXPORT_PACKAGE));
- assertEquals("org.jboss.test;version=[1.2.0,?),org.jboss.test.other;version=[1.5.0,2.0.1)", headers.get(Constants.IMPORT_PACKAGE));
- }
-}
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-02-29 07:08:34 UTC (rev 70251)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleImplTestCase.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.bundle;
+import java.net.URL;
+import java.util.Enumeration;
import junit.framework.Test;
@@ -33,21 +35,22 @@
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.bundle.metadata.AbstractManifestTestCase;
+import org.jboss.test.BaseTestCase;
import org.jboss.test.bundle.support.TestControllerContext;
import org.jboss.test.bundle.support.TestMainDeployer;
import org.osgi.framework.Bundle;
/**
- *
* A BundleImplTestCase.
*
* @author <a href="baileyje at gmail.com">John Bailey</a>
* @version $Revision: 1.1 $
*/
-public class BundleImplTestCase extends AbstractManifestTestCase
+public class BundleImplTestCase extends BaseTestCase
{
private Bundle bundle;
+
+ private DeploymentContext deploymentContext;
private DeploymentUnit deploymentUnit;
@@ -55,22 +58,37 @@
private TestMainDeployer mainDeployer;
+ /**
+ *
+ * Create a new BundleImplTestCase.
+ *
+ * @param name
+ */
public BundleImplTestCase(String name)
{
super(name);
}
+ /**
+ * Get suite for test
+ *
+ * @return test suite
+ */
public static Test suite()
{
return suite(BundleImplTestCase.class);
}
+ /**
+ * Setup test
+ */
@Override
protected void setUp() throws Exception
{
super.setUp();
- DeploymentContext deploymentContext = new AbstractDeploymentContext("UniqueName", "/simple.jar");
+ 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);
@@ -110,6 +128,16 @@
}
/**
+ * Returns the id for a Bundle
+ *
+ * @throws Exception
+ */
+ public void testGetBundleId() throws Exception
+ {
+ assertEquals("UniqueName".hashCode(), bundle.getBundleId());
+ }
+
+ /**
* Verifies the Bundle.start method calls the MainDeployer.change method with the INSTALL DeploymentStage
*
* @throws Exception
@@ -121,6 +149,146 @@
}
/**
+ * Verifies the Bundle.stop method calls the MainDeployer.change method with the DESCRIBE DeploymentStage
+ *
+ * @throws Exception
+ */
+ public void testStopBundle() throws Exception
+ {
+ bundle.stop();
+ assertChangeRequested(deploymentUnit.getName(), DeploymentStages.DESCRIBE);
+ }
+
+ /**
+ * Test the Bundle.loadClass method with valid class
+ *
+ * @throws Exception
+ */
+ public void testLoadClass() throws Exception
+ {
+ Class<?> testClass = bundle.loadClass("org.jboss.test.bundle.support.TestActivator");
+ assertNotNull(testClass);
+ }
+
+ /**
+ * Test Bundle.loadClass with a missing class. Should throw normal ClassNotFound
+ *
+ * @throws Exception
+ */
+ public void testLoadClassNotFound() throws Exception
+ {
+ try
+ {
+ bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
+ fail("Should have thrown ClassNotFoundException");
+ }
+ catch (ClassNotFoundException expectedException)
+ {
+ assertEquals("org.jboss.test.bundle.support.MissingClass", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test Bundle.loadClass with no ClassLoader. Should throw ClassNotFound with message relating to missing classloader
+ *
+ * @throws Exception
+ */
+ public void testLoadClassNoClassLoader() throws Exception
+ {
+ deploymentContext.setClassLoader(null);
+ try
+ {
+ bundle.loadClass("org.jboss.test.bundle.support.MissingClass");
+ fail("Should have thrown ClassNotFoundException");
+ }
+ catch (ClassNotFoundException expectedException)
+ {
+ assertEquals("No classloader found for class: org.jboss.test.bundle.support.MissingClass", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test the Bundle.getResource method with valid resource
+ *
+ * @throws Exception
+ */
+ public void testGetResource() throws Exception
+ {
+ URL resource = bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
+ assertNotNull(resource);
+ }
+
+ /**
+ * Test the Bundle.getResource method with missing resource
+ *
+ * @throws Exception
+ */
+ public void testGetResourceMissingResource() throws Exception
+ {
+ URL resource = bundle.getResource("org/jboss/test/bundle/metadata/Missing.mf");
+ assertNull(resource);
+ }
+
+ /**
+ * Test the Bundle.getResource method with missing DeploymentUnit ClassLoader
+ *
+ * @throws Exception
+ */
+ public void testGetResourceMissingClassLoader() throws Exception
+ {
+ deploymentContext.setClassLoader(null);
+ try {
+ bundle.getResource("org/jboss/test/bundle/metadata/Manifest.mf");
+ fail("Should have thrown IllegalStateException");
+ } catch (IllegalStateException expectedException) {
+ assertEquals("ClassLoader has not been set", expectedException.getMessage());
+ }
+ }
+
+ /**
+ * Test the Bundle.getResources method with valid resource
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testGetResources() throws Exception
+ {
+ Enumeration<URL> resources = bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
+ assertNotNull(resources);
+ assertTrue(resources.hasMoreElements());
+ }
+
+ /**
+ * Test the Bundle.getResources method with missing resource
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testGetResourceMissingResources() throws Exception
+ {
+ Enumeration<URL> resources = bundle.getResources("org/jboss/test/bundle/metadata/Missing.mf");
+ assertNotNull(resources);
+ assertFalse(resources.hasMoreElements());
+ }
+
+ /**
+ * Test the Bundle.getResources method with missing DeploymentUnit ClassLoader
+ *
+ * @throws Exception
+ */
+ public void testGetResourcesMissingClassLoader() throws Exception
+ {
+ deploymentContext.setClassLoader(null);
+ try {
+ bundle.getResources("org/jboss/test/bundle/metadata/Manifest.mf");
+ fail("Should have thrown IllegalStateException");
+ } catch (IllegalStateException expectedException) {
+ assertEquals("ClassLoader has not been set", expectedException.getMessage());
+ }
+ }
+
+
+ /**
* Assert the correct change was requested of the MainDeployer
*
* @param deploymentName
Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java 2008-02-29 07:08:34 UTC (rev 70251)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -24,12 +24,15 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+
+import org.jboss.test.bundle.helper.BundleHelperTestSuite;
import org.jboss.test.bundle.metadata.MetaDataTestSuite;
/**
* Bundle Test Suite.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
*/
public class BundleTestSuite extends TestSuite
{
@@ -43,8 +46,8 @@
TestSuite suite = new TestSuite("Bundle Tests");
suite.addTest(BundleImplTestCase.suite());
- suite.addTest(BundleHeaderTestCase.suite());
suite.addTest(MetaDataTestSuite.suite());
+ suite.addTest(BundleHelperTestSuite.suite());
return suite;
}
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,92 @@
+/*
+ * 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.helper;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.test.BaseTestCase;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A AbsractBundleEntryTestCase - used for helper classes or Bundle entries
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractBundleEntryTestCase extends BaseTestCase
+{
+
+ /**
+ * Create a new AbsractBundleEntryTestCase.
+ *
+ * @param name
+ */
+ public AbstractBundleEntryTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite(Class<? extends TestCase> clazz)
+ {
+ return new TestSuite(clazz);
+ }
+
+ /**
+ * 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
+ * @param virualFilePath a path to a virtual file in the root
+ * @param entryUrl a URL to an entry to assert same as expected path
+ * @throws IOException
+ * @throws URISyntaxException
+ */
+ protected void assertEntry(VirtualFile root, String virualFilePath, URL entryUrl) throws IOException,
+ URISyntaxException
+ {
+ VirtualFile expectedEntry = root.getChild(virualFilePath);
+ assertNotNull("Invalid assertiong. Expected file does not exisist", expectedEntry); // Sanity check
+
+ assertEquals(expectedEntry.toURL(), entryUrl);
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/AbstractBundleEntryTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,265 @@
+/*
+ * 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.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.osgi.plugins.facade.helpers.BundleEntryHelper;
+import org.jboss.test.bundle.support.TestVFSDeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A BundleEntryHelperTestCase.
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleEntryHelperTestCase extends AbstractBundleEntryTestCase
+{
+ private VirtualFile root;
+
+ private DeploymentUnit deploymentUnit;
+
+ /**
+ * Create a new BundleEntryHelperTestCase.
+ *
+ * @param name
+ */
+ public BundleEntryHelperTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get Suite for BundleEntryHelperTestCase
+ *
+ * @return test suite
+ */
+ public static Test suite()
+ {
+ return suite(BundleEntryHelperTestCase.class);
+ }
+
+ /**
+ * Setup the test
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ root = getVirtualFile("/org/jboss/test/bundle/helper", "simple.jar");
+ deploymentUnit = new TestVFSDeploymentUnit(root);
+ }
+
+ /**
+ * Test findEntryMethod
+ *
+ * @throws Exception
+ */
+ public void testGetEntry() throws Exception
+ {
+ URL entry = BundleEntryHelper.getEntry(deploymentUnit, "META-INF/manifest.mf");
+ assertNotNull(entry);
+ assertEntry(root, "META-INF/manifest.mf", entry);
+ }
+
+ /**
+ * Test findEntryMethod with no results
+ *
+ * @throws Exception
+ */
+ public void testGetEntryNoResult() throws Exception
+ {
+ URL entry = BundleEntryHelper.getEntry(deploymentUnit, "META-INF/missing.mf");
+ assertNull(entry);
+ }
+
+ /**
+ * Test findEntryMethod
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testGetEntryPaths() throws Exception
+ {
+ Enumeration<String> entries = BundleEntryHelper.getEntryPaths(deploymentUnit, "META-INF/");
+ assertNotNull(entries);
+ 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());
+ assertFalse(entries.hasMoreElements());
+ }
+
+ /**
+ * Test findEntryMethod with no results
+ *
+ * @throws Exception
+ */
+ @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);
+ }
+ }
+
+ /**
+ * Test findEntryMethod with missing path
+ *
+ * @throws Exception
+ */
+ public void testGetEntryPathsMissingDirPath() throws Exception
+ {
+ try
+ {
+ BundleEntryHelper.getEntryPaths(deploymentUnit, "mising/path");
+ fail("Should have throw FileNotFoundException");
+ }
+ catch (RuntimeException expectedException)
+ {
+ assertTrue(expectedException.getCause() instanceof FileNotFoundException);
+ }
+ }
+
+ /**
+ * Test finding entries without wild cards (*)
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testFindEntriesNoWildCard() throws Exception
+ {
+ Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "manifest.mf", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/META-INF/manifest.mf", entries.nextElement());
+
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "/org", "custom.properties", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.properties", entries.nextElement());
+
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "/org/jboss", "custom.xml", true);
+ 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());
+
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "fromroot.xml", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/fromroot.xml", entries.nextElement());
+
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "bogus.txt", true);
+ assertNull(entries);
+ }
+
+ /**
+ * Test finding entries without wild cards (*) or recursion
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testFindEntriesNoWildCardOrRecurse() throws Exception
+ {
+ Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "manifest.mf", false);
+ assertNull(entries);
+
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "fromroot.xml", false);
+ assertEntry(root, "/fromroot.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements() == false);
+ }
+
+ /**
+ * Test finding entries with wild cards (*)
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testFindEntriesWildCard() throws Exception
+ {
+ // starts with wildcard
+ Enumeration<URL> entries = BundleEntryHelper.findEntries(deploymentUnit, "/", "*.mf", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/META-INF/manifest.mf", entries.nextElement());
+
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "/org/jboss", "*.properties", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.properties", entries.nextElement());
+
+ // 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, "/org/jboss/osgi/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements() == false);
+
+ // ends in wildcard and matches multiple
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "org/", "custom*", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.properties", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements() == false);
+
+ // begins and ends with wildcard
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "org/", "*xml*", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/notanxmlfile.txt", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements() == false);
+
+ // wildcard within
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "META-INF/", "jboss*.xml", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/META-INF/jboss-service.xml", entries.nextElement());
+
+ // several wildcards
+ entries = BundleEntryHelper.findEntries(deploymentUnit, "org/", "*t*xml*", true);
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/notanxmlfile.txt", entries.nextElement());
+ assertTrue(entries.hasMoreElements());
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", entries.nextElement());
+ assertTrue(entries.hasMoreElements() == false);
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryHelperTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,217 @@
+/*
+ * 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.helper;
+
+import junit.framework.Test;
+
+import org.jboss.osgi.plugins.facade.helpers.BundleEntryVisitor;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A BundleEntryVisitorTest.
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleEntryVisitorTestCase extends AbstractBundleEntryTestCase
+{
+
+ private VirtualFile root;
+
+ /**
+ * Create a new BundleEntryVisitorTest.
+ *
+ * @param name
+ */
+ public BundleEntryVisitorTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get Suite for BundleEntryVisitorTest
+ *
+ * @return
+ */
+ public static Test suite()
+ {
+ return suite(BundleEntryVisitorTestCase.class);
+ }
+
+ /**
+ * Setup the test
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ root = getVirtualFile("/org/jboss/test/bundle/helper", "simple.jar");
+ }
+
+ /**
+ * Test finding entries without wild cards (*)
+ *
+ * @throws Exception
+ */
+ public void testFindEntriesNoWildCard() throws Exception
+ {
+
+ 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));
+
+ visitor = new BundleEntryVisitor("custom.properties", true);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+
+ assertEntry(root, "/org/jboss/osgi/test/custom.properties", visitor.getEntries().get(0));
+
+ visitor = new BundleEntryVisitor("custom.xml", true);
+ root.visit(visitor);
+ assertEquals(2, visitor.getEntries().size());
+
+ assertEntry(root, "/org/jboss/osgi/custom.xml", visitor.getEntries().get(0));
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", visitor.getEntries().get(1));
+
+ visitor = new BundleEntryVisitor("fromroot.xml", true);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
+
+ visitor = new BundleEntryVisitor("bogus.txt", false);
+ root.visit(visitor);
+ assertEquals(0, visitor.getEntries().size());
+
+ }
+
+ /**
+ * Test finding entries without wild cards (*) or recursion
+ *
+ * @throws Exception
+ */
+ public void testFindEntriesNoWildCardOrRecurse() throws Exception
+ {
+
+ BundleEntryVisitor visitor = new BundleEntryVisitor("manifest.mf", false);
+ root.visit(visitor);
+ assertEquals(0, visitor.getEntries().size());
+
+ visitor = new BundleEntryVisitor("custom.properties", false);
+ root.visit(visitor);
+ assertEquals(0, visitor.getEntries().size());
+
+ visitor = new BundleEntryVisitor("fromroot.xml", false);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
+ }
+
+ /**
+ * Test finding entries with wild cards (*)
+ *
+ * @throws Exception
+ */
+ public void testFindEntriesWildCard() throws Exception
+ {
+
+ // starts with wildcard
+ BundleEntryVisitor visitor = new BundleEntryVisitor("*.mf", true);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/META-INF/manifest.mf", visitor.getEntries().get(0));
+
+ visitor = new BundleEntryVisitor("*.properties", true);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/org/jboss/osgi/test/custom.properties", visitor.getEntries().get(0));
+
+ // starts with wildcard and matches multiple
+ 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, "/org/jboss/osgi/custom.xml", visitor.getEntries().get(2));
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", visitor.getEntries().get(3));
+
+ // ends in wildcard and matches multiple
+ visitor = new BundleEntryVisitor("custom*", true);
+ root.visit(visitor);
+ assertEquals(3, visitor.getEntries().size());
+ assertEntry(root, "/org/jboss/osgi/custom.xml", visitor.getEntries().get(0));
+ assertEntry(root, "/org/jboss/osgi/test/custom.properties", visitor.getEntries().get(1));
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", visitor.getEntries().get(2));
+
+ // begins and ends with wildcard
+ 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, "/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));
+
+ // wildcard within
+ visitor = new BundleEntryVisitor("jboss*.xml", true);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/META-INF/jboss-service.xml", visitor.getEntries().get(0));
+
+ // several wildcards
+ visitor = new BundleEntryVisitor("*t*xml*", true);
+ root.visit(visitor);
+ assertEquals(4, visitor.getEntries().size());
+ assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
+ assertEntry(root, "/org/jboss/osgi/custom.xml", visitor.getEntries().get(1));
+ assertEntry(root, "/org/jboss/osgi/notanxmlfile.txt", visitor.getEntries().get(2));
+ assertEntry(root, "/org/jboss/osgi/test/custom.xml", visitor.getEntries().get(3));
+ }
+
+ /**
+ * Test finding entries with wild cards (*) and no recursion
+ *
+ * @throws Exception
+ */
+ public void testFindEntriesWildCardNoRecurse() throws Exception
+ {
+
+ BundleEntryVisitor visitor = new BundleEntryVisitor("*.mf", false);
+ root.visit(visitor);
+ assertEquals(0, visitor.getEntries().size());
+
+ visitor = new BundleEntryVisitor("custom.*", false);
+ root.visit(visitor);
+ assertEquals(0, visitor.getEntries().size());
+
+ visitor = new BundleEntryVisitor("*.xml", false);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
+
+ visitor = new BundleEntryVisitor("*xml*", false);
+ root.visit(visitor);
+ assertEquals(1, visitor.getEntries().size());
+ assertEntry(root, "/fromroot.xml", visitor.getEntries().get(0));
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleEntryVisitorTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHeaderTestCase.java (from rev 70235, projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleHeaderTestCase.java)
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHeaderTestCase.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHeaderTestCase.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,106 @@
+/*
+ * 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.helper;
+
+import java.util.Dictionary;
+
+import junit.framework.Test;
+
+import org.jboss.classloading.plugins.metadata.PackageCapability;
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.version.Version;
+import org.jboss.classloading.spi.version.VersionRange;
+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.helpers.BundleHeaders;
+import org.jboss.test.BaseTestCase;
+import org.osgi.framework.Constants;
+
+/**
+ * A BundleHeaderTestCase.
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleHeaderTestCase extends BaseTestCase
+{
+ private BundleHeaders bundleHeaders;
+
+ /**
+ * Create a new BundleHeaderTestCase.
+ *
+ * @param name
+ */
+ public BundleHeaderTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Get test suite
+ *
+ * @return
+ */
+ public static Test suite()
+ {
+ return suite(BundleHeaderTestCase.class);
+ }
+
+ /**
+ * Setup test
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ DeploymentContext deploymentContext = new AbstractDeploymentContext("aDeployment", "/test.jar");
+
+ DeploymentUnit deploymentUnit = new AbstractDeploymentUnit(deploymentContext);
+
+ ClassLoadingMetaData clMetaData = new ClassLoadingMetaData();
+ clMetaData.getCapabilities().addCapability(new PackageCapability("org.jboss.test", new Version(1,2,0)));
+ clMetaData.getCapabilities().addCapability(new PackageCapability("org.jboss.test.other", new Version(1,5,0)));
+
+
+ clMetaData.getRequirements().addRequirement(new PackageRequirement("org.jboss.test", new VersionRange(new Version(1,2,0))));
+ clMetaData.getRequirements().addRequirement(new PackageRequirement("org.jboss.test.other", new VersionRange(new Version(1,5,0),new Version(2,0,1))));
+ deploymentUnit.addAttachment(ClassLoadingMetaData.class, clMetaData);
+
+ bundleHeaders = new BundleHeaders(deploymentUnit);
+ }
+ /**
+ * Test getting BundleHeaders as a Dictionary
+ *
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testToDictionary() throws Exception
+ {
+ Dictionary<String, Object> headers = bundleHeaders.toDictionary();
+ assertNotNull(headers);
+ assertEquals("org.jboss.test;version=1.2.0,org.jboss.test.other;version=1.5.0", headers.get(Constants.EXPORT_PACKAGE));
+ assertEquals("org.jboss.test;version=[1.2.0,?),org.jboss.test.other;version=[1.5.0,2.0.1)", headers.get(Constants.IMPORT_PACKAGE));
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHeaderTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHelperTestSuite.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHelperTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHelperTestSuite.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,61 @@
+/*
+ * 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.helper;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * A BundleHelperTestSuite.
+ *
+ * @author <a href="baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleHelperTestSuite extends TestSuite
+{
+
+ /**
+ * Run test using TestRunner
+ *
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ /**
+ * Get suite of BundleHelper tests
+ *
+ * @return suite for test
+ */
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Bundle Helper Tests");
+ suite.addTest(BundleHeaderTestCase.suite());
+ suite.addTest(BundleEntryVisitorTestCase.suite());
+ suite.addTest(BundleEntryHelperTestCase.suite());
+ return suite;
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/helper/BundleHelperTestSuite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestActivator.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,35 @@
+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");
+ }
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestActivator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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 (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestVFSDeploymentUnit.java 2008-02-29 07:35:20 UTC (rev 70252)
@@ -0,0 +1,424 @@
+/*
+ * 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;
+ }
+
+}
Property changes on: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/support/TestVFSDeploymentUnit.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jboss-cvs-commits
mailing list