Package javax.ws.rs.core

Examples of javax.ws.rs.core.MediaType


   }

   @Test
   public void testGetAsText()
   {
      MediaType type = MediaType.valueOf("application/xml");
      propertyEditor.setValue(type);
      String text = propertyEditor.getAsText();
      assertEquals("application/xml", text);
   }
View Full Code Here


   }

   @Test
   public void testGetAsTextCustom()
   {
      MediaType type = MediaType.valueOf("application/custom");
      propertyEditor.setValue(type);
      String text = propertyEditor.getAsText();
      assertEquals("application/custom", text);
   }
View Full Code Here

   public void testAcceptGet() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(WebResource.class);

      MediaType contentType = new MediaType("text", "plain");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/foo"));
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
View Full Code Here

   public void testConsume() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(XmlResource.class);

      MediaType contentType = MediaType.valueOf("application/xml;schema=bar");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("PUT", "/xml", contentType, accepts));
         Assert.assertNotNull(method);
View Full Code Here

   public void testConsume2() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(XmlResource2.class);

      MediaType contentType = MediaType.valueOf("application/xml;schema=bar");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/xml;schema=junk;q=1.0"));
         accepts.add(MediaType.valueOf("application/xml;schema=stuff;q=0.5"));
View Full Code Here

   public void testConsume3() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(XmlResource2.class);

      MediaType contentType = MediaType.valueOf("application/xml;schema=blah");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/xml;schema=junk;q=1.0"));
         accepts.add(MediaType.valueOf("application/xml;schema=stuff;q=0.5"));
View Full Code Here

   public void testAcceptGetWildCard() throws Exception
   {
      Registry registry = new ResourceMethodRegistry(ResteasyProviderFactory.getInstance());
      registry.addPerRequestResource(WebResource.class);

      MediaType contentType = new MediaType("text", "plain");

      {
         ArrayList<MediaType> accepts = new ArrayList<MediaType>();
         accepts.add(MediaType.valueOf("application/wildcard"));
         accepts.add(MediaType.valueOf("application/foo;q=0.6"));
View Full Code Here

   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);
         ResourceMethod method = (ResourceMethod) registry.getResourceInvoker(createRequest("GET", "/", contentType, accepts));
View Full Code Here

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

   @Test
   public void testMatching()
   {
      MediaTypeMap<String> map = new MediaTypeMap<String>();
      String defaultPlainText = "defaultPlainText";
      map.add(new MediaType("text", "plain"), defaultPlainText);
      String jaxb = "jaxb";
      map.add(new MediaType("text", "xml"), jaxb);
      String wildcard = "wildcard";
      map.add(new MediaType("*", "*"), wildcard);
      String allText = "allText";
      map.add(new MediaType("text", "*"), allText);
      String allXML = "allXML";
      map.add(new MediaType("text", "*+xml"), allXML);
      String app = "app";
      map.add(new MediaType("application", "*"), app);

      List<String> list = map.getPossible(new MediaType("text", "plain"));
      Assert.assertNotNull(list);
      Assert.assertEquals(3, list.size());
      Assert.assertTrue(list.get(0) == defaultPlainText);
      Assert.assertTrue(list.get(1) == allText);
      Assert.assertTrue(list.get(2) == wildcard);

      list = map.getPossible(new MediaType("*", "*"));
      Assert.assertNotNull(list);
      Assert.assertEquals(6, list.size());
      Assert.assertTrue(list.get(0), list.get(0) == defaultPlainText || list.get(0) == jaxb);
      Assert.assertTrue(list.get(1), list.get(1) == defaultPlainText || list.get(1) == jaxb);
      Assert.assertTrue(list.get(2), list.get(2) == allXML);
      Assert.assertTrue(list.get(3), list.get(3) == allText || list.get(3) == app);
      Assert.assertTrue(list.get(4), list.get(4) == allText || list.get(4) == app);
      Assert.assertTrue(list.get(5), list.get(5) == wildcard);

      list = map.getPossible(new MediaType("text", "*"));
      Assert.assertNotNull(list);
      Assert.assertEquals(5, list.size());
      Assert.assertTrue(list.get(0), list.get(0) == defaultPlainText || list.get(0) == jaxb);
      Assert.assertTrue(list.get(1), list.get(1) == defaultPlainText || list.get(1) == jaxb);
      Assert.assertTrue(list.get(2), list.get(2) == allXML);
      Assert.assertTrue(list.get(3), list.get(3) == allText);
      Assert.assertTrue(list.get(4), list.get(4) == wildcard);

      list = map.getPossible(new MediaType("text", "xml"));
      Assert.assertNotNull(list);
      Assert.assertEquals(4, list.size());
      Assert.assertTrue(list.get(0) == jaxb);
      Assert.assertTrue(list.get(1) == allXML);
      Assert.assertTrue(list.get(2) == allText);
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.MediaType

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.