JaxRsHandler handler = HandlerCreator.getHandler(MyResource.class,
PersonWriter.class);
Request requestMock = EasyMock.createNiceMock(Request.class);
ResponseImpl responseImpl = new ResponseImpl();
//Response responseMock = EasyMock.createNiceMock(Response.class);
//makeThreadSafe(responseMock, true);
//responseMock.setBody((MessageBody) anyObject());
expect(requestMock.getMethod()).andReturn(Method.GET).anyTimes();
RequestURI requestURI = EasyMock.createNiceMock(RequestURI.class);
expect(requestURI.getPath()).andReturn("/");
expect(requestMock.getRequestURI()).andReturn(requestURI).anyTimes();
//responseMock.addHeader(StringValueMatcher.eqToString(HeaderName.CONTENT_TYPE), StringValueMatcher.eqToString("text/html"));
replay(requestMock);
replay(requestURI);
//replay(responseMock);
handler.handle(requestMock, responseImpl);
responseImpl.consumeBody();
String[] contentType = responseImpl.getHeaders().get(HeaderName.CONTENT_TYPE);
Assert.assertTrue(contentType.length == 1);
Assert.assertEquals("text/html", contentType[0]);
}