use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.
the class HeaderFilterInterceptorTest method doit.
@Test
public void doit() throws Exception {
Exchange exc = new Exchange(null);
exc.setResponse(Response.ok().header("a", "b").header("c", "d").header("c", "d2").header("e", "f").build());
HeaderFilterInterceptor fhi = new HeaderFilterInterceptor();
fhi.setRules(Lists.newArrayList(new Rule[] { // implicitly set by Response.ok()
new Rule("Server", Action.REMOVE), new Rule("a", Action.KEEP), new Rule("c.*", Action.REMOVE) }));
fhi.handleResponse(exc);
HeaderField[] h = exc.getResponse().getHeader().getAllHeaderFields();
assertEquals(3, h.length);
assertEquals("Content-Length", h[0].getHeaderName().toString());
assertEquals("a", h[1].getHeaderName().toString());
assertEquals("e", h[2].getHeaderName().toString());
}
use of com.predic8.membrane.core.rules.Rule 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();
}
}
use of com.predic8.membrane.core.rules.Rule 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.Rule 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.Rule in project service-proxy by membrane.
the class ReadRulesWithInterceptorsConfigurationTest method testRuleInterceptorSize.
@Test
public void testRuleInterceptorSize() throws Exception {
Rule rule = rules.get(0);
assertEquals(1, rule.getInterceptors().size());
}
Aggregations