简体   繁体   中英

How to test automatically that xsd and generated classes are synchronized?

I have an xml schema file and have generated classes out of that. During development the xsd can change. How can I make sure that the xsd and the generated classes are synchronized?

There is the possibility to generate the classes at build time via maven. Using this or not, I would like to be sure in a unit test.

Thanks and greetings Steff

Under which circumstances can they not be synchronized? While I can imagine writing a simple JAXB plugin which would add a schema timestamp to the generated classes - so that you could compare timestamps in a unit test.

However I have doubt in the whole approach. Schema compilation is aa part of the build process and this must be flawless by design. You are not checking that Java files are "synchronized" with the compiled .class files, are you? The same should be the case for schema compilation.

You force the execution of the generation every build. Or under a Profile not to execute it so many times and make your compilation time in development longer.

Here you can take a look at a JAXB plugin for generate the sources every time.

http://java.net/projects/maven-jaxb2-plugin/pages/Home

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM