@Test(expected = IOException.class) public void doNotCacheLocalDirResourceURI() throws IOException, URISyntaxException { Cache cache = Mockito.mock(Cache.class); URI localFileURI = getClass().getResource("archive.zip").toURI(); URI cachedLocalURI = new File(localFileURI).getParentFile().toURI(); assertTrue(CacheUtil.isLocalDir(cachedLocalURI)); when(cache.retrieve(any(URI.class))).thenThrow(new IOException("kaboom!")); DatasetImpl datasetUncached = new DatasetImpl("some/namespace", cachedLocalURI, inStream -> inStream); DatasetWithCache datasetWithCache = new DatasetWithCache(datasetUncached, cache); try { datasetWithCache.retrieve(cachedLocalURI); } catch (IOException ex) { assertThat(ex.getMessage(), is("kaboom!")); throw ex; } }
@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);  }