[webbeans-commits] Webbeans SVN: r2377 - in test-harness/trunk: impl/src/main/java/org/jboss/testharness/impl/packaging/ear and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Thu Apr 9 19:12:44 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-04-09 19:12:44 -0400 (Thu, 09 Apr 2009)
New Revision: 2377

Added:
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarXml.java
Modified:
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EarArtifactDescriptor.java
   test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarArtifactDescriptor.java
   test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
Log:
add ejbjarxml

Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java	2009-04-09 22:30:05 UTC (rev 2376)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ArtifactGenerator.java	2009-04-09 23:12:44 UTC (rev 2377)
@@ -18,6 +18,7 @@
 import org.jboss.testharness.api.Configuration;
 import org.jboss.testharness.api.ResourceDescriptor;
 import org.jboss.testharness.impl.packaging.ear.EarArtifactDescriptor;
+import org.jboss.testharness.impl.packaging.ear.EjbJarXml;
 import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
 import org.jboss.testharness.impl.packaging.jsr299.JSR299ArtifactDescriptor;
 import org.jboss.testharness.impl.packaging.jsr299.TCKArtifactDescriptor;
@@ -35,6 +36,7 @@
       private final boolean runLocally;
       private final boolean addDeclaringPackage;
       private final String beansXml;
+      private final String ejbJarXml;
       private final PackagingType packagingType;
       private final Collection<ResourceDescriptor> resources;
       private final Collection<Class<?>> classes;
@@ -78,6 +80,16 @@
             this.packagingType = WAR;
          }
          
+         if (declaringClass.isAnnotationPresent(EjbJarXml.class))
+         {
+            this.ejbJarXml = asAbsolutePath(declaringClass.getAnnotation(EjbJarXml.class).value());	
+         }
+         else
+         {
+            this.ejbJarXml = null;
+         }
+        	 
+         
          if (declaringClass.isAnnotationPresent(IntegrationTest.class))
          {
             this.unit = false;
@@ -151,7 +163,7 @@
       
       public TCKArtifactDescriptor createArtifact()
       {
-         final TCKArtifactDescriptor artifact = newArtifact(packagingType, declaringClass, beansXml, standalone, addDeclaringPackage);
+         final TCKArtifactDescriptor artifact = newArtifact(packagingType, declaringClass, beansXml, ejbJarXml, standalone, addDeclaringPackage);
          artifact.setUnit(unit);
          artifact.setRunLocally(runLocally);
          artifact.setExpectedDeploymentException(expectedDeploymentException);
@@ -189,16 +201,20 @@
          }
       }
       
-      private static TCKArtifactDescriptor newArtifact(PackagingType packagingType, Class<?> declaringClass, String beansXml, boolean standalone, boolean addDeclaringPackage)
+      private static TCKArtifactDescriptor newArtifact(PackagingType packagingType, Class<?> declaringClass, String beansXml, String ejbJarXml, boolean standalone, boolean addDeclaringPackage)
       {
          TCKArtifactDescriptor artifact;
          if (!standalone && packagingType.equals(WAR))
          {
                artifact = new WarArtifactDescriptor(declaringClass, beansXml).initialize();
+               if (ejbJarXml != null)
+               {
+                  artifact.getResources().add(new ResourceDescriptorImpl("WEB-INF/ejb-jar.xml", ejbJarXml));
+               }
          } 
          else if (!standalone && packagingType.equals(EAR))
          {
-            artifact = new EarArtifactDescriptor(declaringClass, beansXml).initialize();
+            artifact = new EarArtifactDescriptor(declaringClass, beansXml, ejbJarXml).initialize();
          }
          else
          {

Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EarArtifactDescriptor.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EarArtifactDescriptor.java	2009-04-09 22:30:05 UTC (rev 2376)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EarArtifactDescriptor.java	2009-04-09 23:12:44 UTC (rev 2377)
@@ -24,10 +24,10 @@
    private final EjbJarArtifactDescriptor ejbJar;
    private final WarArtifactDescriptor war;
    
-   public EarArtifactDescriptor(Class<?> declaringClass, String beansXmlSourceFileName)
+   public EarArtifactDescriptor(Class<?> declaringClass, String beansXmlSourceFileName, String ejbJarXml)
    {
       super(declaringClass, null);
-      this.ejbJar = new EjbJarArtifactDescriptor(declaringClass, beansXmlSourceFileName).initialize();
+      this.ejbJar = new EjbJarArtifactDescriptor(declaringClass, beansXmlSourceFileName, ejbJarXml).initialize();
       this.war = new WarArtifactDescriptor(declaringClass, null)
       {
          

Modified: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarArtifactDescriptor.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarArtifactDescriptor.java	2009-04-09 22:30:05 UTC (rev 2376)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarArtifactDescriptor.java	2009-04-09 23:12:44 UTC (rev 2377)
@@ -13,21 +13,32 @@
    public static final String STANDARD_EJB_JAR_XML_FILE_NAME = "org/jboss/testharness/impl/packaging/ear/ejb-jar.xml";
    public static final String CUSTOM_EJB_JAR_XML_FILE_NAME = "org/jboss/testharness/impl/packaging/ear/custom-ejb-jar.xml";
    
-   public EjbJarArtifactDescriptor(Class<?> declaringClass, String beansXmlSourceFileName)
+   private final String ejbJarXml;
+   
+   public EjbJarArtifactDescriptor(Class<?> declaringClass, String beansXmlSourceFileName, String ejbJarXml)
    {
       super(declaringClass, beansXmlSourceFileName);
+      this.ejbJarXml = ejbJarXml;
    }
    
    @Override
    public EjbJarArtifactDescriptor initialize()
    {
       super.initialize();
-      URL ejbJarXml = loadResource(CUSTOM_EJB_JAR_XML_FILE_NAME);
-      if (ejbJarXml == null)
+      if (ejbJarXml != null)
       {
-         ejbJarXml = loadResource(STANDARD_EJB_JAR_XML_FILE_NAME);
+         getResources().add(new ResourceDescriptorImpl(EJB_JAR_XML_DESTINATION, ejbJarXml));
       }
-      getResources().add(new ResourceDescriptorImpl(EJB_JAR_XML_DESTINATION, ejbJarXml));
+      else
+      {
+         URL ejbJarXml = loadResource(CUSTOM_EJB_JAR_XML_FILE_NAME);
+         if (ejbJarXml == null)
+         {
+            ejbJarXml = loadResource(STANDARD_EJB_JAR_XML_FILE_NAME);
+         }
+         getResources().add(new ResourceDescriptorImpl(EJB_JAR_XML_DESTINATION, ejbJarXml));
+      }
+      
       return this;
    }
    

Added: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarXml.java
===================================================================
--- test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarXml.java	                        (rev 0)
+++ test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarXml.java	2009-04-09 23:12:44 UTC (rev 2377)
@@ -0,0 +1,33 @@
+package org.jboss.testharness.impl.packaging.ear;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.jboss.testharness.impl.packaging.Resource;
+
+/**
+ * Override the default META-INF/ejb-jar.xml
+ * 
+ * @see Resource
+ * 
+ * @author Pete Muir
+ *
+ */
+ at Documented
+ at Retention(RUNTIME)
+ at Target(TYPE)
+public @interface EjbJarXml
+{
+   
+   /**
+    * Location of the overriding file, relative to the current location or the
+    * root this classpath
+    * 
+    */
+   String value();
+   
+}


Property changes on: test-harness/trunk/impl/src/main/java/org/jboss/testharness/impl/packaging/ear/EjbJarXml.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java
===================================================================
--- test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java	2009-04-09 22:30:05 UTC (rev 2376)
+++ test-harness/trunk/tests/src/test/java/org/jboss/testharness/test/impl/packaging/descriptors/ear/EarArtifactTest.java	2009-04-09 23:12:44 UTC (rev 2377)
@@ -19,7 +19,7 @@
    @Test
    public void testDefaultEar() throws Exception
    {
-      EarArtifactDescriptor ear = new EarArtifactDescriptor(DummyTest.class, null).initialize();
+      EarArtifactDescriptor ear = new EarArtifactDescriptor(DummyTest.class, null, null).initialize();
       ear.getClasses().add(Cow.class);
       File root = ear.getExplodedJar();
       assert root.isDirectory();
@@ -117,7 +117,7 @@
    @Test
    public void testJarProduction() throws Exception
    {
-      EarArtifactDescriptor ear = new EarArtifactDescriptor(DummyTest.class, null).initialize();
+      EarArtifactDescriptor ear = new EarArtifactDescriptor(DummyTest.class, null, null).initialize();
       ear.getClasses().add(Cow.class);
       JarInputStream is = new JarInputStream(ear.getJarAsStream());
       JarEntry entry;




More information about the weld-commits mailing list