Search in sources :

Example 56 with AdaptrisMessage

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

the class JettyWrapperTest method testUnwrap.

@Test
public void testUnwrap() {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    JettyWrapper wrapper = new JettyWrapper();
    msg.addObjectHeader(JettyConstants.JETTY_WRAPPER, wrapper);
    assertEquals(wrapper, JettyWrapper.unwrap(msg));
    assertNotSame(wrapper, JettyWrapper.unwrap(AdaptrisMessageFactory.getDefaultInstance().newMessage()));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 57 with AdaptrisMessage

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

the class StandardResponseProducerTest method testResponse_NoOpResponseHeaders.

@Test
public void testResponse_NoOpResponseHeaders() throws Exception {
    StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
    responder.setResponseHeaderProvider(new NoOpResponseHeaderProvider());
    HttpConnection httpConnection = createConnection();
    Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), new ServiceList(new Service[] { new StandaloneProducer(responder) })));
    StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
    AdaptrisMessage msg = createMessage();
    try {
        c.requestStart();
        start(requestor);
        requestor.doService(msg);
        assertEquals(TEXT, msg.getContent());
    } finally {
        c.requestClose();
        stop(requestor);
        PortManager.release(httpConnection.getPort());
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 58 with AdaptrisMessage

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

the class StandardResponseProducerTest method testNoObjectMetadata.

@Test
public void testNoObjectMetadata() throws Exception {
    StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
    StandaloneProducer p = new StandaloneProducer(responder);
    try {
        // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
        LifecycleHelper.prepare(p);
        start(p);
        AdaptrisMessage msg = createMessage();
        p.doService(msg);
    } finally {
        stop(p);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 59 with AdaptrisMessage

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

the class StandardResponseProducerTest method testResponse_MetadataContentType.

@Test
public void testResponse_MetadataContentType() throws Exception {
    StandardResponseProducer responder = new StandardResponseProducer(HttpStatus.OK_200);
    responder.setContentTypeProvider(new MetadataContentTypeProvider("MyContentType"));
    AddMetadataService addMetadata = new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement("MyContentType", "text/xml") }));
    HttpConnection httpConnection = createConnection();
    Channel c = createChannel(httpConnection, createWorkflow(createConsumer(URL_TO_POST_TO), new MockMessageProducer(), new ServiceList(new Service[] { addMetadata, new StandaloneProducer(responder) })));
    StandaloneRequestor requestor = createRequestor(httpConnection.getPort());
    AdaptrisMessage msg = createMessage();
    try {
        c.requestStart();
        start(requestor);
        requestor.doService(msg);
        assertEquals(TEXT, msg.getContent());
        assertTrue(msg.containsKey("Content-Type"));
        assertTrue(msg.getMetadataValue("Content-Type").startsWith("text/xml"));
    } finally {
        c.requestClose();
        stop(requestor);
        PortManager.release(httpConnection.getPort());
    }
}
Also used : MetadataContentTypeProvider(com.adaptris.core.http.MetadataContentTypeProvider) StandaloneRequestor(com.adaptris.core.StandaloneRequestor) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) JettyHelper.createChannel(com.adaptris.core.http.jetty.JettyHelper.createChannel) Channel(com.adaptris.core.Channel) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 60 with AdaptrisMessage

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

the class FilesystemRetryStoreTest method testWrite_Exception.

@Test(expected = InterlokException.class)
public void testWrite_Exception() throws Exception {
    FilesystemRetryStore store = new FilesystemRetryStore().withBaseUrl(INVALID_URL);
    try {
        LifecycleHelper.initAndStart(store);
        AdaptrisMessage msg = new DefaultMessageFactory().newMessage("hello");
        store.write(msg);
    } finally {
        LifecycleHelper.stopAndClose(store);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1495 Test (org.junit.Test)1362 ServiceException (com.adaptris.core.ServiceException)171 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)158 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)156 StandaloneProducer (com.adaptris.core.StandaloneProducer)125 Channel (com.adaptris.core.Channel)122 MetadataElement (com.adaptris.core.MetadataElement)94 File (java.io.File)89 TimeInterval (com.adaptris.util.TimeInterval)77 CoreException (com.adaptris.core.CoreException)67 Session (javax.jms.Session)62 StandardWorkflow (com.adaptris.core.StandardWorkflow)57 GuidGenerator (com.adaptris.util.GuidGenerator)56 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)50 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)49 Message (javax.jms.Message)47 XPath (com.adaptris.util.text.xml.XPath)45 ServiceList (com.adaptris.core.ServiceList)43 Document (org.w3c.dom.Document)40