[jboss-cvs] JBossAS SVN: r57880 - in projects/microcontainer/trunk/deployers/src: resources/tests/structure resources/tests/structure/ear resources/tests/structure/ear/complexwithappxml.ear resources/tests/structure/ear/complexwithappxml.ear/META-INF resources/tests/structure/ear/complexwithappxml.ear/lib resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/META-INF resources/tests/structure/ear/simplewithappxml.ear resources/tests/structure/ear/simplewithappxml.ear/META-INF resources/tests/structure/ear/simplewithappxml.ear/lib tests/org/jboss/test/deployers/structure tests/org/jboss/test/deployers/structure/ear tests/org/jboss/test/deployers/structure/ear/support tests/org/jboss/test/deployers/structure/ear/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 27 00:40:01 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-10-27 00:39:50 -0400 (Fri, 27 Oct 2006)
New Revision: 57880

Added:
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/META-INF/application.properties
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/lib/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/lib/lib0.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-bean1ejb.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-bean2.ejb3/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-client1.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/META-INF/jboss-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/extensions.aop/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/submbean.sar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/submbean2-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mcf1-ds.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mcf1.rar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-web1.war/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-bean1ejb.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-bean2.ejb3/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-client1.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-mbean1.sar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-mcf1-ds.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-mcf1.rar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-web1.war/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/notanear/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/META-INF/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/META-INF/application.properties
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/lib/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/lib/lib0.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-bean1ejb.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-bean2.ejb3/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-client1.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-mbean1.sar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-mcf1-ds.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-mcf1.rar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-web1.war/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-bean1ejb.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-bean2.ejb3/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-client1.jar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-mbean1.sar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-mcf1-ds.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-mcf1.rar/
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-service.xml
   projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-web1.war/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/EarModule.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java
Modified:
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
Log:
Add tests of a mock ear structure deployer

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/META-INF/application.properties
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/META-INF/application.properties	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/META-INF/application.properties	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1,8 @@
+service1=module-service.xml
+bean1ejb=module-bean1ejb.jar
+bean2=module-bean2.ejb3
+client1=module-client1.jar
+mbean1=module-mbean1.sar
+mcf1-ds=module-mcf1-ds.xml
+rar1=module-mcf1.rar
+war1=module-web1.war

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/META-INF/jboss-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/META-INF/jboss-service.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/META-INF/jboss-service.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<server />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/submbean2-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/submbean2-service.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mbean1.sar/submbean2-service.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<server />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mcf1-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mcf1-ds.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-mcf1-ds.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<datasource />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-service.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/module-service.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<service/>
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-mcf1-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-mcf1-ds.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-mcf1-ds.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<datasource />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-service.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/complexwithappxml.ear/notinapp-service.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<service />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/META-INF/application.properties
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/META-INF/application.properties	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/META-INF/application.properties	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1,8 @@
+service1=module-service.xml
+bean1ejb=module-bean1ejb.jar
+bean2=module-bean2.ejb3
+client1=module-client1.jar
+mbean1=module-mbean1.sar
+mcf1-ds=module-mcf1-ds.xml
+rar1=module-mcf1.rar
+war1=module-web1.war

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-mcf1-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-mcf1-ds.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-mcf1-ds.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<datasource />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-service.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/module-service.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<service/>
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-mcf1-ds.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-mcf1-ds.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-mcf1-ds.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<datasource />
\ No newline at end of file

Added: projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-service.xml
===================================================================
--- projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-service.xml	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/resources/tests/structure/ear/simplewithappxml.ear/notinapp-service.xml	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1 @@
+<service />
\ No newline at end of file

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/StructureTestSuite.java	2006-10-27 04:39:50 UTC (rev 57880)
@@ -25,6 +25,7 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
+import org.jboss.test.deployers.structure.ear.test.EARStructureUnitTestCase;
 import org.jboss.test.deployers.structure.file.test.FileStructureUnitTestCase;
 import org.jboss.test.deployers.structure.jar.test.JARStructureUnitTestCase;
 import org.jboss.test.deployers.structure.main.test.MainDeployerFileStructureUnitTestCase;
@@ -54,6 +55,7 @@
       suite.addTest(FileStructureUnitTestCase.suite());
       suite.addTest(JARStructureUnitTestCase.suite());
       suite.addTest(WARStructureUnitTestCase.suite());
+      suite.addTest(EARStructureUnitTestCase.suite());
       suite.addTest(MainDeployerStructureUnitTestCase.suite());
       suite.addTest(MainDeployerStructureOrderingUnitTestCase.suite());
       suite.addTest(MainDeployerFileStructureUnitTestCase.suite());

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/EarModule.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/EarModule.java	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/EarModule.java	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1,56 @@
+/*
+ * 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.test.deployers.structure.ear.support;
+
+/**
+ * Represent an ear module entry
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class EarModule
+{
+   private String name;
+   private String fileName;
+
+   public EarModule(String name, String fileName)
+   {
+      this.name = name;
+      this.fileName = fileName;
+   }
+   public String getName()
+   {
+      return name;
+   }
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+   public String getFileName()
+   {
+      return fileName;
+   }
+   public void setFileName(String fileName)
+   {
+      this.fileName = fileName;
+   }
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/support/MockEarStructureDeployer.java	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1,209 @@
+/*
+ * 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.test.deployers.structure.ear.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jboss.deployers.plugins.structure.ContextInfoImpl;
+import org.jboss.deployers.plugins.structure.vfs.AbstractStructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructureMetaData;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixMatchFilter;
+
+/**
+ * A mock ear structure deployer that illustrates concepts involved with an ear
+ * type of deployer.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MockEarStructureDeployer extends AbstractStructureDeployer
+{
+   /**
+    * The default ear/lib filter
+    */
+   public static final VirtualFileFilter DEFAULT_EAR_LIB_FILTER = new SuffixMatchFilter(".jar");
+
+   /**
+    * The ear/lib filter
+    */
+   private VirtualFileFilter earLibFilter = DEFAULT_EAR_LIB_FILTER;
+
+   @Override
+   public int getRelativeOrder()
+   {
+      return 1000;
+   }
+
+   /**
+    * Get the earLibFilter.
+    * 
+    * @return the earLibFilter.
+    */
+   public VirtualFileFilter getEarLibFilter()
+   {
+      return earLibFilter;
+   }
+
+   /**
+    * Set the earLibFilter.
+    * 
+    * @param earLibFilter
+    * @throws IllegalArgumentException for a null filter
+    */
+   public void setEarLibFilter(VirtualFileFilter earLibFilter)
+   {
+      if (earLibFilter == null)
+         throw new IllegalArgumentException("Null filter");
+      this.earLibFilter = earLibFilter;
+   }
+
+   /**
+    * Determine the structure of the ear.
+    * 
+    * @param root - a candidate ear file
+    * @param metaData - the structure metadata to populate
+    * @param deployers - the deployer chain to use for subdeployment recoginition.
+    */
+   public boolean determineStructure(VirtualFile root,
+         StructureMetaData metaData, StructuredDeployers deployers)
+   {
+      boolean valid = false;
+      try
+      {
+         if (root.isLeaf() == true || root.getName().endsWith(".ear") == false)
+            return false;
+
+         ContextInfoImpl context = new ContextInfoImpl(root.getPathName());
+         context.setMetaDataPath("META-INF");
+
+         VirtualFile applicationProps = getMetaDataFile(root, "META-INF/application.properties");
+         boolean scan = true;
+         List<EarModule> modules = new ArrayList<EarModule>();
+         if (applicationProps != null)
+         {
+            // This is a simple module-name=earPath properties file
+            InputStream in = applicationProps.openStream();
+            Properties props = new Properties();
+            props.load(in);
+            in.close();
+            scan = false;
+            for(Object key : props.keySet())
+            {
+               String name = (String) key;
+               String fileName = props.getProperty(name);
+               EarModule module = new EarModule(name, fileName);
+               modules.add(module);
+            }
+         }
+         // Add the ear lib contents to the classpath
+         String libDir = "lib";
+         try
+         {
+            VirtualFile lib = root.findChild(libDir);
+            if (lib != null)
+            {
+               List<VirtualFile> archives = lib.getChildren(earLibFilter);
+               for (VirtualFile archive : archives)
+                  super.addClassPath(root, archive, true, true, context);
+            }
+         }
+         catch (IOException ignored)
+         {
+            // lib directory does not exist
+         }
+
+         // Add the ear manifest locations?
+         super.addClassPath(root, root, false, true, context);
+         metaData.addContext(context);
+
+         // TODO: need to scan for annotationss
+         if (scan)
+         {
+            throw new RuntimeException("Scanning not implemented: "+root.getName());
+         }
+         else
+         {
+            // Create subdeployments for the ear modules
+            for(EarModule mod : modules)
+            {
+               String fileName = mod.getFileName();
+               if (fileName != null && (fileName = fileName.trim()).length() > 0)
+               {
+                  try
+                  {
+                     VirtualFile module = root.findChild(fileName);
+                     if (module == null)
+                     {
+                        throw new RuntimeException(fileName
+                                    + " module listed in application.xml does not exist within .ear "
+                                    + root.getName());
+                     }
+                     // Ask the deployers to analyze this
+                     if( deployers.determineStructure(module, metaData) == false )
+                     {
+                        throw new RuntimeException(fileName
+                              + " module listed in application.xml is not a recognized deployment, .ear: "
+                              + root.getName());
+                     }
+                  }
+                  catch (IOException e)
+                  {
+                     throw new RuntimeException(fileName
+                                 + " module listed in application.xml does not exist within .ear "
+                                 + root.getName(), e);
+                  }
+               }
+            }
+         }
+
+         valid = true;
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Error determining structure: "+ root.getName(), e);
+      }
+
+      return valid;
+   }
+
+   private VirtualFile getMetaDataFile(VirtualFile file, String path)
+   {
+      VirtualFile metaFile = null;
+      try
+      {
+         metaFile = file.findChild(path);
+      }
+      catch (IOException e)
+      {
+      }
+      return metaFile;
+   }
+
+}

Added: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java	2006-10-27 04:39:03 UTC (rev 57879)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java	2006-10-27 04:39:50 UTC (rev 57880)
@@ -0,0 +1,190 @@
+/*
+* 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 softeare; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Softeare Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This softeare is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied earranty 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 softeare; if not, write to the Free
+* Softeare 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.structure.ear.test;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.deployers.plugins.structure.BasicStructuredDeployers;
+import org.jboss.deployers.plugins.structure.vfs.file.FileStructure;
+import org.jboss.deployers.plugins.structure.vfs.jar.JARStructure;
+import org.jboss.deployers.plugins.structure.vfs.war.WARStructure;
+import org.jboss.deployers.spi.structure.DeploymentContext;
+import org.jboss.deployers.spi.structure.vfs.StructureDeployer;
+import org.jboss.deployers.spi.structure.vfs.StructuredDeployers;
+import org.jboss.test.deployers.BaseDeployersTest;
+import org.jboss.test.deployers.structure.ear.support.MockEarStructureDeployer;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Mock ear structure deployer tests
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class EARStructureUnitTestCase extends BaseDeployersTest
+{
+   /** The ear structure deployer */
+   private static final MockEarStructureDeployer structure = new MockEarStructureDeployer();
+   
+   public static Test suite()
+   {
+      return new TestSuite(EARStructureUnitTestCase.class);
+   }
+   
+   public EARStructureUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      enableTrace("org.jboss.deployers");
+   }
+
+   @Override
+   protected StructureDeployer getStrucutureDeployer()
+   {
+      return structure;
+   }
+
+   /**
+    * We need more than just the ear deployer since ears are containers
+    * for other deployments so we add them here.
+    */
+   @Override
+   protected StructuredDeployers getStrucuturedDeployers()
+   {
+      BasicStructuredDeployers deployers = new BasicStructuredDeployers();
+      FileStructure fs = new FileStructure();
+      WARStructure ws = new WARStructure();
+      JARStructure js = new JARStructure();
+      HashSet<String> suffixes = new HashSet<String>(js.getSuffixes());
+      suffixes.add(".ejb3");
+      js.setSuffixes(suffixes);
+      deployers.addDeployer(getStrucutureDeployer());
+      deployers.addDeployer(fs);
+      deployers.addDeployer(ws);
+      deployers.addDeployer(js);
+      return deployers;
+   }
+
+   protected DeploymentContext assertValidContext(String root, String path)
+      throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      boolean recognized = determineStructure(context, false);
+      assertTrue("Structure should be valid: " + context.getName(), recognized);
+      return context;
+   }
+
+   protected DeploymentContext assertNotValidContext(String root, String path)
+      throws Exception
+   {
+      DeploymentContext context = createDeploymentContext(root, path);
+      boolean recognized = determineStructure(context, false);
+      assertFalse("Structure should not be valid: " + context.getName(), recognized);
+      return context;
+   }
+   
+   public void testNotAnEAR() throws Exception
+   {
+      assertNotValidContext("/structure/", "ear/notanear");
+   }
+
+   /**
+    * Validate a basic ear with modules having no subdeployments 
+    * @throws Exception
+    */
+   public void testSimpleWithAppXml() throws Exception
+   {      
+      DeploymentContext ear = assertValidContext("/structure/", "ear/simplewithappxml.ear");
+      List<VirtualFile> classpath = ear.getClassPath();
+      assertNotNull("classpath", classpath);
+      assertEquals("classpath.size = 1", 1, classpath.size());
+      VirtualFile earFile = ear.getRoot();
+      VirtualFile j0 = earFile.findChild("lib/lib0.jar");
+      assertTrue("lib/j0.jar in classpath", classpath.contains(j0));
+      // Validate that the expected module contexts exist
+      HashSet<String> expected = new HashSet<String>();
+      URL rootURL = ear.getRoot().toURL();
+      expected.add("module-service.xml");
+      expected.add("module-bean1ejb.jar/");
+      expected.add("module-bean2.ejb3/");
+      expected.add("module-client1.jar/");
+      expected.add("module-mbean1.sar/");
+      expected.add("module-mcf1-ds.xml");
+      expected.add("module-mcf1.rar/");
+      expected.add("module-web1.war/");
+      Set<DeploymentContext> children = ear.getChildren();
+      Set<String> childPaths = super.createDeploymentPathSet(children, rootURL);
+      assertEquals("ear child count", expected, childPaths);
+   }
+
+   /**
+    * Validate a ear with modules having subdeployments 
+    * @throws Exception
+    */
+   public void testComplexWithAppXml() throws Exception
+   {      
+      DeploymentContext ear = assertValidContext("/structure/", "ear/complexwithappxml.ear");
+      List<VirtualFile> classpath = ear.getClassPath();
+      assertNotNull("classpath", classpath);
+      assertEquals("classpath.size = 1", 1, classpath.size());
+      VirtualFile earFile = ear.getRoot();
+      VirtualFile j0 = earFile.findChild("lib/lib0.jar");
+      assertTrue("lib/j0.jar in classpath", classpath.contains(j0));
+      // Validate that the expected module contexts exist
+      HashSet<String> expected = new HashSet<String>();
+      URL rootURL = ear.getRoot().toURL();
+      expected.add("module-service.xml");
+      expected.add("module-bean1ejb.jar/");
+      expected.add("module-bean2.ejb3/");
+      expected.add("module-client1.jar/");
+      expected.add("module-mbean1.sar/");
+      expected.add("module-mcf1-ds.xml");
+      expected.add("module-mcf1.rar/");
+      expected.add("module-web1.war/");
+      Set<DeploymentContext> children = ear.getChildren();
+      Set<String> childPaths = super.createDeploymentPathSet(children, rootURL);
+      assertEquals("ear child count", expected, childPaths);
+
+      // Validate that the expected module subdeployments are there
+      Map<String, DeploymentContext> pathMap = createDeploymentPathMap(ear);
+      DeploymentContext extensionsAop = pathMap.get("complexwithappxml.ear/module-mbean1.sar/extensions.aop");
+      assertNotNull("complexwithappxml.ear/module-mbean1.sar/extensions.aop/", extensionsAop);
+      DeploymentContext submbean1 = pathMap.get("complexwithappxml.ear/module-mbean1.sar/submbean.sar");
+      assertNotNull("complexwithappxml.ear/submbean.sar", submbean1);
+      DeploymentContext submbean2 = pathMap.get("complexwithappxml.ear/module-mbean1.sar/submbean2-service.xml");
+      assertNotNull("complexwithappxml.ear/submbean2-service.xml", submbean2);
+   }
+   
+}




More information about the jboss-cvs-commits mailing list