@Test
    void requireThatMergeExceptionIsCaught() {
        SimpleProtocol protocol = new SimpleProtocol();
        protocol.addPolicyFactory("Custom", param -> new RoutingPolicy() {

            @Override
            public void select(RoutingContext context) {
                context.addChild(Route.parse(dstSessName));
            }

            @Override
            public void merge(RoutingContext context) {
                throw new RuntimeException("69");
            }

            @Override
            public void destroy() {

            }
        });
        srcServer.mb.putProtocol(protocol);
        assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom]")).isAccepted());
        Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
        assertNotNull(msg);
        dstSession.acknowledge(msg);
        Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
        assertNotNull(reply);
        assertEquals(1, reply.getNumErrors());
        assertEquals(ErrorCode.POLICY_ERROR, reply.getError(0).getCode());
        assertTrue(reply.getError(0).getMessage().contains("69"));
    }
@author havardpe
@author Simon Thoresen Hult
messagebus/src/test/java/com/yahoo/messagebus/routing/RoutingTestCase.java