Search in sources :

Example 1 with MessageTarget

use of com.adaptris.interlok.client.MessageTarget in project interlok by adaptris.

the class InterlokJmxClientTest method testProcessAsync_LocalJmx.

@Test
public void testProcessAsync_LocalJmx() throws Exception {
    MyMessageProcessor proc = new MyMessageProcessor();
    MessageTarget target = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName());
    DefaultSerializableMessage msg = new DefaultSerializableMessage().withPayload(testName.getMethodName());
    register(createObjectName(target), proc);
    InterlokJmxClient client = new InterlokJmxClient();
    try {
        client.connect();
        client.processAsync(target, msg);
        assertEquals(msg.getUniqueId(), proc.getMessage().getUniqueId());
        assertEquals(msg.getContent(), proc.getMessage().getContent());
    } finally {
        client.disconnect();
    }
}
Also used : MessageTarget(com.adaptris.interlok.client.MessageTarget) DefaultSerializableMessage(com.adaptris.interlok.types.DefaultSerializableMessage) Test(org.junit.Test)

Example 2 with MessageTarget

use of com.adaptris.interlok.client.MessageTarget in project interlok by adaptris.

the class InterlokJmxClientTest method testProcessAsync_Convenience.

@Test
public void testProcessAsync_Convenience() throws Exception {
    MyMessageProcessor proc = new MyMessageProcessor();
    MessageTarget target = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName());
    register(createObjectName(target), proc);
    InterlokJmxClient client = new InterlokJmxClient(jmxConnectorServer.getAddress());
    try {
        client.connect();
        client.processAsync(target, testName.getMethodName(), new HashMap<String, String>());
        assertEquals(testName.getMethodName(), proc.getMessage().getContent());
    } finally {
        client.disconnect();
    }
}
Also used : MessageTarget(com.adaptris.interlok.client.MessageTarget) Test(org.junit.Test)

Example 3 with MessageTarget

use of com.adaptris.interlok.client.MessageTarget in project interlok by adaptris.

the class InterlokJmxClientTest method testMessageTarget_NoWorkflow.

@Test
public void testMessageTarget_NoWorkflow() throws Exception {
    MyMessageProcessor proc = new MyMessageProcessor();
    DefaultSerializableMessage msg = new DefaultSerializableMessage().withPayload(testName.getMethodName());
    register(createObjectName(new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName())), proc);
    MessageTarget notFound = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow("abcde");
    InterlokJmxClient client = new InterlokJmxClient(jmxConnectorServer.getAddress());
    try {
        client.connect();
        client.processAsync(notFound, msg);
        fail();
    } catch (InterlokException expected) {
        assertTrue(expected.getMessage().endsWith(" does not narrow to a single workflow"));
    } finally {
        client.disconnect();
    }
}
Also used : MessageTarget(com.adaptris.interlok.client.MessageTarget) InterlokException(com.adaptris.interlok.InterlokException) DefaultSerializableMessage(com.adaptris.interlok.types.DefaultSerializableMessage) Test(org.junit.Test)

Example 4 with MessageTarget

use of com.adaptris.interlok.client.MessageTarget in project interlok by adaptris.

the class InterlokJmxClientTest method testMessageTarget_Wildcard.

@Test
public void testMessageTarget_Wildcard() throws Exception {
    MyMessageProcessor proc = new MyMessageProcessor();
    MyMessageProcessor proc2 = new MyMessageProcessor();
    MessageTarget target1 = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName());
    MessageTarget target2 = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName() + "2");
    DefaultSerializableMessage msg = new DefaultSerializableMessage().withPayload(testName.getMethodName());
    register(createObjectName(target1), proc);
    register(createObjectName(target2), proc2);
    MessageTarget wildcard = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow("*");
    InterlokJmxClient client = new InterlokJmxClient(jmxConnectorServer.getAddress());
    try {
        client.connect();
        client.processAsync(wildcard, msg);
        fail();
    } catch (InterlokException expected) {
        assertTrue(expected.getMessage().endsWith(" does not narrow to a single workflow"));
    } finally {
        client.disconnect();
    }
}
Also used : MessageTarget(com.adaptris.interlok.client.MessageTarget) InterlokException(com.adaptris.interlok.InterlokException) DefaultSerializableMessage(com.adaptris.interlok.types.DefaultSerializableMessage) Test(org.junit.Test)

Example 5 with MessageTarget

use of com.adaptris.interlok.client.MessageTarget in project interlok by adaptris.

the class InterlokJmxClientTest method testProcess.

@Test
public void testProcess() throws Exception {
    MyMessageProcessor proc = new MyMessageProcessor();
    MessageTarget target = new MessageTarget().withAdapter(testName.getMethodName()).withChannel(testName.getMethodName()).withWorkflow(testName.getMethodName());
    DefaultSerializableMessage msg = new DefaultSerializableMessage().withPayload(testName.getMethodName());
    register(createObjectName(target), proc);
    InterlokJmxClient client = new InterlokJmxClient(jmxConnectorServer.getAddress());
    try {
        client.connect();
        SerializableMessage reply = client.process(target, msg);
        assertNotSame(reply.getUniqueId(), proc.getMessage().getUniqueId());
        assertEquals(testName.getMethodName(), reply.getContent());
        assertEquals(testName.getMethodName(), reply.getContent());
    } finally {
        client.disconnect();
    }
}
Also used : MessageTarget(com.adaptris.interlok.client.MessageTarget) DefaultSerializableMessage(com.adaptris.interlok.types.DefaultSerializableMessage) SerializableMessage(com.adaptris.interlok.types.SerializableMessage) DefaultSerializableMessage(com.adaptris.interlok.types.DefaultSerializableMessage) Test(org.junit.Test)

Aggregations

MessageTarget (com.adaptris.interlok.client.MessageTarget)6 Test (org.junit.Test)6 DefaultSerializableMessage (com.adaptris.interlok.types.DefaultSerializableMessage)5 InterlokException (com.adaptris.interlok.InterlokException)2 SerializableMessage (com.adaptris.interlok.types.SerializableMessage)1