Search in sources :

Example 41 with SimpleProtocol

use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.

the class ProtocolRepositoryTestCase method requireThatPolicyCanBeNull.

@Test
public void requireThatPolicyCanBeNull() {
    ProtocolRepository repo = new ProtocolRepository();
    SimpleProtocol protocol = new SimpleProtocol();
    repo.putProtocol(protocol);
    assertNull(repo.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null));
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Test(org.junit.Test)

Example 42 with SimpleProtocol

use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.

the class ProtocolRepositoryTestCase method requireThatCreatePolicyExceptionIsCaught.

@Test
public void requireThatCreatePolicyExceptionIsCaught() {
    ProtocolRepository repo = new ProtocolRepository();
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("Custom", new SimpleProtocol.PolicyFactory() {

        @Override
        public RoutingPolicy create(String param) {
            throw new RuntimeException();
        }
    });
    repo.putProtocol(protocol);
    assertNull(repo.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null));
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) RoutingPolicy(com.yahoo.messagebus.routing.RoutingPolicy) Test(org.junit.Test)

Example 43 with SimpleProtocol

use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.

the class ProtocolRepositoryTestCase method requireThatPolicyCanBeCreated.

@Test
public void requireThatPolicyCanBeCreated() {
    ProtocolRepository repo = new ProtocolRepository();
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("Custom", new MyFactory());
    repo.putProtocol(protocol);
    assertNotNull(repo.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null));
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Test(org.junit.Test)

Example 44 with SimpleProtocol

use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.

the class ProtocolRepositoryTestCase method requireThatPolicyIsCached.

@Test
public void requireThatPolicyIsCached() {
    ProtocolRepository repo = new ProtocolRepository();
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("Custom", new MyFactory());
    repo.putProtocol(protocol);
    RoutingPolicy prev = repo.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null);
    assertNotNull(prev);
    RoutingPolicy next = repo.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null);
    assertNotNull(next);
    assertSame(prev, next);
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) RoutingPolicy(com.yahoo.messagebus.routing.RoutingPolicy) Test(org.junit.Test)

Aggregations

SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)44 Receptor (com.yahoo.messagebus.test.Receptor)30 Test (org.junit.Test)26 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)15 CustomPolicyFactory (com.yahoo.messagebus.routing.test.CustomPolicyFactory)13 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)12 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)11 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)8 Identity (com.yahoo.messagebus.network.Identity)7 Error (com.yahoo.messagebus.Error)5 RoutingPolicy (com.yahoo.messagebus.routing.RoutingPolicy)4 MessageBusParams (com.yahoo.messagebus.MessageBusParams)3 MessageBus (com.yahoo.messagebus.MessageBus)2 LocalNetwork (com.yahoo.messagebus.network.local.LocalNetwork)2 SharedMessageBus (com.yahoo.messagebus.shared.SharedMessageBus)2 Before (org.junit.Before)2 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)1 Spec (com.yahoo.jrt.Spec)1 DestinationSessionParams (com.yahoo.messagebus.DestinationSessionParams)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1