Search in sources :

Example 21 with HttpRouter

use of com.predic8.membrane.core.HttpRouter in project service-proxy by membrane.

the class XSLTInterceptorTest method testXSLTParameter.

@Test
public void testXSLTParameter() throws Exception {
    exc = new Exchange(null);
    exc.setResponse(Response.ok().body(getClass().getResourceAsStream("/customer.xml"), true).build());
    exc.setProperty("XSLT_COMPANY", "predic8");
    XSLTInterceptor i = new XSLTInterceptor();
    i.setXslt("classpath:/customer2personAddCompany.xsl");
    i.init(new HttpRouter());
    i.handleResponse(exc);
    // printBodyContent();
    assertXPath("/person/name/first", "Rick");
    assertXPath("/person/name/last", "Cort\u00e9s Ribotta");
    assertXPath("/person/address/street", "Calle P\u00fablica \"B\" 5240 Casa 121");
    assertXPath("/person/address/city", "Omaha");
    assertXPath("/person/company", "predic8");
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) HttpRouter(com.predic8.membrane.core.HttpRouter) Test(org.junit.Test)

Example 22 with HttpRouter

use of com.predic8.membrane.core.HttpRouter in project service-proxy by membrane.

the class WSDLPublisherTest method before.

@Before
public void before() throws Exception {
    router = new HttpRouter();
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", port), "", -1);
    WSDLPublisherInterceptor wi = new WSDLPublisherInterceptor();
    wi.setWsdl(wsdlLocation);
    wi.init(router);
    sp2.getInterceptors().add(wi);
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Example 23 with HttpRouter

use of com.predic8.membrane.core.HttpRouter in project service-proxy by membrane.

the class ServiceInvocationTest method createRouter.

private HttpRouter createRouter() throws Exception {
    HttpRouter router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(createFirstRule());
    router.getRuleManager().addProxyAndOpenPortIfNew(createServiceRule());
    router.getTransport().getInterceptors().add(router.getTransport().getInterceptors().size() - 1, new MockInterceptor("transport-log"));
    router.init();
    return router;
}
Also used : MockInterceptor(com.predic8.membrane.core.interceptor.MockInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 24 with HttpRouter

use of com.predic8.membrane.core.HttpRouter in project service-proxy by membrane.

the class RewriteInterceptorIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    interceptor = new RewriteInterceptor();
    interceptor.getMappings().add(new Mapping("/blz-service\\?wsdl", "/axis2/services/BLZService?wsdl", null));
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3006), "thomas-bayer.com", 80);
    rule.getInterceptors().add(interceptor);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
Also used : Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 25 with HttpRouter

use of com.predic8.membrane.core.HttpRouter in project service-proxy by membrane.

the class REST2SOAPInterceptorIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3004), "www.thomas-bayer.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
    REST2SOAPInterceptor rest2SoapInt = new REST2SOAPInterceptor();
    rest2SoapInt.setMappings(getMappings());
    rule.getInterceptors().add(rest2SoapInt);
    router.init();
}
Also used : Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter)

Aggregations

HttpRouter (com.predic8.membrane.core.HttpRouter)38 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)24 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)23 Before (org.junit.Before)19 Exchange (com.predic8.membrane.core.exchange.Exchange)14 Rule (com.predic8.membrane.core.rules.Rule)11 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)8 Outcome (com.predic8.membrane.core.interceptor.Outcome)8 IOException (java.io.IOException)7 Test (org.junit.Test)6 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 DummyWebServiceInterceptor (com.predic8.membrane.core.services.DummyWebServiceInterceptor)3 Request (com.predic8.membrane.core.http.Request)2 RoundRobinStrategy (com.predic8.membrane.core.interceptor.balancer.RoundRobinStrategy)2 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)2 ProxyRuleKey (com.predic8.membrane.core.rules.ProxyRuleKey)2 URISyntaxException (java.net.URISyntaxException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)1 MemoryExchangeStore (com.predic8.membrane.core.exchangestore.MemoryExchangeStore)1