Skip to content

Commit

Permalink
NIFI-13709 Added more meaningful message when validation fails with n…
Browse files Browse the repository at this point in the history
…on-compliant XML is validated and no schema is provided.

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #9229.
  • Loading branch information
dan-s1 authored and pvillard31 committed Sep 5, 2024
1 parent 5f0cbed commit 727b0ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void validate(final InputStream in) {
reader.next();
}
} catch (final XMLStreamException e) {
throw new ProcessingException("Reading stream failed", e);
throw new ProcessingException("Reading stream failed: " + e.getMessage(), e);
}
} else {
final XMLStreamReaderProvider readerProvider = new StandardXMLStreamReaderProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public void testInvalidXMLAttributeStructure() {

runner.assertAllFlowFilesTransferred(ValidateXml.REL_INVALID, 1);
runner.assertAllFlowFilesContainAttribute(ValidateXml.REL_INVALID, ValidateXml.ERROR_ATTRIBUTE_KEY);
String errorAttribute = runner.getFlowFilesForRelationship(ValidateXml.REL_INVALID).get(0).getAttribute(ValidateXml.ERROR_ATTRIBUTE_KEY);
assertTrue(errorAttribute.contains("ParseError"));
}

@Test
Expand All @@ -191,5 +193,7 @@ public void testInvalidXMLContentStructure() {

runner.assertAllFlowFilesTransferred(ValidateXml.REL_INVALID, 1);
runner.assertAllFlowFilesContainAttribute(ValidateXml.REL_INVALID, ValidateXml.ERROR_ATTRIBUTE_KEY);
String errorAttribute = runner.getFlowFilesForRelationship(ValidateXml.REL_INVALID).get(0).getAttribute(ValidateXml.ERROR_ATTRIBUTE_KEY);
assertTrue(errorAttribute.contains("ParseError"));
}
}

0 comments on commit 727b0ba

Please sign in to comment.