public void testPrintLineText_parentheses() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), "test < test > test"); String current = stringWriter.toString(); String expected = " <tag>test < test > test</tag>"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineEmptyText() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), ""); String current = stringWriter.toString(); String expected = " <tag />"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineText_ampersand() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), "ampersand & ampersand"); String current = stringWriter.toString(); String expected = " <tag>ampersand & ampersand</tag>"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineWidthText() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), "name"); String current = stringWriter.toString(); String expected = " <tag>name</tag>"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineNullText() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), null); String current = stringWriter.toString(); String expected = " <tag />"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public static void writePlacemarksFile(Writer writer, List<Placemark> placemarks) throws IOException { XmlWriter xmlWriter = new XmlWriter(writer, true); final String[] tags = XmlWriter.createTags(0, "Placemarks"); xmlWriter.println(tags[0]); for (Placemark placemark : placemarks) { if (placemark != null) { writeXML(placemark, xmlWriter, 1); } } xmlWriter.println(tags[1]); xmlWriter.close(); }
protected void writeImageDisplayElements(int indent) { final StringWriter stringWriter = new StringWriter(); final XmlWriter sXmlW = new XmlWriter(stringWriter, false); final Band[] bands = product.getBands(); final String[] idTags = createTags(indent, DimapProductConstants.TAG_IMAGE_DISPLAY); writeBandStatistics(sXmlW, indent, bands); writeMaskUsages(sXmlW, indent + 1, bands); writeMaskUsages(sXmlW, indent + 1, product.getTiePointGrids()); sXmlW.close(); final String childTags = stringWriter.toString(); if (childTags != null && childTags.length() > 0) { println(idTags[0]); print(childTags); println(idTags[1]); } }
public void testWriteXML_DifferentValidIndent() { Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "pinName", "pinLabel", "", null, new GeoPos(4f, 87f), product.getGeoCoding()); placemark.setDescription("pinDescription"); StringWriter stringWriter = new StringWriter(); PlacemarkIO.writeXML(placemark, new XmlWriter(stringWriter, false), 0); String expected = "" + "<Placemark name=\"pinName\">" + _ls + " <LABEL>pinLabel</LABEL>" + _ls + " <DESCRIPTION>pinDescription</DESCRIPTION>" + _ls + " <LATITUDE>4.0</LATITUDE>" + _ls + " <LONGITUDE>87.0</LONGITUDE>" + _ls + "</Placemark>" + _ls; assertEquals(expected, stringWriter.toString()); stringWriter = new StringWriter(); PlacemarkIO.writeXML(placemark, new XmlWriter(stringWriter, false), 3); expected = "" + " <Placemark name=\"pinName\">" + _ls + " <LABEL>pinLabel</LABEL>" + _ls + " <DESCRIPTION>pinDescription</DESCRIPTION>" + _ls + " <LATITUDE>4.0</LATITUDE>" + _ls + " <LONGITUDE>87.0</LONGITUDE>" + _ls + " </Placemark>" + _ls; assertEquals(expected, stringWriter.toString()); }
public void testWriteXML_IndentIsSmallerThanZero() { Placemark placemark = Placemark.createPointPlacemark(PinDescriptor.getInstance(), "pinName", "pinLabel", "", null, new GeoPos(), product.getGeoCoding()); try { int indent = -1; PlacemarkIO.writeXML(placemark, new XmlWriter(new StringWriter(), false), indent); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected IllegalArgumentException } catch (Exception e) { fail("IllegalArgumentException expected"); } }