@Test
public void callsSubResourceLocator() throws Exception {

    when(applicationContext.getPathSegments(false)).thenReturn(createPathSegments("a", "b", "c", "d;x=y"));
    LocatorResource locatorResource = new LocatorResource();
    SubResourceLocatorDescriptor subResourceLocator = mockSubResourceLocator(LocatorResource.class.getMethod("resource"), "c/d");
    ObjectFactory resourceFactory = mockResourceFactory(locatorResource, newArrayList(), newArrayList(), newArrayList(subResourceLocator));
    matchRequestPath("c/d");
    when(resources.getMatchedResource(eq("/a/b/c/d"), anyList())).thenReturn(resourceFactory);
    SubResource subResource = new SubResource();
    when(methodInvoker.invokeMethod(same(locatorResource), same(subResourceLocator), same(applicationContext))).thenReturn(subResource);
    when(methodInvoker.invokeMethod(same(subResource), isA(ResourceMethodDescriptor.class), same(applicationContext))).thenReturn("foo");
    requestDispatcher.dispatch(request, response);
    ArgumentCaptor<Response> argumentCaptor = ArgumentCaptor.forClass(Response.class);
    verify(response, atLeastOnce()).setResponse(argumentCaptor.capture());
    assertEquals(OK, argumentCaptor.getValue().getStatusInfo());
    assertEquals("foo", argumentCaptor.getValue().getEntity());
}