forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bd...@apache.org
Subject svn commit: r1100442 - in /forrest/trunk/whiteboard/forrest-osgi: master.xml org.apache.forrest.util/build.xml org.apache.forrest.util/src/test/org/apache/forrest/util/ContentTypeTest.java
Date Sat, 07 May 2011 04:14:05 GMT
Author: bdube
Date: Sat May  7 04:14:04 2011
New Revision: 1100442

URL: http://svn.apache.org/viewvc?rev=1100442&view=rev
Log:
Add generic test harness to build process using JUnit and break on failed tests

Modified:
    forrest/trunk/whiteboard/forrest-osgi/master.xml
    forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/build.xml
    forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/src/test/org/apache/forrest/util/ContentTypeTest.java

Modified: forrest/trunk/whiteboard/forrest-osgi/master.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest-osgi/master.xml?rev=1100442&r1=1100441&r2=1100442&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest-osgi/master.xml (original)
+++ forrest/trunk/whiteboard/forrest-osgi/master.xml Sat May  7 04:14:04 2011
@@ -43,13 +43,16 @@
   <property name="bundle.bnd.file" location="" />
   <property name="src.dir" location="src" />
   <property name="java.src.dir" location="${src.dir}/java" />
+  <property name="java.test.src.dir" location="${src.dir}/test" />
   <property name="bundle.resource.dir" location="${src.dir}/bundle" />
   <property name="build.dir" location="build" />
   <property name="build.classes" location="${build.dir}/classes" />
+  <property name="build.test.classes" location="${build.dir}/test" />
   <property name="jar.file" value="${bundle.symbolic.name}.jar" />
 
   <target name="init">
     <mkdir dir="${build.classes}" />
+    <mkdir dir="${build.test.classes}" />
 
     <path id="classpath">
       <fileset dir="${forrest.lib.dir}" includes="*.jar" />
@@ -68,7 +71,36 @@
     </javac>
   </target>
 
-  <target name="jar" depends="compile">
+  <target name="compile-tests" depends="compile">
+    <echo>Compiling tests for ${ant.project.name}</echo>
+    <javac srcdir="${java.test.src.dir}"
+           destdir="${build.test.classes}"
+           debug="true"
+           includeantruntime="false">
+      <classpath>
+        <pathelement location="${forrest.lib.dir}/junit-4.8.1.jar" />
+        <pathelement location="${build.classes}" />
+        <pathelement location="${java.test.src.dir}" />
+      </classpath>
+    </javac>
+  </target>
+
+  <target name="test" depends="compile,compile-tests">
+    <junit printsummary="true"
+           failureproperty="junit.failure">
+      <classpath>
+        <pathelement location="${forrest.lib.dir}/junit-4.8.1.jar" />
+        <pathelement location="${build.classes}" />
+        <pathelement location="${build.test.classes}" />
+      </classpath>
+      <batchtest>
+        <fileset dir="${build.test.classes}" />
+      </batchtest>
+    </junit>
+    <fail if="junit.failure" message="There are unit test failures. Please check the output
above." />
+  </target>
+
+  <target name="jar" depends="test">
     <echo>Packaging ${ant.project.name}</echo>
     <jar destfile="${build.dir}/${jar.file}">
       <fileset dir="${build.classes}" />

Modified: forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/build.xml
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/build.xml?rev=1100442&r1=1100441&r2=1100442&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/build.xml (original)
+++ forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/build.xml Sat May  7 04:14:04
2011
@@ -25,29 +25,6 @@
   <property name="bundle.symbolic.name" value="org.apache.forrest.util" />
   <property name="bundle.bnd.file" location="util.bnd" />
 
-  <target name="compile-tests">
-    <javac srcdir="src/test"
-           destdir="build/classes"
-           debug="true"
-           includeantruntime="false">
-      <compilerarg value="-Xlint" />
-      <classpath>
-        <pathelement location="../lib/junit-4.8.1.jar" />
-      </classpath>
-    </javac>
-  </target>
-
-  <target name="test" depends="compile-tests">
-    <java classname="org.junit.runner.JUnitCore"
-          fork="no">
-      <classpath>
-        <pathelement location="../lib/junit-4.8.1.jar" />
-        <pathelement location="build/classes" />
-      </classpath>
-      <arg value="org.apache.forrest.util.ContentTypeTest" />
-    </java>
-  </target>
-
   <import file="../master.xml" />
 
 </project>

Modified: forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/src/test/org/apache/forrest/util/ContentTypeTest.java
URL: http://svn.apache.org/viewvc/forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/src/test/org/apache/forrest/util/ContentTypeTest.java?rev=1100442&r1=1100441&r2=1100442&view=diff
==============================================================================
--- forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/src/test/org/apache/forrest/util/ContentTypeTest.java
(original)
+++ forrest/trunk/whiteboard/forrest-osgi/org.apache.forrest.util/src/test/org/apache/forrest/util/ContentTypeTest.java
Sat May  7 04:14:04 2011
@@ -23,16 +23,18 @@ import org.apache.forrest.util.ContentTy
 
 public class ContentTypeTest {
 
+  static final String HTML_NAME = "index.html";
+
   @Test
   public void getExtensionByName() {
-    String extension = ContentType.getExtensionByName("index.html");
-    assertTrue("html".equals(extension));
+    String extension = ContentType.getExtensionByName(HTML_NAME);
+    assertEquals("html", extension);
   }
 
   @Test
   public void getContentTypeByName() {
-    String contentType = ContentType.getContentTypeByName("index.html");
-    assertTrue("text/html".equals(contentType));
+    String contentType = ContentType.getContentTypeByName(HTML_NAME);
+    assertEquals("text/html", contentType);
   }
 
 }



Mime
View raw message