use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.
the class EncodingServiceTest method testMockEncoder.
@Test
public void testMockEncoder() throws Exception {
EncodingService service = new EncodingService(new MockEncoder());
AdaptrisMessage msg = createSimpleMessage();
execute(service, msg);
assertEquals(TEST_PAYLOAD, new String(msg.getPayload()));
}
use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.
the class EncodingServiceTest method testInit.
@Test
public void testInit() throws Exception {
EncodingService service = new EncodingService();
try {
LifecycleHelper.init(service);
fail();
} catch (CoreException expected) {
}
service.setEncoder(new MockEncoder());
LifecycleHelper.init(service);
service = new EncodingService(new MockEncoder());
LifecycleHelper.init(service);
}
use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.
the class AdaptrisMessageCase method testEncoder.
@Test
public void testEncoder() throws Exception {
AdaptrisMessage msg1 = createMessage();
MockEncoder m = new MockEncoder();
byte[] bytes = msg1.encode(m);
assertTrue(Arrays.equals(PAYLOAD.getBytes(), bytes));
byte[] b2 = msg1.encode(null);
assertTrue(Arrays.equals(PAYLOAD.getBytes(), b2));
}
use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.
the class DecodingServiceTest method testMockEncoder.
@Test
public void testMockEncoder() throws Exception {
DecodingService service = new DecodingService(new MockEncoder());
AdaptrisMessage msg = createSimpleMessage();
execute(service, msg);
assertEquals(TEST_PAYLOAD, new String(msg.getPayload()));
}
use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.
the class RelaxedFtpConsumerTest method testSingleFileWithEncoderConsume.
@Test
public void testSingleFileWithEncoderConsume() throws Exception {
String payload = "My file payload";
String oldname = Thread.currentThread().getName();
try {
Thread.currentThread().setName(getName());
setFilesToConsume(new String[] { "/MySingleFile.txt" }, new String[] { payload }, new long[] { calendarOneYearAgo.getTimeInMillis() });
consumer.setEncoder(new MockEncoder());
LifecycleHelper.init(consumer);
LifecycleHelper.start(consumer);
waitForConsumer(1, 3000);
assertEquals(1, messageListener.getMessages().size());
assertEquals(payload, messageListener.getMessages().get(0).getContent());
} finally {
Thread.currentThread().setName(oldname);
}
}
Aggregations