Message msg2 = MessageFactory.getInstance().getMessage(
MessageType.JAVA_SERIALIZED);
assertEquals((msg1 != null), true);
assertEquals((msg2 != null), true);
MessageStore store = MessageStoreFactory.getInstance().getMessageStore();
assertEquals((store != null), true);
// set some properties inside the Message
msg1.getProperties().setProperty("prop1", "val1");
msg2.getProperties().setProperty("prop1", "val1");
msg1.getProperties().setProperty("prop2", "val2");
msg2.getProperties().setProperty("prop2", "val2");
// set the body inside the Message
msg1.getBody().add(("TEST BODY").getBytes());
msg2.getBody().add(("TEST BODY").getBytes());
// set some object attachments inside the Message
msg1.getAttachment().addItem(new String("TEST ATTACHMENT1"));
msg1.getAttachment().addItem(new String("TEST ATTACHMENT2"));
msg2.getAttachment().addItem(new String("TEST ATTACHMENT1"));
msg2.getAttachment().addItem(new String("TEST ATTACHMENT2"));
// keep track of the UID to use in retrieving the Message
URI uid1 = null;
uid1 = store.addMessage(msg1, MessageStore.CLASSIFICATION_DEFAULT);
// System.out.println(uid1);
assertEquals((uid1 != null), true);
URI uid2 = null;
uid2 = store.addMessage(msg2,MessageStore.CLASSIFICATION_DEFAULT);
// System.out.println(uid2);
assertEquals((uid2 != null), true);
// now retrieve the messages
try
{
Message msgIn1 = store.getMessage(uid1);
assertEquals((msgIn1 != null), true);
Message msgIn2 = store.getMessage(uid2);
assertEquals((msgIn2 != null), true);
}
catch (Exception e)
{
log.error( e );