}
@Test(dataProvider = "queryPaths")
public void testEchos(final String resourcePath) throws Exception
{
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echouri")
{
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{
assert response.getStatus() == 200;
assert response.getContentAsString().endsWith("/echouri");
}
}.run();
reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoquery")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
request.setQueryString("asdf=123");
request.addQueryParameter("bar", "bbb");
request.addQueryParameter("baz", "bzzz");
}
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{
assert response.getStatus() == 200;
assert response.getContentAsString().equals("bbb");
}
}.run();
reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echoheader")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
request.addHeader("bar", "baz");
}
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{
assert response.getStatus() == 200;
assert response.getContentAsString().equals("baz");
}
}.run();
reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echocookie")
{
@Override
protected void prepareRequest(EnhancedMockHttpServletRequest request)
{
request.addCookie(new Cookie("bar", "baz"));
}
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{
assert response.getStatus() == 200;
assert response.getContentAsString().equals("baz");
}
}.run();
reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/foo/bar/asdf")
{
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{
assert response.getStatus() == 200;
assert response.getContentAsString().equals("bar: asdf");
}
}.run();
reset();
new ResourceRequest(requestEnv, Method.GET, resourcePath + "/echotwoparams/foo/bar")
{
@Override
protected void onResponse(EnhancedMockHttpServletResponse response)
{