assertEquals("test", pi.getValue());
assertEquals("test", pi.getTarget());
try {
new ProcessingInstruction("test:test", "test");
fail("Processing instruction targets cannot contain colons");
}
catch (IllegalTargetException success) {
assertNotNull(success.getMessage());
assertEquals("test:test", success.getData());
}
try {
new ProcessingInstruction("", "test");
fail("Processing instruction targets cannot be empty");
}
catch (IllegalTargetException success) {
assertNotNull(success.getMessage());
assertEquals("", success.getData());
}
try {
new ProcessingInstruction(null, "test");
fail("Processing instruction targets cannot be empty");
}
catch (IllegalTargetException success) {
assertNotNull(success.getMessage());
assertNull(success.getData());
}
try {
new ProcessingInstruction("12345", "test");
fail("Processing instruction targets must be NCNames");
}
catch (IllegalTargetException success) {
assertEquals("12345", success.getData());
}
// test empty data allowed
pi = new ProcessingInstruction("test", "");
assertEquals("", pi.getValue());
assertEquals("<?test?>", pi.toXML());
}