@Test
public void testQueryParamValueEncoding()
{
RestLiConfig config = new RestLiConfig();
config.setResourcePackageNames(QueryParamMockCollection.class.getPackage().getName());
RestLiServer server = new RestLiServer(config, new PrototypeResourceFactory(), null);
for (char c = 0; c < 256; ++c)
{
final String testValue = String.valueOf(c);
GetRequest<QueryParamMockCollection.DummyRecord> req =
new GetRequestBuilder<String, QueryParamMockCollection.DummyRecord>(
QueryParamMockCollection.RESOURCE_NAME,
QueryParamMockCollection.DummyRecord.class,
new ResourceSpecImpl(Collections.<ResourceMethod> emptySet(),
Collections.<String, DynamicRecordMetadata> emptyMap(),
Collections.<String, DynamicRecordMetadata> emptyMap(),
String.class,
null,
null,
QueryParamMockCollection.DummyRecord.class,
Collections.<String, CompoundKey.TypeInfo> emptyMap()),
RestliRequestOptions.DEFAULT_OPTIONS)
.id("dummy")
.setParam(QueryParamMockCollection.VALUE_KEY, testValue).build();
RestRequest restRequest = new RestRequestBuilder(RestliUriBuilderUtil.createUriBuilder(req).build())
.setMethod(req.getMethod().getHttpMethod().toString()).build();
// N.B. since QueryParamMockCollection is implemented using the synchronous rest.li interface,
// RestLiServer.handleRequest() will invoke the application resource *and* the callback
// *synchronously*, ensuring that the all instances of the callback are invoked before the
// loop terminates.
server.handleRequest(restRequest, new RequestContext(), new Callback<RestResponse>()
{
@Override
public void onError(Throwable e)
{
Assert.fail();