MediaType contentType = new MediaType("text", "plain");
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("application/foo"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(WebResource.class.getMethod("doGetFoo"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("application/foo;q=0.1"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(WebResource.class.getMethod("doGetFoo"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("application/foo"));
accepts.add(MediaType.valueOf("application/bar;q=0.4"));
accepts.add(MediaType.valueOf("application/baz;q=0.2"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(WebResource.class.getMethod("doGetFoo"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("application/foo;q=0.4"));
accepts.add(MediaType.valueOf("application/bar"));
accepts.add(MediaType.valueOf("application/baz;q=0.2"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(WebResource.class.getMethod("doGetBar"), method.getMethod());
}
{
ArrayList<MediaType> accepts = new ArrayList<MediaType>();
accepts.add(MediaType.valueOf("application/foo;q=0.4"));
accepts.add(MediaType.valueOf("application/bar;q=0.2"));
accepts.add(MediaType.valueOf("application/baz"));
ResourceMethodInvoker method = (ResourceMethodInvoker) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
Assert.assertNotNull(method);
Assert.assertEquals(WebResource.class.getMethod("doGetBaz"), method.getMethod());
}
}