@Test public void testBuild() throws JAXBException { XMLBuilder xMLBuilder = new XMLBuilder(); String result = xMLBuilder.build(gpx); Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<gpx version=\"1.0\" xmlns=\"https: " <metadata>\n" + " <name></name>\n" + " <desc></desc>\n" + " <author>\n" + " <name></name>\n" + " <email id=\"id\" domain=\"@domain\"/>\n" + " <link href=\"\">\n" + " <text></text>\n" + " <type></type>\n" + " </link>\n" + " </author>\n" + " <copyright author=\"\">\n" + " <year></year>\n" + " <license></license>\n" + " </copyright>\n" + " <time></time>\n" + " <keywords></keywords>\n" + " <bounds/>\n" + " <extensions>\n" + " <system-message>System message string</system-message>\n" + " </extensions>\n" + " </metadata>\n" + " <wpt lat=\"0.0\" lon=\"0.0\">\n" + " <ele>0.0</ele>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <type>0</type>\n" + " <step>0</step>\n" + " </extensions>\n" + " </wpt>\n" + " <rte>\n" + " <rtept lat=\"0.0\" lon=\"0.0\">\n" + " <ele>0.0</ele>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <type>0</type>\n" + " <step>0</step>\n" + " </extensions>\n" + " </rtept>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <distanceActual>0.0</distanceActual>\n" + " <ascent>0.0</ascent>\n" + " <descent>0.0</descent>\n" + " <avgspeed>0.0</avgspeed>\n" + " <bounds minLat=\"0.0\" minLon=\"0.0\" maxLat=\"0.0\" maxLon=\"0.0\"/>\n" + " </extensions>\n" + " </rte>\n" + " <trk>\n" + " <extensions>\n" + " <example1>0.0</example1>\n" + " </extensions>\n" + " <trkseg>\n" + " <trkpt lat=\"0.0\" lon=\"0.0\">\n" + " <ele>0.0</ele>\n" + " <extensions>\n" + " <distance>0.0</distance>\n" + " <duration>0.0</duration>\n" + " <type>0</type>\n" + " <step>0</step>\n" + " </extensions>\n" + " </trkpt>\n" + " <extensions>\n" + " <example1>0.0</example1>\n" + " </extensions>\n" + " </trkseg>\n" + " </trk>\n" + " <extensions>\n" + " <attribution></attribution>\n" + " <engine></engine>\n" + " <build_date></build_date>\n" + " <profile></profile>\n" + " <preference></preference>\n" + " <language></language>\n" + " <distance-units></distance-units>\n" + " <duration-units></duration-units>\n" + " <instructions></instructions>\n" + " <elevation></elevation>\n" + " </extensions>\n" + "</gpx>\n", result); }
public String build(Gpx gpx) throws JAXBException { JAXBContext context = JAXBContext.newInstance(Gpx.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter sw = new StringWriter(); m.marshal(gpx, sw); return sw.toString(); }
XMLBuilder { public String build(Gpx gpx) throws JAXBException { JAXBContext context = JAXBContext.newInstance(Gpx.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter sw = new StringWriter(); m.marshal(gpx, sw); return sw.toString(); } }
XMLBuilder { public String build(Gpx gpx) throws JAXBException { JAXBContext context = JAXBContext.newInstance(Gpx.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter sw = new StringWriter(); m.marshal(gpx, sw); return sw.toString(); }  }
XMLBuilder { public String build(Gpx gpx) throws JAXBException { JAXBContext context = JAXBContext.newInstance(Gpx.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter sw = new StringWriter(); m.marshal(gpx, sw); return sw.toString(); }  String build(Gpx gpx); }
XMLBuilder { public String build(Gpx gpx) throws JAXBException { JAXBContext context = JAXBContext.newInstance(Gpx.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter sw = new StringWriter(); m.marshal(gpx, sw); return sw.toString(); }  String build(Gpx gpx);  }