Package juzu.impl.fs.spi.ram

Examples of juzu.impl.fs.spi.ram.RAMFileSystem


    fic.deleteOnExit();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class);
    jar.addAsResource(new StringAsset("the_resource"), "resource.txt");
    jar.as(ZipExporter.class).exportTo(fic, true);
    JarFileSystem classpath = new JarFileSystem(new JarFile(fic));
    RAMFileSystem output = new RAMFileSystem();
    Compiler compiler = Compiler.builder().
        javaCompiler(compilerProvider).
        config(new CompilerConfig().force(true)).
        addClassPath(classpath).
        sourcePath(new RAMFileSystem()).
        output(output).build();
    GetResource processor = new GetResource(StandardLocation.CLASS_PATH, FileKey.newResourceName("", "resource.txt"));
    compiler.addAnnotationProcessor(processor);
    compiler.compile();
    processor.assertResource("the_resource");
View Full Code Here


    processor.assertResource("the_resource");
  }

  // For now we don't support this until we figure the feature fully
  public void _testChange() throws Exception {
    RAMFileSystem ramFS = new RAMFileSystem();
    String[] root = ramFS.getRoot();
    String[] foo = ramFS.makePath(root, "foo");
    String[] a = ramFS.makePath(foo, "A.java");
    ramFS.updateResource(a, new Resource("package foo; public class A {}"));
    String[] b = ramFS.makePath(foo, "B.java");
    ramFS.updateResource(b, new Resource("package foo; public class B {}"));

    //
    RAMFileSystem output = new RAMFileSystem();
    Compiler compiler = Compiler.builder().sourcePath(ramFS).output(output).build();
    compiler.compile();
    assertEquals(2, output.size(ReadFileSystem.FILE));
    Timestamped<Resource> aClass = output.getResource(new String[]{"foo", "A"});
    assertNotNull(aClass);
    Timestamped<Resource> bClass = output.getResource(new String[]{"foo", "B"});
    assertNotNull(bClass);

    //
    while (true) {
      ramFS.updateResource(b, new Resource("package foo; public class B extends A {}"));
      if (bClass.getTime() < ramFS.getLastModified(b)) {
        break;
      }
      else {
        Thread.sleep(1);
      }
    }

    //
    compiler.compile();
    assertEquals(1, output.size(ReadFileSystem.FILE));
    bClass = output.getResource(new String[]{"foo", "B"});
    assertNotNull(bClass);
  }
View Full Code Here

TOP

Related Classes of juzu.impl.fs.spi.ram.RAMFileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.