@Test public void getURIRelativeInArchive() throws IOException { Cache cache = Mockito.mock(Cache.class); when(cache.retrieve(URI.create("some:bla"))).thenReturn(getClass().getResourceAsStream("archive.zip")); when(cache.retrieve(URI.create("jar:uri:cached!/template-dataset-e68f4487ebc3bc70668c0f738223b92da0598c00/foo"))).thenReturn(IOUtils.toInputStream("relative", StandardCharsets.UTF_8)); when(cache.provenanceOf(URI.create("some:bla"))).thenReturn(new ContentProvenance("foo/bar", URI.create("uri:source"), URI.create("uri:cached"), "1234", "1970-01-01")); DatasetImpl datasetUncached = new DatasetImpl("some/namespace", URI.create("some:bla"), inStream -> inStream); DatasetWithCache datasetWithCache = new DatasetWithCache(datasetUncached, cache); InputStream is = datasetWithCache.retrieve(URI.create("foo")); assertThat(IOUtils.toString(is, StandardCharsets.UTF_8), is("relative")); }
@Override public InputStream retrieve(URI resourceName) throws IOException { return cache.retrieve(resourceName); }
DatasetWithCache implements Dataset { @Override public InputStream retrieve(URI resourceName) throws IOException { return cache.retrieve(resourceName); } }
DatasetWithCache implements Dataset { @Override public InputStream retrieve(URI resourceName) throws IOException { return cache.retrieve(resourceName); } DatasetWithCache(Dataset dataset, final Cache cache); }
DatasetWithCache implements Dataset { @Override public InputStream retrieve(URI resourceName) throws IOException { return cache.retrieve(resourceName); } DatasetWithCache(Dataset dataset, final Cache cache); @Override InputStream retrieve(URI resourceName); URI getArchiveURI(); @Override String getOrDefault(String key, String defaultValue); String getNamespace(); JsonNode getConfig(); DOI getDOI(); String getCitation(); String getFormat(); URI getConfigURI(); @Override void setConfig(JsonNode config); @Override void setConfigURI(URI configURI); }
DatasetWithCache implements Dataset { @Override public InputStream retrieve(URI resourceName) throws IOException { return cache.retrieve(resourceName); } DatasetWithCache(Dataset dataset, final Cache cache); @Override InputStream retrieve(URI resourceName); URI getArchiveURI(); @Override String getOrDefault(String key, String defaultValue); String getNamespace(); JsonNode getConfig(); DOI getDOI(); String getCitation(); String getFormat(); URI getConfigURI(); @Override void setConfig(JsonNode config); @Override void setConfigURI(URI configURI);  }