Search in sources :

Example 1 with RequestQuoter

use of org.apache.hadoop.http.HttpServer2.QuotingInputFilter.RequestQuoter in project hadoop by apache.

the class TestHttpServer method testRequestQuoterWithNotNull.

@Test
public void testRequestQuoterWithNotNull() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    String[] values = new String[] { "abc", "def" };
    Mockito.doReturn(values).when(request).getParameterValues("dummy");
    RequestQuoter requestQuoter = new RequestQuoter(request);
    String[] parameterValues = requestQuoter.getParameterValues("dummy");
    Assert.assertTrue("It should return Parameter Values", Arrays.equals(values, parameterValues));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestQuoter(org.apache.hadoop.http.HttpServer2.QuotingInputFilter.RequestQuoter) Test(org.junit.Test)

Example 2 with RequestQuoter

use of org.apache.hadoop.http.HttpServer2.QuotingInputFilter.RequestQuoter in project hadoop by apache.

the class TestHttpServer method testRequestQuoterWithNull.

@Test
public void testRequestQuoterWithNull() throws Exception {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    Mockito.doReturn(null).when(request).getParameterValues("dummy");
    RequestQuoter requestQuoter = new RequestQuoter(request);
    String[] parameterValues = requestQuoter.getParameterValues("dummy");
    Assert.assertNull("It should return null " + "when there are no values for the parameter", parameterValues);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RequestQuoter(org.apache.hadoop.http.HttpServer2.QuotingInputFilter.RequestQuoter) Test(org.junit.Test)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)2 RequestQuoter (org.apache.hadoop.http.HttpServer2.QuotingInputFilter.RequestQuoter)2 Test (org.junit.Test)2