Search in sources :

Example 1 with MockEncoder

use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.

the class DecodingServiceTest method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    DecodingService s = new DecodingService();
    assertNull(s.getMessageFactory());
    s = new DecodingService(new MockEncoder());
    assertNull(s.getMessageFactory());
    assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
    s = new DecodingService(new MockEncoder());
    AdaptrisMessageFactory amf = new StubMessageFactory();
    s.setMessageFactory(amf);
    try {
        LifecycleHelper.init(s);
        assertEquals(amf, s.getMessageFactory());
        assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
        assertEquals(amf, s.getEncoder().currentMessageFactory());
    } finally {
        LifecycleHelper.close(s);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessageFactory(com.adaptris.core.AdaptrisMessageFactory) MockEncoder(com.adaptris.core.stubs.MockEncoder) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Example 2 with MockEncoder

use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.

the class DecodingServiceTest method testSetEncoder.

@Test
public void testSetEncoder() throws Exception {
    DecodingService s = new DecodingService();
    assertNull(s.getEncoder());
    MockEncoder me = new MockEncoder();
    s = new DecodingService(me);
    assertEquals(me, s.getEncoder());
    s = new DecodingService();
    s.setEncoder(me);
    assertEquals(me, s.getEncoder());
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) Test(org.junit.Test)

Example 3 with MockEncoder

use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.

the class DecodingServiceTest method testInit.

@Test
public void testInit() throws Exception {
    DecodingService service = new DecodingService();
    try {
        LifecycleHelper.init(service);
        fail();
    } catch (CoreException expected) {
    }
    service.setEncoder(new MockEncoder());
    LifecycleHelper.init(service);
    service = new DecodingService(new MockEncoder());
    LifecycleHelper.init(service);
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 4 with MockEncoder

use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.

the class EncodingServiceTest method testSetMessageFactory.

@Test
public void testSetMessageFactory() throws Exception {
    EncodingService s = new EncodingService();
    assertNull(s.getMessageFactory());
    s = new EncodingService(new MockEncoder());
    assertNull(s.getMessageFactory());
    assertTrue(s.getEncoder().currentMessageFactory() instanceof DefaultMessageFactory);
    s = new EncodingService(new MockEncoder());
    AdaptrisMessageFactory amf = new StubMessageFactory();
    s.setMessageFactory(amf);
    try {
        LifecycleHelper.init(s);
        assertEquals(amf, s.getMessageFactory());
        assertTrue(s.getEncoder().currentMessageFactory() instanceof StubMessageFactory);
        assertEquals(amf, s.getEncoder().currentMessageFactory());
    } finally {
        LifecycleHelper.close(s);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessageFactory(com.adaptris.core.AdaptrisMessageFactory) MockEncoder(com.adaptris.core.stubs.MockEncoder) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) Test(org.junit.Test)

Example 5 with MockEncoder

use of com.adaptris.core.stubs.MockEncoder in project interlok by adaptris.

the class EncodingServiceTest method testSetEncoder.

@Test
public void testSetEncoder() throws Exception {
    EncodingService s = new EncodingService();
    assertNull(s.getEncoder());
    MockEncoder me = new MockEncoder();
    s = new EncodingService(me);
    assertEquals(me, s.getEncoder());
    s = new EncodingService();
    s.setEncoder(me);
    assertEquals(me, s.getEncoder());
}
Also used : MockEncoder(com.adaptris.core.stubs.MockEncoder) 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