Code example for Attributes

Methods: put

0
    public void test_classpath() throws Exception { 
        File resources = Support_Resources.createTempFolder();
 
        File fooJar = File.createTempFile("hyts_", ".jar");
        fooJar.deleteOnExit();
 
        JarOutputStream joutFoo = new JarOutputStream(new FileOutputStream(
                fooJar));
        joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Foo.class"));
        joutFoo.write(getResource(resources, "hyts_Foo.ser"));
        joutFoo.putNextEntry(new JarEntry("foo/bar/execjartest/Bar.class"));
        joutFoo.write(getResource(resources, "hyts_Bar.ser"));
        joutFoo.close();
 
        // execute the JAR and read the result 
        ProcessBuilder builder = javaProcessBuilder();
        builder.environment().put("CLASSPATH", fooJar.getAbsolutePath());
        builder.command().add("foo.bar.execjartest.Foo");
 
        assertTrue("Error executing class from ClassPath",
                execAndGetOutput(builder).startsWith("FOOBAR"));