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);
}
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);
}
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 = "& > < " '";
StringWriter stringWriter = new StringWriter(128);
PrintWriter escapingPrintWriter = new EscapingPrintWriter(stringWriter);
escapingPrintWriter.setValue(unescaped);
escapingPrintWriter.flush();
String processed = stringWriter.toString();
assertEquals(escaped, processed);
}
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 = "͸";
StringWriter stringWriter = new StringWriter(8);
PrintWriter escapingPrintWriter = new EscapingPrintWriter(stringWriter);
escapingPrintWriter.setValue(input);
escapingPrintWriter.flush();
String output = stringWriter.toString();
assertEquals(expected, output);
}
Aggregations