Search in sources :

Example 1 with Interceptor

use of com.lonepulse.robozombie.request.Interceptor in project RoboZombie by sahan.

the class InterceptorEndpointTest method testParamInterceptor.

/**
	 * <p>Test for {@link Interceptor}s passed as a request parameters.</p>
	 * 
	 * @since 1.3.0
	 */
@Test
public final void testParamInterceptor() {
    Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
    String subpath = "/param";
    stubFor(get(urlEqualTo(subpath)).willReturn(aResponse().withStatus(200)));
    final String value = "param";
    interceptorEndpoint.paramInterceptor(new Interceptor() {

        public void intercept(InvocationContext context, HttpRequestBase request) {
            request.addHeader("X-Header", value);
        }
    });
    verify(getRequestedFor(urlEqualTo(subpath)).withHeader("X-Header", equalTo("endpoint")).withHeader("X-Header", equalTo("request")).withHeader("X-Header", equalTo(value)).withHeader("Accept-Charset", equalTo("utf-8")));
}
Also used : HttpRequestBase(org.apache.http.client.methods.HttpRequestBase) InvocationContext(com.lonepulse.robozombie.proxy.InvocationContext) Interceptor(com.lonepulse.robozombie.request.Interceptor) Test(org.junit.Test)

Aggregations

InvocationContext (com.lonepulse.robozombie.proxy.InvocationContext)1 Interceptor (com.lonepulse.robozombie.request.Interceptor)1 HttpRequestBase (org.apache.http.client.methods.HttpRequestBase)1 Test (org.junit.Test)1