@Override public InputStream getInputStream() throws IOException { return resource.getObject().getInputStream(); }
@Override public InputStream getInputStream() throws IOException { return resource.getObject().getInputStream(); }
@Override public Reader getReader(String resourceName) { Path.Relative partialPath = (Path.Relative)Path.parse(resourceName); Timestamped<Resource> partial = context.resolveResource(partialPath); if (partial != null) { return new StringReader(partial.getObject().getCharSequence().toString()); } else { return null; } }
@Override public Reader getReader(String resourceName) { Path.Relative partialPath = (Path.Relative)Path.parse(resourceName); Timestamped<Resource> partial = context.resolveResource(partialPath); if (partial != null) { return new StringReader(partial.getObject().getCharSequence().toString()); } else { return null; } }
public final InputStream openInputStream() throws IOException { return assertContent().getObject().getInputStream(); }
public final CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return assertContent().getObject().getCharSequence(); }
public final CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { return assertContent().getObject().getCharSequence(); }
public final InputStream openInputStream() throws IOException { return assertContent().getObject().getInputStream(); }
@Override protected long stampOf(P file) throws IOException { juzu.impl.common.Timestamped<Resource> resource = fs.getResource(file); InputStream in = resource.getObject().getInputStream(); byte[] bytes = Tools.bytes(in); return Tools.md5(bytes); }
@Override protected long stampOf(P file) throws IOException { juzu.impl.common.Timestamped<Resource> resource = fs.getResource(file); InputStream in = resource.getObject().getInputStream(); byte[] bytes = Tools.bytes(in); return Tools.md5(bytes); }
public String assertContent() { try { Resource content = sourcePath.getResource(path).getObject(); return content.getCharSequence().toString(); } catch (Exception e) { throw AbstractTestCase.failure(e); } }
public String assertContent() { try { Resource content = sourcePath.getResource(path).getObject(); return content.getCharSequence().toString(); } catch (Exception e) { throw AbstractTestCase.failure(e); } }
public void assertTouch() { try { Resource content = sourcePath.getResource(path).getObject(); sourcePath.updateResource(path, content); } catch (Exception e) { throw AbstractTestCase.failure(e); } }
public void assertTouch() { try { Resource content = sourcePath.getResource(path).getObject(); sourcePath.updateResource(path, content); } catch (Exception e) { throw AbstractTestCase.failure(e); } }
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); } } return cu; }
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); } } return cu; }
@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(); Context a = composite.getChild(root, "a"); assertNotNull(a); assertEquals(PathType.DIR, composite.typeOf(a)); // Context b = composite.getChild(a, "b"); assertNotNull(b); assertEquals(PathType.FILE, composite.typeOf(b)); assertEquals(Tools.list("a", "b"), composite.getNames(b)); // Timestamped<Resource> content = composite.getResource(b); assertNotNull(content); assertEquals("foo", content.getObject().getCharSequence().toString()); } }
@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(); Context a = composite.getChild(root, "a"); assertNotNull(a); assertEquals(PathType.DIR, composite.typeOf(a)); // Context b = composite.getChild(a, "b"); assertNotNull(b); assertEquals(PathType.FILE, composite.typeOf(b)); assertEquals(Tools.list("a", "b"), composite.getNames(b)); // Timestamped<Resource> content = composite.getResource(b); assertNotNull(content); assertEquals("foo", content.getObject().getCharSequence().toString()); } }