[jboss-cvs] JBossAS SVN: r97994 - in projects/jboss-deployers/branches/vfs3/deployers-vfs/src: main/java/org/jboss/deployers/vfs/plugins/client and 27 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 18 12:14:13 EST 2009
Author: johnbailey
Date: 2009-12-18 12:14:12 -0500 (Fri, 18 Dec 2009)
New Revision: 97994
Added:
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/support/AssembledDirectory.java
Removed:
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java
Modified:
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSDeploymentResourceLoaderImpl.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BaseDeployersVFSTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AbstractAnnotationsScanningUnitTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestMetaDataUrlIntegrationDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestPathUrlIntegrationDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/IntegrationDeployerUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ManifestClassLoaderUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deploymentfactory/test/VFSDeploymentFactoryUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/metadata/support/ServicesFilter.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/redeploy/test/VFSRedeployTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/InnerModificationUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/explicit/test/ModificationTypeUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/test/WARUnpackUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/webbeans/test/AbstractWebBeansTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java
projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/resources/bootstrap/bootstrap.xml
Log:
Initial integration with Automounter into the deployers-vfs and substantial test cleanup
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderClassPathDeployer.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,6 +21,7 @@
*/
package org.jboss.deployers.vfs.plugins.classloader;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -33,6 +34,7 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.helpers.ClassPathVisitor;
import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.Automounter;
/**
* VFSClassLoaderClassPathDeployer.
@@ -104,8 +106,18 @@
{
if (vfsClassPath.contains(file) == false)
{
- if (canSeeParent == false || (canSeeParent && parentClassPath.contains(file) == false))
+ if (canSeeParent == false || (canSeeParent && parentClassPath.contains(file) == false))
+ {
+ try
+ {
+ Automounter.mount(unit.getRoot(), file);
+ }
+ catch (IOException e)
+ {
+ DeploymentException.rethrowAsDeploymentException("Failed to mount " + file, e);
+ }
vfsClassPath.add(file);
+ }
}
}
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/client/AbstractVFSDeployment.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -56,7 +56,15 @@
if (root == null)
throw new IllegalArgumentException("Null root");
- return root.getName();
+ try
+ {
+ return root.toURI().toString();
+ }
+ catch (Exception e)
+ {
+ return root.getName();
+ }
+
}
/**
Added: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java (rev 0)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSArchiveStructureDeployer.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.deployers.vfs.plugins.structure;
+
+import java.io.IOException;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.Automounter;
+
+/**
+ * Abstract {@link StructureDeployer} used to help mount VFS archive based {@link StructureDeployer}s.
+ *
+ * @author <a href="jbailey at redhat.com">John Bailey</a>
+ */
+public abstract class AbstractVFSArchiveStructureDeployer extends AbstractVFSStructureDeployer
+{
+
+ /**
+ * Determine the structure of a deployment invoking the Automounter for archive files.
+ *
+ * @param context the structure context
+ * @return true when it recognized the context
+ * @throws DeploymentException for an error
+ */
+ public boolean determineStructure(StructureContext context) throws DeploymentException
+ {
+ VirtualFile file = context.getFile();
+ boolean valid = false;
+ try
+ {
+ if (file.isFile())
+ {
+ if (hasValidSuffix(file.getName()) == false || mountArchive(file) == false)
+ {
+ return false;
+ }
+ }
+ valid = doDetermineStructure(context);
+ }
+ catch (DeploymentException e)
+ {
+ valid = false;
+ throw e;
+ }
+ finally
+ {
+ if (!valid)
+ {
+ Automounter.cleanup(file);
+ }
+ }
+ return valid;
+ }
+
+ /**
+ * Template method for VFS archive structure deployers to determine the structure once the archive has been mounted.
+ *
+ * @param context the structure context
+ * @return true if the structure was determined
+ * @throws DeploymentException
+ */
+ protected abstract boolean doDetermineStructure(StructureContext context) throws DeploymentException;
+
+ /**
+ * Template method for VFS archive structure deployers to correctly match file suffixes for their archive type.
+ *
+ * @param name the name of the file
+ * @return true if the file matches the required pattern
+ */
+ protected abstract boolean hasValidSuffix(String name);
+
+ /**
+ * Determine whether to mount the archive as an expanded file system.
+ * Defaults to false. Should be overridden by children as needed.
+ *
+ * @return
+ */
+ protected boolean mountExpanded() {
+ return false;
+ }
+
+ /**
+ * Mounts the the provided file as an archive using the {@link Automounter}
+ *
+ * @param file the file to mount
+ * @return true if the mount was successful
+ * @throws DeploymentException
+ */
+ private boolean mountArchive(VirtualFile file) throws DeploymentException
+ {
+ try
+ {
+ if(!mountExpanded())
+ Automounter.mount(file);
+ else
+ Automounter.mountExpanded(file);
+ }
+ catch (IOException e)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Failed to mount archive: " + file, e);
+ }
+ return true;
+ }
+
+}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSDeploymentContext.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -37,6 +37,7 @@
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
+import org.jboss.vfs.util.Automounter;
/**
* AbstractVFSDeploymentContext.
@@ -66,6 +67,26 @@
private transient VFSDeploymentResourceLoader loader;
/**
+ * Get the vfs file name safely
+ *
+ * @param root the virutal file
+ * @return the name
+ */
+ static final String safeVirtualFileName(VirtualFile root)
+ {
+ if (root == null)
+ throw new IllegalArgumentException("Null root");
+ try
+ {
+ return root.toURI().toString();
+ }
+ catch (Exception e)
+ {
+ return root.getName();
+ }
+ }
+
+ /**
* For serialization
*/
public AbstractVFSDeploymentContext()
@@ -94,7 +115,7 @@
*/
public AbstractVFSDeploymentContext(VirtualFile root, String relativePath)
{
- super(root.getName(), root.getName(), relativePath);
+ super(safeVirtualFileName(root), root.getName(), relativePath);
this.root = root;
}
@@ -203,6 +224,9 @@
deployed();
break;
}
+ else {
+ result = null;
+ }
}
return result;
}
@@ -455,10 +479,7 @@
@Override
public void cleanup()
{
- if(VFSHandleRegistry.isMounted(root))
- {
- VFSHandleRegistry.cleanup(root);
- }
+ Automounter.cleanup(root);
super.cleanup();
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/AbstractVFSStructureDeployer.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,15 +21,20 @@
*/
package org.jboss.deployers.vfs.plugins.structure;
+import java.io.IOException;
+
import org.jboss.classloader.spi.filter.ClassFilter;
import org.jboss.classloading.plugins.vfs.VFSResourceVisitor;
import org.jboss.classloading.spi.visitor.ResourceFilter;
import org.jboss.deployers.plugins.annotations.GenericAnnotationResourceVisitor;
import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
+import org.jboss.deployers.spi.structure.ContextInfo;
import org.jboss.deployers.structure.spi.DeploymentResourceLoader;
import org.jboss.deployers.structure.spi.helpers.DeploymentResourceClassLoader;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer;
import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.Automounter;
/**
* VFS aware structure deployer.
@@ -94,4 +99,20 @@
{
this.recurseFilter = recurseFilter;
}
+
+ @Override
+ protected void addClassPath(StructureContext structureContext, VirtualFile entry, boolean includeEntry,
+ boolean includeRootManifestCP, ContextInfo context)
+ {
+ // Need to make sure the entry is mounted before it can be used for classpath data
+ try
+ {
+ Automounter.mount(structureContext.getFile(), entry);
+ }
+ catch (IOException e)
+ {
+
+ }
+ super.addClassPath(structureContext, entry, includeEntry, includeRootManifestCP, context);
+ }
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSDeploymentResourceLoaderImpl.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSDeploymentResourceLoaderImpl.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSDeploymentResourceLoaderImpl.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -23,7 +23,6 @@
import java.io.IOException;
import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Vector;
@@ -72,10 +71,6 @@
{
return null;
}
- catch (IOException e)
- {
- return null;
- }
}
public Enumeration<URL> getResources(String name) throws IOException
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/VFSStructureBuilder.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -41,6 +41,7 @@
import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.Automounter;
import org.jboss.vfs.util.SuffixMatchFilter;
/**
@@ -87,7 +88,7 @@
try
{
VirtualFile parentFile = vfsParent.getRoot();
- VirtualFile file = parentFile.getChild(path); // leaving the findChild usage
+ VirtualFile file = parentFile.getChild(path);
return new AbstractVFSDeploymentContext(applyModification(file.exists() ? file : null, child), path);
}
catch (RuntimeException t)
@@ -206,6 +207,7 @@
// Process any Manifest Class-Path refs
for (VirtualFile file : matches)
{
+ Automounter.mount(root, file);
VFSUtils.addManifestLocations(file, classPath);
if (classPathHadVF == false)
classPathHadVF = file.equals(root);
@@ -217,7 +219,10 @@
VirtualFile file = vfsContext.getRoot();
if (classPathHadVF == false && SecurityActions.isLeaf(file) == false)
+ {
+ Automounter.mount(root, file);
VFSUtils.addManifestLocations(file, classPath);
+ }
if (classPath.isEmpty() == false)
vfsContext.setClassPath(classPath);
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/jar/JARStructure.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,23 +21,17 @@
*/
package org.jboss.deployers.vfs.plugins.structure.jar;
-import java.io.Closeable;
import java.util.Set;
import java.util.Collections;
import java.util.HashSet;
-import java.util.concurrent.Executors;
import org.jboss.beans.metadata.api.annotations.Install;
import org.jboss.beans.metadata.api.annotations.Uninstall;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.matchers.JarExtensionProvider;
import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
-import org.jboss.deployers.vfs.plugins.structure.VFSHandleRegistry;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer;
import org.jboss.deployers.vfs.spi.structure.StructureContext;
-import org.jboss.vfs.TempFileProvider;
-import org.jboss.vfs.VFS;
-import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
/**
@@ -47,20 +41,34 @@
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class JARStructure extends AbstractVFSStructureDeployer
+public class JARStructure extends AbstractVFSArchiveStructureDeployer
{
private final Set<String> suffixes = Collections.synchronizedSet(new HashSet<String>());
+ public static Set<String> DEFAULT_JAR_SUFFIXES = new HashSet<String>();
+ static
+ {
+ DEFAULT_JAR_SUFFIXES = new HashSet<String>();
+ DEFAULT_JAR_SUFFIXES.add(".zip");
+ DEFAULT_JAR_SUFFIXES.add(".ear");
+ DEFAULT_JAR_SUFFIXES.add(".jar");
+ DEFAULT_JAR_SUFFIXES.add(".rar");
+ DEFAULT_JAR_SUFFIXES.add(".war");
+ DEFAULT_JAR_SUFFIXES.add(".sar");
+ DEFAULT_JAR_SUFFIXES.add(".har");
+ DEFAULT_JAR_SUFFIXES.add(".aop");
+ }
+
/**
* Create a new JARStructure. with the default suffixes
*/
public JARStructure()
{
- this(null);
+ this(DEFAULT_JAR_SUFFIXES);
}
/**
- * Sets the default relative order 10000.
+ * DEFAULT_JAR_SUFFIXESs the default relative order 10000.
*
* @param suffixes the suffixes
*/
@@ -80,6 +88,7 @@
{
return suffixes;
}
+
/**
* Gets the set of suffixes recognised as jars
*
@@ -107,7 +116,7 @@
suffixes.remove(extension);
}
- private boolean isArchive(String name)
+ protected boolean hasValidSuffix(String name)
{
int idx = name.lastIndexOf('.');
if (idx == -1)
@@ -115,65 +124,41 @@
return suffixes.contains(name.substring(idx).toLowerCase());
}
- public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+ public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
{
ContextInfo context = null;
VirtualFile file = structureContext.getFile();
- Closeable handle = null;
- boolean valid = true;
try
{
boolean trace = log.isTraceEnabled();
- if (isLeaf(file) == false)
+ // For non top level directories that don't look like jars
+ // we require a META-INF otherwise each subdirectory would be a subdeployment
+ if (hasValidSuffix(file.getName()) == false)
{
- // For non top level directories that don't look like jars
- // we require a META-INF otherwise each subdirectory would be a subdeployment
- if (isArchive(file.getName()) == false)
+ if (structureContext.isTopLevel() == false)
{
- if (structureContext.isTopLevel() == false)
+ VirtualFile child = file.getChild("META-INF");
+ if (child.exists())
{
- VirtualFile child = file.getChild("META-INF");
- if (child != null)
- {
- if (trace)
- log.trace("... ok - non top level directory has a META-INF subdirectory");
- }
- else
- {
- if (trace)
- log.trace("... no - doesn't look like a jar and no META-INF subdirectory.");
- return false;
- }
+ if (trace)
+ log.trace("... ok - non top level directory has a META-INF subdirectory");
}
- else if (trace)
+ else
{
- log.trace("... ok - doesn't look like a jar but it is a top level directory.");
+ if (trace)
+ log.trace("... no - doesn't look like a jar and no META-INF subdirectory.");
+ return false;
}
}
- else
+ else if (trace)
{
- log.trace("... ok - its an archive or at least pretending to be");
+ log.trace("... ok - doesn't look like a jar but it is a top level directory.");
}
}
- else if (isArchive(file.getName()))
- {
- if(!VFSHandleRegistry.isMounted(file))
- {
- // Need to mount the archive.
- handle = VFS.mountZip(file, file, TempFileProvider.create(file.getName(), Executors.newSingleThreadScheduledExecutor()));
- VFSHandleRegistry.addHandle(file, handle);
- }
-
- if (trace)
- log.trace("... ok - its an archive or at least pretending to be.");
- }
- else
- {
- if (trace)
- log.trace("... no - not a directory or an archive.");
- return false;
- }
+ if(trace)
+ log.trace("... ok - its an archive or at least pretending to be");
+ boolean valid = true;
if (isSupportsCandidateAnnotations())
{
StructureContext parentContext = structureContext.getParentContext();
@@ -200,19 +185,11 @@
}
catch (Exception e)
{
- valid = false;
// Remove the invalid context
- if(context != null)
+ if (context != null)
structureContext.removeChild(context);
throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
}
- finally
- {
- if(!valid)
- {
- VFSUtils.safeClose(handle);
- }
- }
}
}
Copied: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java (from rev 94634, projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java)
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java (rev 0)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/main/java/org/jboss/deployers/vfs/plugins/structure/war/WARStructure.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.deployers.vfs.plugins.structure.war;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ContextInfo;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.StructureContext;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.VirtualFileFilter;
+import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.SuffixMatchFilter;
+
+/**
+ * WARStructure.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 83811 $
+ */
+public class WARStructure extends AbstractVFSArchiveStructureDeployer
+{
+ /** The default filter which allows jars/jar directories */
+ public static final VirtualFileFilter DEFAULT_WEB_INF_LIB_FILTER = new SuffixMatchFilter(".jar", VisitorAttributes.DEFAULT);
+
+ /** The web-inf/lib filter */
+ private VirtualFileFilter webInfLibFilter = DEFAULT_WEB_INF_LIB_FILTER;
+
+ /** The web-inf/lib/[some-archive]/META-INF filter */
+ private VirtualFileFilter webInfLibMetaDataFilter;
+
+ /** Whether to include web-inf in the classpath */
+ private boolean includeWebInfInClasspath;
+
+ /**
+ * Sets the default relative order 1000.
+ *
+ */
+ public WARStructure()
+ {
+ setRelativeOrder(1000);
+ }
+
+ /**
+ * Get the webInfLibFilter.
+ *
+ * @return the webInfLibFilter.
+ */
+ public VirtualFileFilter getWebInfLibFilter()
+ {
+ return webInfLibFilter;
+ }
+
+ /**
+ * Set the webInfLibFilter.
+ *
+ * @param webInfLibFilter the webInfLibFilter.
+ * @throws IllegalArgumentException for a null filter
+ */
+ public void setWebInfLibFilter(VirtualFileFilter webInfLibFilter)
+ {
+ if (webInfLibFilter == null)
+ throw new IllegalArgumentException("Null filter");
+ this.webInfLibFilter = webInfLibFilter;
+ }
+
+ /**
+ * Get webInfLibMetaDataFilter
+ *
+ * @return the webInfLibMetaDataFilter
+ */
+ public VirtualFileFilter getWebInfLibMetaDataFilter()
+ {
+ return webInfLibMetaDataFilter;
+ }
+
+ /**
+ * Set the webInfLibMetaDataFilter.
+ *
+ * @param webInfLibMetaDataFilter the webInfLibFilter.
+ */
+ public void setWebInfLibMetaDataFilter(VirtualFileFilter webInfLibMetaDataFilter)
+ {
+ this.webInfLibMetaDataFilter = webInfLibMetaDataFilter;
+ }
+
+ /**
+ * Should we include web-inf in classpath.
+ *
+ * @param includeWebInfInClasspath the include web-inf flag
+ */
+ public void setIncludeWebInfInClasspath(boolean includeWebInfInClasspath)
+ {
+ this.includeWebInfInClasspath = includeWebInfInClasspath;
+ }
+
+ @Override
+ protected boolean hasValidSuffix(String name)
+ {
+ return name.endsWith(".war");
+ }
+
+ @Override
+ protected boolean mountExpanded()
+ {
+ return true;
+ }
+
+ public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
+ {
+ ContextInfo context = null;
+ VirtualFile file = structureContext.getFile();
+ try
+ {
+ boolean trace = log.isTraceEnabled();
+
+ // the WEB-INF
+ VirtualFile webinf = null;
+
+ // We require either a WEB-INF or the name ends in .war
+ if (hasValidSuffix(file.getName()) == false)
+ {
+ webinf = file.getChild("WEB-INF");
+ if (webinf.exists())
+ {
+ if (trace)
+ log.trace("... ok - directory has a WEB-INF subdirectory");
+ }
+ else
+ {
+ if (trace)
+ log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
+ return false;
+ }
+ }
+ else if (trace)
+ {
+ log.trace("... ok - name ends in .war.");
+ }
+
+ List<String> metaDataLocations = new ArrayList<String>();
+ metaDataLocations.add("WEB-INF");
+
+ // Check for WEB-INF/classes
+ VirtualFile classes = file.getChild("WEB-INF/classes");
+
+ // Check for a META-INF for metadata
+ if (classes.exists())
+ metaDataLocations.add("WEB-INF/classes/META-INF");
+
+ // Check for jars in WEB-INF/lib
+ List<VirtualFile> archives = null;
+ try
+ {
+ VirtualFile webinfLib = file.getChild("WEB-INF/lib");
+ if (webinfLib != null)
+ {
+ archives = webinfLib.getChildren(webInfLibFilter);
+ // Add the jars' META-INF for metadata
+ for (VirtualFile jar : archives)
+ {
+ // either same as plain lib filter, null or accepts the jar
+ if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
+ metaDataLocations.add("WEB-INF/lib/" + jar.getName() + "/META-INF");
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
+ }
+
+ // Create a context for this war file and all its metadata locations
+ context = createContext(structureContext, metaDataLocations.toArray(new String[metaDataLocations.size()]));
+
+ // Add the war manifest classpath entries
+ addClassPath(structureContext, file, false, true, context);
+
+ // Add WEB-INF/classes if present
+ if (classes != null)
+ addClassPath(structureContext, classes, true, false, context);
+ else if (trace)
+ log.trace("No WEB-INF/classes for: " + file.getPathName());
+
+ // and the top level jars in WEB-INF/lib
+ if (archives != null)
+ {
+ for (VirtualFile jar : archives)
+ addClassPath(structureContext, jar, true, true, context);
+ }
+ else if (trace)
+ {
+ log.trace("No WEB-INF/lib for: " + file.getPathName());
+ }
+
+ // do we include WEB-INF in classpath
+ if (includeWebInfInClasspath && webinf != null)
+ {
+ addClassPath(structureContext, webinf, true, false, context);
+ }
+
+ // There are no subdeployments for wars
+ return true;
+ }
+ catch (Exception e)
+ {
+ // Remove the invalid context
+ if (context != null)
+ structureContext.removeChild(context);
+
+ throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
+ }
+ }
+}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BaseDeployersVFSTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BaseDeployersVFSTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BaseDeployersVFSTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -95,7 +95,7 @@
protected String getVfsURL(String path) throws Exception
{
URL url = getResource(path);
- return "vfs"+url.toString();
+ return url.toString();
}
/**
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/BootstrapDeployersTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -25,13 +25,14 @@
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.io.Closeable;
import java.io.IOException;
import junit.framework.AssertionFailedError;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.classloader.plugins.jdk.AbstractJDKChecker;
import org.jboss.dependency.spi.ControllerContext;
@@ -43,10 +44,11 @@
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.deployers.support.AssembledDirectory;
import org.jboss.test.kernel.junit.MicrocontainerTest;
import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.util.SuffixesExcludeFilter;;
+import org.jboss.vfs.VirtualFileAssembly;
/**
* BootstrapDeployersTest.
@@ -56,6 +58,8 @@
*/
public abstract class BootstrapDeployersTest extends MicrocontainerTest
{
+ private static Map<VirtualFile, Closeable> assemblyHandles = new HashMap<VirtualFile, Closeable>();
+
public static BootstrapDeployersTestDelegate getDelegate(Class<?> clazz) throws Exception
{
return new BootstrapDeployersTestDelegate(clazz);
@@ -298,34 +302,6 @@
}
}
- protected AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return createAssembledDirectory(name, "");
- }
-
- protected AssembledDirectory createAssembledDirectory(String name, String rootName) throws Exception
- {
- return AssembledDirectory.createAssembledDirectory(name, rootName);
- }
-
- protected void addPackage(AssembledDirectory dir, Class<?> reference) throws Exception
- {
- String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
- dir.addResources(reference, new String[] { packagePath + "/*.class" } , new String[0]);
- }
-
- protected void addPath(final AssembledDirectory dir, String path, String name) throws Exception
- {
- URL url = getResource(path);
- if (url == null)
- fail(path + " not found");
-
- VirtualFile file = VFS.getVirtualFile(url, name);
- // TODO - remove this filter after new VFS relase
- SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
- dir.addPath(file, noJars);
- }
-
protected DeploymentUnit assertChild(DeploymentUnit parent, String name)
{
String parentName = parent.getName();
@@ -343,11 +319,40 @@
}
throw new AssertionFailedError("Child " + name + " not found in " + children);
}
+
+ protected AssembledDirectory createAssembledDirectory(VirtualFile mountPoint) throws Exception
+ {
+ VirtualFileAssembly assembly = new VirtualFileAssembly();
+ assemblyHandles.put(mountPoint, VFS.mountAssembly(assembly, mountPoint));
+ return new AssembledDirectory(assembly);
+ }
+
+ protected VirtualFile getVirtualFile(String path) throws URISyntaxException
+ {
+ URL resource = getResource(path);
+ if(resource != null)
+ return VFS.getChild(resource);
+ return null;
+ }
+ protected void closeAssembly(VirtualFile mountPoint) throws IOException
+ {
+ if (assemblyHandles.containsKey(mountPoint))
+ assemblyHandles.get(mountPoint).close();
+ }
+
protected void setUp() throws Exception
{
super.setUp();
// This is a hack for a hack. ;-)
AbstractJDKChecker.getExcluded().add(BootstrapDeployersTest.class);
}
+
+ protected void tearDown() throws Exception
+ {
+ for (Closeable handle : assemblyHandles.values())
+ {
+ handle.close();
+ }
+ }
}
Added: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/support/AssembledDirectory.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/support/AssembledDirectory.java (rev 0)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/support/AssembledDirectory.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -0,0 +1,227 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.deployers.support;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.VirtualFileAssembly;
+import org.jboss.vfs.VirtualFileFilter;
+import org.jboss.vfs.VisitorAttributes;
+import org.jboss.vfs.util.FilterVirtualFileVisitor;
+import org.jboss.vfs.util.SuffixesExcludeFilter;
+
+/**
+ * Bridge class used to help migrate existing tests to use VirtualFileAssembly.
+ *
+ * @author <a href="jbailey at redhat.com">John Bailey</a>
+ *
+ */
+public class AssembledDirectory
+{
+ private final VirtualFileAssembly assembly;
+
+ public AssembledDirectory(VirtualFileAssembly assembly)
+ {
+ this.assembly = assembly;
+ }
+
+ public AssembledDirectory add(VirtualFile virtualFile)
+ {
+ assembly.add(virtualFile);
+ return this;
+ }
+
+ public AssembledDirectory addPackage(String path, Class<?> reference) throws Exception
+ {
+ String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
+ return addResources(path + "/" + packagePath, reference, new String[] {packagePath + "/*.class"}, new String[0]);
+ }
+
+ public AssembledDirectory addResources(String path, Class<?> reference, final String[] includes, final String[] excludes)
+ {
+ return addResources(path, reference, includes, excludes, reference.getClassLoader());
+ }
+
+ public AssembledDirectory addResources(String path, Class<?> reference, final String[] includes, final String[] excludes, ClassLoader loader)
+ {
+ String resource = reference.getName().replace('.', '/') + ".class";
+ URL url = loader.getResource(resource);
+ if (url == null)
+ throw new RuntimeException("Could not find baseResource: " + resource);
+
+ String urlString = url.toString();
+ int idx = urlString.lastIndexOf(resource);
+ urlString = urlString.substring(0, idx);
+
+ try
+ {
+ url = new URL(urlString);
+ final VirtualFile parent = VFS.getChild(url);
+
+ VisitorAttributes va = new VisitorAttributes();
+ va.setLeavesOnly(true);
+ va.setRecurseFilter(new SuffixesExcludeFilter(JARStructure.DEFAULT_JAR_SUFFIXES));
+
+ VirtualFileFilter filter = new VirtualFileFilter()
+ {
+ public boolean accepts(VirtualFile file)
+ {
+ boolean matched = false;
+ String path = VFSUtils.getRelativePathString(parent, file);
+ for (String include : includes)
+ {
+ if (antMatch(path, include))
+ {
+ matched = true;
+ break;
+ }
+ }
+ if (matched == false)
+ return false;
+ if (excludes != null)
+ {
+ for (String exclude : excludes)
+ {
+ if (antMatch(path, exclude))
+ return false;
+ }
+ }
+ return true;
+ }
+ };
+
+ FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, va);
+ parent.visit(visitor);
+ List<VirtualFile> files = visitor.getMatched();
+ for (VirtualFile vf : files)
+ {
+ assembly.add(path + "/" + vf.getName(), vf);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (URISyntaxException e)
+ {
+ throw new RuntimeException(e);
+ }
+ return this;
+ }
+
+ public AssembledDirectory addPath(VirtualFile existingPath, String assemblyPath) throws Exception
+ {
+ SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JARStructure.DEFAULT_JAR_SUFFIXES);
+ FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(noJars);
+ existingPath.visit(visitor);
+ for (VirtualFile match : visitor.getMatched())
+ {
+ assembly.add(assemblyPath + "/" + match.getName(), match);
+ }
+ return this;
+ }
+
+ /**
+ * Create a regular expression pattern from an Ant file matching pattern
+ *
+ * @param matcher the matcher pattern
+ * @return the pattern instance
+ */
+ private Pattern getPattern(String matcher)
+ {
+ if (matcher == null)
+ throw new IllegalArgumentException("Null matcher");
+
+ matcher = matcher.replace(".", "\\.");
+ matcher = matcher.replace("*", ".*");
+ matcher = matcher.replace("?", ".{1}");
+ return Pattern.compile(matcher);
+ }
+
+ /**
+ * Determine whether a given file path matches an Ant pattern.
+ *
+ * @param path the path
+ * @param expression the expression
+ * @return true if we match
+ */
+ private boolean antMatch(String path, String expression)
+ {
+ if (path == null)
+ throw new IllegalArgumentException("Null path");
+ if (expression == null)
+ throw new IllegalArgumentException("Null expression");
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ if (expression.endsWith("/"))
+ expression += "**";
+ String[] paths = path.split("/");
+ String[] expressions = expression.split("/");
+
+ int x = 0, p;
+ Pattern pattern = getPattern(expressions[0]);
+
+ for (p = 0; p < paths.length && x < expressions.length; p++)
+ {
+ if (expressions[x].equals("**"))
+ {
+ do
+ {
+ x++;
+ }
+ while (x < expressions.length && expressions[x].equals("**"));
+ if (x == expressions.length)
+ return true; // "**" with nothing after it
+ pattern = getPattern(expressions[x]);
+ }
+ String element = paths[p];
+ if (pattern.matcher(element).matches())
+ {
+ x++;
+ if (x < expressions.length)
+ {
+ pattern = getPattern(expressions[x]);
+ }
+ }
+ else if (!(x > 0 && expressions[x - 1].equals("**"))) // our previous isn't "**"
+ {
+ return false;
+ }
+ }
+ if (p < paths.length)
+ return false;
+ if (x < expressions.length)
+ return false;
+ return true;
+ }
+
+
+}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AbstractAnnotationsScanningUnitTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AbstractAnnotationsScanningUnitTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/annotations/test/AbstractAnnotationsScanningUnitTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -36,7 +36,8 @@
import org.jboss.test.deployers.vfs.annotations.support.war.WebMarkOnClass;
import org.jboss.test.deployers.vfs.annotations.support.war.impl.WebMarkOnClassImpl;
import org.jboss.test.deployers.vfs.annotations.support.warlib.SomeUIClass;
-import org.jboss.vfs.AssembledDirectory;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -50,23 +51,18 @@
public void testBasicScanning() throws Throwable
{
- AssembledDirectory ear = createTopLevelWithUtil();
+ VirtualFile ear = createTopLevelWithUtil();
+ createAssembledDirectory(ear.getChild("simple.jar"))
+ .addPackage("", JarMarkOnClassImpl.class)
+ .addPackage("", JarMarkOnClass.class)
+ .addPath(getVirtualFile("/annotations/basic-scan/jar/META-INF"), "META-INF");
+
+ createAssembledDirectory(ear.getChild("simple.war"))
+ .addPackage("WEB-INF/classes", WebMarkOnClassImpl.class)
+ .addPackage("WEB-INF/classes", WebMarkOnClass.class)
+ .addPackage("WEB-INF/lib/ui.jar", SomeUIClass.class)
+ .addPath(getVirtualFile("/annotations/basic-scan/web/WEB-INF"), "WEB-INF");
- AssembledDirectory jar = ear.mkdir("simple.jar");
- addPackage(jar, JarMarkOnClassImpl.class);
- addPackage(jar, JarMarkOnClass.class);
- addPath(jar, "/annotations/basic-scan/jar", "META-INF");
-
- AssembledDirectory war = ear.mkdir("simple.war");
- AssembledDirectory webinf = war.mkdir("WEB-INF");
- AssembledDirectory classes = webinf.mkdir("classes");
- addPackage(classes, WebMarkOnClassImpl.class);
- addPackage(classes, WebMarkOnClass.class);
- AssembledDirectory lib = webinf.mkdir("lib");
- AssembledDirectory uijar = lib.mkdir("ui.jar");
- addPackage(uijar, SomeUIClass.class);
- addPath(war, "/annotations/basic-scan/web", "WEB-INF");
-
enableTrace("org.jboss.deployers");
DeploymentUnit unit = assertDeploy(ear);
@@ -113,17 +109,15 @@
assertEquals(onFiled, fields.size());
}
- protected AssembledDirectory createTopLevelWithUtil() throws Exception
+ protected VirtualFile createTopLevelWithUtil() throws Exception
{
- AssembledDirectory topLevel = createAssembledDirectory("top-level.ear", "top-level.ear");
- addPath(topLevel, "/annotations/basic-scan", "META-INF");
- AssembledDirectory earLib = topLevel.mkdir("lib");
- AssembledDirectory util = earLib.mkdir("util.jar");
- addPackage(util, Util.class);
- AssembledDirectory ext = earLib.mkdir("ext.jar");
- addPackage(ext, External.class);
- AssembledDirectory ann = earLib.mkdir("ann.jar");
- addPackage(ann, NoExtRecurseFilter.class);
+ VirtualFile topLevel = VFS.getChild(getName()).getChild("top-level.ear");
+
+ createAssembledDirectory(topLevel)
+ .addPath(getVirtualFile("/annotations/basic-scan/META-INF"), "META-INF")
+ .addPackage("lib/util.jar", Util.class)
+ .addPackage("lib/ext.jar", External.class)
+ .addPackage("lib/ann.jar", NoExtRecurseFilter.class);
return topLevel;
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestMetaDataUrlIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestMetaDataUrlIntegrationDeployer.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestMetaDataUrlIntegrationDeployer.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -25,6 +25,7 @@
import org.jboss.deployers.vfs.plugins.classloader.MetaDataUrlIntegrationDeployer;
import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.vfs.VFS;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -35,7 +36,7 @@
{
super(KernelDeployment.class);
setFiles(new String[]{"metadata-touch-beans.xml"});
- URL dynamicClassRoot = new URL("vfsmemory", "integration-test", "");
+ URL dynamicClassRoot = VFS.getChild("/integration-test").toURL();
setIntegrationURL(dynamicClassRoot);
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestPathUrlIntegrationDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestPathUrlIntegrationDeployer.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/support/TestPathUrlIntegrationDeployer.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -25,6 +25,7 @@
import org.jboss.deployers.vfs.plugins.classloader.PathUrlIntegrationDeployer;
import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.vfs.VFS;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -35,7 +36,7 @@
{
super(KernelDeployment.class);
setFiles(new String[]{"data/path-touch-beans.xml"});
- URL dynamicClassRoot = new URL("vfsmemory", "integration-test", "");
+ URL dynamicClassRoot = VFS.getChild("/integration-test").toURL();
setIntegrationURL(dynamicClassRoot);
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/BootstrapDeployersSmokeTestUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -33,7 +33,8 @@
import org.jboss.test.deployers.BootstrapDeployersTest;
import org.jboss.test.deployers.vfs.classloader.support.a.A;
import org.jboss.test.deployers.vfs.classloader.support.b.B;
-import org.jboss.vfs.AssembledDirectory;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
/**
* BootstrapDeployersSmokeTestUnitTestCase.
@@ -111,9 +112,10 @@
public void testAssembledDirectory() throws Exception
{
- AssembledDirectory dirA = createAssembledDirectory("a");
- addPackage(dirA, A.class);
- addPath(dirA, "/bootstrap/test-assembled", "META-INF");
+ VirtualFile dirA = VFS.getChild(getName()).getChild("/assembly");
+ createAssembledDirectory(dirA)
+ .addPackage("", A.class)
+ .addPath(getVirtualFile("/bootstrap/test-assembled/META-INF"), "META-INF");
VFSDeploymentUnit unitA = assertDeploy(dirA);
try
{
@@ -132,11 +134,11 @@
public void testAssembledSubDirectory() throws Exception
{
- AssembledDirectory dirA = createAssembledDirectory("a");
- addPackage(dirA, A.class);
- AssembledDirectory dirB = dirA.mkdir("b");
- addPackage(dirB, B.class);
- addPath(dirB, "/bootstrap/test-assembled", "META-INF");
+ VirtualFile dirA = VFS.getChild(getName()).getChild("/assembly");
+ createAssembledDirectory(dirA)
+ .addPackage("", A.class)
+ .addPackage("/b", B.class)
+ .addPath(getVirtualFile("/bootstrap/test-assembled/META-INF"), "/b/META-INF");
VFSDeploymentUnit unitA = assertDeploy(dirA);
try
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/IntegrationDeployerUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/IntegrationDeployerUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/IntegrationDeployerUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,16 +21,21 @@
*/
package org.jboss.test.deployers.vfs.classloader.test;
-import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
+import java.util.concurrent.Executors;
import junit.framework.Test;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.test.deployers.BootstrapDeployersTest;
-import org.jboss.vfs.MemoryFileFactory;
+import org.jboss.vfs.TempFileProvider;
import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
+import org.jboss.vfs.VirtualFile;
/**
* IntegrationDeployerUnitTestCase.
@@ -39,6 +44,8 @@
*/
public class IntegrationDeployerUnitTestCase extends BootstrapDeployersTest
{
+ private Closeable tmpDirHandle;
+
public static Test suite()
{
return suite(IntegrationDeployerUnitTestCase.class);
@@ -51,33 +58,38 @@
protected void setUp() throws Exception
{
- VFS.init();
-
- URL dynamicClassRoot = new URL("vfsmemory", "integration-test", "");
- VFS vfs = MemoryFileFactory.createRoot(dynamicClassRoot);
- System.setProperty("integration.test.url", vfs.getRoot().toURL().toExternalForm());
-
+ VirtualFile dynamicClassRoot = VFS.getChild("/integration-test");
+ tmpDirHandle = VFS.mountTemp(dynamicClassRoot, TempFileProvider.create("test", Executors.newSingleThreadScheduledExecutor()));
+ System.setProperty("integration.test.url", dynamicClassRoot.toURL().toExternalForm());
+
URL file = getResource("/org/jboss/test/deployers/vfs/classloader/test/Touch.class");
assertNotNull(file);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ File tempFile = dynamicClassRoot.getChild("Touch.class").getPhysicalFile();
+
+ FileOutputStream os = new FileOutputStream(tempFile);
InputStream is = file.openStream();
try
{
int read = is.read();
while(read >= 0)
{
- baos.write(read);
+ os.write(read);
read = is.read();
}
}
finally
{
- is.close();
+ VFSUtils.safeClose(is);
+ VFSUtils.safeClose(os);
}
- MemoryFileFactory.putFile(new URL(dynamicClassRoot.toExternalForm() + "/Touch.class"), baos.toByteArray());
-
super.setUp();
}
+
+ protected void tearDown() throws Exception
+ {
+ VFSUtils.safeClose(tmpDirHandle);
+ }
public void testPath() throws Exception
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ManifestClassLoaderUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ManifestClassLoaderUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/ManifestClassLoaderUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -30,7 +30,8 @@
import org.jboss.test.deployers.BootstrapDeployersTest;
import org.jboss.test.deployers.vfs.classloader.support.a.A;
import org.jboss.test.deployers.vfs.classloader.support.usea.UseA;
-import org.jboss.vfs.AssembledDirectory;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
/**
* ManifestClassLoaderUnitTestCase.
@@ -52,10 +53,11 @@
public void testBasicManifest() throws Exception
{
- AssembledDirectory topLevel = createTopLevelWithUtil();
- AssembledDirectory sub = topLevel.mkdir("sub.jar");
- addPackage(sub, UseA.class);
- addPath(sub, "/classloader/manifest/basic", "META-INF");
+ VirtualFile topLevel = createTopLevelWithUtil();
+ VirtualFile sub = topLevel.getChild("sub.jar");
+ createAssembledDirectory(sub)
+ .addPackage("", UseA.class)
+ .addPath(getVirtualFile("/classloader/manifest/basic/META-INF"), "META-INF");
VFSDeploymentUnit unit = assertDeploy(topLevel);
try
{
@@ -72,10 +74,11 @@
public void testScopedManifest() throws Exception
{
- AssembledDirectory topLevel = createTopLevelWithUtil();
- AssembledDirectory sub = topLevel.mkdir("sub.jar");
- addPackage(sub, UseA.class);
- addPath(sub, "/classloader/manifest/scoped", "META-INF");
+ VirtualFile topLevel = createTopLevelWithUtil();
+ VirtualFile sub = topLevel.getChild("sub.jar");
+ createAssembledDirectory(sub)
+ .addPackage("", UseA.class)
+ .addPath(getVirtualFile("/classloader/manifest/scoped/META-INF"), "META-INF");
enableTrace("org.jboss.deployers");
VFSDeploymentUnit unit = assertDeploy(topLevel);
try
@@ -95,13 +98,15 @@
public void testScopedManifests() throws Exception
{
- AssembledDirectory topLevel = createTopLevelWithUtil();
- AssembledDirectory sub1 = topLevel.mkdir("sub1.jar");
- addPackage(sub1, UseA.class);
- addPath(sub1, "/classloader/manifest/scoped", "META-INF");
- AssembledDirectory sub2 = topLevel.mkdir("sub2.jar");
- addPackage(sub2, UseA.class);
- addPath(sub2, "/classloader/manifest/scoped", "META-INF");
+ VirtualFile topLevel = createTopLevelWithUtil();
+ VirtualFile sub1 = topLevel.getChild("sub1.jar");
+ createAssembledDirectory(sub1)
+ .addPackage("", UseA.class)
+ .addPath(getVirtualFile("/classloader/manifest/scoped/META-INF"), "META-INF");
+ VirtualFile sub2 = topLevel.getChild("sub2.jar");
+ createAssembledDirectory(sub2)
+ .addPackage("", UseA.class)
+ .addPath(getVirtualFile("/classloader/manifest/scoped/META-INF"), "META-INF");
VFSDeploymentUnit unit = assertDeploy(topLevel);
try
{
@@ -125,16 +130,17 @@
public void testScopedManifestNotParent() throws Exception
{
// Dummy parent to create a different parent domain
- AssembledDirectory dummyParent = createAssembledDirectory("dummyParent.jar");
- addPath(dummyParent, "/classloader/manifest/dummyparent", "META-INF");
+ VirtualFile dummyParent = VFS.getChild(getName()).getChild("dummyParent.jar");
+ createAssembledDirectory(dummyParent)
+ .addPath(getVirtualFile("/classloader/manifest/dummyparent/META-INF"), "META-INF");
VFSDeploymentUnit dummy = assertDeploy(dummyParent);
try
{
- AssembledDirectory topLevel = createTopLevelWithUtil();
- addPath(topLevel, "/classloader/manifest/topscoped", "META-INF");
- AssembledDirectory sub = topLevel.mkdir("sub.jar");
- addPackage(sub, UseA.class);
- addPath(sub, "/classloader/manifest/scopednotparent", "META-INF");
+ VirtualFile topLevel = createTopLevelWithUtil();
+ VirtualFile sub = topLevel.getChild("sub.jar");
+ createAssembledDirectory(sub)
+ .addPackage("", UseA.class)
+ .addPath(getVirtualFile("/classloader/manifest/scopednotparent/META-INF"), "META-INF");
VFSDeploymentUnit unit = assertDeploy(topLevel);
try
{
@@ -164,11 +170,11 @@
return (Class) a.get(null);
}
- protected AssembledDirectory createTopLevelWithUtil() throws Exception
+ protected VirtualFile createTopLevelWithUtil() throws Exception
{
- AssembledDirectory topLevel = createAssembledDirectory("top-level.jar");
- AssembledDirectory util = topLevel.mkdir("util.jar");
- addPackage(util, A.class);
- return topLevel;
+ VirtualFile virtualFile = VFS.getChild(getName()).getChild("top-level.jar");
+ createAssembledDirectory(virtualFile)
+ .addPackage("util.jar", A.class);
+ return virtualFile;
}
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -104,7 +104,7 @@
protected VFSDeployment createDeployment(String name) throws Exception
{
URL url = getClass().getProtectionDomain().getCodeSource().getLocation();
- VirtualFile file = VFS.getRoot(url);
+ VirtualFile file = VFS.getChild(url);
VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(file);
DeploymentFactory factory = new DeploymentFactory();
factory.addContext(deployment, "");
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/facelets/test/BookingUnitTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -45,10 +45,6 @@
import org.jboss.test.deployers.vfs.deployer.AbstractDeployerUnitTest;
import org.jboss.test.deployers.vfs.deployer.facelets.support.SearchDeployer;
import org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer;
-import org.jboss.vfs.VFSUtils;
-import org.jboss.vfs.plugins.cache.IterableTimedVFSCache;
-import org.jboss.vfs.spi.cache.VFSCache;
-import org.jboss.vfs.spi.cache.VFSCacheFactory;
/**
* BookingUnitTestCase.
@@ -67,13 +63,7 @@
protected void setUp() throws Exception
{
super.setUp();
- // Uncomment this to test VFS nested jar copy handling
- System.setProperty(VFSUtils.FORCE_COPY_KEY, "true");
- VFSCache cache = new IterableTimedVFSCache();
- cache.start();
- VFSCacheFactory.setInstance(cache);
-
addStructureDeployer(main, new WARStructure());
addStructureDeployer(main, new MockEarStructureDeployer());
}
@@ -81,7 +71,6 @@
@Override
protected void tearDown() throws Exception
{
- VFSCacheFactory.setInstance(null);
super.tearDown();
}
Deleted: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/support/MyVirtualFile.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -1,206 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.deployers.vfs.deployer.validate.support;
-
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URI;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.security.cert.Certificate;
-
-import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.spi.VirtualFileHandler;
-import org.jboss.vfs.spi.VFSContext;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class MyVirtualFile extends VirtualFile
-{
- /**
- * The serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- public MyVirtualFile()
- {
- super(getVirtualFileHandler());
- }
-
- public String getName()
- {
- return "";
- }
-
- public InputStream openStream() throws IOException
- {
- return null;
- }
-
- private static VirtualFileHandler getVirtualFileHandler()
- {
- return new VirtualFileHandler()
- {
- /**
- * The serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- public String getName()
- {
- return null;
- }
-
- public String getPathName()
- {
- return null;
- }
-
- public URL toVfsUrl() throws MalformedURLException, URISyntaxException
- {
- return null;
- }
-
- public URI toURI() throws URISyntaxException
- {
- return null;
- }
-
- public URL toURL() throws MalformedURLException, URISyntaxException
- {
- return null;
- }
-
- public long getLastModified() throws IOException
- {
- return 0;
- }
-
- public boolean hasBeenModified() throws IOException
- {
- return false;
- }
-
- public long getSize() throws IOException
- {
- return 0;
- }
-
- public boolean exists() throws IOException
- {
- return false;
- }
-
- public boolean isLeaf() throws IOException
- {
- return true;
- }
-
- public boolean isArchive() throws IOException
- {
- return false;
- }
-
- public boolean isHidden() throws IOException
- {
- return false;
- }
-
- public String getLocalPathName()
- {
- return null;
- }
-
- public boolean isNested() throws IOException
- {
- return false;
- }
-
- public InputStream openStream() throws IOException
- {
- return null;
- }
-
- public VirtualFileHandler getParent() throws IOException
- {
- return null;
- }
-
- public List<VirtualFileHandler> getChildren(boolean ignoreErrors) throws IOException
- {
- return null;
- }
-
- public VirtualFileHandler getChild(String path) throws IOException
- {
- return null;
- }
-
- public VFSContext getVFSContext()
- {
- return null;
- }
-
- public VirtualFile getVirtualFile()
- {
- return null;
- }
-
- public void close()
- {
-
- }
-
- public void replaceChild(VirtualFileHandler original, VirtualFileHandler replacement)
- {
-
- }
-
- public boolean removeChild(String name) throws IOException
- {
- return false;
- }
-
- public boolean delete(int gracePeriod) throws IOException
- {
- return false;
- }
-
- public URL getRealURL() throws IOException, URISyntaxException
- {
- return null;
- }
-
- public void cleanup()
- {
- }
-
- public Certificate[] getCertificates()
- {
- return null;
- }
- };
- }
-}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deployer/validate/test/DeployersValidateInputTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -35,8 +35,8 @@
import org.jboss.test.BaseTestCase;
import org.jboss.test.deployers.vfs.deployer.nonmetadata.support.MockBshDeployer;
import org.jboss.test.deployers.vfs.deployer.validate.support.MyVFSDeploymentContext;
-import org.jboss.test.deployers.vfs.deployer.validate.support.MyVirtualFile;
import org.jboss.test.deployers.vfs.deployer.validate.support.TestXmlDeployer;
+import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
import org.jboss.xb.binding.JBossXBException;
@@ -69,7 +69,7 @@
map.put(xmlDeployer, RuntimeException.class);
map.put(new SchemaResolverDeployer<Object>(Object.class), JBossXBException.class);
- VirtualFile root = new MyVirtualFile();
+ VirtualFile root = VFS.getChild("/NonExistent/File/Path");
AbstractVFSDeploymentContext context = new MyVFSDeploymentContext(root, "");
DeploymentUnit unit = context.getDeploymentUnit();
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deploymentfactory/test/VFSDeploymentFactoryUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deploymentfactory/test/VFSDeploymentFactoryUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/deploymentfactory/test/VFSDeploymentFactoryUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.deployers.vfs.deploymentfactory.test;
-import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
import junit.framework.Test;
@@ -94,9 +94,9 @@
{
resource = getResource("/dummy");
assertNotNull(resource);
- return VFS.getRoot(resource);
+ return VFS.getChild(resource);
}
- catch (IOException e)
+ catch (URISyntaxException e)
{
throw new RuntimeException("Failed to get resource: " + resource, e);
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/metadata/support/ServicesFilter.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/metadata/support/ServicesFilter.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/metadata/support/ServicesFilter.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,7 +21,7 @@
*/
package org.jboss.test.deployers.vfs.metadata.support;
-import org.jboss.vfs.plugins.vfs.helpers.AbstractVirtualFileFilterWithAttributes;
+import org.jboss.vfs.util.AbstractVirtualFileFilterWithAttributes;
import org.jboss.vfs.VisitorAttributes;
import org.jboss.vfs.VirtualFile;
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/parsing/test/DeployersAltDDTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -21,24 +21,14 @@
*/
package org.jboss.test.deployers.vfs.parsing.test;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-import java.security.cert.Certificate;
-
import junit.framework.Test;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.structure.AbstractVFSDeploymentContext;
import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.test.BaseTestCase;
+import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.spi.VFSContext;
-import org.jboss.vfs.spi.VirtualFileHandler;
/**
* alt-dd tests.
@@ -84,142 +74,6 @@
private static VirtualFile getMockVF()
{
- return new VirtualFile(new VirtualFileHandler()
- {
- private static final long serialVersionUID = 1L;
-
- public void close()
- {
- }
-
- public boolean exists() throws IOException
- {
- return false;
- }
-
- public VirtualFileHandler getChild(String arg0) throws IOException
- {
- return null;
- }
-
- public List<VirtualFileHandler> getChildren(boolean arg0) throws IOException
- {
- return null;
- }
-
- public long getLastModified() throws IOException
- {
- return 0;
- }
-
- public String getName()
- {
- return null;
- }
-
- public VirtualFileHandler getParent() throws IOException
- {
- return null;
- }
-
- public String getPathName()
- {
- return null;
- }
-
- public long getSize() throws IOException
- {
- return 0;
- }
-
- public VFSContext getVFSContext()
- {
- return null;
- }
-
- public VirtualFile getVirtualFile()
- {
- return null;
- }
-
- public boolean hasBeenModified() throws IOException
- {
- return false;
- }
-
- public boolean isHidden() throws IOException
- {
- return false;
- }
-
- public boolean isLeaf() throws IOException
- {
- return false;
- }
-
- public boolean isArchive() throws IOException
- {
- return false;
- }
-
- public String getLocalPathName()
- {
- return null;
- }
-
- public boolean isNested() throws IOException
- {
- return false;
- }
-
- public InputStream openStream() throws IOException
- {
- return null;
- }
-
- public URI toURI() throws URISyntaxException
- {
- return null;
- }
-
- public URL toURL() throws MalformedURLException, URISyntaxException
- {
- return null;
- }
-
- public URL toVfsUrl() throws MalformedURLException, URISyntaxException
- {
- return null;
- }
-
- public void replaceChild(VirtualFileHandler original, VirtualFileHandler replacement)
- {
-
- }
-
- public boolean removeChild(String name) throws IOException
- {
- return false;
- }
-
- public boolean delete(int gracePeriod) throws IOException
- {
- return false;
- }
-
- public URL getRealURL() throws IOException, URISyntaxException
- {
- return null;
- }
-
- public void cleanup()
- {
- }
-
- public Certificate[] getCertificates()
- {
- return null;
- }
- });
+ return VFS.getChild("/mock/file");
}
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/redeploy/test/VFSRedeployTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/redeploy/test/VFSRedeployTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/redeploy/test/VFSRedeployTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -33,9 +33,6 @@
import org.jboss.test.deployers.BaseDeployersVFSTest;
import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
-import org.jboss.vfs.plugins.cache.LRUVFSCache;
-import org.jboss.vfs.spi.VirtualFileHandler;
-import org.jboss.vfs.spi.cache.VFSCacheFactory;
/**
* Tests that a deployer sees the same underlying child during redeployment.
@@ -63,16 +60,10 @@
public void setUp() throws Exception
{
super.setUp();
-
- LRUVFSCache cache = new LRUVFSCache(50, 100);
- cache.start();
- VFSCacheFactory.setInstance(cache);
}
public void tearDown() throws Exception
{
- VFSCacheFactory.setInstance(null);
-
super.tearDown();
}
@@ -85,31 +76,15 @@
VirtualFile registryRoot;
try
{
- registryRoot = VFS.getRoot(deploymentRoot.toURL());
+ registryRoot = VFS.getChild(deploymentRoot.toURL());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
- VirtualFileHandler deploymentHandler = getHandler(deploymentRoot);
- VirtualFileHandler registryHandler = getHandler(registryRoot);
- assertSame(deploymentHandler, registryHandler);
+ assertSame(deploymentRoot, registryRoot);
}
-
- public VirtualFileHandler getHandler(VirtualFile file)
- {
- try
- {
- Method method = VirtualFile.class.getDeclaredMethod("getHandler");
- method.setAccessible(true);
- return (VirtualFileHandler)method.invoke(file);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
}
public void testDeploy() throws Exception
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/AbstractStructureTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -32,13 +32,14 @@
import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
import org.jboss.deployers.vfs.plugins.structure.file.FileStructure;
import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
-//import org.jboss.deployers.vfs.plugins.structure.war.WARStructure;
+import org.jboss.deployers.vfs.plugins.structure.war.WARStructure;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
import org.jboss.test.BaseTestCase;
import org.jboss.vfs.VFS;
+import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
/**
@@ -249,7 +250,7 @@
protected VFSDeploymentContext determineStructureWithAllStructureDeployers(VFSDeployment deployment) throws Exception
{
- return determineStructureWithStructureDeployers(deployment, new FileStructure(), /**new WARStructure(),*/ new JARStructure());
+ return determineStructureWithStructureDeployers(deployment, new FileStructure(), new WARStructure(), new JARStructure());
}
protected VFSDeploymentContext determineStructureWithStructureDeployers(VFSDeployment deployment, StructureDeployer... deployers) throws Exception
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/support/MockEarStructureDeployer.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -35,7 +35,7 @@
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.annotations.AnnotationEnvironment;
import org.jboss.deployers.spi.structure.ContextInfo;
-import org.jboss.deployers.vfs.plugins.structure.AbstractVFSStructureDeployer;
+import org.jboss.deployers.vfs.plugins.structure.AbstractVFSArchiveStructureDeployer;
import org.jboss.deployers.vfs.spi.structure.CandidateAnnotationsCallback;
import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.logging.Logger;
@@ -52,7 +52,7 @@
* @author Ales.Justin at jboss.org
* @version $Revision:$
*/
-public class MockEarStructureDeployer extends AbstractVFSStructureDeployer
+public class MockEarStructureDeployer extends AbstractVFSArchiveStructureDeployer
{
/**
* The default ear/lib filter
@@ -93,14 +93,21 @@
this.earLibFilter = earLibFilter;
}
- public boolean determineStructure(StructureContext structureContext) throws DeploymentException
+
+ @Override
+ protected boolean hasValidSuffix(String name)
{
+ return name.endsWith(".ear");
+ }
+
+ public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
+ {
ContextInfo context;
boolean valid;
VirtualFile file = structureContext.getFile();
try
{
- if (file.isFile() == true || file.getName().endsWith(".ear") == false)
+ if (hasValidSuffix(file.getName()) == false)
return false;
context = createContext(structureContext, "META-INF");
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/AbstractEARStructureTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -36,7 +36,6 @@
import org.jboss.test.deployers.vfs.structure.ear.support.Service;
import org.jboss.test.deployers.vfs.structure.ear.support.Servlet;
import org.jboss.test.deployers.vfs.structure.ear.support.Stateless;
-import org.jboss.vfs.plugins.context.jar.JarUtils;
/**
* Abstract ear structure deployer tests
@@ -64,7 +63,7 @@
protected VFSDeploymentContext determineStructure(VFSDeployment deployment) throws Exception
{
- Set<String> defaultSuffixes = JarUtils.getSuffixes();
+ Set<String> defaultSuffixes = JARStructure.DEFAULT_JAR_SUFFIXES;
JARStructure jarStructure = new JARStructure();
jarStructure.setSupportsCandidateAnnotations(true);
jarStructure.addCandidateAnnotation(Stateless.class);
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/InnerModificationUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/InnerModificationUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/ear/test/InnerModificationUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -65,6 +65,6 @@
{
VFSDeploymentContext root = assertDeploy("/structure/explicit", "explicit.ear");
assertChildContexts(root, "inner.war");
- assertUnpacked(root.getRoot().findChild("inner.war"));
+ assertTrue(root.getRoot().getChild("inner.war").isDirectory());
}
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/explicit/test/ModificationTypeUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/explicit/test/ModificationTypeUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/explicit/test/ModificationTypeUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -65,6 +65,6 @@
{
VFSDeploymentContext root = assertDeploy("/structure/explicit", "explicit.ear");
assertChildContexts(root, "inner.war");
- assertUnpacked(root.getRoot().findChild("inner.war"));
+ assertTrue(root.getRoot().getChild("inner.war").isDirectory());
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/jar/test/ConfiguredSuffixJARStructureUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -39,7 +39,7 @@
public class ConfiguredSuffixJARStructureUnitTestCase extends BaseTestCase
{
/** The file structure deployer */
- private static final Set<String> defaultSuffixes = JARStructure.DEFAULT_SUFFIXES;
+ private static final Set<String> defaultSuffixes = JARStructure.DEFAULT_JAR_SUFFIXES;
public static Test suite()
{
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/DirRemovalModificationTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -94,7 +94,7 @@
File tmpParent = tmpFile.getParentFile();
tmpDir = new File(tmpParent, "tmp-dir");
assertTrue(tmpDir.mkdir());
- return VFS.createNewRoot(tmpDir.toURI());
+ return VFS.getChild(tmpDir.toURI());
}
protected void testStructureModified(VirtualFile root, StructureModificationChecker checker, VFSDeploymentUnit deploymentUnit) throws Exception
@@ -107,7 +107,7 @@
assertTrue(tmpDir.delete());
tmpDir = new File(parentDir, "tmp-dir");
assertTrue(tmpDir.mkdir());
- root = VFS.createNewRoot(tmpDir.toURI());
+ root = VFS.getChild(tmpDir.toURI());
assertTrue("We created new directory, expecting modified root.", checker.hasStructureBeenModified(root));
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/MetaDataStructureModificationTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -30,8 +30,8 @@
import org.jboss.deployers.vfs.spi.structure.modified.MetaDataStructureModificationChecker;
import org.jboss.deployers.vfs.spi.structure.modified.StructureCache;
import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
+import org.jboss.test.deployers.support.AssembledDirectory;
import org.jboss.test.deployers.vfs.structure.modified.support.XmlIncludeVirtualFileFilter;
-import org.jboss.vfs.AssembledDirectory;
import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
@@ -79,8 +79,8 @@
// already cached run
assertFalse(checker.hasStructureBeenModified(root));
- AssembledDirectory jar = (AssembledDirectory)ear.getChild("simple.jar");
- AssembledDirectory jarMD = (AssembledDirectory)jar.getChild("META-INF");
+ VirtualFile jar = ear.getChild("simple.jar");
+ VirtualFile jarMD = jar.getChild("META-INF");
// 'update' web-beans.xml
URL url = getResource("/webbeans/simple/jar/META-INF/web-beans.xml");
@@ -91,38 +91,46 @@
// should be the same
assertFalse(checker.hasStructureBeenModified(root));
+ AssembledDirectory jarMDAssembly = createAssembledDirectory(jarMD);
+
// add new xml
url = getResource("/scanning/smoke/META-INF/jboss-scanning.xml");
assertNotNull(url);
- jarMD.addChild(VFS.createNewRoot(url));
+ jarMDAssembly.add(VFS.getChild(url));
assertTrue(checker.hasStructureBeenModified(root));
// should be the same
assertFalse(checker.hasStructureBeenModified(root));
// 'remove' new xml
- jarMD = jar.mkdir("META-INF");
+
+ closeAssembly(jarMD);
+ jarMDAssembly = createAssembledDirectory(jarMD);
url = getResource("/dependency/module/META-INF/jboss-dependency.xml");
assertNotNull(url);
- jarMD.addChild(VFS.createNewRoot(url));
+ jarMDAssembly.add(VFS.getChild(url));
url = getResource("/webbeans/simple/ejb/META-INF/web-beans.xml");
assertNotNull(url);
- jarMD.addChild(VFS.createNewRoot(url));
+ jarMDAssembly.add(VFS.getChild(url));
assertTrue(checker.hasStructureBeenModified(root));
// should be the same
assertFalse(checker.hasStructureBeenModified(root));
// 'remove' whole metadata dir
- jar.mkdir("META-INF");
+ closeAssembly(jarMD);
+ jarMDAssembly = createAssembledDirectory(jarMD);
assertTrue(checker.hasStructureBeenModified(root));
}
public void testInitialEmptyDir() throws Exception
{
- AssembledDirectory top = createAssembledDirectory("top.jar", "top.jar");
- AssembledDirectory metainf = top.mkdir("META-INF");
+ VirtualFile topJar = VFS.getChild(getName()).getChild("top.jar");
+ createAssembledDirectory(topJar);
+ VirtualFile metaInf = topJar.getChild("META-INF");
+ AssembledDirectory metaInfAssembly = createAssembledDirectory(metaInf);
+
StructureModificationChecker checker = createStructureModificationChecker();
- VFSDeploymentUnit vdu = assertDeploy(top);
+ VFSDeploymentUnit vdu = assertDeploy(topJar);
try
{
VirtualFile root = vdu.getRoot();
@@ -130,7 +138,7 @@
URL url = getResource("/scanning/smoke/META-INF/jboss-scanning.xml");
assertNotNull(url);
- metainf.addChild(VFS.createNewRoot(url));
+ metaInfAssembly.add(VFS.getChild(url));
assertTrue(checker.hasStructureBeenModified(root));
}
finally
@@ -141,11 +149,13 @@
public void testMultipleChanges() throws Exception
{
- AssembledDirectory top = createAssembledDirectory("top.jar", "top.jar");
- AssembledDirectory metainf = top.mkdir("META-INF");
+ VirtualFile topJar = VFS.getChild(getName()).getChild("top.jar");
+ createAssembledDirectory(topJar);
+ VirtualFile metaInf = topJar.getChild("META-INF");
+ AssembledDirectory metaInfAssembly = createAssembledDirectory(metaInf);
StructureModificationChecker checker = createStructureModificationChecker();
- VFSDeploymentUnit vdu = assertDeploy(top);
+ VFSDeploymentUnit vdu = assertDeploy(topJar);
try
{
VirtualFile root = vdu.getRoot();
@@ -153,10 +163,10 @@
URL url1 = getResource("/scanning/smoke/META-INF/jboss-scanning.xml");
assertNotNull(url1);
- metainf.addChild(VFS.createNewRoot(url1));
+ metaInfAssembly.add(VFS.getChild(url1));
URL url2 = getResource("/dependency/module/META-INF/jboss-dependency.xml");
assertNotNull(url2);
- metainf.addChild(VFS.createNewRoot(url2));
+ metaInfAssembly.add(VFS.getChild(url2));
assertTrue(checker.hasStructureBeenModified(root));
assertFalse(checker.hasStructureBeenModified(root));
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/modified/test/SynchModificationTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -26,7 +26,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.net.URI;
import java.net.URL;
import junit.framework.Test;
@@ -35,7 +34,6 @@
import org.jboss.deployers.vfs.spi.structure.modified.StructureModificationChecker;
import org.jboss.deployers.vfs.spi.structure.modified.SynchAdapter;
import org.jboss.test.deployers.vfs.structure.modified.support.XmlIncludeVirtualFileFilter;
-import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
import org.jboss.vfs.VirtualFileFilter;
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/test/WARUnpackUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/test/WARUnpackUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structure/war/test/WARUnpackUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -23,12 +23,13 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
import org.jboss.test.deployers.vfs.structure.AbstractStructureTest;
import org.jboss.test.deployers.vfs.structure.support.WarUnpackStructure;
-import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.Automounter;
/**
* WARUnpackUnitTestCase.
@@ -56,6 +57,13 @@
{
VFSDeploymentContext root = assertDeploy("/structure/war/simple", "simple.war");
VirtualFile file = root.getRoot();
- assertSame(file, VFSUtils.unpack(file));
+ try {
+ Automounter.mount(file);
+ assertSame(root.getRoot(), file);
+ }
+ finally
+ {
+ Automounter.cleanup(file);
+ }
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -22,6 +22,7 @@
package org.jboss.test.deployers.vfs.structurebuilder.test;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
@@ -36,6 +37,7 @@
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.deployers.vfs.spi.structure.helpers.AbstractStructureDeployer;
import org.jboss.test.deployers.structure.structurebuilder.StructureBuilderTest;
import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
@@ -68,10 +70,10 @@
URL url = getDeploymentURL();
try
{
- VirtualFile file = VFS.getRoot(url);
+ VirtualFile file = VFS.getChild(url);
return new AbstractVFSDeployment(file);
}
- catch (IOException e)
+ catch (URISyntaxException e)
{
throw new RuntimeException("Failed to get virtual file " + url + " for " + getName());
}
@@ -115,7 +117,7 @@
else
{
VirtualFile root = context.getRoot();
- VirtualFile expected = root.findChild(metaDataPaths.get(0));
+ VirtualFile expected = root.getChild(metaDataPaths.get(0));
assertEquals(1, metaDataLocations.size());
assertEquals(expected, metaDataLocations.get(0));
}
@@ -138,12 +140,13 @@
ClassPathEntry entry = classPathEntries.get(i);
VirtualFile file = (i < cpSize) ? classPath.get(i) : null;
String path = entry.getPath();
+ String relativeFilePath = AbstractStructureDeployer.getRelativePath(context.getTopLevel().getRoot(), file);
if ("".equals(path))
- assertTrue(file == null || "".equals(file.getPathName()));
+ assertTrue("".equals(relativeFilePath));
else
{
assertNotNull(file);
- assertEquals(path, file.getPathName());
+ assertEquals(path, relativeFilePath);
}
}
}
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/structureprocessor/test/VFSStructureProcessorUnitTestCase.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -37,8 +37,8 @@
import org.jboss.deployers.vfs.plugins.structure.modify.ModificationTypeStructureProcessor;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
-import org.jboss.vfs.VFSUtils;
import org.jboss.vfs.VirtualFile;
+import org.jboss.vfs.util.Automounter;
/**
* VFSStructureProcessorUnitTestCase.
@@ -109,7 +109,7 @@
{
VFSDeploymentContext vdc = getTopDeploymentContext(main, path);
VirtualFile root = vdc.getRoot();
- assertTrue("Should be temp", VFSUtils.isTemporaryFile(root));
+ assertTrue("Should be temp", root.isDirectory());
}
finally
{
@@ -141,11 +141,11 @@
VirtualFile file = root.getChild("tempchild.jar");
try
{
- assertTrue("Should be temp", VFSUtils.isTemporaryFile(file));
+ assertTrue("Should be temp", file.isDirectory());
}
finally
{
- file.cleanup();
+ Automounter.cleanup(root);
}
}
finally
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/webbeans/test/AbstractWebBeansTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/webbeans/test/AbstractWebBeansTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/webbeans/test/AbstractWebBeansTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -31,7 +31,8 @@
import org.jboss.test.deployers.vfs.webbeans.support.util.SomeUtil;
import org.jboss.test.deployers.vfs.webbeans.support.web.ServletWebBean;
import org.jboss.test.deployers.vfs.webbeans.support.crm.CrmWebBean;
-import org.jboss.vfs.AssembledDirectory;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
/**
* AbstractWebBeansTest.
@@ -66,62 +67,48 @@
super.tearDown();
}
- protected AssembledDirectory createBasicEar() throws Exception
+ protected VirtualFile createBasicEar() throws Exception
{
- AssembledDirectory ear = createTopLevelWithUtil();
+ VirtualFile ear = createTopLevelWithUtil();
- AssembledDirectory jar = ear.mkdir("simple.jar");
- addPackage(jar, PlainJavaBean.class);
- addPath(jar, "/webbeans/simple/jar", "META-INF");
+ VirtualFile jar = ear.getChild("simple.jar");
+ createAssembledDirectory(jar)
+ .addPackage("", PlainJavaBean.class)
+ .addPath(getVirtualFile("/webbeans/simple/jar/META-INF"), "META-INF");
- AssembledDirectory ejbs = ear.mkdir("ejbs.jar");
- addPackage(ejbs, MySLSBean.class);
- addPath(ejbs, "/webbeans/simple/ejb", "META-INF");
+ VirtualFile ejbs = ear.getChild("ejbs.jar");
+ createAssembledDirectory(ejbs)
+ .addPackage("", MySLSBean.class)
+ .addPath(getVirtualFile("/webbeans/simple/ejb/META-INF"), "META-INF");
- AssembledDirectory war = ear.mkdir("simple.war");
- AssembledDirectory webinf = war.mkdir("WEB-INF");
- AssembledDirectory classes = webinf.mkdir("classes");
- addPackage(classes, ServletWebBean.class);
- addPath(war, "/webbeans/simple/web", "WEB-INF");
+
+ VirtualFile war = ear.getChild("simple.war");
+ createAssembledDirectory(war)
+ .addPackage("WEB-INF/classes", ServletWebBean.class)
+ .addPath(getVirtualFile("/webbeans/simple/web/WEB-INF"), "WEB-INF")
+ .addPackage("WEB-INF/lib/ui.jar", UIWebBean.class)
+ .addPath(getVirtualFile("/webbeans/simple/ui/META-INF"), "WEB-INF/lib/ui.jar/META-INF");
- AssembledDirectory lib = webinf.mkdir("lib");
-
- AssembledDirectory uijar = lib.mkdir("ui.jar");
- addPackage(uijar, UIWebBean.class);
- addPath(uijar, "/webbeans/simple/ui", "META-INF");
-
// war w/o web-beans.xml
+ war = ear.getChild("crm.war");
+ createAssembledDirectory(war)
+ .addPackage("WEB-INF/classes", NotWBJsfBean.class)
+ .addPackage("WEB-INF/lib/crm.jar", CrmWebBean.class)
+ .addPath(getVirtualFile("/webbeans/simple/crm/META-INF"), "WEB-INF/lib/crm.jar/META-INF");
- war = ear.mkdir("crm.war");
- webinf = war.mkdir("WEB-INF");
- classes = webinf.mkdir("classes");
- addPackage(classes, NotWBJsfBean.class);
-
- lib = webinf.mkdir("lib");
-
- uijar = lib.mkdir("crm.jar");
- addPackage(uijar, CrmWebBean.class);
- addPath(uijar, "/webbeans/simple/crm", "META-INF");
-
enableTrace("org.jboss.deployers");
return ear;
}
- protected AssembledDirectory createTopLevelWithUtil() throws Exception
+ protected VirtualFile createTopLevelWithUtil() throws Exception
{
- AssembledDirectory topLevel = createAssembledDirectory("top-level.ear", "top-level.ear");
- addPath(topLevel, "/webbeans/simple", "META-INF");
-
- AssembledDirectory earLib = topLevel.mkdir("lib");
-
- AssembledDirectory util = earLib.mkdir("util.jar");
- addPackage(util, SomeUtil.class);
-
- AssembledDirectory ext = earLib.mkdir("ext.jar");
- addPackage(ext, ExternalWebBean.class);
- addPath(ext, "/webbeans/simple/ext", "META-INF");
-
- return topLevel;
+ VirtualFile earFile = VFS.getChild(getName()).getChild("top-level.ear");
+ createAssembledDirectory(earFile)
+ .addPath(getVirtualFile("/webbeans/simple/META-INF"), "META-INF")
+ .addPackage("lib/util.jar", SomeUtil.class)
+ .addPackage("lib/ext.jar", ExternalWebBean.class)
+ .addPath(getVirtualFile("/webbeans/simple/ext/META-INF"), "lib/ext.jar/META-INF");
+ return earFile;
}
}
\ No newline at end of file
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/java/org/jboss/test/deployers/vfs/xb/test/AbstractSchemaResolverXBTest.java 2009-12-18 17:14:12 UTC (rev 97994)
@@ -61,7 +61,7 @@
String common = "/org/jboss/test/deployers/vfs/xb/test/deployment";
URL url = getClass().getResource(common);
assertNotNull(url);
- VirtualFile file = VFS.getRoot(url);
+ VirtualFile file = VFS.getChild(url);
assertNotNull(file);
VFSDeploymentContext context = new AbstractVFSDeploymentContext(file, "");
Modified: projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/resources/bootstrap/bootstrap.xml
===================================================================
--- projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/resources/bootstrap/bootstrap.xml 2009-12-18 15:46:23 UTC (rev 97993)
+++ projects/jboss-deployers/branches/vfs3/deployers-vfs/src/test/resources/bootstrap/bootstrap.xml 2009-12-18 17:14:12 UTC (rev 97994)
@@ -52,7 +52,7 @@
<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.vfs.plugins.vfs.helpers.SuffixesExcludeFilter">
+ <bean name="JARFilter" class="org.jboss.vfs.util.SuffixesExcludeFilter">
<constructor><parameter>
<list elementClass="java.lang.String">
<!-- Exclude class files as subdeployments -->
More information about the jboss-cvs-commits
mailing list