Search in sources :

Example 46 with Router

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

the class RegExReplaceInterceptorTest method testReplace.

@Test
public void testReplace() throws Exception {
    router = Router.init("src/test/resources/regex-monitor-beans.xml");
    Rule serverRule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3009), "www.predic8.de", 80);
    router.getRuleManager().addProxyAndOpenPortIfNew(serverRule);
    router.init();
    try {
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod("http://localhost:3009");
        method.setRequestHeader(Header.CONTENT_TYPE, MimeType.TEXT_XML_UTF8);
        method.setRequestHeader(Header.SOAP_ACTION, "");
        assertEquals(200, client.executeMethod(method));
        assertTrue(new String(method.getResponseBody()).contains("Membrane RegEx Replacement Is Cool"));
    } finally {
        router.shutdown();
    }
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) HttpClient(org.apache.commons.httpclient.HttpClient) GetMethod(org.apache.commons.httpclient.methods.GetMethod) Rule(com.predic8.membrane.core.rules.Rule) Test(org.junit.Test)

Example 47 with Router

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

the class AccessControlInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    router = new HttpRouter();
    interceptor = new AccessControlInterceptor();
    interceptor.setFile("classpath:/acl/acl.xml");
    Rule rule4000 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 4000), "oio.de", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule4000);
    router.addUserFeatureInterceptor(interceptor);
    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 48 with Router

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

the class HostnameTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    router = new Router();
    h1 = new Hostname(router);
    h1.setPattern("localhost");
    ip = new Ip(router);
    ip.setPattern("127.0.0.1");
}
Also used : Router(com.predic8.membrane.core.Router) Before(org.junit.Before)

Example 49 with Router

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

the class LimitInterceptorTest method before.

@BeforeClass
public static void before() throws Exception {
    router = new HttpRouter();
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3026), "", -1);
    LimitInterceptor wi = new LimitInterceptor();
    wi.setMaxBodyLength(10);
    wi.setFlow(Flow.Set.REQUEST);
    sp2.getInterceptors().add(wi);
    WebServerInterceptor wi2 = new WebServerInterceptor();
    wi2.setDocBase("classpath:");
    wi2.init();
    sp2.getInterceptors().add(wi2);
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) WebServerInterceptor(com.predic8.membrane.core.interceptor.server.WebServerInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 50 with Router

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

the class MethodTest method setUp.

@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 4000), "oio.de", 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)

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