java: Add JUnit to ivy config. Convert Nonblocking server tests to use JUnit. Framework laid to convert the remainder of the tests.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@927693 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/java/build.xml b/lib/java/build.xml
index e8e5d78..4cf7c8f 100644
--- a/lib/java/build.xml
+++ b/lib/java/build.xml
@@ -163,7 +163,34 @@
     <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
   </target>
 
-  <target name="test" description="Run the full test suite" depends="compile-test">
+  <property name="build.test" location="${build.dir}/test"/>
+  <property name="test.junit.output.format" value="plain"/>
+  <property name="test.timeout" value="2000000"/>
+  <property name="test.src.dir" location="${basedir}/test"/>
+  <property name="test.log.dir" value="${build.test}/log"/>
+
+  <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
+    <mkdir dir="${test.log.dir}"/>
+    <junit
+      printsummary="yes" showoutput="${test.output}" 
+      haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m"
+      errorProperty="tests.failed" failureProperty="tests.failed"
+      timeout="${test.timeout}"
+    >
+      <sysproperty key="build.test" value="${build.test}"/>
+      <classpath refid="test.classpath"/>
+      <formatter type="${test.junit.output.format}" />
+      <batchtest todir="${test.log.dir}" unless="testcase">
+        <fileset dir="${test.src.dir}" includes="**/Test*.java" />
+      </batchtest>
+      <batchtest todir="${test.log.dir}" if="testcase">
+        <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
+      </batchtest>
+    </junit>
+    <fail if="tests.failed">Tests failed!</fail>
+  </target>
+
+  <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
     <java classname="org.apache.thrift.test.JSONProtoTest"
       classpathref="test.classpath" failonerror="true" />
     <java classname="org.apache.thrift.test.TCompactProtocolTest"
@@ -192,6 +219,8 @@
       classpathref="test.classpath" failonerror="true" />
   </target>
 
+  <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
+
   <target name="testclient" description="Run a test client">
     <java classname="org.apache.thrift.test.TestClient"
       classpathref="test.classpath" failonerror="true">