Package juzu.impl.common

Examples of juzu.impl.common.Resource


    if (fs instanceof ReadWriteFileSystem<?>) {
      final ReadWriteFileSystem<P> fs = (ReadWriteFileSystem<P>)this.fs;
      return new ByteArrayOutputStream() {
        @Override
        public void close() throws IOException {
          Resource content = new Resource(toByteArray(), null);
          long lastModified = fs.updateResource(file, content);
          JavaFileObjectImpl.this.content = new Timestamped<Resource>(lastModified, content);
          JavaFileObjectImpl.this.writing = false;
        }
      };
View Full Code Here


    if (fs instanceof ReadWriteFileSystem<?>) {
      final ReadWriteFileSystem<P> fs = (ReadWriteFileSystem<P>)this.fs;
      return new StringWriter() {
        @Override
        public void close() throws IOException {
          Resource content = new Resource(getBuffer());
          long lastModified = fs.updateResource(file, content);
          JavaFileObjectImpl.this.content = new Timestamped<Resource>(lastModified, content);
          JavaFileObjectImpl.this.writing = false;
        }
      };
View Full Code Here

    P foo = fs.makePath(Collections.singleton("foo"));
    P bar = fs.makePath(foo, "bar");
    assertEquals(1, fs.size(ReadFileSystem.PATH));

    // Now create
    fs.updateResource(bar, new Resource("FOO"));

    //
    assertEquals(3, fs.size(ReadFileSystem.PATH));
    assertEquals(2, fs.size(ReadFileSystem.DIR));
    assertEquals(1, fs.size(ReadFileSystem.FILE));
View Full Code Here

  }

  public CompilationUnit assertCompilationUnit() {
    if (cu == null) {
      try {
        Resource content = sourcePath.getResource(path).getObject();
        InputStream in = content.getInputStream();
        cu = JavaParser.parse(in);
      }
      catch (Exception e) {
        throw AbstractTestCase.failure(e);
      }
View Full Code Here

  @Test
  public void testFoo() throws IOException {

    RAMFileSystem ramFS = new RAMFileSystem();
    ramFS.updateResource(new String[]{"a", "b"}, new Resource("foo"));

    //
    CompositeFileSystem composite = new CompositeFileSystem(ramFS);

    Context root = composite.getRoot();
View Full Code Here

    this.path = path;
  }

  public String assertContent() {
    try {
      Resource content = sourcePath.getResource(path).getObject();
      return content.getCharSequence().toString();
    }
    catch (Exception e) {
      throw AbstractTestCase.failure(e);
    }
  }
View Full Code Here

    }
  }

  public void assertTouch() {
    try {
      Resource content = sourcePath.getResource(path).getObject();
      sourcePath.updateResource(path, content);
    }
    catch (Exception e) {
      throw AbstractTestCase.failure(e);
    }
View Full Code Here

    }
  }

  public void assertSave(String content) {
    try {
      sourcePath.updateResource(path, new Resource(content));
    }
    catch (Exception e) {
      throw AbstractTestCase.failure(e);
    }
  }
View Full Code Here

  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);
View Full Code Here

    assertEquals(1, classOutput.size(ReadFileSystem.FILE));

    //
    ReadWriteFileSystem<File> sourcePath = (ReadWriteFileSystem<File>)compiler.getSourcePath();
    File b = sourcePath.makePath(sourcePath.getPath("compiler", "incremental"), "B.java");
    sourcePath.updateResource(b, new Resource("package compiler.incremental; public class B extends A {}"));
    compiler.assertCompile();
    assertEquals(2, classOutput.size(ReadFileSystem.FILE));
  }
View Full Code Here

TOP

Related Classes of juzu.impl.common.Resource

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.