Package org.jboss.resteasy.core

Examples of org.jboss.resteasy.core.ResourceMethodRegistry



   @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());
      }
   }
View Full Code Here


   }

   @Test
   public void testComplex() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(ComplexResource.class);

      MediaType contentType = MediaType.TEXT_XML_TYPE;

      ArrayList<MediaType> accepts = new ArrayList<MediaType>();
      accepts.add(MediaType.WILDCARD_TYPE);
      accepts.add(MediaType.TEXT_HTML_TYPE);

      {
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
         Assert.assertNotNull(method);
         Assert.assertEquals(ComplexResource.class.getMethod("method2"), method.getMethod());
      }
   }
View Full Code Here

   }

   @Before
   public void init()
   {
      registry = new ResourceMethodRegistry(ResteasyProviderFactory
              .getInstance());
      root = registry.getRoot();
      registry.addSingletonResource(new NullResource());
   }
View Full Code Here

      return context;
   }

   private Registry someRegistry()
   {
      return new ResourceMethodRegistry(someProviderFactory());
   }
View Full Code Here

{
   @GET
   @Produces({"application/xml", "application/json"})
   public RegistryData get(@Context Registry reg) throws JAXBException
   {
      ResourceMethodRegistry registry = (ResourceMethodRegistry) reg;

      RegistryData data = new RegistryData();

      for (String key : registry.getRoot().getBounded().keySet())
      {
         List<ResourceInvoker> invokers = registry.getRoot().getBounded().get(key);

         RegistryEntry entry = new RegistryEntry();
         data.getEntries().add(entry);
         entry.setUriTemplate(key);
View Full Code Here

      return context;
   }

   private Registry someRegistry()
   {
      return new ResourceMethodRegistry(someProviderFactory());
   }
View Full Code Here


   @Test
   public void testBasic() throws URISyntaxException
   {
      ResourceMethodRegistry registry = new ResourceMethodRegistry(ResteasyProviderFactory
              .getInstance());
      registry.addSingletonResource(new NullResource());
      assertMatchRoot(registry, "/", "doNothing", NullResource.class);
      assertMatchRoot(registry, "/child", "childDoNothing", NullResource.class);
      assertMatchRoot(registry, "/child/foo", "childWithName", NullResource.class);
      assertMatchRoot(registry, "/child/1", "childWithId", NullResource.class);
      assertMatchRoot(registry, "/child1/1", "child1WithId", NullResource.class);
View Full Code Here

   }

   @Test
   public void testDefaultOptions() throws URISyntaxException
   {
      ResourceMethodRegistry registry = new ResourceMethodRegistry(ResteasyProviderFactory
              .getInstance());
      registry.addPerRequestResource(Resource.class);
      try
      {
         ResourceInvoker invoker = registry.getResourceInvoker(MockHttpRequest.options("/resource/sub"));
      }
      catch (DefaultOptionsMethodException e)
      {
      }
      try
      {
         ResourceInvoker invoker = registry.getResourceInvoker(MockHttpRequest.put("/resource/sub"));
      }
      catch (NotAllowedException e)
      {
      }
   }
View Full Code Here

   }

   @Test
   public void testLocatorOptions() throws URISyntaxException
   {
      ResourceMethodRegistry registry = new ResourceMethodRegistry(ResteasyProviderFactory
              .getInstance());
      registry.addPerRequestResource(Resource2.class);
      ResourceLocatorInvoker invoker = (ResourceLocatorInvoker)registry.getResourceInvoker(MockHttpRequest.options("/resource/sub"));
      Assert.assertNotNull(invoker);
      Assert.assertEquals(invoker.getMethod().getName(), "locator");
   }
View Full Code Here


   @Test
   public void testLocator3() throws URISyntaxException
   {
      ResourceMethodRegistry registry = new ResourceMethodRegistry(ResteasyProviderFactory
              .getInstance());
      registry.addPerRequestResource(Locator3.class);
      ResourceLocatorInvoker invoker = (ResourceLocatorInvoker)registry.getResourceInvoker(MockHttpRequest.get("/locator/responseok/responseok"));
      Assert.assertNotNull(invoker);
      Assert.assertEquals(invoker.getMethod().getName(), "responseOk");
   }
View Full Code Here

TOP

Related Classes of org.jboss.resteasy.core.ResourceMethodRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.