Search in sources :

Example 11 with HttpRouter

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

the class Http11Test method setUp.

@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 4000), "thomas-bayer.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
    router.init();
}
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 12 with HttpRouter

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

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

the class MultipleLoadBalancersTest method setUp.

@Before
public void setUp() throws Exception {
    service1 = new MockService(2001);
    service2 = new MockService(2002);
    service11 = new MockService(2011);
    service12 = new MockService(2012);
    balancer = new HttpRouter();
    balancingInterceptor1 = createBalancingInterceptor(7000, "Default");
    balancingInterceptor2 = createBalancingInterceptor(7001, "Balancer2");
    BalancerUtil.lookupBalancer(balancer, "Default").up("Default", "localhost", service1.port);
    BalancerUtil.lookupBalancer(balancer, "Default").up("Default", "localhost", service2.port);
    BalancerUtil.lookupBalancer(balancer, "Balancer2").up("Default", "localhost", service11.port);
    BalancerUtil.lookupBalancer(balancer, "Balancer2").up("Default", "localhost", service12.port);
    roundRobinStrategy1 = new RoundRobinStrategy();
    roundRobinStrategy2 = new RoundRobinStrategy();
}
Also used : HttpRouter(com.predic8.membrane.core.HttpRouter) RoundRobinStrategy(com.predic8.membrane.core.interceptor.balancer.RoundRobinStrategy) Before(org.junit.Before)

Example 14 with HttpRouter

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

the class InterceptorInvocationTest method createRouter.

private HttpRouter createRouter() throws Exception {
    HttpRouter router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(createServiceProxy());
    addMockInterceptors(router, regularInterceptorNames);
    router.init();
    return router;
}
Also used : HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 15 with HttpRouter

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

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