Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect ReqM2 preamble #197

Open
redcatbear opened this issue Nov 17, 2018 · 2 comments
Open

Detect ReqM2 preamble #197

redcatbear opened this issue Nov 17, 2018 · 2 comments
Labels

Comments

@redcatbear
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
OFT auto-detects files by extension. Unfortunately ReqM2's extension is to generic (.xml) this leads to other XML files unnecessarily being scanned, which has two consequences:

  1. The import is slower than necessary because it could skip files which are do not contain ReqM2 content.
  2. Lots of error messages about unknown XML content are dumped to STDERR

Describe the solution you'd like
When an XML file is about to be imported, OFT should check whether it really contains ReqM2 content. This comes in two variants at the moment:

  1. Plain ReqM2 file
  2. DocBook file with embedded ReqM2 content (supported but not really recommended)

Describe alternatives you've considered

  • Enforcing a strict extension (e.g. .reqm2): While being perfect for OFT this has the downside that it breaks compatibility and also that XML Editors don't know this extensions by default.
  • Enforcing a compound extension (.reqm2.xml): Works for OFT and XML editors. Downsides are that it is clunky and still breaks compatibility.

Additional context
This is an excerpt of example error output:

Nov 17, 2018 1:11:57 PM org.itsallcode.openfasttrace.importer.specobject.handler.SpecDocumentHandlerBuilder lambda$0
INFO: Found unknown root element TreeElement [element=StartElementEvent [qName=testsuite, attributeMap={tests=Attribute [qName=tests, value=5], failures=Attribute [qName=failures, value=0], xsi:noNamespaceSchemaLocation=Attribute [qName=xsi:noNamespaceSchemaLocation, value=https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd], name=Attribute [qName=name, value=org.itsallcode.openfasttrace.importer.input.TestStreamInput], xmlns:xsi=Attribute [qName=xmlns:xsi, value=http://www.w3.org/2001/XMLSchema-instance], time=Attribute [qName=time, value=0.001], errors=Attribute [qName=errors, value=0], skipped=Attribute [qName=skipped, value=0]}, location=/home/johndoe/git/openfasttrace/target/surefire-reports/TEST-org.itsallcode.openfasttrace.importer.input.TestStreamInput.xml:2:309], characterData=, endElementListeners=[]]: skip file
@redcatbear
Copy link
Collaborator Author

@kaklakariada, could you please take care of this one?

@kaklakariada
Copy link
Contributor

Detection of ReqM2 is already implemented. If the root element of an XML file is not <specdocument>, the observed log message is printed and further processing is stopped. However the XML file is parsed until the end without processing any events. We can fix this by throwing an exception (and catching it later) as described in the documentation of XMLReader.parse().

@kaklakariada kaklakariada removed their assignment Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 📫 Backlog
Development

No branches or pull requests

2 participants