/** * Tests that contents of 'pre' tag are untouched. * * @throws IOException */ public void testPreTagIsUntouched() throws IOException { String cleaned = compactXmlSerializer.getAsString(" <pre>some text</pre>"); assertEquals("<pre>some text</pre>\n", cleaned); cleaned = compactXmlSerializer.getAsString("<pre> some text</pre>"); assertEquals("<pre> some text</pre>\n", cleaned); cleaned = compactXmlSerializer.getAsString("<pre>some /n/n text</pre>"); assertEquals("<pre>some /n/n text</pre>\n", cleaned); }
/** * Tests that serializer removes white spaces properly. * * @throws IOException */ public void testRemoveInsignificantWhitespaces() throws IOException { String cleaned = compactXmlSerializer.getAsString(" <u>text here, </u><b>some text</b> "); assertEquals("<u>text here, </u><b>some text</b>", cleaned); cleaned = compactXmlSerializer.getAsString(" <div class=\"foo\">2 roots < here > </div>"); assertEquals("<div class=\"foo\">2 roots < here ></div>\n", cleaned); cleaned = compactXmlSerializer.getAsString(" <div class=\"foo\">2 roots \n < here > </div>"); assertEquals("<div class=\"foo\">2 roots < here ></div>\n", cleaned); cleaned = compactXmlSerializer.getAsString(" <div class=\"foo\">2 roots \n\n < here > </div>"); assertEquals("<div class=\"foo\">2 roots <br />< here ></div>\n", cleaned); }
/** * Non-breakable spaces also must be removed from start and end. * * @throws IOException */ public void testRemoveLeadingAndEndingNbsp() throws IOException { String cleaned = compactXmlSerializer.getAsString( " We have just released Jericho Road. Listen to Still Waters the lead-off track."); assertEquals( "We have just released Jericho Road. Listen to Still Waters the lead-off track.", cleaned); cleaned = compactXmlSerializer.getAsString( " We have just released Jericho Road. Listen to Still Waters the lead-off track. "); assertEquals( "We have just released Jericho Road. Listen to Still Waters the lead-off track.", cleaned); cleaned = compactXmlSerializer.getAsString( " We have just released Jericho Road. Listen to Still Waters the lead-off track. "); assertEquals( "We have just released Jericho Road. Listen to Still Waters the lead-off track.", cleaned); cleaned = compactXmlSerializer.getAsString( SpecialEntities.NON_BREAKABLE_SPACE + "We have just released Jericho Road. Listen to Still Waters the lead-off track. " + SpecialEntities.NON_BREAKABLE_SPACE); assertEquals( "We have just released Jericho Road. Listen to Still Waters the lead-off track.", cleaned); }