use of java.util.jar.JarOutputStream in project buck by facebook.
the class CustomZipEntryTest method writeSimpleJarAndGetHash.
private HashCode writeSimpleJarAndGetHash() throws Exception {
Path output = Files.createTempFile("example", ".jar");
try (FileOutputStream fileOutputStream = new FileOutputStream(output.toFile());
ZipOutputStream out = new JarOutputStream(fileOutputStream)) {
ZipEntry entry = new CustomZipEntry("test");
out.putNextEntry(entry);
out.write(new byte[0]);
entry = new ZipEntry("test1");
entry.setTime(ZipConstants.getFakeTime());
out.putNextEntry(entry);
out.write(new byte[0]);
}
return Hashing.sha1().hashBytes(Files.readAllBytes(output));
}
use of java.util.jar.JarOutputStream in project error-prone by google.
the class BoxedPrimitiveConstructorTest method incompleteClasspath.
@Test
public void incompleteClasspath() throws Exception {
File libJar = tempFolder.newFile("lib.jar");
try (FileOutputStream fis = new FileOutputStream(libJar);
JarOutputStream jos = new JarOutputStream(fis)) {
addClassToJar(jos, BoxedPrimitiveConstructorTest.class);
addClassToJar(jos, Inner.class);
}
compilationHelper.addSourceLines("Test.java", "import " + Inner.class.getCanonicalName() + ";", "class Test {", " void m() {", " new Inner();", " }", "}").setArgs(Arrays.asList("-cp", libJar.toString())).doTest();
}
use of java.util.jar.JarOutputStream in project error-prone by google.
the class CheckReturnValueTest method noCRVonClasspath.
@Test
public void noCRVonClasspath() throws Exception {
File libJar = tempFolder.newFile("lib.jar");
try (FileOutputStream fis = new FileOutputStream(libJar);
JarOutputStream jos = new JarOutputStream(fis)) {
addClassToJar(jos, CRVTest.class);
addClassToJar(jos, CheckReturnValueTest.class);
}
compilationHelper.addSourceLines("Test.java", "class Test {", " void m() {", " // BUG: Diagnostic contains: Ignored return value", " com.google.errorprone.bugpatterns.CheckReturnValueTest.CRVTest.f();", " }", "}").setArgs(Arrays.asList("-cp", libJar.toString())).doTest();
}
use of java.util.jar.JarOutputStream in project error-prone by google.
the class FunctionalInterfaceClashTest method incompleteClasspath.
@Test
public void incompleteClasspath() throws Exception {
File libJar = tempFolder.newFile("lib.jar");
try (FileOutputStream fis = new FileOutputStream(libJar);
JarOutputStream jos = new JarOutputStream(fis)) {
addClassToJar(jos, getClass());
addClassToJar(jos, Super.class);
}
testHelper.addSourceLines("Test.java", "import " + Super.class.getCanonicalName() + ";", "class Test extends Super {}").setArgs(Arrays.asList("-cp", libJar.toString())).doTest();
}
use of java.util.jar.JarOutputStream in project error-prone by google.
the class JUnit4SetUpNotRunTest method noBeforeOnClasspath.
@Test
public void noBeforeOnClasspath() throws Exception {
File libJar = tempFolder.newFile("lib.jar");
try (FileOutputStream fis = new FileOutputStream(libJar);
JarOutputStream jos = new JarOutputStream(fis)) {
addClassToJar(jos, RunWith.class);
addClassToJar(jos, JUnit4.class);
addClassToJar(jos, BlockJUnit4ClassRunner.class);
addClassToJar(jos, ParentRunner.class);
addClassToJar(jos, SuperTest.class);
addClassToJar(jos, SuperTest.class.getEnclosingClass());
}
compilationHelper.addSourceLines("Test.java", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "import " + SuperTest.class.getCanonicalName() + ";", "@RunWith(JUnit4.class)", "class Test extends SuperTest {", " @Override public void setUp() {}", "}").setArgs(Arrays.asList("-cp", libJar.toString())).doTest();
}
Aggregations