X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-codec-xml%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fxml%2FStrictParsingModeTest.java;h=17f23fac1195928acb5b4d4f39efc2e2e7225212;hb=refs%2Fchanges%2F18%2F95118%2F1;hp=c50593102e8af040abbd049f1b80d7b6daa1a3a9;hpb=7f41bd0651d810544aa1359ce1d762a8185df016;p=yangtools.git diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java index c50593102e..17f23fac11 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/StrictParsingModeTest.java @@ -5,12 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.yangtools.yang.data.codec.xml; -import static org.junit.Assert.assertEquals; +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertThrows; import java.io.InputStream; import javax.xml.stream.XMLStreamException; @@ -72,12 +72,9 @@ public class StrictParsingModeTest { final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, topLevelContainer, true); - try { - xmlParser.parse(reader); - fail("XMLStreamException should have been thrown because of an unknown child node."); - } catch (XMLStreamException ex) { - assertEquals("Schema for node with name unknown-container-a and namespace foo does not exist at " - + "AbsoluteSchemaPath{path=[(foo)top-level-container]}", ex.getMessage()); - } + + final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader)); + assertThat(ex.getMessage(), containsString("Schema for node with name unknown-container-a and namespace foo " + + "does not exist at AbsoluteSchemaPath{path=[(foo)top-level-container]}")); } }