Search in sources :

Example 6 with MockEncoder

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()));
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 7 with MockEncoder

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);
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 8 with MockEncoder

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));
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) Test(org.junit.Test)

Example 9 with MockEncoder

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()));
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 10 with MockEncoder

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);
    }
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

MockEncoder (com.adaptris.core.stubs.MockEncoder)10 Test (org.junit.Test)10 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)2 CoreException (com.adaptris.core.CoreException)2 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 StubMessageFactory (com.adaptris.core.stubs.StubMessageFactory)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1