Search in sources :

Example 21 with ServiceProxy

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

the class ServiceInvocationTest method createServiceRule.

private ServiceProxy createServiceRule() {
    ServiceProxy rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", "*", 3012), "thomas-bayer.com", 80);
    rule.setName("log");
    rule.getInterceptors().add(new MockInterceptor("log"));
    return rule;
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) MockInterceptor(com.predic8.membrane.core.interceptor.MockInterceptor)

Example 22 with ServiceProxy

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

the class ResolverTest method setup.

@BeforeClass
public static void setup() throws Exception {
    ServiceProxy sp = new ServiceProxy(new ServiceProxyKey(3029), "localhost", 8080);
    sp.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            hit = true;
            return Outcome.CONTINUE;
        }
    });
    WebServerInterceptor i = new WebServerInterceptor();
    if (deployment.equals(STANDALONE))
        i.setDocBase("src/test/resources");
    else {
        i.setDocBase("/test");
        router.getResolverMap().addSchemaResolver(resolverMap.getFileSchemaResolver());
    }
    sp.getInterceptors().add(i);
    router.add(sp);
    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) WebServerInterceptor(com.predic8.membrane.core.interceptor.server.WebServerInterceptor) InvalidParameterException(java.security.InvalidParameterException) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 23 with ServiceProxy

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

the class ConnectionTest method setUp.

@Before
public void setUp() throws Exception {
    Rule rule2000 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 2000), "predic8.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule2000);
    conLocalhost = Connection.open("localhost", 2000, null, null, 30000);
    con127_0_0_1 = Connection.open("127.0.0.1", 2000, null, null, 30000);
}
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 24 with ServiceProxy

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

the class IllegalCharactersInURLTest method init.

@Before
public void init() throws Exception {
    r = new HttpRouter();
    r.setHotDeploy(false);
    r.add(new ServiceProxy(new ServiceProxyKey(3027), "localhost", 3028));
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey(3028), null, 80);
    sp2.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            Assert.assertEquals("/foo{}", exc.getRequestURI());
            exc.setResponse(Response.ok().build());
            return Outcome.RETURN;
        }
    });
    r.add(sp2);
    r.start();
}
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) Before(org.junit.Before)

Example 25 with ServiceProxy

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

the class EmbeddingJava method main.

public static void main(String[] args) throws Exception {
    String hostname = "*";
    String method = "GET";
    String path = ".*";
    int listenPort = 4000;
    ServiceProxyKey key = new ServiceProxyKey(hostname, method, path, listenPort);
    String targetHost = "predic8.com";
    int targetPort = 80;
    ServiceProxy sp = new ServiceProxy(key, targetHost, targetPort);
    sp.getInterceptors().add(new AddMyHeaderInterceptor());
    HttpRouter router = new HttpRouter();
    router.add(sp);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) HttpRouter(com.predic8.membrane.core.HttpRouter)

Aggregations

ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)47 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)34 HttpRouter (com.predic8.membrane.core.HttpRouter)25 Before (org.junit.Before)19 Rule (com.predic8.membrane.core.rules.Rule)17 Exchange (com.predic8.membrane.core.exchange.Exchange)16 Outcome (com.predic8.membrane.core.interceptor.Outcome)14 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)12 IOException (java.io.IOException)9 Test (org.junit.Test)9 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)5 ArrayList (java.util.ArrayList)4 Router (com.predic8.membrane.core.Router)3 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)3 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)3 HttpClientConfiguration (com.predic8.membrane.core.transport.http.client.HttpClientConfiguration)3 URISyntaxException (java.net.URISyntaxException)3 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)2 MockInterceptor (com.predic8.membrane.core.interceptor.MockInterceptor)2