Entity receiver = EntityImpl.parse("to_exist@example.com");
Entity noReceiver = EntityImpl.parse("to_unavail@example.com");
StanzaReceiverRelay stanzaRelay = (StanzaReceiverRelay) senderSessionContext.getServerRuntimeContext()
.getStanzaRelay();
StanzaReceiverQueue senderQueue = new StanzaReceiverQueue();
StanzaReceiverQueue receiverQueue = new StanzaReceiverQueue();
stanzaRelay.add(sender, senderQueue);
stanzaRelay.add(receiver, receiverQueue);
Stanza successfulMessageStanza = StanzaBuilder.createMessageStanza(sender, receiver, "en", "info").build();
ResponseStanzaContainer responseStanzaContainer = messageHandler.execute(successfulMessageStanza,
senderSessionContext.getServerRuntimeContext(), true, senderSessionContext, null);
assertEquals(successfulMessageStanza, receiverQueue.getNext());
Stanza failureMessageStanza = StanzaBuilder.createMessageStanza(sender, noReceiver, "en", "info").build();
responseStanzaContainer = messageHandler.execute(failureMessageStanza, senderSessionContext
.getServerRuntimeContext(), true, senderSessionContext, null);
assertNull(receiverQueue.getNext());
Stanza rejectionStanza = senderQueue.getNext();
assertNotNull(rejectionStanza);
XMPPCoreStanza rejectionCoreStanza = XMPPCoreStanza.getWrapper(rejectionStanza);
assertEquals("error", rejectionCoreStanza.getType());