| <?xml version="1.0" encoding="ISO-8859-1"?> |
| <!DOCTYPE project [ |
| <!-- |
| |
| Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. |
| |
| This program and the accompanying materials are made available under the |
| terms of the Eclipse Public License v. 2.0, which is available at |
| http://www.eclipse.org/legal/epl-2.0. |
| |
| This Source Code may also be made available under the following Secondary |
| Licenses when the conditions for such availability set forth in the |
| Eclipse Public License v. 2.0 are satisfied: GNU General Public License, |
| version 2 with the GNU Classpath Exception, which is available at |
| https://www.gnu.org/software/classpath/license.html. |
| |
| SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 |
| |
| --> |
| |
| <!ENTITY commonBuild SYSTEM "./../../config/common.xml"> |
| ]> |
| |
| <project name="libclasspath2" default="all" basedir="."> |
| |
| <!-- |
| This set of tests make sure that the handling of <library-directory> is |
| done properly, that the server-side and client-side class paths are set |
| correctly, and that the generated client JAR contains what it should. |
| |
| |
| **** THE APP CLIENT **** |
| |
| The app client that drives the tests invokes an EJB method to make sure the |
| server-side class path is correct, then checks for the very same resources |
| itself on the client side to make sure that its class path and the generated |
| app client JAR file are both correct. |
| |
| The appclient's output servers are property definitions that are written to |
| the client run's log file. The log file is then used by the ant task to |
| define run-specific properties for checking the results and displaying any |
| test failures. |
| |
| |
| **** THE EARS **** |
| |
| The tests use a single EAR structure. The <library-directory> setting |
| in application.xml changes to affect the outcome of the tests. |
| |
| Here is the EAR structure: |
| |
| topLevel.jar - always included due to backward compatibility with the legacy feature |
| that includes all top-level JARs in the class path |
| |
| topLevel.properties |
| |
| lib/lib.jar - accessible when <library-directory> element is omitted |
| because the default is lib (there are no tests in this project that explicitly |
| specify <library-directory>lib</library-directory>) |
| |
| lib.properties |
| |
| lib/sub/lib_sub.jar - should not be accessible because JARs in subdirectories of the |
| library directory should not be accessible |
| |
| lib_sub.properties |
| |
| x/x.jar - accessible when lib dir is "x" - The manifest of x.jar specifies Class-Path: xExtra/xExtra.jar xMore/sub |
| |
| x.properties - accessible (since x.jar contains it and is in the lib directory) |
| |
| x/xExtra/xExtra.jar - accessible when lib dir is "x" since the manifest of x.jar includes xExtra/xExtra.jar |
| |
| x_xExtra.properties |
| |
| xExtra/xExtra.jar - never accessible. Here to make sure that the Class-Path handling |
| of xExtra/xExtra.jar in /x/x.jar's manifest correctly resolves relative to the x directory |
| where x.jar resides and not relative to the top-level of the EAR |
| |
| xExtra.properties |
| |
| x/xMore - never accessible because even when the lib-dir is x (and |
| x.jar's manifest Class-Path specifies xMore/sub), only xMore/sub should be added to the |
| class path, not its parent directory. |
| |
| x_xMore.properties |
| |
| x/xMore/sub - accessible when lib-dir is x |
| |
| x_xMore_sub.properties |
| |
| xExtra/xExtra.jar - neve accessible because the manifest Class-Path entries in x/x.jar should be relative to |
| the URI of the JAR itself, and so should resolve to x/xExtra/xExtra.jar, not xExtra/xExtra.jar |
| |
| xExtra_xExtra.properties |
| |
| xMore/sub/ - never accessible (again because x/x.jar's Class-Path entry for xMore/sub |
| should be resolved relative to x/x.jar's location which is /x and should therefore resovle to x/xMore/sub |
| within the JAR rather than xMore/sub |
| |
| xMore_sub.properties |
| |
| y/y.jar - always accessible to the client (appears in the Class-Path of the app client JAR's manifest) |
| |
| y.properties |
| |
| |
| There are three different versions of the EAR created, each of which uses a |
| different <library-directory> setting: |
| |
| default.ear - omits <library-directory>, so the default of lib should be used |
| none.ear - specifies <library-directory/> (empty); no library directory should be used |
| x.ear - specifies <library-directory> as x |
| |
| Each EAR should give somewhat different results in trying to locate various |
| properties files and properties within them. |
| |
| |
| **** SPECIFYING TESTS **** |
| |
| The app client driver accepts command-line arguments that specify a path for a resource, |
| a property name expected to be found in the resource, and the value expected for that |
| property in that resource. The format of each test expression is |
| |
| {resource-path}:{property-name}={expected-value} |
| |
| The client- and server-side tests use the same common logic in ResourceHelper |
| to parse the test expressions, to search for a |
| resource, to load a Properties object using the resource, and to get the value |
| of a requested property and comparing it to the expected value. |
| --> |
| &commonBuild; |
| |
| <property name="testName" value="libClassPath2"/> |
| <property name="archivedir" value="${build}/archives"/> |
| |
| <property name="x.ear" value="${archivedir}/${testName}x-App.ear"/> |
| <property name="default.ear" value="${archivedir}/${testName}default-App.ear"/> |
| <property name="none.ear" value="${archivedir}/${testName}none-App.ear"/> |
| |
| <property name="ejb.jar.name" value="libdirtest-EJBModule.jar"/> |
| <property name="ejb.jar" value="${build}/${ejb.jar.name}"/> |
| <property name="client.jar.name" value="libdirtest-client.jar"/> |
| <property name="client.jar" value="${build}/client/${client.jar.name}"/> |
| |
| <!-- |
| The next properties point to the various JARs and directories in the |
| build area for constructing the EAR. |
| --> |
| <property name="x.jar" value="${build}/x/x.jar"/> |
| <property name="lib.jar" value="${build}/lib/lib.jar"/> |
| <property name="lib_sub.jar" value="${build}/lib/sub/lib_sub.jar"/> |
| <property name="xExtra.jar" value="${build}/xExtra/xExtra.jar"/> |
| <property name="x_xExtra.jar" value="${build}/x/xExtra/xExtra.jar"/> |
| <property name="x.xMore.dir" value="${build}/x/xMore"/> |
| <property name="x.xMore.sub.dir" value="${x.xMore.dir}/sub"/> |
| <property name="xMore.dir" value="${build}/xMore"/> |
| <property name="xMore.sub.dir" value="${xMore.dir}/sub"/> |
| <property name="topLevel.jar" value="${build}/topLevel.jar"/> |
| <property name="z.jar" value="${build}/client/z/z.jar"/> |
| <property name="y.dir" value="${build}/client/y"/> |
| |
| <!-- |
| The next groups of properties define the possible positive and negative results |
| in trying to find a given resource. Some tests will work in some |
| EARs but not others; some should work in all EARs; some should work |
| in no EARs. |
| --> |
| |
| <!-- |
| The test for the top-level JAR should always be positive, unless |
| and until we retire that legacy feature. |
| --> |
| <property name="test.tl" value="/topLevel.properties:lib.path="/> |
| <property name="test.tl.pos" value="${test.tl}topLevel"/> |
| |
| <!-- |
| x.properties is accessible only using x.ear (lib-dir specified as x) |
| --> |
| <property name="test.x" value="/x.properties:lib.path="/> |
| <property name="test.x.pos" value="${test.x}x"/> |
| <property name="test.x.neg" value="${test.x}NO_RESOURCE"/> |
| |
| <!-- |
| xExtra.properties is never accessible |
| --> |
| <property name="test.xExtra" value="/xExtra.properties:xExtra="/> |
| <property name="test.xExtra.neg" value="${test.xExtra}NO_RESOURCE"/> |
| |
| <!-- |
| x_xExtra.properties is accessible only using x.ear |
| --> |
| <property name="test.x.xExtra" value="/x_xExtra.properties:x_xExtra="/> |
| <property name="test.x.xExtra.pos" value="${test.x.xExtra}x_xExtra"/> |
| <property name="test.x.xExtra.neg" value="${test.x.xExtra}NO_RESOURCE"/> |
| |
| <!-- |
| lib.properties is accessible only using default.ear |
| --> |
| <property name="test.lib" value="/lib.properties:lib.path="/> |
| <property name="test.lib.pos" value="${test.lib}lib"/> |
| <property name="test.lib.neg" value="${test.lib}NO_RESOURCE"/> |
| |
| <!-- |
| lib_sub.properties is never accessible |
| --> |
| <property name="test.lib.sub" value="/lib_sub.properties:lib_sub="/> |
| <property name="test.lib.sub.neg" value="${test.lib.sub}NO_RESOURCE"/> |
| |
| <!-- |
| x_xMore.properties is never accessible |
| --> |
| <property name="test.x.xMore" value="/x_xMore.properties:x_xMore="/> |
| <property name="test.x.xMore.pos" value="${test.x.xMore}x_xMore"/> |
| <property name="test.x.xMore.neg" value="${test.x.xMore}NO_RESOURCE"/> |
| |
| <!-- |
| xMore_sub.properties is never accessible (because the xMore/sub |
| Class-Path entry in x.jar's manifest must be resolved within the /x |
| directory where x.jar is found, not from the top-level of the EAR |
| --> |
| <property name="test.xMore.sub" value="/xMore_sub.properties:xMore_sub="/> |
| <property name="test.xMore.sub.neg" value="${test.xMore.sub}NO_RESOURCE"/> |
| |
| <!-- |
| x_xMore_sub.properties is accessible only using x.ear |
| --> |
| <property name="test.x.xMore.sub" value="/x_xMore_sub.properties:x_xMore_sub="/> |
| <property name="test.x.xMore.sub.pos" value="${test.x.xMore.sub}x_xMore_sub"/> |
| <property name="test.x.xMore.sub.neg" value="${test.x.xMore.sub}NO_RESOURCE"/> |
| |
| <!-- |
| z.properties is always accessible to the client (it appears in the Class-Path |
| in the app client JAR's manifest) but never to the server |
| --> |
| <property name="test.z" value="/z.properties:value="/> |
| <property name="test.z.pos" value="${test.z}z"/> |
| <property name="test.z.neg" value="${test.z}NO_RESOURCE"/> |
| |
| <!-- |
| y.properties should always be accessible because the |
| app client JAR manifest used for the app client JAR shared by all |
| EARs specifies y/y.properties in its Class-Path. |
| --> |
| <property name="test.y" value="/y.properties:value="/> |
| <property name="test.y.pos" value="${test.y}y"/> |
| <property name="test.y.neg" value="${test.y}NO_RESOURCE"/> |
| |
| <!-- |
| The following properties define the expected results for each test run. |
| --> |
| |
| <!-- library-directory specified as empty, meaning no lib dir should be used --> |
| <property name="noLib.expected.results" |
| value="${test.tl.pos} ${test.x.neg} ${test.xExtra.neg} ${test.lib.neg} ${test.lib.sub.neg} ${test.x.xExtra.neg} ${test.xMore.sub.neg} ${test.x.xMore.neg} ${test.x.xMore.sub.neg} -clientonly ${test.z.pos} -serveronly ${test.z.neg} ${test.y.neg}"/> |
| |
| <!-- library-directory not specified; default of lib used --> |
| <property name="defaultLib.expected.results" |
| value="${test.tl.pos} ${test.x.neg} ${test.xExtra.neg} ${test.lib.pos} ${test.lib.sub.neg} ${test.x.xExtra.neg} ${test.xMore.sub.neg} ${test.x.xMore.neg} ${test.x.xMore.sub.neg} -clientonly ${test.z.pos} -serveronly ${test.z.neg} ${test.y.neg}"/> |
| |
| <!-- library-directory specified as x; x.jar and its Class-Path entries xExtra/xExtra.jar and xMore/sub used --> |
| <property name="explicitLibWithDir.expected.results" |
| value="${test.tl.pos} ${test.x.pos} ${test.xExtra.neg} ${test.lib.neg} ${test.lib.sub.neg} ${test.x.xExtra.pos} ${test.xMore.sub.neg} ${test.x.xMore.neg} -clientonly ${test.z.pos} -serveronly ${test.z.neg} ${test.y.neg}"/> |
| |
| |
| <target name="prepare" depends="init"> |
| <mkdir dir="${build}"/> |
| <mkdir dir="${build}/ejb"/> |
| <mkdir dir="${build}/client"/> |
| <mkdir dir="${build}/client/y"/> |
| <mkdir dir="${build}/client/z"/> |
| |
| <mkdir dir="${archivedir}"/> |
| |
| <!-- The following directories will hold different files so they will |
| appear in the EAR in the right places. |
| --> |
| <mkdir dir="${build}/x"/> <!-- holds x.jar --> |
| <mkdir dir="${build}/x/xExtra"/> <!-- holds xExtra.jar --> |
| <mkdir dir="${build}/x/xMore"/> <!-- holds x_xMore.properties (should not be accessible) --> |
| <mkdir dir="${build}/x/xMore/sub"/> <!-- holds x_xMore_sub.properties --> |
| |
| <mkdir dir="${build}/xMore/"/> |
| <mkdir dir="${build}/xMore/sub"/> <!-- holds xMore_sub.properties (should not be accessible) --> |
| |
| <mkdir dir="${build}/lib"/> <!-- holds lib.jar --> |
| <mkdir dir="${build}/lib/sub"/> <!-- holds lib_sub.jar (should not be accessible) --> |
| |
| <mkdir dir="${build}/xExtra"/> <!-- holds xExtra.jar (should not be accessible) --> |
| |
| </target> |
| |
| <target name="compile" depends="prepare"> |
| <javac srcdir="." destdir="${build}" debug="on" failonerror="true"> |
| <classpath refid="gfv3.classpath"/> |
| </javac> |
| </target> |
| |
| <target name="assemble" depends="makeEars"/> |
| |
| <target name="makeJars" depends="compile"> |
| |
| <!-- |
| Build the various jars used in the different tests. |
| --> |
| |
| <!-- |
| The x/x.jar will have the Class-Path setting in its manifest, so |
| specify the manifest rather than letting ant create it. |
| --> |
| <jar destfile="${x.jar}" manifest="x/MANIFEST.MF"> |
| <fileset dir="x" includes="*.properties"/> |
| </jar> |
| |
| <jar destfile="${x_xExtra.jar}"> |
| <fileset dir="x/xExtra" includes="*.properties"/> |
| </jar> |
| |
| <jar destfile="${xExtra.jar}"> |
| <fileset dir="xExtra" includes="*.properties"/> |
| </jar> |
| |
| <jar destfile="${lib.jar}"> |
| <fileset dir="lib" includes="*.properties"/> |
| </jar> |
| |
| <jar destfile="${lib_sub.jar}"> |
| <fileset dir="lib/sub" includes="*.properties"/> |
| </jar> |
| |
| <jar destfile="${topLevel.jar}"> |
| <fileset dir="topLevel" includes="**/*.properties"/> |
| </jar> |
| |
| <jar destfile="${z.jar}"> |
| <fileset dir="client/z" includes="*.properties"/> |
| </jar> |
| |
| <!-- |
| Copy the properties files that should occupy directories (as opposed |
| to JARs) to the build area so they will be included in the EARs. |
| --> |
| <copy file="x/xMore/x_xMore.properties" todir="${x.xMore.dir}"/> |
| <copy file="x/xMore/sub/x_xMore_sub.properties" todir="${x.xMore.sub.dir}"/> |
| <copy file="xMore/sub/xMore_sub.properties" todir="${xMore.sub.dir}"/> |
| |
| <copy file="client/y/y.properties" todir="${y.dir}"/> |
| |
| <!-- |
| Build the EJB and client jars. The ResourceHelper class is used from |
| the EJB and also from the client, so include it in both submodules. |
| --> |
| <fileset id="resourceHelperClass" dir="${build}" includes="**/ResourceHelper*.class"/> <!-- the shared utility class --> |
| |
| <jar destfile="${ejb.jar}"> |
| <fileset dir="${build}" includes="**/ejb/**/*.class"/> |
| <fileset refid="resourceHelperClass"/> |
| </jar> |
| |
| <jar destfile="${client.jar}" manifest="client/MANIFEST.MF"> |
| <fileset dir="${build}" includes="**/client/**/*.class"/> |
| <fileset dir="${build}" includes="**/ejb/LookupSBRemote.class"/> |
| <fileset refid="resourceHelperClass"/> |
| </jar> |
| </target> |
| |
| <target name="makeEars" depends="makeJars"> |
| |
| <!-- |
| All the EARs are populated with exactly the same content EXCEPT for |
| the application.xml, which differs for each. The earIncludes property |
| defined next spells out all the JARs and directories included in all |
| the EARs. |
| --> |
| <property name="earIncludes" value="libdirtest-EJBModule.jar,client/libdirtest-client.jar,client/z/z.jar,client/y/y.properties,topLevel.jar,lib/lib.jar,lib/sub/lib_sub.jar,x/x.jar,xExtra/xExtra.jar,x/xExtra/xExtra.jar,x/xMore/**,xMore/**"/> |
| |
| <ear destfile="${none.ear}" basedir="${build}" |
| appxml="application-noLibDir.xml" includes="${earIncludes}"/> |
| |
| <ear destfile="${default.ear}" basedir="${build}" |
| appxml="application-defaultLibDir.xml" includes="${earIncludes}"/> |
| |
| <ear destfile="${x.ear}" basedir="${build}" |
| appxml="application-xLibDir.xml" includes="${earIncludes}"/> |
| </target> |
| |
| <target name="deploy.asadmin" depends="prepare"> |
| <antcall target="common.deploy.asadmin"> |
| <param name="arg.list" value="--property compatibility=v2 --retrieve ${archivedir} --name ${module.name} ${ear.file}"/> |
| <param name="testName" value="${testName}"/> |
| </antcall> |
| </target> |
| |
| <target name="undeploy.asadmin" depends="prepare"> |
| <antcall target="common.undeploy.asadmin"> |
| <param name="arg.list" value="${module.name}"/> |
| <param name="testName" value="${testName}"/> |
| </antcall> |
| </target> |
| |
| <target name="runclient" depends="init"> |
| <echo message="appclient -client ${archivedir}/${clientName} ${tests}"/> |
| <exec command="appclient" resultproperty="result" output="${build}/${log.id}.output.log"> |
| <arg value="-client"/> |
| <arg value="${archivedir}/${clientName}"/> |
| <arg value="${tests}"/> |
| </exec> |
| |
| <antcall target="processResult"> |
| <param name="result" value="${result}"/> |
| <param name="log" value="${build}/${log.id}.output.log"/> |
| </antcall> |
| </target> |
| |
| <target name="run" depends="run.positive"/> |
| |
| <target name="run.positive" depends="setHttpPort"> |
| <antcall target="common.run.positive"> |
| <param name="link" value="${contextRoot}/${testName}"/> |
| <param name="log.id" value="${log.id}"/> |
| </antcall> |
| </target> |
| |
| <target name="private-all" depends="prepare" if="PE"> |
| <antcall target="assemble"/> |
| |
| <deploy moduleName="libtest-none" earFile="${none.ear}"/> |
| <run-test tests="${noLib.expected.results}" moduleName="libtest-none" logID="0" testLogTitle="noLibUsed"/> |
| <undeploy moduleName="libtest-none"/> |
| |
| <deploy moduleName="libtest-default" earFile="${default.ear}"/> |
| <run-test tests="${defaultLib.expected.results}" moduleName="libtest-default" logID="1" testLogTitle="defaultLibUsed"/> |
| <undeploy moduleName="libtest-default"/> |
| |
| <deploy moduleName="libtest-explicitWithDir" earFile="${x.ear}"/> |
| <run-test tests="${explicitLibWithDir.expected.results}" moduleName="libtest-explicitWithDir" logID="2" testLogTitle="explicitLibWithDir"/> |
| <undeploy moduleName="libtest-explicitWithDir"/> |
| |
| </target> |
| |
| |
| <macrodef name="deploy"> |
| <attribute name="moduleName"/> |
| <attribute name="earFile" default="${archivedir}/@{moduleName}.ear"/> |
| <sequential> |
| <antcall target="deploy.asadmin"> |
| <param name="module.name" value="@{moduleName}"/> |
| <param name="ear.file" value="@{earFile}"/> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| <macrodef name="undeploy"> |
| <attribute name="moduleName"/> |
| <sequential> |
| <antcall target="undeploy.asadmin"> |
| <param name="module.name" value="@{moduleName}"/> |
| </antcall> |
| </sequential> |
| </macrodef> |
| |
| <macrodef name="run-test"> |
| <attribute name="tests"/> |
| <attribute name="logID"/> |
| <attribute name="moduleName"/> |
| <attribute name="clientFile" default="${archivedir}/@{moduleName}Client.jar"/> |
| <attribute name="testLogTitle" default="@{expectedResult}"/> |
| |
| <sequential> |
| <antcall target="declare-test"> |
| <param name="description" value="ear/libclasspath2 Testing for @{testLogTitle}"/> |
| </antcall> |
| |
| <echo message="${APPCLIENT} -client @{clientFile} @{tests}"/> |
| <exec executable="${APPCLIENT}" resultproperty="result" output="${build}/@{logID}.output.log" failonerror="false"> |
| <arg value="-client"/> |
| <arg value="@{clientFile}"/> |
| <arg line="@{tests}"/> |
| </exec> |
| <checkResult logID="@{logID}"/> |
| |
| </sequential> |
| </macrodef> |
| <!-- |
| <macrodef name="run-test-only"> |
| <attribute name="expectedResult"/> |
| <attribute name="logID"/> |
| <attribute name="appEarPrefix" default="${archivedir}/${testName}@{expectedResult}-App"/> |
| <attribute name="moduleName" default="libtest-@{expectedResult}"/> |
| <attribute name="clientFile" default="${archivedir}/@{moduleName}Client.jar"/> |
| <sequential> |
| <echo message="${APPCLIENT} -client @{clientFile} @{expectedResult}"/> |
| <exec executable="${APPCLIENT}" resultproperty="result" output="${build}/@{logID}.output.log" failonerror="false"> |
| <arg value="-client"/> |
| <arg value="@{clientFile}"/> |
| <arg value="@{expectedResult}"/> |
| </exec> |
| </sequential> |
| </macrodef> |
| |
| <target name="run-only" depends="init"> |
| <run-test-only expectedResult="${expectedResult}" logID="${logID}"/> |
| </target> |
| --> |
| <!-- |
| Convenience target for deploying and running a single test. Hand-edit the |
| expectedResult property (and the logID if you feel like it) so it is |
| one of the test apps build by the assemble task. |
| --> |
| <!-- |
| <target name="deploy-run" depends="init"> |
| <property name="expectedResult" value="topLevel5"/> |
| <property name="logID" value="0"/> |
| --> |
| |
| |
| <macrodef name="checkResult"> |
| <attribute name="logID"/> |
| <attribute name="logFile" default="${build}/@{logID}.output.log"/> |
| <sequential> |
| <property file="@{logFile}" prefix="x@{logID}"/> |
| |
| <concat> |
| <fileset file="@{logFile}"/> |
| </concat> |
| <antcall target="processResult"> |
| <param name="result" value="${x@{logID}.result}"/> |
| </antcall> |
| </sequential> |
| </macrodef> |
| </project> |