@Test
public void complex() throws Exception
{
String acceptParamName = "bar";
AcceptParameterHttpPreprocessor processor = new AcceptParameterHttpPreprocessor(acceptParamName);
List<MediaType> expected = Arrays.asList(
MediaType.valueOf("application/xhtml+xml"),
MediaType.valueOf("text/html"),
MediaType.valueOf("application/xml;q=0.9"),
MediaType.valueOf("*/*;q=0.8")
);
String param1 = URLEncoder.encode("application/xml;q=0.9,application/xhtml+xml,*/*;q=0.8", "UTF-8");
String param2 = URLEncoder.encode("text/html", "UTF-8");
HttpRequest request = MockHttpRequest.get(
"foo?" + acceptParamName + "=" + param1 + "&" +
acceptParamName + "=" + param2);
processor.preProcess(request);
List<MediaType> actual = request.getHttpHeaders().getAcceptableMediaTypes();
Assert.assertEquals("Incorrect acceptable media type extracted", expected, actual);
}