Search in sources :

Example 6 with QueryMap

use of io.apiman.gateway.engine.beans.util.QueryMap in project apiman-plugins by apiman.

the class JsonpPolicyTest method shouldSaveCallbackParamNameInContextWhenPresent.

@Test
public void shouldSaveCallbackParamNameInContextWhenPresent() throws Exception {
    // given
    JsonpConfigBean config = new JsonpConfigBean();
    config.setCallbackParamName("testParam");
    QueryMap queryParams = new QueryMap();
    queryParams.put("testParam", "testFunction");
    ApiRequest request = new ApiRequest();
    request.setQueryParams(queryParams);
    IPolicyChain<ApiRequest> chain = mock(IPolicyChain.class);
    // when
    jsonpPolicy.doApply(request, sContext, config, chain);
    // then
    assertEquals("testFunction", sContext.getAttribute("callbackFunctionName", null));
    verify(chain).doApply(request);
}
Also used : JsonpConfigBean(io.apiman.plugins.jsonp_policy.beans.JsonpConfigBean) QueryMap(io.apiman.gateway.engine.beans.util.QueryMap) ApiRequest(io.apiman.gateway.engine.beans.ApiRequest) Test(org.junit.Test)

Aggregations

QueryMap (io.apiman.gateway.engine.beans.util.QueryMap)6 ApiRequest (io.apiman.gateway.engine.beans.ApiRequest)4 Test (org.junit.Test)4 JsonpConfigBean (io.apiman.plugins.jsonp_policy.beans.JsonpConfigBean)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ApiRequestPathInfo (io.apiman.common.util.ApimanPathUtils.ApiRequestPathInfo)1 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1