log.info("TEST 1: Testing filtered PtP message");
String content = "12345678901"; // content is too long, our plugin denies this message
try {
PublishQos pq = new PublishQos(glob);
pq.addDestination(new Destination(new SessionName(glob, name)));
PublishReturnQos rq = con.publish(new MsgUnit("<key oid='MSG'/>", content.getBytes(), pq.toXml()));
log.info("TEST 1: SUCCESS returned state=" + rq.getState());
assertTrue("Return OK", !Constants.STATE_OK.equals(rq.getState()));
} catch(XmlBlasterException e) {
log.warning("XmlBlasterException: " + e.getMessage());
assertTrue("publish - XmlBlasterException: " + e.getMessage(), false);
}
try {
MsgUnit[] msgUnits = con.get("<key oid='MSG'/>", null);
assertTrue("Invalid return", msgUnits!=null);
assertEquals("Expected no returned message", 0, msgUnits.length);
} catch(XmlBlasterException e) {
log.warning("get - XmlBlasterException: " + e.getMessage());
fail("get - XmlBlasterException: " + e.getMessage());
}
log.info("TEST 2: Testing unfiltered PtP message");
content = "1234567890";
try {
PublishQos pq = new PublishQos(glob);
pq.addDestination(new Destination(new SessionName(glob, name)));
PublishReturnQos rq = con.publish(new MsgUnit("<key oid='MSG'/>", content.getBytes(), pq.toXml()));
assertEquals("Return not OK", Constants.STATE_OK, rq.getState());
log.info("TEST 2: SUCCESS");
} catch(XmlBlasterException e) {
log.warning("XmlBlasterException: " + e.getMessage());
assertTrue("publish - XmlBlasterException: " + e.getMessage(), false);
}