@Test
    void requireThatTransientErrorsAreRetriedWithPolicy() {
        SimpleProtocol protocol = new SimpleProtocol();
        protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
        srcServer.mb.putProtocol(protocol);
        assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:" + 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, "err1"));
        dstSession.reply(reply);
        assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
        reply = new EmptyReply();
        reply.swapState(msg);
        reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err2"));
        dstSession.reply(reply);
        assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
        dstSession.acknowledge(msg);
        assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
        assertFalse(reply.hasErrors());
        assertTrace(List.of("Source session accepted a 3 byte message. 1 message(s) now pending.",
                        "Running routing policy 'Custom'.",
                        "Selecting [" + dstSessName + "].",
                        "Component '" + dstSessName + "' selected by policy 'Custom'.",
                        "Resolving '" + dstSessName + "'.",
                        "Sending message (version ${VERSION}) from client to '" + dstSessName + "'",
                        "Message (type 1) received at 'dst' for session '" + sessName + "'.",
                        "[APP_TRANSIENT_ERROR @ localhost]: err1",
                        "Sending reply (version ${VERSION}) from 'dst'.",
                        "Reply (type 0) received at client.",
                        "Routing policy 'Custom' merging replies.",
                        "Merged [" + dstSessName + "].",
                        "Message scheduled for retry 1 in 0.0 seconds.",
                        "Resender resending message.",
                        "Running routing policy 'Custom'.",
                        "Selecting [" + dstSessName + "].",
                        "Component '" + dstSessName + "' selected by policy 'Custom'.",
                        "Resolving '" + dstSessName + "'.",
                        "Sending message (version ${VERSION}) from client to '" + dstSessName + "'",
                        "Message (type 1) received at 'dst' for session '" + sessName + "'.",
                        "[APP_TRANSIENT_ERROR @ localhost]: err2",
                        "Sending reply (version ${VERSION}) from 'dst'.",
                        "Reply (type 0) received at client.",
                        "Routing policy 'Custom' merging replies.",
                        "Merged [" + dstSessName + "].",
                        "Message scheduled for retry 2 in 0.0 seconds.",
                        "Resender resending message.",
                        "Running routing policy 'Custom'.",
                        "Selecting [" + dstSessName + "].",
                        "Component '" + dstSessName + "' selected by policy 'Custom'.",
                        "Resolving '" + dstSessName + "'.",
                        "Sending message (version ${VERSION}) from client to '" + dstSessName + "'",
                        "Message (type 1) received at 'dst' for session '" + sessName + "'.",
                        "Sending reply (version ${VERSION}) from 'dst'.",
                        "Reply (type 0) received at client.",
                        "Routing policy 'Custom' merging replies.",
                        "Merged [" + dstSessName + "].",
                        "Source session received reply. 0 message(s) now pending."),
                reply.getTrace());
    }
@author havardpe
@author Simon Thoresen Hult
messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java