- System.setProperty("KEY_STORE_PASSWORD", "OBF:");
- final CauseMatcher expectedCause = new CauseMatcher(IOException.class, "password was incorrect");
- expectedEx.expectCause(expectedCause);
- BabelApplication.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);
- }
+ Throwable exception = assertThrows(ApplicationContextException.class, () -> {
+ System.setProperty("KEY_STORE_PASSWORD", "OBF:");
+ BabelApplication.main(new String[]{});
+ });