UTs on Windows when project path contains space & some exception review

This commit is contained in:
Alix Lourme
2016-11-22 23:33:40 +01:00
parent 2ad08d2367
commit 6ecf55be91
8 changed files with 27 additions and 27 deletions

View File

@@ -115,7 +115,6 @@ class DriverShim implements Driver {
* @throws SQLFeatureNotSupportedException thrown if the feature is not supported
* @see java.sql.Driver#getParentLogger()
*/
@Override
public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException {
//return driver.getParentLogger();
Method m = null;

View File

@@ -65,7 +65,7 @@ public abstract class BaseDBTestCase extends BaseTest {
FileInputStream fis = null;
ZipInputStream zin = null;
try {
File path = new File(BaseDBTestCase.class.getClassLoader().getResource("data.zip").getPath());
File path = new File(BaseDBTestCase.class.getClassLoader().getResource("data.zip").toURI().getPath());
fis = new FileInputStream(path);
zin = new ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;

View File

@@ -17,6 +17,8 @@ package org.owasp.dependencycheck;
import java.io.File;
import java.io.InputStream;
import java.net.URISyntaxException;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.BeforeClass;
@@ -69,8 +71,12 @@ public class BaseTest {
* @return the resource as an File
*/
public static File getResourceAsFile(Object o, String resource) {
File f = new File(o.getClass().getClassLoader().getResource(resource).getPath());
Assume.assumeTrue(String.format("%n%n[SEVERE] Unable to load resource for test case: %s%n%n", resource), f.exists());
return f;
try{
File f = new File(o.getClass().getClassLoader().getResource(resource).toURI().getPath());
Assume.assumeTrue(String.format("%n%n[SEVERE] Unable to load resource for test case: %s%n%n", resource), f.exists());
return f;
}catch (URISyntaxException e){
throw new UnsupportedOperationException(e);
}
}
}

View File

@@ -42,8 +42,7 @@ public class UpdateableNvdCveTest extends BaseTest {
public void testIsUpdateNeeded() throws MalformedURLException, DownloadFailedException, IOException {
String id = "key";
//use a local file as this test will load the result and check the timestamp
File f = new File("target/test-classes/nvdcve-2.0-2012.xml");
String url = "file:///" + f.getCanonicalPath();
String url = new File("target/test-classes/nvdcve-2.0-2012.xml").toURI().toString();
UpdateableNvdCve instance = new UpdateableNvdCve();
instance.add(id, url, url, false);
@@ -64,9 +63,8 @@ public class UpdateableNvdCveTest extends BaseTest {
@Test
public void testAdd_3args() throws Exception {
String id = "key";
File f = new File("target/test-classes/nvdcve-2.0-2012.xml");
//use a local file as this test will load the result and check the timestamp
String url = "file:///" + f.getCanonicalPath();
String url = "file:///" + new File("target/test-classes/nvdcve-2.0-2012.xml").toURI().toString();
UpdateableNvdCve instance = new UpdateableNvdCve();
instance.add(id, url, url);
NvdCveInfo results = instance.get(id);
@@ -82,8 +80,7 @@ public class UpdateableNvdCveTest extends BaseTest {
public void testAdd_4args() throws Exception {
String id = "key";
//use a local file as this test will load the result and check the timestamp
File f = new File("target/test-classes/nvdcve-2.0-2012.xml");
String url = "file:///" + f.getCanonicalPath();
String url = new File("target/test-classes/nvdcve-2.0-2012.xml").toURI().toString();
UpdateableNvdCve instance = new UpdateableNvdCve();
instance.add(id, url, url, false);
@@ -107,8 +104,7 @@ public class UpdateableNvdCveTest extends BaseTest {
public void testClear() throws MalformedURLException, DownloadFailedException, IOException {
String id = "key";
//use a local file as this test will load the result and check the timestamp
File f = new File("target/test-classes/nvdcve-2.0-2012.xml");
String url = "file:///" + f.getCanonicalPath();
String url = new File("target/test-classes/nvdcve-2.0-2012.xml").toURI().toString();
UpdateableNvdCve instance = new UpdateableNvdCve();
instance.add(id, url, url, false);
assertFalse(instance.getCollection().isEmpty());
@@ -122,8 +118,7 @@ public class UpdateableNvdCveTest extends BaseTest {
@Test
public void testIterator() throws IOException {
//use a local file as this test will load the result and check the timestamp
File f = new File("target/test-classes/nvdcve-2.0-2012.xml");
String url = "file:///" + f.getCanonicalPath();
String url = new File("target/test-classes/nvdcve-2.0-2012.xml").toURI().toString();
UpdateableNvdCve instance = new UpdateableNvdCve();
instance.add("one", url, url, false);
instance.add("two", url, url, false);