<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
GPL Classpath Exception:
Oracle designates this particular file as subject to the "Classpath"
exception as provided by Oracle in the GPL Version 2 section of the License
file that accompanied this code.
Modifications:
If applicable, add the following below the License Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyright [year] [name of copyright owner]"
Contributor(s):
If you wish your version of this file to be governed by only the CDDL or
only the GPL Version 2, indicate your decision by adding "[Contributor]
elects to include this software in this distribution under the [CDDL or GPL
Version 2] license." If you don't indicate a single choice of license, a
recipient has the option to distribute your version of this file under
either the CDDL, the GPL Version 2 or to extend the choice of license to
its licensees as provided above. However, if you add GPL Version 2 code
and therefore, elected the GPL Version 2 license, then the option applies
only if the new code is made subject to such option by the copyright
holder.
-->
<project name="GlassFish-V3-QuickLook" default="all" basedir=".">
<property environment="env"/>
<property name="QL_DOMAIN" value="qltest-domain"/>
<property name="QL_ADMIN_PORT" value="4848"/>
<property file="build.properties"/>
<property file="${basedir}/gfproject/derby.properties"/>
<import file="${basedir}/gfproject/db-targets.xml"/>
<description>Builds, tests, and runs the project V3 Quicklook</description>
<target name="all_cluster">
<antcall target="create-ql-domain"/>
<antcall target="start-server-felix"/>
<antcall target="build-cluster"/>
<antcall target="runtest">
</antcall>
<antcall target="stop-server"/>
<antcall target="testng-summary"/>
</target>
<target name="all_embedded">
<antcall target="runtest-embedded">
</antcall>
</target>
<target name="build-cluster">
</target>
<!-- target name="all_wd" depends="clean" -->
<target name="all_wd" >
<antcall target="verify-xml"/>
<antcall target="start-derby"/>
<antcall target="create-ql-domain"/>
<antcall target="start-server-felix"/>
<antcall target="build-deploy"/>
<antcall target="runtest">
<antcall target="undeploy"/>
<antcall target="quicklook-summary"/>
<antcall target="stop-server"/>
<antcall target="stop-derby"/>
<antcall target="check-logged-messages"/>
<antcall target="testng-summary"/>
</target>
<target name="all_wd_security">
<antcall target="create-ql-domain"/>
<antcall target="add-quicklook-policy-grants" />
<antcall target="start_server_with_security_manager_enabled" />
<antcall target="build-deploy"/>
<antcall target="runtest">
<antcall target="undeploy"/>
<antcall target="quicklook-summary"/>
<antcall target="remove-quicklook-policy-grants" />
<antcall target="stop_server_with_security_manager_enabled" />
<antcall target="check-logged-messages"/>
<antcall target="testng-summary"/>
</target>
<target name="start_server_with_security_manager_enabled">
<antcall target="verify-xml"/>
<antcall target="start-derby"/>
<antcall target="start-server-felix"/>
<antcall target="enable-security-manager"/>
<antcall target="stop-server"/>
<antcall target="start-server-felix"/>
</target>
<target name="stop_server_with_security_manager_enabled">
<antcall target="disable-security-manager"/>
<antcall target="stop-server"/>
<antcall target="stop-derby"/>
</target>
<!-- Target for testing glassfish distribution (containing EJB) -->
<target name="all" depends="clean">
<antcall target="verify-xml"/>
<antcall target="start-derby"/>
<antcall target="create-ql-domain"/>
<antcall target="start-server-felix"/>
<antcall target="build-deploy"/>
<antcall target="build-deploy-gd"/>
<antcall target="build-cluster"/>
<antcall target="runtest">
<antcall target="undeploy"/>
<antcall target="undeploy-gd"/>
<antcall target="quicklook-summary"/>
<antcall target="stop-server"/>
<antcall target="stop-derby"/>
<copy file="test-output/emailable-report.html" tofile="test-output/QL-GP-report.html" failonerror="false"/>
<antcall target="check-logged-messages"/>
<antcall target="testng-summary"/>
</target>
<!-- Target for testing glassfish distribution (containing EJB) -->
<target name="all_ri" depends="clean">
<antcall target="verify-xml"/>
<antcall target="start-derby"/>
<antcall target="create-ql-domain"/>
<antcall target="start-server-felix"/>
<antcall target="build-deploy"/>
<antcall target="build-deploy-gd"/>
<antcall target="runtest">
<antcall target="undeploy"/>
<antcall target="undeploy-gd"/>
<antcall target="quicklook-summary"/>
<antcall target="stop-server"/>
<antcall target="stop-derby"/>
<copy file="test-output/emailable-report.html" tofile="test-output/QL-GP-report.html" failonerror="false"/>
<antcall target="check-logged-messages"/>
<antcall target="testng-summary"/>
</target>
<!-- Target for testing glassfish distribution (containing EJB) -->
<target name="all_gd_security" depends="clean">
<antcall target="verify-xml"/>
<antcall target="start-derby"/>
<antcall target="create-ql-domain"/>
<antcall target="add-quicklook-policy-grants" />
<antcall target="start-server-felix"/>
<antcall target="enable-security-manager"/>
<antcall target="stop-server"/>
<antcall target="start-server-felix"/>
<antcall target="build-deploy"/>
<antcall target="build-deploy-gd"/>
<antcall target="build-cluster"/>
<antcall target="runtest">
<antcall target="undeploy"/>
<antcall target="undeploy-gd"/>
<antcall target="quicklook-summary"/>
<antcall target="remove-quicklook-policy-grants" />
<antcall target="disable-security-manager"/>
<antcall target="stop-server"/>
<antcall target="stop-derby"/>
<copy file="test-output/emailable-report.html" tofile="test-output/QL-GP-report.html" failonerror="false"/>
<antcall target="check-logged-messages"/>
<antcall target="testng-summary"/>
</target>
<!-- Target for testing glassfish distribution (containing EJB) -->
<target name="dev_debug" depends="clean">
<antcall target="verify-xml"/>
<antcall target="start-derby"/>
<antcall target="build-deploy"/>
<antcall target="runtest">
<antcall target="undeploy"/>
<antcall target="stop-derby"/>
<antcall target="check-logged-messages"/>
<antcall target="testng-summary"/>
</target>
<target name="build-deploy">
<echo message="ANT PROJECT ${ant.project.name}"/>
<ant dir="amx" target="build"/>
<ant dir="admin" target="build"/>
<ant dir="admincli" target="build"/>
<ant dir="adminconsole" target="build"/>
<ant dir="rest" target="build"/>
</target>
<target name="build-deploy-gd">
<echo message="Glassfish Distribution Build Deploy"/>
<!-- Temporarily jruby test is commented, because we need to integrate a newer version
for the test to pass. We are waiting for RE to release a newer version.
-->
</target>
<target name="undeploy">
</target>
<target name="undeploy-gd">
<!-- Temporarily jruby test is commented, because we need to integrate a newer version
for the test to pass. We are waiting for RE to release a newer version.
-->
</target>
<!-- Target is re-definted here as didn't want to specify ws.root property -->
<target name="clean">
<delete dir="${basedir}/classes"/>
<delete verbose="true" includeemptydirs="true">
<fileset dir="${basedir}" includes="**/classes"/>
</delete>
<delete dir="${basedir}/test-output" includeemptydirs="true"/>
<delete dir="${basedir}/dist" includeemptydirs="true"/>
<!-- Temporarily jruby test is commented, because we need to integrate a newer version
for the test to pass. We are waiting for RE to release a newer version.
<delete dir="${basedir}/web/jruby/helloworld" includeemptydirs="true"/>
-->
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<include name="**/*.output"/>
</fileset>
</delete>
</target>
<classpath>
<pathelement path="${plugin_classpath}"/>
</classpath>
</taskdef>
<!-- Target is re-definted here as didn't want to specify ws.root property -->
<target name="runtest" depends="initprops,setOSConditions,asenv-unix,asenv-windows">
<echo message="=============Starting TestNG functional tests from ${testng.xml} ============"/>
<property name="hasTestNGXML" value="true"/>
<mkdir dir="${test.report}"/>
<testng outputdir="${test.report}"
classpathref="run.testng.classpath">
<jvmarg value="-Djava.compiler=NONE"/>
<jvmarg value="-Dhttp.host=${glassfish.http.host}"/>
<jvmarg value="-Dhttp.port=${glassfish.http.port}"/>
<jvmarg value="-Djava.endorsed.dirs=${glassfish.home}/modules/endorsed" />
<jvmarg value="-DASADMIN=${ASADMIN}" />
<jvmarg value="-DAPPCLIENT=${APPCLIENT}"/>
<sysproperty key="BASEDIR" value="${basedir}"/>
<!--<classfileset dir="classes/test" includes="**/SeleniumTest.class"/>-->
</testng>
</target>
<target name="runtest-embedded" depends="initprops">
<mkdir dir="${test.report}"/>
<testng outputdir="${test.report}"
classpathref="embedded.testng.classpath">
<jvmarg value="-Djava.compiler=NONE"/>
<sysproperty key="BASEDIR" value="${basedir}"/>
</testng>
</target>
<!-- Generate the TestNG report -->
<target name="report" depends="initprops">
<echo message="Generating report at ${test.report}"/>
<junitreport todir="${basedir}/test-output">
<fileset dir=".">
<include name="**/test-output/**/*.xml"/>
<!--<exclude name="**/testng-failed.xml"/>-->
</fileset>
<report format="noframes" todir="${basedir}/test-output"/>
</junitreport>
<echo message="Test Report available at ${test.report}/index.html"/>
</target>
<!-- Fail the build unless the expected number of tests has passed -->
<target name="assert.expected.passed.test.count">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement
location="${maven.repo.local}/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<if>
<isset property="expected.passed.test.count" />
<then>
<echo>perform the assertion</echo>
<sequential>
<property name="test.report.dir"
value="${basedir}/test-output" />
<loadfile property="report.summary"
srcFile="${test.report.dir}/index.html" />
<propertyregex property="actual.passed.test.count"
input="${report.summary}"
regexp="(?s)(.*)(invocation-passed...td..em.Total./em../td..td..em.)([0-9]{1,6})(.*)"
select="\3"
/>
operation="subtract"
operand1="${actual.passed.test.count}"
operand2="${expected.passed.test.count}" />
<propertyregex property="actual.lessthan.expected"
input="${passed.test.count.difference}"
regexp="^-.*"
replace="actual.lessthan.expected" />
message="
--JOB FAILED!-- Fewer than expected tests passed. Expected: ${expected.passed.test.count} Actual: ${actual.passed.test.count}"/>
</sequential>
</then>
</if>
</target>
<!--
<target name="reportAll" depends="initprops">
<echo message="Generating report at ${test.report}"/>
<macrodef name="gen-report">
<attribute name="name" />
<sequential>
<junitreport todir="${basedir}/test-output-@{name}">
<fileset dir=".">
<include name="**/test-output-@{name}/**/*.xml"/>
</fileset>
<report format="noframes" todir="${basedir}/test-output-@{name}"/>
</junitreport>
</sequential>
</macrodef>
<gen-report name="web" />
<gen-report name="glassfish" />
<echo message="Test Report available at ${test.report}/index.html"/>
</target>
-->
<target name="initprops">
<mkdir dir="${test.report}"/>
<path id="run.testng.classpath">
<fileset dir="${glassfish.home}/modules">
<include name="**/hk2*.jar"/>
<include name="**/glassfish-api.jar"/>
<include name="**/amx-all.jar"/>
<include name="**/management-api.jar"/>
</fileset>
<fileset dir="${glassfish.home}/lib">
<include name="**/gf-client.jar"/>
</fileset>
<pathelement path="${plugin_classpath}"/>
<pathelement location="${Java_SE}"/>
<pathelement location="${build.class.dir}"/>
</path>
<path id="embedded.testng.classpath">
<fileset dir="${glassfish.home}/lib/embedded">
<include name="**/glassfish-embedded-static-shell.jar"/>
</fileset>
<pathelement location="${build.class.dir}"/>
<pathelement location="${build.class.dir}/EJB_Embedded/app"/>
</path>
</target>
<target name="testng-summary">
<filterchain>
<tailfilter lines="6"/>
</filterchain>
</loadfile>
<echo message="${testng_output}"/>
</target>
<target name="quicklook-summary">
<tstamp>
</tstamp>
<filterchain>
<tailfilter lines="4" skip="1"/>
<tokenfilter>
<replacestring from="[testng]" to=""/>
</tokenfilter>
</filterchain>
</loadfile>
<antcall target="build-version"/>
<antcall target="quicklook-report"/>
<delete file="version.output"/>
</target>
<filterchain>
<headfilter lines="1"/>
</filterchain>
</loadfile>
<property name="titleTime" value="<H1> GF QuickLook Test Results </H1> <HR> Build Info: ${build_version} <p> Test Completed at: ${end.timestamp}"/>
<property name="confRow1" value="<TABLE class=param> <TR> <TD>OS arch</TD> <TD>Java version </TD> <TD>Machine Name </TD> <TD>Security Manager</TD> </TR>"/>
<property name="confRow2" value="<TR> <TD>${os.name}-${os.arch}</TD> <TD>${java.version}</TD> <TD>${host.name}</TD> <TD>${env.security_manager}</TD> </TR> </TABLE>"/>
<replace file="test-output/emailable-report.html" token="<body>" value="<body> ${titleTime} ${confRow1} ${confRow2} <HR> <p>"/>
</target>
<target name="archive" depends="initprops,clean">
<tstamp>
<!--<format property="TODAY_UK" pattern="d-MMMM-yyyy" locale="en,UK"/>-->
</tstamp>
<delete>
<fileset dir="${basedir}" includes="*.zip"/>
</delete>
<exclude name="${test.report}/**"/>
<exclude name="${build.class.dir}/**"/>
<exclude name="**/*.log"/>
<exclude name="**/*.output"/>
<exclude name="**/*.war"/>
<exclude name="**/*.class"/>
<exclude name="**/CVS"/>
<exclude name="**/nbproject"/>
</zip>
</target>
<target name="setOSConditions">
<condition property="isUnix">
<os family="unix"/>
</condition>
<condition property="isWindows">
<os family="windows" />
</condition>
</target>
<target name="asenv-unix" if="isUnix">
</target>
<target name="asenv-windows" if="isWindows">
</target>
<target name="create-ql-domain" depends="setOSConditions,asenv-unix,asenv-windows">
<exec executable="${ASADMIN}" outputproperty="message1">
<arg line="create-domain --adminport ${QL_ADMIN_PORT} --nopassword ${QL_DOMAIN}"/>
</exec>
<echo message="${message1}"/>
</target>
<target name="start-server-hk2" depends="setOSConditions" if="v3">
<echo>+-----------------------------+</echo>
<echo>| |</echo>
<echo>| S T A R T I N G GLASSFISH |</echo>
<echo>| in HK2 mode |</echo>
<echo>| |</echo>
<echo>+-----------------------------+</echo>
<antcall target="start-server-hk2-unix"/>
<antcall target="start-server-hk2-windows"/>
</target>
<target name="start-server-hk2-windows" if="isWindows">
<exec executable="cmd" spawn="true">
<env key="GlassFish_Platform" value="HK2"/>
<arg value="/c"/>
<arg value="${glassfish.home}\bin\asadmin.bat"/>
<arg value="start-domain"/>
</exec>
</target>
<target name="start-server-hk2-unix" if="isUnix">
<exec executable="${glassfish.home}/bin/asadmin">
<env key="GlassFish_Platform" value="HK2"/>
<arg value="start-domain"/>
</exec>
</target>
<target name="start-server-felix" depends="setOSConditions" if="v3">
<echo>+-----------------------------+</echo>
<echo>| |</echo>
<echo>| S T A R T I N G GLASSFISH |</echo>
<echo>| in Felix mode |</echo>
<echo>| |</echo>
<echo>+-----------------------------+</echo>
<antcall target="start-server-felix-unix"/>
<antcall target="start-server-felix-windows"/>
<!-- GF takes longer than usual while starting Felix. Until we fix the
startup issue, let's introduce a delay.
<echo message="Sleeping for 20 seconds while the server is starting"/>
<sleep seconds="20"/>
-->
</target>
<target name="start-server-felix-windows" if="isWindows">
<exec executable="cmd" spawn="true">
<arg value="/c"/>
<arg value="${glassfish.home}\bin\asadmin.bat"/>
<arg value="start-domain"/>
<arg value="${QL_DOMAIN}"/>
</exec>
<waitfor maxwait="30" maxwaitunit="second" checkevery="500">
<http url="http://localhost:${QL_ADMIN_PORT}/"/>
</waitfor>
</target>
<target name="start-server-felix-unix" if="isUnix">
<exec executable="${glassfish.home}/bin/asadmin">
<arg value="start-domain"/>
<!-- <arg value="dashdashdebug=true"/> -->
<arg value="${QL_DOMAIN}"/>
</exec>
</target>
<target name="build-version" depends="setOSConditions">
<antcall target="build-version-unix"/>
<antcall target="build-version-windows"/>
</target>
<target name="build-version-unix" if="isUnix">
<arg value="version"/>
</exec>
</target>
<target name="build-version-windows" if="isWindows">
<arg value="/c"/>
<arg value="${glassfish.home}\bin\asadmin.bat"/>
<arg value="version"/>
</exec>
</target>
<target name="stop-server" depends="setOSConditions">
<echo message="stopping server"/>
<antcall target="stop-server-unix"/>
<antcall target="stop-server-windows"/>
<copy file="${glassfish.home}/domains/${QL_DOMAIN}/logs/server.log" tofile="${glassfish.home}/domains/domain1/logs/server.log" failonerror="false"/>
</target>
<target name="stop-server-windows" if="isWindows">
<exec executable="cmd">
<arg value="/c"/>
<arg value="${glassfish.home}\bin\asadmin.bat"/>
<arg value="stop-domain"/>
<arg value="${QL_DOMAIN}"/>
</exec>
</target>
<target name="stop-server-unix" if="isUnix">
<exec executable="${glassfish.home}/bin/asadmin">
<arg value="stop-domain"/>
<arg value="${QL_DOMAIN}"/>
</exec>
</target>
<target name="verify-xml" depends="setOSConditions">
<echo message="Verify Domain.xml"/>
<antcall target="verify-xml-unix"/>
<antcall target="verify-xml-windows"/>
</target>
<target name="verify-xml-unix" if="isUnix">
<exec executable="${glassfish.home}/bin/asadmin">
<arg value="verify-domain-xml"/>
</exec>
</target>
<target name="verify-xml-windows" if="isWindows">
<exec executable="cmd">
<arg value="/c"/>
<arg value="${glassfish.home}\bin\asadmin.bat"/>
<arg value="verify-domain-xml"/>
</exec>
</target>
</project>