Search in sources :

Example 11 with Interceptor

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

the class ValidatorInterceptorTest method createSchemaValidatorInterceptor.

private ValidatorInterceptor createSchemaValidatorInterceptor(String schema) throws Exception {
    ValidatorInterceptor interceptor = new ValidatorInterceptor();
    interceptor.setResourceResolver(new ResolverMap());
    interceptor.setSchema(schema);
    interceptor.init();
    return interceptor;
}
Also used : ResolverMap(com.predic8.membrane.core.resolver.ResolverMap)

Example 12 with Interceptor

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

the class HelpLinkExistenceTest method doit.

@Test
public void doit() throws Exception {
    Set<Class<?>> classes = getElementClasses();
    Assert.assertNotEquals(0, classes.size());
    HttpClient hc = new HttpClient();
    for (Class<?> clazz : classes) {
        if (Interceptor.class.isAssignableFrom(clazz)) {
            Interceptor i = (Interceptor) clazz.newInstance();
            String helpId = i.getHelpId();
            String url = "http://membrane-soa.org/service-proxy-doc/" + getVersion() + "/configuration/reference/" + helpId + ".htm";
            Response r = hc.call(new Request.Builder().get(url).buildExchange()).getResponse();
            try {
                Assert.assertEquals(200, r.getStatusCode());
            } catch (Throwable e) {
                throw new RuntimeException(url, e);
            }
        }
    }
}
Also used : Response(com.predic8.membrane.core.http.Response) HttpClient(com.predic8.membrane.core.transport.http.HttpClient) Interceptor(com.predic8.membrane.core.interceptor.Interceptor) Test(org.junit.Test)

Example 13 with Interceptor

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

the class AccessControlInterceptorIntegrationTest method setInterceptor.

/*
	 * This test can only by run on a specific machine.
	 */
/*@Test
	public void testLocalhost() throws Exception {
		setInterceptor(FILE_CLIENTS_FROM_LOCALHOST);

		HttpClient client = new HttpClient();
		HostConfiguration config = new HostConfiguration();
		config.setLocalAddress(InetAddress.getByName("localhost"));
		client.setHostConfiguration(config);

		assertEquals(200, client.executeMethod(getBLZRequestMethod()));
	}*/
/*
	 * This test can only by run on a specific machine.
	 */
/*@Test
	public void test192_168_2_Star() throws Exception {
		setInterceptor(FILE_CLIENTS_FROM_192_168_2_STAR);
		assertEquals(200, getClient(FIXED_IP).executeMethod(getBLZRequestMethod()));
	}*/
private void setInterceptor(String fileName) throws Exception {
    AccessControlInterceptor interceptor = new AccessControlInterceptor();
    interceptor.setFile(fileName);
    router.addUserFeatureInterceptor(interceptor);
    router.init();
}
Also used : AccessControlInterceptor(com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor)

Example 14 with Interceptor

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

the class XMLProtectionInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    exc = new Exchange(null);
    exc.setRequest(MessageUtil.getGetRequest("/axis2/services/BLZService"));
    exc.setOriginalHostHeader("thomas-bayer.com:80");
    interceptor = new XMLProtectionInterceptor();
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Before(org.junit.Before)

Example 15 with Interceptor

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

the class ProxyRuleTest method getInterceptors.

private List<Interceptor> getInterceptors() {
    List<Interceptor> interceptors = new ArrayList<Interceptor>();
    Interceptor balancer = new LoadBalancingInterceptor();
    balancer.setId("roundRobinBalancer");
    interceptors.add(balancer);
    Interceptor acl = new AccessControlInterceptor();
    acl.setId("accessControlInterceptor");
    interceptors.add(acl);
    return interceptors;
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) AccessControlInterceptor(com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor) ArrayList(java.util.ArrayList) AccessControlInterceptor(com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor) LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) Interceptor(com.predic8.membrane.core.interceptor.Interceptor)

Aggregations

Interceptor (com.predic8.membrane.core.interceptor.Interceptor)11 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)6 Test (org.junit.Test)6 HttpRouter (com.predic8.membrane.core.HttpRouter)5 Rule (com.predic8.membrane.core.rules.Rule)5 Before (org.junit.Before)5 Exchange (com.predic8.membrane.core.exchange.Exchange)4 ArrayList (java.util.ArrayList)4 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)3 ResolverMap (com.predic8.membrane.core.resolver.ResolverMap)3 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)3 Response (com.predic8.membrane.core.http.Response)2 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)2 DispatchingInterceptor (com.predic8.membrane.core.interceptor.DispatchingInterceptor)2 HTTPClientInterceptor (com.predic8.membrane.core.interceptor.HTTPClientInterceptor)2 RuleMatchingInterceptor (com.predic8.membrane.core.interceptor.RuleMatchingInterceptor)2 UserFeatureInterceptor (com.predic8.membrane.core.interceptor.UserFeatureInterceptor)2 AccessControlInterceptor (com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor)2 User (com.predic8.membrane.core.interceptor.authentication.session.StaticUserDataProvider.User)2 RequestInterceptor (com.predic8.membrane.core.interceptor.flow.RequestInterceptor)2