- 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]}"));