Search in sources :

Example 36 with HttpRouter

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

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

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

Example 39 with HttpRouter

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

the class OAuth2AuthorizationServerInterceptorBase method setUp.

@Before
public void setUp() throws Exception {
    router = new HttpRouter();
    initOasi();
    initMas();
    initLoginMockParametersForJohn();
}
Also used : HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Example 40 with HttpRouter

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

the class AbortExchangeTest method setup.

@Before
public void setup() throws Exception {
    router = new HttpRouter();
    LimitedMemoryExchangeStore es = new LimitedMemoryExchangeStore();
    router.setExchangeStore(es);
    router.getTransport().getInterceptors().add(2, new ExchangeStoreInterceptor(es));
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3031), "", -1);
    sp2.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            exc.getRequest().readBody();
            exc.setResponse(Response.ok("").body(new InputStream() {

                int l = 0;

                @Override
                public int read() throws IOException {
                    if (l >= 2000000)
                        return -1;
                    return 0;
                }
            }, true).build());
            return Outcome.RETURN;
        }
    });
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) 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) InputStream(java.io.InputStream) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) ExchangeStoreInterceptor(com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter) IOException(java.io.IOException) 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