Search in sources :

Example 1 with MetadataStatusProvider

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

the class MetadataStatusProviderTest method testGetStatus_MissingMetadata_WithText.

@Test
public void testGetStatus_MissingMetadata_WithText() {
    MetadataStatusProvider prov = new MetadataStatusProvider("httpStatus", "httpStatusText");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.addMetadata("httpStatusText", "Really Not OK");
    assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, prov.getStatus(msg).getCode());
    assertNotSame("Internal Server Error", prov.getStatus(msg).getText());
    assertEquals("Really Not OK", prov.getStatus(msg).getText());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MetadataStatusProvider(com.adaptris.core.http.server.MetadataStatusProvider) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 2 with MetadataStatusProvider

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

the class MetadataStatusProviderTest method testGetStatus_WithMetadata.

@Test
public void testGetStatus_WithMetadata() {
    MetadataStatusProvider prov = new MetadataStatusProvider("httpStatus");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.addMetadata("httpStatus", "200");
    assertEquals(HttpURLConnection.HTTP_OK, prov.getStatus(msg).getCode());
    assertEquals("OK", prov.getStatus(msg).getText());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MetadataStatusProvider(com.adaptris.core.http.server.MetadataStatusProvider) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 3 with MetadataStatusProvider

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

the class MetadataStatusProviderTest method testGetStatus_MissingMetadata.

@Test
public void testGetStatus_MissingMetadata() {
    MetadataStatusProvider prov = new MetadataStatusProvider("httpStatus");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, prov.getStatus(msg).getCode());
    assertEquals("Internal Server Error", prov.getStatus(msg).getText());
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) MetadataStatusProvider(com.adaptris.core.http.server.MetadataStatusProvider) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 4 with MetadataStatusProvider

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

the class MetadataStatusProviderTest method testGetStatus_WithText.

@Test
public void testGetStatus_WithText() {
    MetadataStatusProvider prov = new MetadataStatusProvider("httpStatus", "httpStatusText");
    AdaptrisMessage msg = new DefaultMessageFactory().newMessage("");
    msg.addMetadata("httpStatus", "200");
    msg.addMetadata("httpStatusText", "Really Not OK");
    assertEquals(HttpURLConnection.HTTP_OK, 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) MetadataStatusProvider(com.adaptris.core.http.server.MetadataStatusProvider) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)4 MetadataStatusProvider (com.adaptris.core.http.server.MetadataStatusProvider)4 Test (org.junit.Test)4