Program: 91719
Project: 91719
Buggy source:
/** 
 * Tests XML (un)marshalling of a resolution element. The main purpose of this method is to test our workaround for a strange JAXB behavior (bug?).  For an unknown reason, we are unable to annotate the  {@link DefaultResolution#getDistance()} method directly. Doing so cause JAXB to randomly ignores the{@code <gmd:distance>} property. Annotating a separated method which in turn invokes the real methodseems to work. <p>This test creates a  {@link DefaultResolution} instance which is expected to be marshalled as below(ignoring namespace declarations):</p> {@preformat xml<gmd:MD_Resolution> <gmd:distance> <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance> </gmd:distance> </gmd:MD_Resolution>}If we annotate the public   {@code getDistance()} directly, JAXB will sometime marshals the resolution asexpected, or sometime marshals an empty element as below: {@preformat xml<gmd:MD_Resolution/>}In the later case, debugging shows that the   {@code getDistance()} method is simply never invoked.Whether the distance is marshaled or not seems totally random: just executing this test many time make both cases to occur (however failures occur more often the successes). <p>Annotating an other method as a workaround seems to always work. See the  {@link DefaultResolution#getValue()}javadoc for instructions about how to check if this workaround is still needed with more recent JAXB versions.</p>
 * @throws JAXBException if an error occurred while marshalling the element.
 * @see DefaultResolution#getValue()
 */
@Test public void testXML() throws JAXBException {
  final DefaultResolution resolution=new DefaultResolution();
  resolution.setDistance(1000.0);
  final String xml=XML.marshal(resolution);
  assertTrue("String_Node_Str" + "String_Node_Str",xml.contains("String_Node_Str"));
  assertXmlEquals("String_Node_Str" + Namespaces.GMD + '"'+ "String_Node_Str"+ Namespaces.GCO+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ Schemas.METADATA_ROOT+ Schemas.UOM_PATH+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",xml,"String_Node_Str");
  assertEquals(resolution,XML.unmarshal(xml));
}

Fixed version (ground truth):
/** 
 * Tests XML (un)marshalling of a resolution element. This test creates a   {@link DefaultResolution}instance which is expected to be marshalled as below (ignoring namespace declarations):  {@preformat xml<gmd:MD_Resolution> <gmd:distance> <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance> </gmd:distance> </gmd:MD_Resolution>}
 * @throws JAXBException if an error occurred while marshalling the element.
 */
@Test public void testXML() throws JAXBException {
  final DefaultResolution resolution=new DefaultResolution();
  resolution.setDistance(1000.0);
  final String xml=XML.marshal(resolution);
  assertTrue("String_Node_Str" + "String_Node_Str",xml.contains("String_Node_Str"));
  assertXmlEquals("String_Node_Str" + Namespaces.GMD + '"'+ "String_Node_Str"+ Namespaces.GCO+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ Schemas.METADATA_ROOT+ Schemas.UOM_PATH+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",xml,"String_Node_Str");
  assertEquals(resolution,XML.unmarshal(xml));
}