Search in sources :

Example 1 with EscapingPrintWriter

use of ddf.catalog.transformer.xml.EscapingPrintWriter in project ddf by codice.

the class TestEscapingPrintWriter method testUndefinedCharacter.

@Test
public void testUndefinedCharacter() throws CatalogTransformerException {
    String input = new String(Character.toChars(55296));
    String expected = "�";
    StringWriter stringWriter = new StringWriter(8);
    PrintWriter escapingPrintWriter = new EscapingPrintWriter(stringWriter);
    escapingPrintWriter.setValue(input);
    escapingPrintWriter.flush();
    String output = stringWriter.toString();
    assertEquals(expected, output);
}
Also used : StringWriter(java.io.StringWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) PrintWriter(ddf.catalog.transformer.api.PrintWriter) Test(org.junit.Test)

Example 2 with EscapingPrintWriter

use of ddf.catalog.transformer.xml.EscapingPrintWriter in project ddf by codice.

the class TestEscapingPrintWriter method testControlCharacters.

@Test
public void testControlCharacters() throws CatalogTransformerException {
    String input = "\0 \t \n \r";
    String expected = "� \t \n 
";
    StringWriter stringWriter = new StringWriter(8);
    PrintWriter escapingPrintWriter = new EscapingPrintWriter(stringWriter);
    escapingPrintWriter.setValue(input);
    escapingPrintWriter.flush();
    String output = stringWriter.toString();
    assertEquals(expected, output);
}
Also used : StringWriter(java.io.StringWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) PrintWriter(ddf.catalog.transformer.api.PrintWriter) Test(org.junit.Test)

Example 3 with EscapingPrintWriter

use of ddf.catalog.transformer.xml.EscapingPrintWriter in project ddf by codice.

the class TestEscapingPrintWriter method testXmlMetaCharacters.

@Test
public void testXmlMetaCharacters() throws CatalogTransformerException {
    String unescaped = "& > < \" \'";
    String escaped = "&amp; &gt; &lt; &quot; &apos;";
    StringWriter stringWriter = new StringWriter(128);
    PrintWriter escapingPrintWriter = new EscapingPrintWriter(stringWriter);
    escapingPrintWriter.setValue(unescaped);
    escapingPrintWriter.flush();
    String processed = stringWriter.toString();
    assertEquals(escaped, processed);
}
Also used : StringWriter(java.io.StringWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) PrintWriter(ddf.catalog.transformer.api.PrintWriter) Test(org.junit.Test)

Example 4 with EscapingPrintWriter

use of ddf.catalog.transformer.xml.EscapingPrintWriter in project ddf by codice.

the class TestEscapingPrintWriter method testSurrogateCharacter.

@Test
public void testSurrogateCharacter() throws CatalogTransformerException {
    String input = new String(Character.toChars(888));
    String expected = "&#x378;";
    StringWriter stringWriter = new StringWriter(8);
    PrintWriter escapingPrintWriter = new EscapingPrintWriter(stringWriter);
    escapingPrintWriter.setValue(input);
    escapingPrintWriter.flush();
    String output = stringWriter.toString();
    assertEquals(expected, output);
}
Also used : StringWriter(java.io.StringWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) EscapingPrintWriter(ddf.catalog.transformer.xml.EscapingPrintWriter) PrintWriter(ddf.catalog.transformer.api.PrintWriter) Test(org.junit.Test)

Aggregations

PrintWriter (ddf.catalog.transformer.api.PrintWriter)4 EscapingPrintWriter (ddf.catalog.transformer.xml.EscapingPrintWriter)4 StringWriter (java.io.StringWriter)4 Test (org.junit.Test)4