@Test
    void requireThatReplyCanBeReusedOnRetry() {
        SimpleProtocol protocol = new SimpleProtocol();
        protocol.addPolicyFactory("ReuseReply", param -> new ReuseReplyPolicy(false,
                                                                              List.of(ErrorCode.APP_FATAL_ERROR),
                                                                      CustomPolicyFactory.parseRoutes(param)));
        protocol.addPolicyFactory("SetReply", param -> new SetReplyPolicy(false,
                                                                          List.of(ErrorCode.APP_FATAL_ERROR),
                                                                  param));
        srcServer.mb.putProtocol(protocol);
        assertTrue(srcSession.send(createMessage("msg"),
                Route.parse("[ReuseReply:[SetReply:foo]," + dstSessName + "]")).isAccepted());
        Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
        assertNotNull(msg);
        Reply reply = new EmptyReply();
        reply.swapState(msg);
        reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "dst"));
        dstSession.reply(reply);
        assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
        dstSession.acknowledge(msg);
        assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
        assertFalse(reply.hasErrors());
    }
@author havardpe
@author Simon Thoresen Hult
messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java