@Test
public void testServletResourceFields() throws Exception {
ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true);
cri.setResourceProvider(new PerRequestResourceProvider(Customer.class));
OperationResourceInfo ori = new OperationResourceInfo(null, cri);
Customer c = new Customer();
// Creating mocks for the servlet request, response and context
HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
HttpServletResponse response = EasyMock.createMock(HttpServletResponse.class);
ServletContext context = EasyMock.createMock(ServletContext.class);
EasyMock.replay(request);
EasyMock.replay(response);
EasyMock.replay(context);
Message m = createMessage();
m.put(AbstractHTTPDestination.HTTP_REQUEST, request);
m.put(AbstractHTTPDestination.HTTP_RESPONSE, response);
m.put(AbstractHTTPDestination.HTTP_CONTEXT, context);
InjectionUtils.injectResourceFields(c, ori.getClassResourceInfo(), m);
assertSame(request.getClass(), c.getServletRequestResource().getClass());
HttpServletResponseFilter filter = (HttpServletResponseFilter)c.getServletResponseResource();
assertSame(response.getClass(), filter.getResponse().getClass());
assertSame(context.getClass(), c.getServletContextResource().getClass());
assertNull(c.getServletRequest());
assertNull(c.getServletResponse());
assertNull(c.getServletContext());
c = new Customer();
InjectionUtils.injectContextFields(c, ori.getClassResourceInfo(), m);
assertNull(c.getServletRequestResource());
assertNull(c.getServletResponseResource());
assertNull(c.getServletContextResource());
assertSame(request.getClass(), c.getServletRequest().getClass());
filter = (HttpServletResponseFilter)c.getServletResponse();