use of com.predic8.membrane.core.rules.ServiceProxy 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();
}
use of com.predic8.membrane.core.rules.ServiceProxy 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();
}
use of com.predic8.membrane.core.rules.ServiceProxy in project service-proxy by membrane.
the class SpringReferencesTest method doit.
@Test
public void doit() {
ServiceProxy p = (ServiceProxy) r.getRules().iterator().next();
List<Interceptor> is = p.getInterceptors();
Assert.assertEquals(LogInterceptor.class, is.get(0).getClass());
Assert.assertEquals(LogInterceptor.class, is.get(1).getClass());
Assert.assertEquals(LogInterceptor.class, is.get(2).getClass());
Assert.assertEquals(SpringInterceptor.class, is.get(3).getClass());
Assert.assertEquals(LogInterceptor.class, is.get(4).getClass());
SpringInterceptor si = (SpringInterceptor) is.get(3);
Assert.assertSame(is.get(1), is.get(2));
Assert.assertSame(is.get(1), si.getInner());
}
use of com.predic8.membrane.core.rules.ServiceProxy 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();
}
use of com.predic8.membrane.core.rules.ServiceProxy 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();
}
Aggregations