@Test public void testGetResourceURL_fromDirectory_resourceFileDoesNotExist() throws IOException { File targetDirectory = null; try { targetDirectory = createTestDirectory(); System.setProperty(ResourceHandler.SMOS_DDDB_DIR_PROPERTY_NAME, targetDirectory.getAbsolutePath()); final URL resourceUrl = resourceHandler.getResourceUrl("wurst"); assertNull(resourceUrl); } finally { System.clearProperty(ResourceHandler.SMOS_DDDB_DIR_PROPERTY_NAME); if (targetDirectory != null && targetDirectory.isDirectory()) { if (!FileUtils.deleteTree(targetDirectory)) { fail("Unable to delete test directory"); } } } }
URL getResourceUrl(String path) throws MalformedURLException { final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME); if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) { final File resourceFile = new File(dddbDirFromProperty, path); if (resourceFile.isFile()) { return new URL("file", "", 0, resourceFile.getAbsolutePath()); } } return getClass().getResource(path); }
ResourceHandler { URL getResourceUrl(String path) throws MalformedURLException { final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME); if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) { final File resourceFile = new File(dddbDirFromProperty, path); if (resourceFile.isFile()) { return new URL("file", "", 0, resourceFile.getAbsolutePath()); } } return getClass().getResource(path); } }
ResourceHandler { URL getResourceUrl(String path) throws MalformedURLException { final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME); if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) { final File resourceFile = new File(dddbDirFromProperty, path); if (resourceFile.isFile()) { return new URL("file", "", 0, resourceFile.getAbsolutePath()); } } return getClass().getResource(path); }  }
ResourceHandler { URL getResourceUrl(String path) throws MalformedURLException { final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME); if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) { final File resourceFile = new File(dddbDirFromProperty, path); if (resourceFile.isFile()) { return new URL("file", "", 0, resourceFile.getAbsolutePath()); } } return getClass().getResource(path); }   }
ResourceHandler { URL getResourceUrl(String path) throws MalformedURLException { final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME); if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) { final File resourceFile = new File(dddbDirFromProperty, path); if (resourceFile.isFile()) { return new URL("file", "", 0, resourceFile.getAbsolutePath()); } } return getClass().getResource(path); }    }