Search in sources :

Example 51 with ServiceList

use of com.adaptris.core.ServiceList in project interlok by adaptris.

the class StatelessServiceWrapperTest method testWrappingOfServiceListWrappedSettersAreCalled.

@Test
public void testWrappingOfServiceListWrappedSettersAreCalled() throws Exception {
    ServiceList ws = new ServiceList();
    ws.setUniqueId(ServiceList.class.getSimpleName());
    StatelessServiceWrapper s = new StatelessServiceWrapper(ws);
    s.setUniqueId(StatelessServiceWrapper.class.getSimpleName());
    s.setContinueOnFail(true);
    s.setIsTrackingEndpoint(true);
    assertNotNull(ws.getIsTrackingEndpoint());
    assertEquals(s.getIsTrackingEndpoint(), ws.getIsTrackingEndpoint());
    assertEquals(ws.isTrackingEndpoint(), s.isTrackingEndpoint());
}
Also used : ServiceList(com.adaptris.core.ServiceList) Test(org.junit.Test)

Example 52 with ServiceList

use of com.adaptris.core.ServiceList in project interlok by adaptris.

the class StatelessServiceWrapperTest method testWrappingOfServiceList.

@Test
public void testWrappingOfServiceList() throws Exception {
    ServiceList ws = new ServiceList();
    ws.setUniqueId(ServiceList.class.getSimpleName());
    ws.setContinueOnFail(true);
    ws.setIsTrackingEndpoint(true);
    StatelessServiceWrapper s = new StatelessServiceWrapper(ws);
    s.setUniqueId(StatelessServiceWrapper.class.getSimpleName());
    assertNotNull(ws.getIsTrackingEndpoint());
    assertEquals(ws.isTrackingEndpoint(), s.isTrackingEndpoint());
    assertEquals(ws.isBranching(), s.isBranching());
    assertEquals(ws.createName(), s.createName());
    assertEquals(ws.createQualifier(), s.createQualifier());
    assertNotSame(ws.getUniqueId(), s.getUniqueId());
}
Also used : ServiceList(com.adaptris.core.ServiceList) Test(org.junit.Test)

Example 53 with ServiceList

use of com.adaptris.core.ServiceList in project interlok by adaptris.

the class HttpHelper method createAndStartChannel.

public static Channel createAndStartChannel(MockMessageProducer mock, HttpStatusProvider.HttpStatus status) throws Exception {
    JettyMessageConsumer mc = createConsumer(URL_TO_POST_TO);
    mc.setHeaderHandler(new MetadataHeaderHandler());
    HttpConnection jc = createConnection();
    Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new StandaloneProducer(new StandardResponseProducer(status)) })));
    start(c);
    return c;
}
Also used : MetadataHeaderHandler(com.adaptris.core.http.jetty.MetadataHeaderHandler) HttpConnection(com.adaptris.core.http.jetty.HttpConnection) StandardResponseProducer(com.adaptris.core.http.jetty.StandardResponseProducer) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 54 with ServiceList

use of com.adaptris.core.ServiceList in project interlok by adaptris.

the class HttpRequestServiceTest method testRequest_EmptyReply.

@Test
public void testRequest_EmptyReply() throws Exception {
    MockMessageProducer mock = new MockMessageProducer();
    HttpConnection jc = HttpHelper.createConnection();
    JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
    StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
    responder.setSendPayload(false);
    Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new StandaloneProducer(responder) })));
    HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("POST");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
    try {
        start(c);
        execute(service, msg);
        waitForMessages(mock, 1);
    } finally {
        HttpHelper.stopChannelAndRelease(c);
    }
    assertEquals(1, mock.messageCount());
    AdaptrisMessage m2 = mock.getMessages().get(0);
    assertEquals("POST", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
    assertEquals(0, msg.getSize());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) HttpConnection(com.adaptris.core.http.jetty.HttpConnection) StandardResponseProducer(com.adaptris.core.http.jetty.StandardResponseProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test) HttpConsumerTest(com.adaptris.core.http.jetty.HttpConsumerTest)

Example 55 with ServiceList

use of com.adaptris.core.ServiceList in project interlok by adaptris.

the class HttpRequestServiceTest method testRequest_PostMethod_ZeroBytes.

@Test
public void testRequest_PostMethod_ZeroBytes() throws Exception {
    MockMessageProducer mock = new MockMessageProducer();
    HttpConnection jc = HttpHelper.createConnection();
    JettyMessageConsumer mc = createConsumer(HttpHelper.URL_TO_POST_TO);
    Channel c = createChannel(jc, createWorkflow(mc, mock, new ServiceList(new Service[] { new PayloadFromTemplateService().withTemplate(TEXT), new StandaloneProducer(new StandardResponseProducer(HttpStatus.OK_200)) })));
    HttpRequestService service = new HttpRequestService(HttpHelper.createProduceDestination(c)).withMethod("POST");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage();
    try {
        start(c);
        execute(service, msg);
        waitForMessages(mock, 1);
    } finally {
        HttpHelper.stopChannelAndRelease(c);
    }
    assertEquals(1, mock.messageCount());
    AdaptrisMessage m2 = mock.getMessages().get(0);
    assertEquals("POST", m2.getMetadataValue(CoreConstants.HTTP_METHOD));
    assertEquals(TEXT, msg.getContent());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) HttpConnection(com.adaptris.core.http.jetty.HttpConnection) StandardResponseProducer(com.adaptris.core.http.jetty.StandardResponseProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) JettyMessageConsumer(com.adaptris.core.http.jetty.JettyMessageConsumer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test) HttpConsumerTest(com.adaptris.core.http.jetty.HttpConsumerTest)

Aggregations

ServiceList (com.adaptris.core.ServiceList)64 Test (org.junit.Test)52 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)43 StandaloneProducer (com.adaptris.core.StandaloneProducer)39 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)33 Channel (com.adaptris.core.Channel)31 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)29 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)23 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)20 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)18 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)18 PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)17 Service (com.adaptris.core.Service)16 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)16 MetadataElement (com.adaptris.core.MetadataElement)14 ConfiguredRequestMethodProvider (com.adaptris.core.http.client.ConfiguredRequestMethodProvider)11 LogMessageService (com.adaptris.core.services.LogMessageService)11 StandardWorkflow (com.adaptris.core.StandardWorkflow)10