Update yang-parser-api
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / ParsingExtensionValueTest.java
index 197ef7de7dcf9a3eddc50512174542d1cee59a13..e1fb43fb53db9b0fbcd2196d044f0da32daf4ddb 100644 (file)
@@ -7,32 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThrows;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 /**
  * Test for testing of extensions and their arguments.
- *
- * @author Lukas Sedlak <lsedlak@cisco.com>
  */
 public class ParsingExtensionValueTest {
-
     @Test
-    public void extensionTest() throws IOException, YangSyntaxErrorException, URISyntaxException {
-        try {
-            TestUtils.loadModules(getClass().getResource("/extensions").toURI());
-        } catch (ReactorException e) {
-            assertEquals(SomeModifiersUnresolvedException.class, e.getClass());
-            assertTrue(e.getCause() instanceof SourceException);
-            assertTrue(e.getCause().getMessage().startsWith("ext:id is not a YANG statement or use of extension"));
-        }
+    public void extensionTest() {
+        final ReactorException ex = assertThrows(ReactorException.class,
+            () -> TestUtils.loadModules(getClass().getResource("/extensions").toURI()));
+        assertEquals(SomeModifiersUnresolvedException.class, ex.getClass());
+        final Throwable cause = ex.getCause();
+        assertThat(cause, instanceOf(SourceException.class));
+        assertThat(cause.getMessage(), startsWith("ext:id is not a YANG statement or use of extension"));
     }
 }