use of org.apache.solr.servlet.SolrRequestParsers.RawRequestParser in project lucene-solr by apache.
the class SolrRequestParserTest method testStandardParseParamsAndFillStreamsISO88591.
@Test
public void testStandardParseParamsAndFillStreamsISO88591() throws Exception {
final String getParams = "qt=%FC&dup=foo&ie=iso-8859-1&dup=%FC", postParams = "qt2=%FC&q=hello&d%75p=bar";
final byte[] postBytes = postParams.getBytes(StandardCharsets.US_ASCII);
final String contentType = "application/x-www-form-urlencoded; charset=iso-8859-1";
// Set up the expected behavior
HttpServletRequest request = getMock("/solr/select", contentType, postBytes.length);
when(request.getMethod()).thenReturn("POST");
when(request.getQueryString()).thenReturn(getParams);
when(request.getInputStream()).thenReturn(new ByteServletInputStream(postBytes));
MultipartRequestParser multipart = new MultipartRequestParser(2048);
RawRequestParser raw = new RawRequestParser();
FormDataRequestParser formdata = new FormDataRequestParser(2048);
StandardRequestParser standard = new StandardRequestParser(multipart, raw, formdata);
SolrParams p = standard.parseParamsAndFillStreams(request, new ArrayList<ContentStream>());
assertEquals("contentType: " + contentType, "hello", p.get("q"));
assertEquals("contentType: " + contentType, "ü", p.get("qt"));
assertEquals("contentType: " + contentType, "ü", p.get("qt2"));
assertArrayEquals("contentType: " + contentType, new String[] { "foo", "ü", "bar" }, p.getParams("dup"));
verify(request).getInputStream();
}
use of org.apache.solr.servlet.SolrRequestParsers.RawRequestParser in project lucene-solr by apache.
the class SolrRequestParserTest method testStandardParseParamsAndFillStreams.
@Test
public void testStandardParseParamsAndFillStreams() throws Exception {
final String getParams = "qt=%C3%BC&dup=foo", postParams = "q=hello&d%75p=bar";
final byte[] postBytes = postParams.getBytes(StandardCharsets.US_ASCII);
// Set up the expected behavior
final String[] ct = new String[] { "application/x-www-form-urlencoded", "Application/x-www-form-urlencoded", "application/x-www-form-urlencoded; charset=utf-8", "application/x-www-form-urlencoded;" };
for (String contentType : ct) {
HttpServletRequest request = getMock("/solr/select", contentType, postBytes.length);
when(request.getMethod()).thenReturn("POST");
when(request.getQueryString()).thenReturn(getParams);
when(request.getInputStream()).thenReturn(new ByteServletInputStream(postBytes));
MultipartRequestParser multipart = new MultipartRequestParser(2048);
RawRequestParser raw = new RawRequestParser();
FormDataRequestParser formdata = new FormDataRequestParser(2048);
StandardRequestParser standard = new StandardRequestParser(multipart, raw, formdata);
SolrParams p = standard.parseParamsAndFillStreams(request, new ArrayList<ContentStream>());
assertEquals("contentType: " + contentType, "hello", p.get("q"));
assertEquals("contentType: " + contentType, "ü", p.get("qt"));
assertArrayEquals("contentType: " + contentType, new String[] { "foo", "bar" }, p.getParams("dup"));
verify(request).getInputStream();
}
}
Aggregations