I have a JUnit test that is checking to make sure that a customized xml serialization is working properly. The customized xml serialization is just a few custom converters for Xstream. The deserializers work, but for some reason in Eclipse 3.x, JUnit fails the serialization. In Ant on the command line, it works just fine. It also works just fine in Eclipse if I debug and step through the test case, but if put a break point after the failing testcase executes it fails still.
What gives? Am I having a class path issue?
Some additional information:
Expected:
<site>
<name>origin</name>
<version>0.6.0</version>
<description>Stuff</description>
<source>./fake-file.xml</source>
<location>
<latitude deg="44" min="26" sec="37.640"/>
<longitude deg="-57" min="-38" sec="-6.877"/>
<ellipsoid-height value="-79.256" units="meters"/>
<geoid-height value="0.000" units="meters"/>
</location>
</site>
Actual:
<site>
<name>origin</name>
<version>0.6.0</version>
<description>Stuff</description>
<source>./fake-file.xml</source>
<location>
<latitude deg="44" min="26" sec="37.640"/>
<longitude deg="-57" min="-38" sec="-6.877"/>
<ellipsoid-height value="-79.256" units="meters"/>
<geoid-height value="-79.256" units="meters"/>
</location>
</site>
The code that writes the location fields:
public void marshal(Object source,
HierarchicalStreamWriter writer,
MarshallingContext context)
{
ILatLonEllipsoidHeightPoint aLoc = (ILatLonEllipsoidHeightPoint) source;
synchronized(aLoc)
{
writer.startNode(LATITUDE);
writer.addAttribute(DEGREES,
Integer.toString(
PointUnitConversions.getLatitudeHours(aLoc.getLatitude())));
writer.addAttribute(MINUTES,
Integer.toString(
PointUnitConversions.getLatitudeMinutes(aLoc.getLatitude())));
writer.addAttribute(SECONDS,
String.format("%.3f",
PointUnitConversions.getLatitudeSeconds(aLoc.getLatitude())));
writer.endNode();
writer.startNode(LONGITUDE);
writer.addAttribute(DEGREES,
Integer.toString(
PointUnitConversions.getLongitudeHours(aLoc.getLongitude())));
writer.addAttribute(MINUTES,
Integer.toString(
PointUnitConversions.getLongitudeMinutes(aLoc.getLongitude())));
writer.addAttribute(SECONDS,
String.format("%.3f",
PointUnitConversions.getLongitudeSeconds(aLoc.getLongitude())));
writer.endNode();
writer.startNode(ELLIPSOID_HEIGHT);
writer.addAttribute(VALUE,
String.format("%.3f", aLoc.getEllipsoidHeight()));
writer.addAttribute(UNITS, METERS);
writer.endNode();
writer.startNode(GEOID_HEIGHT);
writer.addAttribute(VALUE,
String.format("%.3f", aLoc.getGeoidHeight()));
writer.addAttribute(UNITS, METERS);
writer.endNode();
}
}
The PointUnitConversions calls do the obvious math to take a decimal degrees and convert to corresponding integer or double values for the component parts.
Its just that last attribute of location that is causing the failure.