use of com.adaptris.core.http.client.ExactMatch in project interlok by adaptris.
the class StatusMatchTest method testExactMatch.
@Test
public void testExactMatch() throws Exception {
ExactMatch match = new ExactMatch(200, "200 OK");
assertEquals(200, match.getStatusCode());
assertEquals("200 OK", match.getServiceId());
assertEquals("200 OK", match.serviceId());
assertTrue(match.matches(200));
assertFalse(match.matches(201));
}
use of com.adaptris.core.http.client.ExactMatch in project interlok by adaptris.
the class BranchingHttpRequestServiceTest method testService_ExactMatch_WithError.
@Test
public void testService_ExactMatch_WithError() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
Channel c = HttpHelper.createAndStartChannel(mock, "This is the reply body", HttpStatus.INTERNAL_ERROR_500);
BranchingHttpRequestService service = new BranchingHttpRequestService(HttpHelper.createProduceDestination(c)).withDefaultServiceId("DefaultServiceId").withStatusMatches(new ExactMatch(500, "500 Server Error"), new ExactMatch(200, "200 OK")).withContentType("text/complicated");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
c.requestStart();
execute(service, msg);
waitForMessages(mock, 1);
assertEquals("This is the reply body", msg.getContent());
} finally {
HttpHelper.stopChannelAndRelease(c);
}
assertEquals(1, mock.messageCount());
assertEquals("500 Server Error", msg.getNextServiceId());
}
use of com.adaptris.core.http.client.ExactMatch in project interlok by adaptris.
the class BranchingHttpRequestServiceTest method testService_ExactMatch.
@Test
public void testService_ExactMatch() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
Channel c = HttpHelper.createAndStartChannel(mock, getName());
BranchingHttpRequestService service = new BranchingHttpRequestService(HttpHelper.createProduceDestination(c)).withDefaultServiceId("DefaultServiceId").withStatusMatches(new ExactMatch(500, "500 Server Error"), new ExactMatch(200, "200 OK")).withContentType("text/complicated");
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(TEXT);
try {
c.requestStart();
execute(service, msg);
waitForMessages(mock, 1);
assertEquals(getName(), msg.getContent());
} finally {
HttpHelper.stopChannelAndRelease(c);
}
assertEquals(1, mock.messageCount());
assertEquals("200 OK", msg.getNextServiceId());
}
use of com.adaptris.core.http.client.ExactMatch 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;
}
Aggregations