-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding eid runtime ex test for coverage
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/test/java/pl/wavesoftware/eid/exceptions/EidRuntimeExceptionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package pl.wavesoftware.eid.exceptions; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import javax.xml.bind.JAXBException; | ||
import java.util.UnknownFormatConversionException; | ||
|
||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage; | ||
|
||
/** | ||
* @author Krzysztof Suszyński <[email protected]> | ||
* @since 2015-10-07 | ||
*/ | ||
@SuppressWarnings("ConstantConditions") | ||
public class EidRuntimeExceptionTest { | ||
|
||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
@Test | ||
public void testGetMessage() { | ||
// then | ||
thrown.expect(EidRuntimeException.class); | ||
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(JAXBException.class)); | ||
thrown.expectCause(hasMessage(is((String) null))); | ||
thrown.expectMessage(containsString("20151007:212217")); | ||
thrown.expectMessage(containsString("javax.xml.bind.JAXBException\n - with linked exception:\n" + | ||
"[java.util.UnknownFormatConversionException: Conversion = 'Invalid for unit test']")); | ||
|
||
// given | ||
String message = null; | ||
Throwable original = new UnknownFormatConversionException("Invalid for unit test"); | ||
JAXBException cause = new JAXBException(message); | ||
cause.setLinkedException(original); | ||
throw new EidRuntimeException("20151007:212217", cause); | ||
} | ||
|
||
} |