Search in sources :

Example 11 with MinionIdentity

use of org.opennms.minion.core.api.MinionIdentity in project opennms by OpenNMS.

the class EchoRpcIT method failsWithTimeoutWhenSystemIdDoesNotExist.

/**
 * Issues a RPC to a location at which a listener is registered,
 * but specifies a system id that is not equal to the listener's.
 * Since no matching system can process the request, the request
 * should time out.
 */
@Test(timeout = 60000)
public void failsWithTimeoutWhenSystemIdDoesNotExist() throws Exception {
    assertNotEquals(REMOTE_LOCATION_NAME, identity.getLocation());
    EchoRpcModule echoRpcModule = new EchoRpcModule();
    CamelContext context = getContext();
    context.start();
    MinionIdentity minionIdentity = new MockMinionIdentity(REMOTE_LOCATION_NAME);
    CamelRpcServerRouteManager routeManager = getRouteManager(context);
    routeManager.bind(echoRpcModule);
    EchoRequest request = new EchoRequest("HELLO!!!");
    // Use a different system id, other than the one that's actually listening
    request.setSystemId(minionIdentity.getId() + "!");
    request.setLocation(REMOTE_LOCATION_NAME);
    try {
        echoClient.execute(request).get();
        fail("Did not get ExecutionException");
    } catch (ExecutionException e) {
        assertTrue("Cause is not of type RequestTimedOutException: " + ExceptionUtils.getStackTrace(e), e.getCause() instanceof RequestTimedOutException);
    }
    routeManager.unbind(echoRpcModule);
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) EchoRpcModule(org.opennms.core.rpc.echo.EchoRpcModule) RequestTimedOutException(org.opennms.core.rpc.api.RequestTimedOutException) EchoRequest(org.opennms.core.rpc.echo.EchoRequest) MinionIdentity(org.opennms.minion.core.api.MinionIdentity) RemoteExecutionException(org.opennms.core.rpc.api.RemoteExecutionException) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Aggregations

MinionIdentity (org.opennms.minion.core.api.MinionIdentity)11 Properties (java.util.Properties)9 Dictionary (java.util.Dictionary)7 Component (org.apache.camel.Component)7 CamelContext (org.apache.camel.CamelContext)2 Test (org.junit.Test)2 MessageDispatcherFactory (org.opennms.core.ipc.sink.api.MessageDispatcherFactory)2 EchoRequest (org.opennms.core.rpc.echo.EchoRequest)2 EchoRpcModule (org.opennms.core.rpc.echo.EchoRpcModule)2 ExecutionException (java.util.concurrent.ExecutionException)1 RemoteExecutionException (org.opennms.core.rpc.api.RemoteExecutionException)1 RequestTimedOutException (org.opennms.core.rpc.api.RequestTimedOutException)1 EchoResponse (org.opennms.core.rpc.echo.EchoResponse)1 ServiceDetectorRegistry (org.opennms.netmgt.provision.detector.registry.api.ServiceDetectorRegistry)1