- try {
- xmlParser.parse(reader);
- fail("IllegalStateException should have been thrown because of an unknown child node.");
- } catch (IllegalStateException ex) {
- assertEquals("Schema for node with name my-container-1 and namespace baz-namespace does not exist at "
- + "AbsoluteSchemaPath{path=[(baz-namespace)outer-container, (baz-namespace)my-container-1]}",
- ex.getMessage());
- }
+ final XMLStreamException ex = assertThrows(XMLStreamException.class, () -> xmlParser.parse(reader));
+
+ assertThat(ex.getMessage(), containsString("Schema for node with name my-container-1 and namespace "
+ + "baz-namespace does not exist at "
+ + "AbsoluteSchemaPath{path=[(baz-namespace)outer-container, (baz-namespace)my-container-1]}"));