[jboss-cvs] JBossAS SVN: r70780 - in projects/jboss-deployers/trunk: deployers-vfs/src/resources/tests/structurebuilder/predetermined/testClasspathEntries and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 12 12:33:49 EDT 2008


Author: alesj
Date: 2008-03-12 12:33:49 -0400 (Wed, 12 Mar 2008)
New Revision: 70780

Added:
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structurebuilder/predetermined/testClasspathEntries/META-INF/
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structurebuilder/predetermined/testClasspathEntries/META-INF/jboss-structure.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/ChildFileStructure.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/TestStructuralDeployers.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/FilesStructureBuilderUnitTestCase.java
Modified:
   projects/jboss-deployers/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/structurebuilder/AbstractStructureBuilderTest.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/VFSStructureBuilderTestSuite.java
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java
Log:
JBDEPLOY-11; adding file system tests.

Modified: projects/jboss-deployers/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/structurebuilder/AbstractStructureBuilderTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/structurebuilder/AbstractStructureBuilderTest.java	2008-03-12 16:15:37 UTC (rev 70779)
+++ projects/jboss-deployers/trunk/deployers-structure-spi/src/tests/org/jboss/test/deployers/structure/structurebuilder/AbstractStructureBuilderTest.java	2008-03-12 16:33:49 UTC (rev 70780)
@@ -38,6 +38,7 @@
 /**
  * AbstractStructureBuilderTest.
  * 
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
  * @author <a href="adrian at jboss.org">Adrian Brock</a>
  * @version $Revision: 1.1 $
  */
@@ -65,6 +66,13 @@
 
    public void testSimple() throws Exception
    {
+      Deployment deployment = createSimple();
+      DeploymentContext context = build(deployment);
+      checkDeployment(context, deployment);
+   }
+
+   protected Deployment createSimple() throws Exception
+   {
       Deployment deployment = createDeployment();
       StructureMetaData structure = StructureMetaDataFactory.createStructureMetaData();
       MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
@@ -72,12 +80,17 @@
 
       DeploymentFactory factory = getDeploymentFactory();
       factory.addContext(deployment, "");
+      return deployment;
+   }
 
+   public void testSimpleWithAttachment() throws Exception
+   {
+      Deployment deployment = createSimpleWithAttachment();
       DeploymentContext context = build(deployment);
       checkDeployment(context, deployment);
    }
-   
-   public void testSimpleWithAttachment() throws Exception
+
+   protected Deployment createSimpleWithAttachment() throws Exception
    {
       Deployment deployment = createDeployment();
       StructureMetaData structure = StructureMetaDataFactory.createStructureMetaData();
@@ -87,53 +100,71 @@
 
       DeploymentFactory factory = getDeploymentFactory();
       factory.addContext(deployment, "");
+      return deployment;
+   }
 
+   public void testOneChild() throws Exception
+   {
+      Deployment deployment = createOneChild();
       DeploymentContext context = build(deployment);
       checkDeployment(context, deployment);
    }
-   
-   public void testOneChild() throws Exception
+
+   protected Deployment createOneChild() throws Exception
    {
       DeploymentFactory factory = getDeploymentFactory();
       Deployment deployment = createDeployment(factory);
       factory.addContext(deployment, "child1");
-      
+      return deployment;
+   }
+
+   public void testManyChildren() throws Exception
+   {
+      Deployment deployment = createManyChildren();
       DeploymentContext context = build(deployment);
       checkDeployment(context, deployment);
    }
-   
-   public void testManyChildren() throws Exception
+
+   protected Deployment createManyChildren() throws Exception
    {
       DeploymentFactory factory = getDeploymentFactory();
       Deployment deployment = createDeployment(factory);
       factory.addContext(deployment, "child1");
       factory.addContext(deployment, "child2");
       factory.addContext(deployment, "child3");
-      
+      return deployment;
+   }
+
+   public void testMetaDataLocation() throws Exception
+   {
+      Deployment deployment = createMetaDataLocation();
       DeploymentContext context = build(deployment);
       checkDeployment(context, deployment);
    }
-   
-   public void testMetaDataLocation() throws Exception
+
+   protected Deployment createMetaDataLocation() throws Exception
    {
       DeploymentFactory factory = getDeploymentFactory();
       Deployment deployment = createDeployment();
       factory.addContext(deployment, "", ContextInfo.DEFAULT_METADATA_PATH, DeploymentFactory.createClassPath(""));
-      
+      return deployment;
+   }
+
+   public void testClasspathEntries() throws Exception
+   {
+      Deployment deployment = createClasspathEntries();
       DeploymentContext context = build(deployment);
       checkDeployment(context, deployment);
    }
-   
-   public void testClasspathEntries() throws Exception
+
+   protected Deployment createClasspathEntries() throws Exception
    {
       DeploymentFactory factory = getDeploymentFactory();
       Deployment deployment = createDeployment();
       ContextInfo contextInfo = factory.addContext(deployment, "");
       contextInfo.addClassPathEntry(DeploymentFactory.createClassPathEntry("cp1.txt"));
       contextInfo.addClassPathEntry(DeploymentFactory.createClassPathEntry("cp2.txt"));
-
-      DeploymentContext context = build(deployment);
-      checkDeployment(context, deployment);
+      return deployment;
    }
 
    protected void checkDeployment(DeploymentContext context, Deployment deployment) throws Exception
@@ -145,6 +176,8 @@
       MutableAttachments attachments = (MutableAttachments) deployment.getPredeterminedManagedObjects();
       StructureMetaData structure = attachments.getAttachment(StructureMetaData.class);
       checkAttachments(context, deployment);
+
+      assertNotNull(structure);
       checkDeployment(context, structure);
 
       ContextInfo contextInfo = structure.getContext("");
@@ -175,6 +208,7 @@
    protected void checkDeployment(DeploymentContext context, StructureMetaData structure) throws Exception
    {
       assertNotNull(context);
+      assertNotNull(structure);
       
       List<ContextInfo> contextInfos = structure.getContexts();
       int numContexts = contextInfos.size();

Added: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structurebuilder/predetermined/testClasspathEntries/META-INF/jboss-structure.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structurebuilder/predetermined/testClasspathEntries/META-INF/jboss-structure.xml	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/structurebuilder/predetermined/testClasspathEntries/META-INF/jboss-structure.xml	2008-03-12 16:33:49 UTC (rev 70780)
@@ -0,0 +1,9 @@
+<structure>
+	<context>
+		<path name=""/>
+      <classpath>
+			<path name="cp1.txt"/>
+			<path name="cp2.txt"/>
+		</classpath>
+	</context>
+</structure>

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/VFSStructureBuilderTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/VFSStructureBuilderTestSuite.java	2008-03-12 16:15:37 UTC (rev 70779)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/VFSStructureBuilderTestSuite.java	2008-03-12 16:33:49 UTC (rev 70780)
@@ -26,6 +26,7 @@
 import junit.textui.TestRunner;
 
 import org.jboss.test.deployers.vfs.structurebuilder.test.VFSStructureBuilderUnitTestCase;
+import org.jboss.test.deployers.vfs.structurebuilder.test.FilesStructureBuilderUnitTestCase;
 
 /**
  * VFSStructureBuilderTestSuite.
@@ -45,7 +46,8 @@
       TestSuite suite = new TestSuite("VFS Structure Builder Tests");
 
       suite.addTest(VFSStructureBuilderUnitTestCase.suite());
-      
+      suite.addTest(FilesStructureBuilderUnitTestCase.suite());
+
       return suite;
    }
 }

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/ChildFileStructure.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/ChildFileStructure.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/ChildFileStructure.java	2008-03-12 16:33:49 UTC (rev 70780)
@@ -0,0 +1,36 @@
+/*
+* 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.structurebuilder.support;
+
+import org.jboss.deployers.vfs.plugins.structure.file.FileStructure;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ChildFileStructure extends FileStructure
+{
+   protected boolean checkFileMatchers(VirtualFile file)
+   {
+      return file.getName().contains("child");
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/TestStructuralDeployers.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/TestStructuralDeployers.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/support/TestStructuralDeployers.java	2008-03-12 16:33:49 UTC (rev 70780)
@@ -0,0 +1,40 @@
+/*
+* 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.structurebuilder.support;
+
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class TestStructuralDeployers extends VFSStructuralDeployersImpl
+{
+   @Override
+   protected void determineStructure(Deployment deployment, StructureMetaData structure) throws Exception
+   {
+      super.determineStructure(deployment, structure);
+      ((MutableAttachments)deployment.getPredeterminedManagedObjects()).addAttachment(StructureMetaData.class, structure);
+   }
+}

Added: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/FilesStructureBuilderUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/FilesStructureBuilderUnitTestCase.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/FilesStructureBuilderUnitTestCase.java	2008-03-12 16:33:49 UTC (rev 70780)
@@ -0,0 +1,116 @@
+/*
+* 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.structurebuilder.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl;
+import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+import org.jboss.deployers.vfs.plugins.structure.explicit.DeclaredStructure;
+import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.structure.StructureDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentContext;
+import org.jboss.test.deployers.vfs.structurebuilder.support.ChildFileStructure;
+import org.jboss.test.deployers.vfs.structurebuilder.support.TestStructuralDeployers;
+
+/**
+ * FilesStructureBuilderUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class FilesStructureBuilderUnitTestCase extends VFSStructureBuilderUnitTestCase
+{
+   public static Test suite()
+   {
+      return new TestSuite(FilesStructureBuilderUnitTestCase.class);
+   }
+
+   public FilesStructureBuilderUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   protected DeploymentContext build(Deployment deployment) throws DeploymentException
+   {
+      return deployment.getPredeterminedManagedObjects().getAttachment(DeploymentContext.class);
+   }
+
+   protected Deployment createDeployment(StructureDeployer... deployers) throws Exception
+   {
+      VFSDeployment deployment = createDeployment();
+      VFSDeploymentContext context = determineStructureWithStructureDeployers(deployment, deployers);
+      ((MutableAttachments)deployment.getPredeterminedManagedObjects()).addAttachment(DeploymentContext.class, context);
+      return deployment;
+   }
+
+   protected VFSDeploymentContext determineStructureWithStructureDeployers(VFSDeployment deployment, StructureDeployer... deployers) throws Exception
+   {
+      VFSStructuralDeployersImpl structuralDeployers = new TestStructuralDeployers();
+      VFSStructureBuilder builder = getStructureBuilder();
+      structuralDeployers.setStructureBuilder(builder);
+
+      for (StructureDeployer deployer : deployers)
+         structuralDeployers.addDeployer(deployer);
+
+      return (VFSDeploymentContext) structuralDeployers.determineStructure(deployment);
+   }
+
+   protected Deployment createDefaultDeployment() throws Exception
+   {
+      return createDeployment(new DeclaredStructure(), new ChildFileStructure(), new JARStructure());
+   }
+
+   protected Deployment createSimple() throws Exception
+   {
+      return createDefaultDeployment();
+   }
+
+   protected Deployment createSimpleWithAttachment() throws Exception
+   {
+      return createDefaultDeployment();
+   }
+
+   protected Deployment createOneChild() throws Exception
+   {
+      return createDefaultDeployment();
+   }
+
+   protected Deployment createManyChildren() throws Exception
+   {
+      return createDefaultDeployment();
+   }
+
+   protected Deployment createMetaDataLocation() throws Exception
+   {
+      return createDefaultDeployment();
+   }
+
+   protected Deployment createClasspathEntries() throws Exception
+   {
+      return createDefaultDeployment();
+   }
+}

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java	2008-03-12 16:15:37 UTC (rev 70779)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/structurebuilder/test/VFSStructureBuilderUnitTestCase.java	2008-03-12 16:33:49 UTC (rev 70780)
@@ -27,15 +27,13 @@
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-
-import org.jboss.deployers.client.spi.Deployment;
 import org.jboss.deployers.client.spi.DeploymentFactory;
 import org.jboss.deployers.spi.structure.ClassPathEntry;
 import org.jboss.deployers.spi.structure.ContextInfo;
 import org.jboss.deployers.structure.spi.DeploymentContext;
-import org.jboss.deployers.structure.spi.StructureBuilder;
 import org.jboss.deployers.vfs.plugins.client.AbstractVFSDeployment;
 import org.jboss.deployers.vfs.plugins.structure.VFSStructureBuilder;
+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.test.deployers.structure.structurebuilder.StructureBuilderTest;
@@ -60,12 +58,12 @@
       super(name);
    }
 
-   protected StructureBuilder getStructureBuilder()
+   protected VFSStructureBuilder getStructureBuilder()
    {
       return new VFSStructureBuilder();
    }
 
-   protected Deployment createDeployment()
+   protected VFSDeployment createDeployment()
    {
       URL url = getDeploymentURL();
       try




More information about the jboss-cvs-commits mailing list