1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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 name="Java Script Test" default="test" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:jsl="antlib:com.googlecode.jslint4java">
<description>Java Script Test based on Thrift Java Library</description>
<property name="src" location="src" />
<property name="genjava" location="gen-java" />
<property name="genjs" location="gen-js" />
<property name="build" location="build" />
<property name="jar.file" location="${build}/jstest.jar" />
<!-- the root directory, where you unpack thrift distibution (e.g.: thrift-0.x.x.tar.gz) -->
<property name="thrift.dir" location="../../../" />
<property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
<property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/>
<property file="${basedir}/build.properties"/>
<!-- Include the base Java properties file -->
<property file="${thrift.java.dir}/gradle.properties" />
<property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
<path id="libs.classpath">
<fileset dir="${thrift.java.dir}/build/libs">
<include name="libthrift*.jar" />
<exclude name="libthrift*javadoc.jar" />
<exclude name="libthrift*sources.jar" />
</fileset>
<fileset dir="${build}/lib">
<include name="*.jar" />
</fileset>
</path>
<path id="test.classpath">
<path refid="libs.classpath" />
<pathelement location="${jar.file}" />
</path>
<target name="dependencies">
<fail>
<condition>
<not>
<resourcecount count="2">
<fileset id="fs" dir="${thrift.java.dir}/build/libs">
<include name="libthrift*.jar" />
<exclude name="libthrift*javadoc.jar" />
<exclude name="libthrift*sources.jar" />
</fileset>
</resourcecount>
</not>
</condition>
You need libthrift*.jar and libthrift*test.jar located at
${thrift.java.dir}/build/libs
Did you compile Thrift Java library and its test suite by "make check"?
</fail>
<fail>
<condition>
<not>
<resourcecount count="1">
<fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/>
</resourcecount>
</not>
</condition>
Thrift compiler is missing !
</fail>
</target>
<target name="init" depends="dependencies">
<tstamp />
<mkdir dir="${build.tools.dir}"/>
<mkdir dir="${build}"/>
<mkdir dir="${build}/js/lib"/>
<mkdir dir="${build}/lib"/>
<mkdir dir="${build}/log"/>
<mkdir dir="${build}/test"/>
<mkdir dir="${build}/test/log"/>
</target>
<target name="download_jslibs">
<get src="http://code.jquery.com/jquery-1.11.3.min.js" dest="${build}/js/lib/jquery.js" usetimestamp="true"/>
<get src="http://code.jquery.com/qunit/qunit-2.6.2.js" dest="${build}/js/lib/qunit.js" usetimestamp="true"/>
<get src="http://code.jquery.com/qunit/qunit-2.6.2.css" dest="${build}/js/lib/qunit.css" usetimestamp="true"/>
</target>
<target name="jslibs" depends="init, proxy, download_jslibs">
</target>
<target name="compile" description="compile the test suite" depends="init, generate, resolve">
<!-- //TODO enable <compilerarg value="-Xlint"/>-->
<javac compiler="modern" includeantruntime="false" srcdir="${genjava}" destdir="${build}/test" classpathref="libs.classpath"/>
<javac compiler="modern" includeantruntime="false" srcdir="${src}" destdir="${build}/test" classpathref="libs.classpath"/>
</target>
<target name="jstest" description="create the test suite jar file" depends="compile">
<jar jarfile="${jar.file}" basedir="${build}/test"/>
</target>
<target name="testserver" description="run the test server" depends="jstest, jslibs">
<java classname="test.Httpd" fork="true"
classpathref="test.classpath" failonerror="true">
<arg value="../" />
</java>
</target>
<target name="proxy" if="proxy.enabled">
<setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
proxyuser="${proxy.user}" proxypassword="${proxy.pass}"/>
</target>
<target name="xvfb">
<echo>check if Xvfb is available:</echo>
<exec executable="Xvfb" failifexecutionfails="no" resultproperty="xvfb.present" failonerror="false" output="${build}/log/xvfb.log">
<arg line="--version"/>
</exec>
</target>
<target name="phantomjs" depends="xvfb" if="xvfb.present">
<echo>check if phantomjs is available:</echo>
<exec executable="phantomjs" failifexecutionfails="no" resultproperty="phantomjs.present" failonerror="false" output="${build}/log/phantomjs.log">
<arg line="--version"/>
</exec>
</target>
<target name="unittest" description="do unit tests with headless browser phantomjs" depends="init, phantomjs, jstest, jslibs" if="phantomjs.present">
<parallel>
<exec executable="Xvfb" spawn="true" failonerror="false">
<arg line=":99" />
</exec>
<java classname="test.Httpd" fork="true" timeout="10000"
classpathref="test.classpath" failonerror="false" output="${build}/log/unittest.log">
<arg value="../" />
</java>
<sequential>
<sleep seconds="2"/>
<echo>Running Unit Tests with headless browser!</echo>
<exec executable="phantomjs" failonerror="true">
<env key="DISPLAY" value=":99"/>
<arg line="phantomjs-qunit.js http://localhost:8088/test/test.html" />
</exec>
</sequential>
</parallel>
</target>
<target name="generate">
<exec executable="${thrift.compiler}" failonerror="true">
<arg line="--gen java ${thrift.dir}/test/v0.16/ThriftTest.thrift" />
</exec>
<exec executable="${thrift.compiler}" failonerror="true">
<arg line="--gen js:jquery ${thrift.dir}/test/v0.16/ThriftTest.thrift" />
</exec>
<exec executable="${thrift.compiler}" failonerror="true">
<arg line="--gen js:jquery ${thrift.dir}/test/DoubleConstantsTest.thrift" />
</exec>
</target>
<target name="test" description="run test suite (lint, unittest)" depends="lint, unittest"/>
<target name="lint" description="code quality checks (jslint and gjslint if available)" depends="generate, gjslint, jslint"/>
<target name="jslint" depends="resolve">
<taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" />
<!--
the following options would probably make sense in the future:
browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed
-->
<jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed" encoding="UTF-8">
<formatter type="plain" />
<fileset dir="../src" includes="thrift.js" />
<!-- issues with unsafe character -->
<!-- fileset dir="." includes="*test*.js" /> -->
</jsl:jslint>
</target>
<target name="check-gjslint">
<echo>check if gjslint is available:</echo>
<exec executable="gjslint" failifexecutionfails="no" resultproperty="gjslint.present" failonerror="false">
<arg line="--helpshort"/>
</exec>
</target>
<target name="gjslint" depends="check-gjslint" if="gjslint.present">
<exec executable="gjslint" failifexecutionfails="no">
<arg line="--nojsdoc"/>
<arg line="${genjs}/*.js"/>
<arg line="../src/thrift.js"/>
<!-- issues with unsafe character, etc. -->
<!-- <arg line="*test*.js"/> -->
</exec>
</target>
<target name="clean">
<delete dir="${build}" />
<delete dir="${genjava}" />
<delete dir="${genjs}" />
</target>
<target name="mvn.ant.tasks.download" depends="init,mvn.ant.tasks.check" unless="mvn.ant.tasks.found">
<get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
</target>
<target name="mvn.ant.tasks.check">
<condition property="mvn.ant.tasks.found">
<typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
</condition>
</target>
<target name="resolve" depends="mvn.ant.tasks.download" unless="mvn.finished">
<typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/>
<artifact:dependencies filesetId="js.test.dependency.jars">
<dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
<dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
<dependency groupId="eu.medsea.mimeutil" artifactId="mime-util" version="2.1.3"/>
<dependency groupId="javax.annotation" artifactId="javax.annotation-api" version="1.3.2"/>
<remoteRepository url="${mvn.repo}"/>
</artifact:dependencies>
<!-- Copy the dependencies to the build/lib dir -->
<copy todir="${build}/lib">
<fileset refid="js.test.dependency.jars"/>
<mapper type="flatten"/>
</copy>
<property name="mvn.finished" value="true"/>
</target>
</project>
|