Search in sources :

Example 1 with RawStatusProvider

use of com.adaptris.core.http.server.RawStatusProvider in project interlok by adaptris.

the class JettyResponseService method buildProducer.

protected StandardResponseProducer buildProducer(AdaptrisMessage msg) {
    StandardResponseProducer p = new StandardResponseProducer().withContentTypeProvider(new RawContentTypeProvider(msg.resolve(getContentType()))).withResponseHeaderProvider(getResponseHeaderProvider()).withSendPayload(true).withForwardConnectionException(false).withFlushBuffer(true).withStatusProvider(new RawStatusProvider(Integer.parseInt(msg.resolve(getHttpStatus())))).withMessageFactory(msg.getFactory());
    p.registerConnection(new NullConnection());
    return p;
}
Also used : RawStatusProvider(com.adaptris.core.http.server.RawStatusProvider) NullConnection(com.adaptris.core.NullConnection) RawContentTypeProvider(com.adaptris.core.http.RawContentTypeProvider)

Example 2 with RawStatusProvider

use of com.adaptris.core.http.server.RawStatusProvider in project interlok by adaptris.

the class RawStatusProviderTest method testGetStatus.

@Test
public void testGetStatus() {
    RawStatusProvider prov = new RawStatusProvider(HttpStatus.OK_200.getStatusCode());
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    assertEquals(200, prov.getStatus(msg).getCode());
    assertEquals("OK", prov.getStatus(msg).getText());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RawStatusProvider(com.adaptris.core.http.server.RawStatusProvider) Test(org.junit.Test)

Example 3 with RawStatusProvider

use of com.adaptris.core.http.server.RawStatusProvider in project interlok by adaptris.

the class RawStatusProviderTest method testGetStatus_WithText.

@Test
public void testGetStatus_WithText() {
    RawStatusProvider prov = new RawStatusProvider(HttpURLConnection.HTTP_ACCEPTED);
    prov.setText("Really Not OK");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    assertEquals(HttpURLConnection.HTTP_ACCEPTED, prov.getStatus(msg).getCode());
    assertNotSame("OK", prov.getStatus(msg).getText());
    assertEquals("Really Not OK", prov.getStatus(msg).getText());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) RawStatusProvider(com.adaptris.core.http.server.RawStatusProvider) Test(org.junit.Test)

Aggregations

RawStatusProvider (com.adaptris.core.http.server.RawStatusProvider)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)2 Test (org.junit.Test)2 NullConnection (com.adaptris.core.NullConnection)1 RawContentTypeProvider (com.adaptris.core.http.RawContentTypeProvider)1