Handled JAXB beans hand

I have a big bunch of manually generated JAXB annotated files and some manually created xsd files. I also have some examples of XML files that should create most JAXB beans and set most fields.

How to check if all important (95%) attributes are set? I do not want to check every attribute of every bean.

Can I maybe also or as an alternative test if the manually created beans match the xsd files?

+4
source share
2 answers

There are several ways to handle this, which should provide you some automation at the end; but it all depends on how complex your classes and XSD are.

I would start by using JAXB schemagen against a set of classes that you already have. This may require additional annotations, which you may need to add to your current codebase. With this XSD in hand, you could basically manually compare the two XSDs to see if they are similar. Everything can become complicated if your XSD model uses options, everything, abstractions, groups, etc.

Then I used the XSD tool:

  • to generate all the possible XPaths from these two sets for the given root elements, to ensure that you have the same coverage.
  • to automatically create XML samples using one of the XSDs, depending on which one is your golden copy, and then check it with the other XSD - detect inconsistencies and also discard the XML code using existing code.

Once Blaise has described marshalling and comparison (ideally use XML that maps to the schema, then an XML representation, text comparison, is likely to be useless).

+2
source

You can decouple the XML control documents and then transfer them back to XML. Then compare the two XML documents so that they contain the same content. This would confirm the case with a circular motion.

+1
source

Source: https://habr.com/ru/post/1400022/


All Articles