public void testTextMessage() {
try {
{ // 1. key, content and qos all null in constructor
byte[] content = null;
XBTextMessage msg = new XBTextMessage(null, content);
String txt1 = "funny Things happen";
msg.setText(txt1);
String txt2 = msg.getText();
assertEquals("normal text comparison", txt1, txt2);
txt1 = null;
msg.setText(txt1);
txt2 = msg.getText();
assertEquals("normal text comparison", txt1, txt2);
}
{ // 2. content not null in constructor
XBTextMessage msg = new XBTextMessage(null, "oh I am a text msg".getBytes());
String txt1 = "funny Things happen";
msg.setText(txt1);
String txt2 = msg.getText();
assertEquals("normal text comparison", txt1, txt2);
txt1 = null;
msg.setText(txt1);
txt2 = msg.getText();
assertEquals("normal text comparison", txt1, txt2);
}
}
catch (Exception ex) {
ex.printStackTrace();