Issue #730: Allow multiple suppression files in Ant

The core has not been extended but the Ant task is able to parse and pass to the Settings singleton
NOTE: This change is breaking for users of the Ant Task
This commit is contained in:
Phillip Whittlesea
2017-06-11 18:45:07 +01:00
parent ed214d05fa
commit 237dbe7061
9 changed files with 163 additions and 15 deletions

View File

@@ -18,6 +18,7 @@
package org.owasp.dependencycheck.utils;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
@@ -244,6 +245,37 @@ public class SettingsTest extends BaseTest {
Assert.assertTrue(tmp.exists());
}
/**
* Assert {@link Settings#getArray(String)} from a delimited string returns multiple values in an array.
*/
@Test
public void testGetArrayFromADelimitedString() {
// GIVEN a delimited string
final String delimitedString = "value1,value2";
Settings.setString("key", delimitedString);
// WHEN getting the array
final String[] array = Settings.getArray("key");
// THEN the split array is returned
assertThat("Expected the array to be non-null", array, notNullValue());
assertThat("Expected the array to have two values", array.length, is(2));
assertThat("Expected the first array value to be value1", array[0], is("value1"));
assertThat("Expected the second array value to be value2", array[1], is("value2"));
}
/**
* Assert {@link Settings#getArray(String)} returns {@code null} if the property is not set.
*/
@Test
public void testGetArrayWhereThePropertyIsNotSet() {
// WHEN getting the array
final String[] array = Settings.getArray("key");
// THEN null is returned
assertThat("Expected the array to be null", array, nullValue());
}
/**
* Assert {@link Settings#setArrayIfNotEmpty(String, String[])} with an empty array is ignored.
*/