{
// simple text in CDATA section
final CDATA cdata = new CDATA(text);
assertEquals("incorrect CDATA text", text, cdata.getText());
cdata.append(new Text(text));
assertEquals("incorrect CDATA text", text+text, cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
{
// set it to the empty string
final CDATA cdata = new CDATA(emptyString);
assertEquals("incorrect CDATA text", "", cdata.getText());
cdata.append(new Text(emptyString));
assertEquals("incorrect CDATA text", "", cdata.getText());
cdata.append(new Text(text));
assertEquals("incorrect CDATA text", text, cdata.getText());
cdata.append(new Text(nullString));
assertEquals("incorrect CDATA text", text, cdata.getText());
cdata.append(new Text(specialCharactersText));
assertEquals("incorrect CDATA text", text + specialCharactersText, cdata.getText());
cdata.append(new Text(nullString));
assertEquals("incorrect CDATA text", text + specialCharactersText, cdata.getText());
cdata.append(new Text(emptyString));
assertEquals("incorrect CDATA text", text + specialCharactersText, cdata.getText());
cdata.append(new Text(otherString));
assertEquals("incorrect CDATA text", text + specialCharactersText + otherString, cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
{
// set it to a another string
final CDATA cdata = new CDATA(otherString);
assertEquals("incorrect CDATA text", otherString, cdata.getText());
cdata.append(new Text(text));
assertEquals("incorrect CDATA text", otherString + text, cdata.getText());
cdata.append(new Text(nullString));
assertEquals("incorrect CDATA text", otherString + text, cdata.getText());
cdata.append(new Text(specialCharactersText));
assertEquals("incorrect CDATA text", otherString + text + specialCharactersText, cdata.getText());
cdata.append(new Text(nullString));
assertEquals("incorrect CDATA text", otherString + text + specialCharactersText, cdata.getText());
cdata.append(new Text(emptyString));
assertEquals("incorrect CDATA text", otherString + text + specialCharactersText, cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
{
// set it to the null (after it was set to another string so that we
// are sure comething has changed)
final CDATA cdata = new CDATA(nullString);
assertEquals("incorrect CDATA text", "", cdata.getText());
cdata.append(new Text(specialCharactersText));
assertEquals("incorrect CDATA text", specialCharactersText, cdata.getText());
cdata.append(new Text(nullString));
assertEquals("incorrect CDATA text", specialCharactersText, cdata.getText());
cdata.append(new Text(text));
assertEquals("incorrect CDATA text", specialCharactersText + text, cdata.getText());
cdata.append(new Text(nullString));
assertEquals("incorrect CDATA text", specialCharactersText + text, cdata.getText());
cdata.append(new Text(emptyString));
assertEquals("incorrect CDATA text", specialCharactersText + text, cdata.getText());
cdata.append(new Text(otherString));
assertEquals("incorrect CDATA text", specialCharactersText + text + otherString, cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
{
// set it to the null (after it was set to another string so that we
// are sure comething has changed)
final CDATA cdata = new CDATA(null);
assertEquals("incorrect CDATA text", "", cdata.getText());
cdata.append((String) null);
assertEquals("incorrect CDATA text", "", cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
{
// set it to the null (after it was set to another string so that we
// are sure comething has changed)
final CDATA cdata = new CDATA(null);
assertEquals("incorrect CDATA text", "", cdata.getText());
cdata.append((Text) null);
assertEquals("incorrect CDATA text", "", cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
{
// set text with some special characters
final CDATA cdata = new CDATA(specialCharactersText);
assertEquals("incorrect CDATA text", specialCharactersText, cdata.getText());
cdata.append(new Text(specialCharactersText));
assertEquals("incorrect CDATA text", specialCharactersText + specialCharactersText, cdata.getText());
try {
cdata.append(new Text(cdataEndText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}
try {
// set text with some special characters which sould result into an exception
final CDATA cdata = new CDATA(specialText);
assertEquals("incorrect CDATA text", specialText, cdata.getText());
cdata.append(new Text(specialText));
fail("failed to detect CDATA end marker");
} catch (final IllegalDataException exception) {
}
}