Search in sources :

Example 31 with Router

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

the class UnavailableSoapProxyTest method setup.

@Before
public void setup() {
    r = new Router();
    HttpClientConfiguration httpClientConfig = new HttpClientConfiguration();
    httpClientConfig.setMaxRetries(1);
    r.setHttpClientConfig(httpClientConfig);
    r.setHotDeploy(false);
    r.setRetryInit(true);
    sp = new SOAPProxy();
    sp.setPort(2000);
    sp.setWsdl("http://localhost:2001/axis2/services/BLZService?wsdl");
    sp3 = new ServiceProxy();
    sp3.setPort(2000);
    sp3.setTarget(new AbstractServiceProxy.Target("localhost", 2001));
    ValidatorInterceptor v = new ValidatorInterceptor();
    v.setWsdl("http://localhost:2001/axis2/services/BLZService?wsdl");
    sp3.getInterceptors().add(v);
    SOAPProxy sp2 = new SOAPProxy();
    sp2.setPort(2001);
    sp2.setWsdl("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl");
    r2 = new Router();
    r2.setHotDeploy(false);
    r2.getRules().add(sp2);
// r2 will be started during the test
}
Also used : ValidatorInterceptor(com.predic8.membrane.core.interceptor.schemavalidation.ValidatorInterceptor) Router(com.predic8.membrane.core.Router) HttpClientConfiguration(com.predic8.membrane.core.transport.http.client.HttpClientConfiguration) Before(org.junit.Before)

Example 32 with Router

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

the class ExceptionHandlingTest method setUp.

@Before
public void setUp() throws Exception {
    router = new HttpRouter();
    router.getTransport().setPrintStackTrace(printStackTrace);
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", getPort()), "", -1);
    sp2.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            throw new Exception("secret");
        }
    });
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Outcome(com.predic8.membrane.core.interceptor.Outcome) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Before(org.junit.Before)

Example 33 with Router

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

the class BoundConnectionTest method setUp.

@Before
public void setUp() throws Exception {
    router = new HttpRouter();
    ServiceProxy sp1 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3021), "localhost", 3022);
    router.getRuleManager().addProxyAndOpenPortIfNew(sp1);
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3022), "", -1);
    sp2.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            exc.getRequest().readBody();
            exc.setResponse(Response.ok("OK.").build());
            connectionHash = ((HttpServerHandler) exc.getHandler()).getSrcOut().hashCode();
            return Outcome.RETURN;
        }
    });
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Outcome(com.predic8.membrane.core.interceptor.Outcome) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter) IOException(java.io.IOException) EndOfStreamException(com.predic8.membrane.core.util.EndOfStreamException) Before(org.junit.Before)

Example 34 with Router

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

the class AccessControlInterceptorIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3008), "thomas-bayer.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Example 35 with Router

use of com.predic8.membrane.core.Router 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)

Aggregations

HttpRouter (com.predic8.membrane.core.HttpRouter)24 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)21 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)19 Before (org.junit.Before)18 Rule (com.predic8.membrane.core.rules.Rule)16 IOException (java.io.IOException)9 Router (com.predic8.membrane.core.Router)8 Exchange (com.predic8.membrane.core.exchange.Exchange)6 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)5 Outcome (com.predic8.membrane.core.interceptor.Outcome)5 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)5 StringWriter (java.io.StringWriter)5 Test (org.junit.Test)5 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)3 Node (com.predic8.membrane.core.interceptor.balancer.Node)3 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)3 ProxyRuleKey (com.predic8.membrane.core.rules.ProxyRuleKey)3 HttpClientConfiguration (com.predic8.membrane.core.transport.http.client.HttpClientConfiguration)3 File (java.io.File)3