I have a following piece of pretty standard JAXB code
StringReader is = new StringReader(rspString);
Unmarshaller ums = Util.createUnMarshaller(cL, Schemas.RECEIPT_SCHEMA, GetReceiptCallResponse.class);
UnmarshallerHandler umsHandler = ums.getUnmarshallerHandler();
XMLFilter filter = Util.createSaxNamespaceFilter();
filter.setContentHandler(umsHandler);
InputSource xml = new InputSource(is);
filter.parse(xml);
which runs fine in production and as a part of unit test. However it fails when it is run by Maven/Cobertura plugin. Strangely enough, the code runs fine when it is run by maven surefire plugin (without coverage measurement). Also, it runs fine from IntelliJ IDE both when it is run as a unit test and under an IntelliJ coverage tool. Seems like the only difference is the cobertura tool itself.
I checked the schema and XML files on input, everything looks alright. And the code is getting exactly the same input when run with or without cobertura.
The specific error I am getting is this:
testFailingParseWithCobertura(org.vlad.taxestime.ReceiptImporterTest) Time elapsed: 10.33 sec <<< ERROR!
org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'count' is not allowed to appear in element 'Receipts'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:458)