Author: aheritier
Date: Fri Mar 24 02:43:31 2006
New Revision: 388484

URL: http://svn.apache.org/viewcvs?rev=388484&view=rev
Log:
PR: MPEAR-17
Submitted by: Olivier Mallassi and André Nedelcoux 
Allows to define roles generated in application.xml deployment descriptor

Added:
    maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/
    maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/maven.xml  
 (with props)
    
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.properties
   (with props)
    
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.xml   
(with props)
Modified:
    maven/maven-1/plugins/trunk/ear/plugin.jelly
    maven/maven-1/plugins/trunk/ear/plugin.properties
    maven/maven-1/plugins/trunk/ear/xdocs/properties.xml

Modified: maven/maven-1/plugins/trunk/ear/plugin.jelly
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/ear/plugin.jelly?rev=388484&r1=388483&r2=388484&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/ear/plugin.jelly (original)
+++ maven/maven-1/plugins/trunk/ear/plugin.jelly Fri Mar 24 02:43:31 2006
@@ -234,6 +234,16 @@
             </j:choose> 
           </j:if>        
         </j:forEach>
+        <!-- add the security-role element -->
+        <j:set var="securityRoles" value="${maven.ear.appxml.securityRoles}"/>
+       <j:if test="${!empty(securityRoles)}">
+               <util:tokenize var="roles" delim="," 
trim="true">${maven.ear.appxml.securityRoles}</util:tokenize>
+               <j:forEach var="role" items="${roles}">
+                       <x:element name="security-role">
+                               <x:element 
name="role-name">${role.trim()}</x:element>
+                       </x:element>
+               </j:forEach>
+       </j:if >
        </x:element> 
      </j:file>  
           

Modified: maven/maven-1/plugins/trunk/ear/plugin.properties
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/ear/plugin.properties?rev=388484&r1=388483&r2=388484&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/ear/plugin.properties (original)
+++ maven/maven-1/plugins/trunk/ear/plugin.properties Fri Mar 24 02:43:31 2006
@@ -34,3 +34,6 @@
 maven.ear.appxml.encoding=UTF-8
 # Name of generated EAR file
 maven.ear.final.name=${maven.final.name}.ear
+
+# Security role (a comma separated list)
+# maven.ear.appxml.securityRoles = role1, role2

Added: 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/maven.xml
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/maven.xml?rev=388484&view=auto
==============================================================================
--- maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/maven.xml 
(added)
+++ maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/maven.xml 
Fri Mar 24 02:43:31 2006
@@ -0,0 +1,80 @@
+<!-- 
+/*
+ * Copyright 2001-2006 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.
+ */
+ -->
+<project xmlns:assert="assert"
+         xmlns:util="jelly:util"
+         xmlns:j="jelly:core"
+         xmlns:ant="jelly:ant"
+         xmlns:x="jelly:xml">
+
+  <goal name="testPlugin" prereqs="test-ear">
+    <attainGoal name="clean"/>
+  </goal>
+  
+  <goal name="test-ear" prereqs="ear:init">
+               <echo>SRC: ${maven.ear.src}</echo>
+    <echo>Build ear...</echo>
+    <attainGoal name="ear"/>
+
+    <!-- tests that the ear is generated -->
+    <j:set var="earFile" value="${maven.build.dir}/${maven.ear.final.name}"/>
+    <assert:assertFileExists file="${earFile}"/>
+    <!-- extracts the EAR -->
+    <j:set var="tmpEarDir" value="${maven.build.dir}/extractedEar"/>
+    <ant:unzip src="${earFile}" dest="${tmpEarDir}"/>
+
+    <!-- asserts the application.xml is there -->
+    <assert:assertFileExists file="${tmpEarDir}/META-INF/application.xml"/>
+
+    <!-- asserts the application.xml content is the same as before -->
+    <echo>Loading test file: ${tmpEarDir}/META-INF/application.xml</echo>
+    <!-- load application.xml file -->
+    <util:file var="application.xml" 
name="${tmpEarDir}/META-INF/application.xml"/>
+    <!-- parse application.xml file -->
+    <echo>Parsing file...</echo>
+    <x:parse var="application" xml="${application.xml}"/>
+    <j:set var="countSecurityRoleNodes">
+        <x:expr select="count($application/application/security-role)"/>
+    </j:set>
+    <echo>Compare the number of defined security-role...</echo>
+    <!-- realise assertion on the number of roles found in application.xml 
file -->
+    <assert:assertEquals expected="2" value="${countSecurityRoleNodes}"
+        msg="Security Role Number"/>
+    <!-- realize assertion on the role name found in application.xml-->
+    <x:set var="securityRoleNodes"
+        select="$application/application/security-role"/>
+    <j:set var="counter" value="1"/>
+    <j:forEach var="securityRoleNode" items="${securityRoleNodes}">
+        <j:set var="securityRoleName">
+            <x:expr select="$securityRoleNode/role-name"/>
+        </j:set>
+        <echo>Found: ${securityRoleName}</echo>
+        <!-- first item should be role [role1] -->
+        <j:if test="${counter == 1}">
+            <assert:assertEquals expected="role1"
+                value="${securityRoleName.trim()}"/>
+        </j:if>
+        <!-- second item should be role [role2] -->
+        <j:if test="${counter == 2}">
+            <assert:assertEquals expected="role2"
+                value="${securityRoleName.trim()}"/>
+        </j:if>
+        <!-- ... -->
+        <j:set var="counter" value="${counter + 1}"/>
+    </j:forEach>
+  </goal>
+</project>

Propchange: 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/maven.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.properties
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.properties?rev=388484&view=auto
==============================================================================
--- 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.properties
 (added)
+++ 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.properties
 Fri Mar 24 02:43:31 2006
@@ -0,0 +1,18 @@
+# -------------------------------------------------------------------
+# Copyright 2001-2006 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.
+# -------------------------------------------------------------------
+
+maven.ear.appxml.generate=true
+maven.ear.appxml.securityRoles = role1, role2

Propchange: 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.xml
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.xml?rev=388484&view=auto
==============================================================================
--- 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.xml 
(added)
+++ 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.xml 
Fri Mar 24 02:43:31 2006
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*
+ * Copyright 2001-2006 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.
+ */
+ -->
+<project xmlns="http://maven.apache.org/POM/3.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/3.0.0
+http://maven.apache.org/maven-v3_0_0.xsd";>
+  <pomVersion>3</pomVersion>
+  <name>Ear Plugin - AppXml Security Role Test</name>
+  <artifactId>test-maven-ear-plugin-securityRoleTest</artifactId>
+  <inceptionYear>2006</inceptionYear>
+  <shortDescription>Tests the security-role are well created</shortDescription>
+  <description>Tests the security-role are well created</description>
+  <build>
+    <defaultGoal>testPlugin</defaultGoal>
+  </build>
+</project>

Propchange: 
maven/maven-1/plugins/trunk/ear/src/plugin-test/securityRoleTest/project.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/maven-1/plugins/trunk/ear/xdocs/properties.xml
URL: 
http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/ear/xdocs/properties.xml?rev=388484&r1=388483&r2=388484&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/ear/xdocs/properties.xml (original)
+++ maven/maven-1/plugins/trunk/ear/xdocs/properties.xml Fri Mar 24 02:43:31 
2006
@@ -128,6 +128,16 @@
             ${maven.build.dir}
           </td>
         </tr>
+        <tr>
+          <td>maven.ear.appxml.securityRoles</td>
+          <td>Yes</td>
+          <td>
+               A comma-separated list of role names. Will create xml element 
<code>security-role</code> with sub-element <code>role-name</code>.
+          </td>
+          <td>
+            Empty
+          </td>
+        </tr>
       </table>
     </section>
     <section name="other settings">


Reply via email to