-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test-acceptance/java/jscover/util/ClassVersionChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |