summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/validation/TestApplication.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/aai/validation/TestApplication.java')
-rw-r--r--src/test/java/org/onap/aai/validation/TestApplication.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/test/java/org/onap/aai/validation/TestApplication.java b/src/test/java/org/onap/aai/validation/TestApplication.java
index 3dfa177..9f66df9 100644
--- a/src/test/java/org/onap/aai/validation/TestApplication.java
+++ b/src/test/java/org/onap/aai/validation/TestApplication.java
@@ -20,6 +20,9 @@
*/
package org.onap.aai.validation;
+import java.io.IOException;
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -33,7 +36,7 @@ import org.springframework.test.context.TestPropertySource;
*
*/
@SpringBootTest(classes = ValidationServiceApplication.class)
-@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties"})
+@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:test-application.properties"})
@ContextConfiguration(locations = {"classpath:validation-service-beans.xml"})
public class TestApplication {
@@ -63,4 +66,40 @@ public class TestApplication {
ValidationServiceApplication.main(new String[] {});
}
+ @Test
+ public void testApplicationWithEmptyKeyStorePassword() {
+ System.setProperty("KEY_STORE_PASSWORD", "");
+ final CauseMatcher expectedCause = new CauseMatcher(IOException.class, "password was incorrect");
+ expectedEx.expectCause(expectedCause);
+ ValidationServiceApplication.main(new String[] {});
+ }
+
+ @Test
+ public void testApplicationWithIncorrectKeyStorePassword() {
+ System.setProperty("KEY_STORE_PASSWORD", "test");
+ final CauseMatcher expectedCause = new CauseMatcher(IOException.class, "password was incorrect");
+ expectedEx.expectCause(expectedCause);
+ ValidationServiceApplication.main(new String[] {});
+ }
+
+ private static class CauseMatcher extends TypeSafeMatcher<Throwable> {
+
+ private final Class<? extends Throwable> type;
+ private final String expectedMessage;
+
+ public CauseMatcher(Class<? extends Throwable> type, String expectedMessage) {
+ this.type = type;
+ this.expectedMessage = expectedMessage;
+ }
+
+ @Override
+ protected boolean matchesSafely(Throwable item) {
+ return item.getClass().isAssignableFrom(type) && item.getMessage().contains(expectedMessage);
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendValue(type).appendText(" and message ").appendValue(expectedMessage);
+ }
+ }
}