Part I has covered the building of the parent pom.xml, Part II was about the plugin and now in Part III we talk about the test suite. It’s fair to say that this part seems not to be very interesting, but in this Part we talk also about the why.
Why do I make the org.openntf.base.jaxb.dxl plugin?
The core purpose of the jaxb.dxl plugin is to convert a DXL export of a document, or of some design elements into an object based representation. Imagine this: You have a document with 2 rich text fields, one is a traditional rich text field and the other is mime based. For some reason (like transforming the content of the rich text field to a POI document or PDF document) there is an interest in the structure of this rich text field. A simple export as DXL and conversion to this java objects which are cascaded helps a lot.
Or you have this database, and you want to scan the content of all design element for a specific @Formula….. Export the database to DXL and convert it with jaxb to java object tree. And the scan the tree and analyse.
But why not start with the implementation, that sound better than testing!
Agree. Implementing is always better than writing test for the sake of writing tests. But after reading the book “Test Driven Developement” by Kent Beck, my understanding of test has changed. Tests explains what I want to do. Read the following test:
This test covers my user story “Reading a dxl-document.xml and convert it to a java object structure”. To make this test work, I’ve to writte a lot of implementation stuff, so stay tuned.
The next Maven module -> org.openntf.base.jaxb.dxl.testsuite
Again with the eclipse client:
select as packaging type “eclipse-test-plugin”:
And we have a new project.
And now repeat the following steps, like you have done for the plugin in Part II
- New file called MANIFEST.MF into the folder META-INF
- New file called build.properties
Open the MANIFEST.MF File and go to the MANIFEST.MF Tab and enter the following stuff:
The directive “Fragment-Host” makes this plugin to a fragment of org.openntf.base.jaxb.dxl. This is the best behavior to separate test and implementation in a plugin.
Open the build.properties File and go to the build.properties tab. Enter the following stuff:
Now is a good moment to do a right-click on the project go to Plugin-Tools and execute “Update Classpath”
Open the MANIFEST.MF again and add the following dependency. This is needed that we can start writing our test class.
Let’s write the first Test:
We have also imported the dxl-db-test.xml and the dxl-document-test.xml. This documents were produced by a nice simple DXL Export.
To make the test compile (STEP 2 in TDD), we have to import the XSD File for domino_9_0_1 and convert it to classes. We use for this the JAXB import
JAXB Import of the domino xsd
Start with menu “New” and select the JAXB Classes from Schema Wizard
Select the target project for the import (yes our plugin)
If you do not have the domino_9_0_1.xsd in a project in your workspace, you can import it from your Notes/Data directory
Please specify carefully the package, where the classes should be produced. Existing classes will be overwritten (note to myself, move the DXLActivator Class to an other package or a level up)
Select finish. The import will now generate a lot of classes.
You can now resolve the import of the Document object (yes its a …jaxb.dxl.Document object)
Time to finish the compilation problems in the test class.
Create the ConvertorFactor in the plugin (see the package that I select? It’s outside of the dxl package, because the content of this package was generated before).
We build also a dummy implementation of “convert2DocumentFromStream”.
Only one step, and we can test (with executing our runtime configuration)
We have to include the *.xml Files in our binary build. We open for this step the MANIFEST.MF and add the 2 files
Lets build the project by executing org.openntf.base clean install
Oh yes the build fails! This is total ok at this point, because our test fails, and a failing test should stop our build!
Now its time to have some fun and finalize the plugin… The next Part will cover how to build the feature and the update site
If you wanna follow the project, please watch this repository on github.com https://github.com/guedeWebGate/org.openntf.base