Search in sources :

Example 11 with ServiceProxyKey

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

the class ViaProxyTest method setUp.

@Before
public void setUp() throws Exception {
    ProxyConfiguration proxy = new ProxyConfiguration();
    proxy.setHost("localhost");
    proxy.setPort(3128);
    proxyRouter = new HttpRouter(proxy);
    proxyRouter.getRuleManager().addProxy(new ProxyRule(new ProxyRuleKey(3128)), RuleDefinitionSource.MANUAL);
    proxyRouter.init();
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 4000), "thomas-bayer.com", 80));
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ProxyConfiguration(com.predic8.membrane.core.transport.http.client.ProxyConfiguration) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) ProxyRule(com.predic8.membrane.core.rules.ProxyRule) ProxyRuleKey(com.predic8.membrane.core.rules.ProxyRuleKey) HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Example 12 with ServiceProxyKey

use of com.predic8.membrane.core.rules.ServiceProxyKey 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 13 with ServiceProxyKey

use of com.predic8.membrane.core.rules.ServiceProxyKey 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 14 with ServiceProxyKey

use of com.predic8.membrane.core.rules.ServiceProxyKey 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 15 with ServiceProxyKey

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

Aggregations

ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)35 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)34 HttpRouter (com.predic8.membrane.core.HttpRouter)24 Before (org.junit.Before)18 Rule (com.predic8.membrane.core.rules.Rule)14 Exchange (com.predic8.membrane.core.exchange.Exchange)12 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)11 Outcome (com.predic8.membrane.core.interceptor.Outcome)11 IOException (java.io.IOException)8 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)3 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)3 SSLParser (com.predic8.membrane.core.config.security.SSLParser)2 MockInterceptor (com.predic8.membrane.core.interceptor.MockInterceptor)2 WebServerInterceptor (com.predic8.membrane.core.interceptor.server.WebServerInterceptor)2 ProxyRuleKey (com.predic8.membrane.core.rules.ProxyRuleKey)2 DummyWebServiceInterceptor (com.predic8.membrane.core.services.DummyWebServiceInterceptor)2 HttpClientConfiguration (com.predic8.membrane.core.transport.http.client.HttpClientConfiguration)2 ProxyConfiguration (com.predic8.membrane.core.transport.http.client.ProxyConfiguration)2 MalformedURLException (java.net.MalformedURLException)2