PR: MPEAR-17
Submitted by: Olivier Mallassi and André Nedelcoux Allows to define roles generated in application.xml deployment descriptor git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@388484 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
878e4510a4
commit
2a139378ae
@ -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>
|
||||
|
||||
|
||||
@ -34,3 +34,6 @@ maven.ear.resources=${maven.build.dir}/ear
|
||||
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
|
||||
|
||||
80
ear/src/plugin-test/securityRoleTest/maven.xml
Normal file
80
ear/src/plugin-test/securityRoleTest/maven.xml
Normal file
@ -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>
|
||||
18
ear/src/plugin-test/securityRoleTest/project.properties
Normal file
18
ear/src/plugin-test/securityRoleTest/project.properties
Normal file
@ -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
|
||||
30
ear/src/plugin-test/securityRoleTest/project.xml
Normal file
30
ear/src/plugin-test/securityRoleTest/project.xml
Normal file
@ -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>
|
||||
@ -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">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user