use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class JettyRouteConditionTest method testEvaluate_NoMatch_URI.
@Test
public void testEvaluate_NoMatch_URI() throws Exception {
JettyRouteCondition condition = LifecycleHelper.initAndStart(new JettyRouteCondition().withMetadataKeys(RECORD_ID).withMethod("POST").withUrlPattern(REGEX_WITH_GROUP));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JettyConstants.JETTY_URI, "/hello/world");
msg.addMetadata(CoreConstants.HTTP_METHOD, "POST");
assertFalse(condition.evaluate(msg));
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class JettyRouteConditionTest method testEvaluate_Match_URI_POST.
@Test
public void testEvaluate_Match_URI_POST() throws Exception {
JettyRouteCondition condition = LifecycleHelper.initAndStart(new JettyRouteCondition().withMetadataKeys(RECORD_ID).withMethod("POST").withUrlPattern(REGEX_WITH_GROUP));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JettyConstants.JETTY_URI, URI);
msg.addMetadata(CoreConstants.HTTP_METHOD, "POST");
assertTrue(condition.evaluate(msg));
assertTrue(msg.headersContainsKey(RECORD_ID));
assertEquals(RECORD_ID_VALUE, msg.getMetadataValue(RECORD_ID));
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class JettyRouteConditionTest method testEvaluate_Match_URI.
@Test
public void testEvaluate_Match_URI() throws Exception {
JettyRouteCondition condition = LifecycleHelper.initAndStart(new JettyRouteCondition().withMetadataKeys(RECORD_ID).withUrlPattern(REGEX_WITH_GROUP));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JettyConstants.JETTY_URI, URI);
msg.addMetadata(CoreConstants.HTTP_METHOD, "POST");
assertTrue(condition.evaluate(msg));
assertTrue(msg.headersContainsKey(RECORD_ID));
assertEquals(RECORD_ID_VALUE, msg.getMetadataValue(RECORD_ID));
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class JettyRoutingServiceTest method testMatchedRoute_NoMethod.
@Test
public void testMatchedRoute_NoMethod() throws Exception {
JettyRoutingService service = new JettyRoutingService("NotHandled", createRoutes());
try {
JettyRouteSpec noMethodMatch = new JettyRouteSpec().withCondition(new JettyRouteCondition().withUrlPattern("^/record.*$")).withServiceId("listAll");
service.getRoutes().add(noMethodMatch);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JettyConstants.JETTY_URI, "/records");
msg.addMetadata(CoreConstants.HTTP_METHOD, "GET");
LifecycleHelper.initAndStart(service);
service.doService(msg);
assertEquals("listAll", msg.getNextServiceId());
msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JettyConstants.JETTY_URI, "/records");
msg.addMetadata(CoreConstants.HTTP_METHOD, "GET");
service.doService(msg);
assertEquals("listAll", msg.getNextServiceId());
} finally {
LifecycleHelper.stopAndClose(service);
}
}
use of com.adaptris.core.AdaptrisMessage in project interlok by adaptris.
the class JettyRoutingServiceTest method testUnMatchedRoute.
@Test
public void testUnMatchedRoute() throws Exception {
JettyRoutingService service = new JettyRoutingService("NotHandled", createRoutes());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(JettyConstants.JETTY_URI, "/record/1234");
msg.addMetadata(CoreConstants.HTTP_METHOD, "TRACE");
execute(service, msg);
assertEquals("NotHandled", msg.getNextServiceId());
assertFalse(msg.headersContainsKey("recId"));
}
Aggregations