}
@Test
public void testAcceptMultiple() throws Exception
{
Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
registry.addPerRequestResource(MultipleResource.class);
MediaType contentType = new MediaType("text", "plain");
MediaType foo = MediaType.valueOf("application/foo");
MediaType bar = MediaType.valueOf("application/bar");
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(foo);
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(bar);
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("*/*"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("application/*"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(MultipleResource.class.getMethod("get"), method.getMethod());
}
}