use of org.apache.tools.ant.taskdefs.Java in project elephant-bird by twitter.
the class TestProtobufWritable method testStableHashcodeAcrossJVMs.
@Test
public void testStableHashcodeAcrossJVMs() throws IOException {
int expectedHashCode = referenceAbWritable.hashCode();
Java otherJvm = new Java();
otherJvm.setNewenvironment(true);
otherJvm.setFork(true);
otherJvm.setProject(new Project());
otherJvm.setClassname(OtherJvmClass.class.getName());
for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
Environment.Variable var = new Environment.Variable();
var.setKey(entry.getKey());
var.setValue(entry.getValue());
otherJvm.addEnv(var);
}
for (String prop : System.getProperties().stringPropertyNames()) {
String propValue = System.getProperty(prop);
Environment.Variable var = new Environment.Variable();
var.setKey(prop);
var.setValue(propValue);
otherJvm.addSysproperty(var);
}
otherJvm.setDir(new File(System.getProperty("java.io.tmpdir")));
File tmpOut = File.createTempFile("otherJvm", "txt");
otherJvm.setArgs(tmpOut.getAbsolutePath());
otherJvm.init();
otherJvm.executeJava();
DataInputStream is = new DataInputStream(new FileInputStream(tmpOut));
assertEquals(expectedHashCode, is.readInt());
is.close();
}
Aggregations