You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by am...@apache.org on 2005/07/14 03:53:52 UTC

svn commit: r218963 - in /geronimo/trunk/modules/j2ee-builder: ./ src/java/org/apache/geronimo/j2ee/deployment/ src/test-plan/ src/test/org/apache/geronimo/j2ee/deployment/

Author: ammulder
Date: Wed Jul 13 18:53:51 2005
New Revision: 218963

URL: http://svn.apache.org/viewcvs?rev=218963&view=rev
Log:
Make sure to barf if a Geronimo EAR deployment plan refers to modules
  that weren't declared in application.xml (GERONIMO-348)

Added:
    geronimo/trunk/modules/j2ee-builder/src/test-plan/
    geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-car.xml
    geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-ejb-jar.xml
    geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-rar.xml
    geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-war.xml
Modified:
    geronimo/trunk/modules/j2ee-builder/maven.xml
    geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
    geronimo/trunk/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java

Modified: geronimo/trunk/modules/j2ee-builder/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/maven.xml?rev=218963&r1=218962&r2=218963&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/maven.xml (original)
+++ geronimo/trunk/modules/j2ee-builder/maven.xml Wed Jul 13 18:53:51 2005
@@ -47,6 +47,12 @@
         <attainGoal name="setupEar"/>
 
         <attainGoal name="setupUnpackedEar"/>
+
+        <ant:copy todir="${basedir}/target/plans">
+          <ant:fileset dir="${basedir}/src/test-plan">
+            <ant:include name="*.xml" />
+          </ant:fileset>
+        </ant:copy>
     </preGoal>
 
     <goal name="setupEar">

Modified: geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=218963&r1=218962&r2=218963&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java (original)
+++ geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java Wed Jul 13 18:53:51 2005
@@ -396,6 +396,21 @@
     private void addModules(JarFile earFile, ApplicationType application, GerApplicationType gerApplication, Set moduleLocations, Set modules) throws DeploymentException {
         Map altVendorDDs = new HashMap();
         try {
+            ModuleType[] moduleTypes = application.getModuleArray();
+            Set paths = new HashSet();
+            for (int i = 0; i < moduleTypes.length; i++) {
+                ModuleType type = moduleTypes[i];
+                if (type.isSetEjb()) {
+                    paths.add(type.getEjb().getStringValue());
+                } else if (type.isSetWeb()) {
+                    paths.add(type.getWeb().getWebUri().getStringValue());
+                } else if (type.isSetConnector()) {
+                    paths.add(type.getConnector().getStringValue());
+                } else if (type.isSetJava()) {
+                    paths.add(type.getJava().getStringValue());
+                }
+            }
+
             // build map from module path to alt vendor dd
             GerModuleType gerModuleTypes[] = gerApplication.getModuleArray();
             for (int i = 0; i < gerModuleTypes.length; i++) {
@@ -410,6 +425,9 @@
                 } else if (gerModule.isSetJava()) {
                     path = gerModule.getJava().getStringValue();
                 }
+                if(!paths.contains(path)) {
+                    throw new DeploymentException("Geronimo deployment plan refers to module '"+path+"' but that was not defined in the META-INF/application.xml");
+                }
 
                 if (gerModule.isSetAltDd()) {
                     // the the url of the alt dd
@@ -435,7 +453,6 @@
 
 
             // get a set containing all of the files in the ear that are actually modules
-            ModuleType[] moduleTypes = application.getModuleArray();
             for (int i = 0; i < moduleTypes.length; i++) {
                 ModuleType moduleXml = moduleTypes[i];
 

Added: geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-car.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-car.xml?rev=218963&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-car.xml (added)
+++ geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-car.xml Wed Jul 13 18:53:51 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
+    configId="org/apache/geronimo/j2ee/deployment/test"
+    parentId="org/apache/geronimo/Server">
+
+    <module>
+      <java>this-is-invalid.jar</java>
+      <alt-dd>this-does-not-exist.xml</alt-dd>
+    </module>
+
+    <!-- a random gbean just to verify that the deployer doesn't die because of it -->
+    <gbean gbeanName="foo:j2eeType=J2EEDomain,name=foo" class="org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl"/>
+
+</application>
\ No newline at end of file

Added: geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-ejb-jar.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-ejb-jar.xml?rev=218963&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-ejb-jar.xml (added)
+++ geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-ejb-jar.xml Wed Jul 13 18:53:51 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
+    configId="org/apache/geronimo/j2ee/deployment/test"
+    parentId="org/apache/geronimo/Server">
+
+    <module>
+      <ejb>this-is-invalid.jar</ejb>
+      <alt-dd>this-does-not-exist.xml</alt-dd>
+    </module>
+
+    <!-- a random gbean just to verify that the deployer doesn't die because of it -->
+    <gbean gbeanName="foo:j2eeType=J2EEDomain,name=foo" class="org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl"/>
+
+</application>
\ No newline at end of file

Added: geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-rar.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-rar.xml?rev=218963&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-rar.xml (added)
+++ geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-rar.xml Wed Jul 13 18:53:51 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
+    configId="org/apache/geronimo/j2ee/deployment/test"
+    parentId="org/apache/geronimo/Server">
+
+    <module>
+      <connector>this-is-invalid.rar</connector>
+      <alt-dd>this-does-not-exist.xml</alt-dd>
+    </module>
+
+    <!-- a random gbean just to verify that the deployer doesn't die because of it -->
+    <gbean gbeanName="foo:j2eeType=J2EEDomain,name=foo" class="org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl"/>
+
+</application>
\ No newline at end of file

Added: geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-war.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-war.xml?rev=218963&view=auto
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-war.xml (added)
+++ geronimo/trunk/modules/j2ee-builder/src/test-plan/test-bad-war.xml Wed Jul 13 18:53:51 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
+    configId="org/apache/geronimo/j2ee/deployment/test"
+    parentId="org/apache/geronimo/Server">
+
+    <module>
+      <web>this-is-invalid.war</web>
+      <alt-dd>this-does-not-exist.xml</alt-dd>
+    </module>
+
+    <!-- a random gbean just to verify that the deployer doesn't die because of it -->
+    <gbean gbeanName="foo:j2eeType=J2EEDomain,name=foo" class="org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl"/>
+
+</application>
\ No newline at end of file

Modified: geronimo/trunk/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java?rev=218963&r1=218962&r2=218963&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java (original)
+++ geronimo/trunk/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java Wed Jul 13 18:53:51 2005
@@ -262,6 +262,78 @@
         }
     }
 
+    public void testBadEJBJARConfiguration() throws Exception {
+        EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, ejbConfigBuilder, ejbConfigBuilder, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, serviceReferenceBuilder, null);
+
+        File tempDir = null;
+        try {
+            tempDir = DeploymentUtil.createTempDir();
+            Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-ejb-jar.xml"), earFile);
+            configBuilder.buildConfiguration(plan, earFile, tempDir);
+            fail("Should have thrown a DeploymentException");
+        } catch (DeploymentException e) {
+            if(e.getCause() instanceof IOException) {
+                fail("Should not be complaining about bad vendor DD for invalid module entry");
+            }
+        } finally {
+            DeploymentUtil.recursiveDelete(tempDir);
+        }
+    }
+
+    public void testBadWARConfiguration() throws Exception {
+        EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, ejbConfigBuilder, ejbConfigBuilder, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, serviceReferenceBuilder, null);
+
+        File tempDir = null;
+        try {
+            tempDir = DeploymentUtil.createTempDir();
+            Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-war.xml"), earFile);
+            configBuilder.buildConfiguration(plan, earFile, tempDir);
+            fail("Should have thrown a DeploymentException");
+        } catch (DeploymentException e) {
+            if(e.getCause() instanceof IOException) {
+                fail("Should not be complaining about bad vendor DD for invalid module entry");
+            }
+        } finally {
+            DeploymentUtil.recursiveDelete(tempDir);
+        }
+    }
+
+    public void testBadRARConfiguration() throws Exception {
+        EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, ejbConfigBuilder, ejbConfigBuilder, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, serviceReferenceBuilder, null);
+
+        File tempDir = null;
+        try {
+            tempDir = DeploymentUtil.createTempDir();
+            Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-rar.xml"), earFile);
+            configBuilder.buildConfiguration(plan, earFile, tempDir);
+            fail("Should have thrown a DeploymentException");
+        } catch (DeploymentException e) {
+            if(e.getCause() instanceof IOException) {
+                fail("Should not be complaining about bad vendor DD for invalid module entry");
+            }
+        } finally {
+            DeploymentUtil.recursiveDelete(tempDir);
+        }
+    }
+
+    public void testBadCARConfiguration() throws Exception {
+        EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, ejbConfigBuilder, ejbConfigBuilder, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, serviceReferenceBuilder, null);
+
+        File tempDir = null;
+        try {
+            tempDir = DeploymentUtil.createTempDir();
+            Object plan = configBuilder.getDeploymentPlan(new File(basedir, "target/plans/test-bad-car.xml"), earFile);
+            configBuilder.buildConfiguration(plan, earFile, tempDir);
+            fail("Should have thrown a DeploymentException");
+        } catch (DeploymentException e) {
+            if(e.getCause() instanceof IOException) {
+                fail("Should not be complaining about bad vendor DD for invalid module entry");
+            }
+        } finally {
+            DeploymentUtil.recursiveDelete(tempDir);
+        }
+    }
+
     public void testNoEJBDeployer() throws Exception {
         EARConfigBuilder configBuilder = new EARConfigBuilder(defaultParentId, transactionManagerObjectName, connectionTrackerObjectName, transactionalTimerObjectName, nonTransactionalTimerObjectName, null, null, null, null, webConfigBuilder, connectorConfigBuilder, resourceReferenceBuilder, appClientConfigBuilder, serviceReferenceBuilder, null);