Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
dispatcher.getRegistry().addPerRequestResource(BaseResource.class);
{
MockHttpRequest request = MockHttpRequest.get("/top/base/1/resources");
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
Assert.assertEquals(Subresource.class.getName(), response.getContentAsString());
}
/*
HttpClient client = new HttpClient();
GetMethod method = createGetMethod("/base/1/resources");
try
{
int status = client.executeMethod(method);
Assert.assertEquals(status, HttpResponseCodes.SC_OK);
String response = method.getResponseBodyAsString();
Assert.assertEquals(Subresource.class.getName(), response);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
method.releaseConnection();
*/
{
MockHttpRequest request = MockHttpRequest.get("/top/base/1/resources/subresource2/stuff/2/bar");
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
Assert.assertEquals(Subresource2.class.getName() + "-2", response.getContentAsString());
}
}