@Test
public void testContentTypeMatching() throws Exception
{
Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
registry.addPerRequestResource(ConsumeResource.class);
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
{
ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("text/plain"), accepts));
Assert.assertNotNull(method);
Assert.assertEquals(ConsumeResource.class.getMethod("doGetWildCard"), method.getMethod());
}
{
ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("application/foo"), accepts));
Assert.assertNotNull(method);
Assert.assertEquals(ConsumeResource.class.getMethod("doGetFoo"), method.getMethod());
}
{
ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("application/bar"), accepts));
Assert.assertNotNull(method);
Assert.assertEquals(ConsumeResource.class.getMethod("doGetBar"), method.getMethod());
}
{
ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", MediaType.valueOf("application/baz"), accepts));
Assert.assertNotNull(method);
Assert.assertEquals(ConsumeResource.class.getMethod("doGetBaz"), method.getMethod());
}
}