Search in sources :

Example 51 with AdaptrisMessage

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));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 52 with AdaptrisMessage

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));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 53 with AdaptrisMessage

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));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 54 with AdaptrisMessage

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);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 55 with AdaptrisMessage

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"));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1495 Test (org.junit.Test)1362 ServiceException (com.adaptris.core.ServiceException)171 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)158 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)156 StandaloneProducer (com.adaptris.core.StandaloneProducer)125 Channel (com.adaptris.core.Channel)122 MetadataElement (com.adaptris.core.MetadataElement)94 File (java.io.File)89 TimeInterval (com.adaptris.util.TimeInterval)77 CoreException (com.adaptris.core.CoreException)67 Session (javax.jms.Session)62 StandardWorkflow (com.adaptris.core.StandardWorkflow)57 GuidGenerator (com.adaptris.util.GuidGenerator)56 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)50 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)49 Message (javax.jms.Message)47 XPath (com.adaptris.util.text.xml.XPath)45 ServiceList (com.adaptris.core.ServiceList)43 Document (org.w3c.dom.Document)40