[jscover] 42/69: Fix Java 5 compatibility (https://github.com/tntim96/JSCover/issues/150)

Sylvestre Ledru sylvestre at moszumanska.debian.org
Fri Aug 22 05:54:06 UTC 2014


This is an automated email from the git hooks/post-receive script.

sylvestre pushed a commit to branch master
in repository jscover.

commit 72b568eaaba4932916c73c0d431b7408c4d8c4d6
Author: tntim96 <tntim96 at gmail.com>
Date:   Tue Jul 8 20:17:23 2014 +1000

    Fix Java 5 compatibility (https://github.com/tntim96/JSCover/issues/150)
---
 History.md                                         |  1 +
 build.xml                                          | 18 +++++++++-
 .../java/jscover/util/ClassVersionChecker.java     | 39 ++++++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/History.md b/History.md
index f534fe5..773f892 100644
--- a/History.md
+++ b/History.md
@@ -1,5 +1,6 @@
 1.0.13 / 2014-??-??
 ==================
+  * Fix Java 5 compatibility (https://github.com/tntim96/JSCover/issues/150)
   * Don't copy non-report files (https://github.com/tntim96/JSCover/issues/149)
   * Internal: Remove checked exception from public API
 
diff --git a/build.xml b/build.xml
index 25fe37d..e1eb33d 100644
--- a/build.xml
+++ b/build.xml
@@ -95,7 +95,7 @@
         </jar>
     </target>
 
-    <target name="jar-all" depends="compile">
+    <target name="jar-all" depends="compile-acceptance-tests">
         <property name="tmpDir" value="${build.dir}/tmp"/>
         <mkdir dir="${tmpDir}"/>
         <unzip src="${com.github.tntim96:rhino:jar}" dest="${tmpDir}"/>
@@ -110,6 +110,22 @@
                 <attribute name="Main-Class" value="jscover.Main"/>
             </manifest>
         </jar>
+        <junit haltonfailure="yes" haltonerror="yes" failureProperty="test.failure" errorproperty="test.failure">
+            <classpath>
+                <path refid="classpath-main" />
+                <path refid="compile.classpath" />
+                <path refid="test.classpath" />
+            </classpath>
+            <formatter type="xml" />
+            <formatter type="brief" usefile="no" />
+            <batchtest fork="yes" todir="${report.test.dir}">
+                <fileset dir="${classes.test-acceptance.dir}">
+                    <include name="**/ClassVersionChecker.class" />
+                </fileset>
+            </batchtest>
+        </junit>
+        <antcall target="report-if-failed"/>
+        <fail if="test.failure"/>
     </target>
 
     <target name="mvn-install-local" depends="jar-all">
diff --git a/src/test-acceptance/java/jscover/util/ClassVersionChecker.java b/src/test-acceptance/java/jscover/util/ClassVersionChecker.java
new file mode 100644
index 0000000..ff8e18a
--- /dev/null
+++ b/src/test-acceptance/java/jscover/util/ClassVersionChecker.java
@@ -0,0 +1,39 @@
+package jscover.util;
+
+import org.junit.Test;
+
+import java.io.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class ClassVersionChecker {
+    @Test
+    public void testClasses() throws IOException {
+        File zipFile = new File("target/dist/JSCover-all.jar");
+        ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile));
+        ZipEntry ze;
+        while ((ze = zis.getNextEntry()) != null) {
+            String fileName = ze.getName();
+            if (!fileName.endsWith(".class"))
+                continue;
+            checkClassVersion2(new File(new File("target/tmp"), fileName));
+        }
+        zis.closeEntry();
+        zis.close();
+    }
+
+    private static void checkClassVersion2(File file) throws IOException {
+        byte[] buffer = new byte[8];
+
+        FileInputStream in = new FileInputStream(file);
+        in.read(buffer, 0, 8);
+        in.close();
+
+        int majorVersion = buffer[6] << 8 | buffer[7];
+        //int minorVersion = buffer[4] << 8 | buffer[5];
+        assertThat(file + " is not a 1.5 class!", majorVersion, equalTo(49));
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jscover.git



More information about the pkg-java-commits mailing list