private static final String BODY = "Hello world";
private static final String ERROR_TEXT = "Error!";
@SpecCompliant(spec = "draft-ietf-xmpp-3920bis-22", section = "10.4.3", status = SpecCompliant.ComplianceStatus.FINISHED, coverage = SpecCompliant.ComplianceCoverage.COMPLETE)
public void testSmartDeliveryException() throws Exception {
RecordingStanzaRelay relay = new RecordingStanzaRelay();
ReturnErrorToSenderFailureStrategy strategy = new ReturnErrorToSenderFailureStrategy(relay);
Stanza stanza = XMPPCoreStanza.getWrapper(StanzaBuilder.createMessageStanza(FROM, TO, LANG, BODY).build());
strategy.process(stanza, Arrays.asList((DeliveryException)new RemoteServerNotFoundException(ERROR_TEXT)));
Iterator<Triple> triples = relay.iterator();
Triple triple = triples.next();
Assert.assertEquals(FROM, triple.getEntity());
MessageStanza errorStanza = (MessageStanza) XMPPCoreStanza.getWrapper(triple.getStanza());
Assert.assertEquals("error", errorStanza.getType());
Assert.assertEquals(FROM, errorStanza.getTo());