01: package org.geotools.styling;
02:
03: import java.io.StringReader;
04:
05: import junit.framework.TestCase;
06:
07: import org.geotools.test.TestData;
08:
09: /**
10: * Tests XMLNS attributes serialization that might be missed/ignored if the proper
11: * namespace is not specified. Parsing SLD into object tree, serialization back to
12: * XML and again parsing from this XML says that there is no problem.
13: *
14: * @author Vitalus
15: *
16: */
17: public class XmlnsNamespaceTest extends TestCase {
18:
19: public void testXmlnsNamespaceOutput() throws Exception {
20:
21: java.net.URL sldUrl = TestData.getResource(this ,
22: "xmlnsNamespaces.sld");
23: SLDParser parser = new SLDParser(new StyleFactoryImpl(), sldUrl);
24: Style style = parser.readXML()[0];
25:
26: SLDTransformer transformer = new SLDTransformer();
27: transformer.setNamespaceDeclarationEnabled(true);
28: // transformer.setIndentation(2);
29: String xml = transformer.transform(style);
30: // System.out.println(xml);
31:
32: try {
33: SLDParser parser2 = new SLDParser(new StyleFactoryImpl(),
34: new StringReader(xml));
35: Style style2 = parser2.readXML()[0];
36:
37: } catch (Exception exc) {
38: this
39: .fail("Failed to persist object tree to XML and parse back: "
40: + exc.getMessage());
41: throw exc;
42: }
43:
44: }
45:
46: }
|