Search in sources :

Example 1 with DefaultSerializableMessage

use of com.adaptris.interlok.types.DefaultSerializableMessage 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 DefaultSerializableMessage

use of com.adaptris.interlok.types.DefaultSerializableMessage in project interlok by adaptris.

the class DefaultSerializableMessageTranslatorTest method testBase64WrongValue.

@Test
public void testBase64WrongValue() throws Exception {
    DefaultSerializableMessage serializableMessage = new DefaultSerializableMessage();
    serializableMessage.setUniqueId(null);
    serializableMessage.setContent(BASE64_ENCODED);
    serializableMessage.addMessageHeader("_interlokMessageSerialization", "something-else");
    DefaultSerializableMessageTranslator translator = new DefaultSerializableMessageTranslator();
    AdaptrisMessage adaptrisMessage = translator.translate(serializableMessage);
    assertEquals(BASE64_ENCODED, adaptrisMessage.getContent());
}
Also used : DefaultSerializableMessage(com.adaptris.interlok.types.DefaultSerializableMessage) Test(org.junit.Test)

Example 3 with DefaultSerializableMessage

use of com.adaptris.interlok.types.DefaultSerializableMessage 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 DefaultSerializableMessage

use of com.adaptris.interlok.types.DefaultSerializableMessage 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 DefaultSerializableMessage

use of com.adaptris.interlok.types.DefaultSerializableMessage 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

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