diff --git a/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java b/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java index f8b72a1..7ed8328 100644 --- a/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java +++ b/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java @@ -15,43 +15,32 @@ */ package org.yaml.snakeyaml.error; -import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + public class WrappedExceptionsTest { private static final String INVALID_YAML = "!!seq abc"; - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - - @Before - public void configureExpectedExceptions() { - expectedException.expectMessage("org.yaml.snakeyaml.nodes.ScalarNode"); - expectedException.expectMessage("org.yaml.snakeyaml.nodes.SequenceNode"); - } - @Test public void testWrapped() { - expectedException.expect(YAMLException.class); - expectedException - .expectCause(CoreMatchers. instanceOf(ClassCastException.class)); - - LoaderOptions options = new LoaderOptions(); - options.setWrappedToRootException(true); - Yaml yaml = new Yaml(options); - yaml.load(INVALID_YAML); + try { + LoaderOptions options = new LoaderOptions(); + options.setWrappedToRootException(true); + Yaml yaml = new Yaml(options); + yaml.load(INVALID_YAML); + fail(); + } catch (YAMLException e) { + assertEquals(ClassCastException.class, e.getCause().getClass()); + } } - @Test + @Test(expected = ClassCastException.class) public void testUnWrapped() { - expectedException.expect(ClassCastException.class); - LoaderOptions options = new LoaderOptions(); options.setWrappedToRootException(false); Yaml yaml = new Yaml(options);