use of com.adaptris.core.http.client.RangeMatch in project interlok by adaptris.
the class BranchingHttpRequestServiceTest method testService_RangeMatch.
@Test
public void testService_RangeMatch() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
Channel c = HttpHelper.createAndStartChannel(mock);
BranchingHttpRequestService service = new BranchingHttpRequestService(HttpHelper.createProduceDestination(c)).withDefaultServiceId("DefaultServiceId").withStatusMatches(new RangeMatch(100, 199, "1XX Informational"), new RangeMatch(300, 399, "3XX Moved"), new RangeMatch(200, 299, "2XX OK")).withContentType("text/complicated");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
c.requestStart();
execute(service, msg);
waitForMessages(mock, 1);
} finally {
HttpHelper.stopChannelAndRelease(c);
}
assertEquals(1, mock.messageCount());
assertEquals("2XX OK", msg.getNextServiceId());
}
use of com.adaptris.core.http.client.RangeMatch in project interlok by adaptris.
the class BranchingHttpRequestServiceTest method createForExamples.
private BranchingHttpRequestService createForExamples() {
BranchingHttpRequestService service = new BranchingHttpRequestService("http://myhost.com/url/to/get/data/from/or/post/data/to");
service.setContentType("text/complicated");
service.setDefaultServiceId("DefaultServiceId");
service.setUniqueId("GetData");
service.setMethod("GET");
service.getStatusMatches().add(new RangeMatch(500, 599, "5XX Server Error"));
service.getStatusMatches().add(new RangeMatch(200, 299, "2XX OK"));
service.getStatusMatches().add(new ExactMatch(404, "Not Found"));
service.getStatusMatches().add(new RangeMatch(400, 499, "4XX Client Error"));
service.setAuthenticator(HttpRequestServiceTest.buildAuthenticator("username", "password"));
return service;
}
use of com.adaptris.core.http.client.RangeMatch in project interlok by adaptris.
the class StatusMatchTest method testRangeMatch.
@Test
public void testRangeMatch() throws Exception {
RangeMatch match = new RangeMatch(200, 299, "200 OK");
assertEquals(200, match.getLower());
assertEquals(299, match.getUpper());
assertEquals("200 OK", match.getServiceId());
assertEquals("200 OK", match.serviceId());
assertTrue(match.matches(200));
assertTrue(match.matches(201));
assertFalse(match.matches(400));
assertFalse(match.matches(300));
}
Aggregations