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();
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations