@Test
public void callsResourceMethodRespectsConsumedMediaTypes() throws Exception {

    when(applicationContext.getPathSegments(false)).thenReturn(createPathSegments("a", "b;x=y"));
    when(request.getMediaType()).thenReturn(APPLICATION_XML_TYPE);
    Resource resource = new Resource();
    ResourceMethodDescriptor resourceMethodOne = mockResourceMethod(Resource.class.getMethod("echo", String.class),
                                                                    "POST",
                                                                    newArrayList(TEXT_XML_TYPE, APPLICATION_XML_TYPE),
                                                                    newArrayList(WILDCARD_TYPE));
    ResourceMethodDescriptor resourceMethodTwo = mockResourceMethod(Resource.class.getMethod("echo", String.class),
                                                                    "POST",
                                                                    newArrayList(APPLICATION_JSON_TYPE),
                                                                    newArrayList(WILDCARD_TYPE));
    ObjectFactory resourceFactory = mockResourceFactory(resource, newArrayList(resourceMethodOne, resourceMethodTwo), newArrayList(), newArrayList());
    matchRequestPath();
    when(resources.getMatchedResource(eq("/a/b"), anyList())).thenReturn(resourceFactory);
    when(methodInvoker.invokeMethod(same(resource), same(resourceMethodOne), same(applicationContext))).thenReturn("foo");
    when(methodInvoker.invokeMethod(same(resource), same(resourceMethodTwo), same(applicationContext))).thenReturn("bar");
    requestDispatcher.dispatch(request, response);
    ArgumentCaptor<Response> argumentCaptor = ArgumentCaptor.forClass(Response.class);
    verify(response).setResponse(argumentCaptor.capture());
    assertEquals(OK, argumentCaptor.getValue().getStatusInfo());
    assertEquals("foo", argumentCaptor.getValue().getEntity());
}