Examples of MediaType


Examples of javax.ws.rs.core.MediaType

   private boolean applyCharacterSet(Variant option, VariantQuality quality)
   {
      if (requestedCharacterSets == null)
         return true;
      MediaType mediaType = option.getMediaType();
      if (mediaType == null)
         return true;
      String charsetParameter = mediaType.getParameters().get("charset");
      if (charsetParameter == null)
         return true;
      QualityValue value = requestedCharacterSets.get(charsetParameter);
      if (value == null)   // try wildcard
         value = requestedCharacterSets.get(null);
View Full Code Here

Examples of javax.ws.rs.core.MediaType

            dispatcher.pushContextObjects(httpRequest, response);
            try
            {
               try
               {
                  MediaType resolvedContentType = resolveContentType(httpRequest,
                          httpRequest.getHttpHeaders().getMediaType());
                  ServerResponse responseInvoker = getResponse(model, resolvedContentType);
                  if (responseInvoker != null)
                  {
                     responseInvoker.writeTo(httpRequest, response, dispatcher.getProviderFactory());
View Full Code Here

Examples of javax.ws.rs.core.MediaType

         if (isRestfulData)
         {
            method.getTypeParameters();
            String contentType = servletRequest.getContentType();
            MediaType mediaType = MediaType.valueOf(contentType);
            MessageBodyReader reader = factory.getMessageBodyReader(type,
                    genericType, annotations, mediaType);
            if (reader == null)
               throw new BadRequestException(
                       "Could not find message body reader for type: "
View Full Code Here

Examples of javax.ws.rs.core.MediaType

   @Test
   public void testSetAsText()
   {
      propertyEditor.setAsText("application/xml");
      MediaType type = (MediaType) propertyEditor.getValue();
      assertEquals("application", type.getType());
      assertEquals("xml", type.getSubtype());
   }
View Full Code Here

Examples of javax.ws.rs.core.MediaType

   @Test
   public void testSetAsTextWithCharset()
   {
      propertyEditor.setAsText("application/xml;charset=UTF-8");
      MediaType type = (MediaType) propertyEditor.getValue();
      assertEquals("application", type.getType());
      assertEquals("xml", type.getSubtype());
      assertEquals("UTF-8", type.getParameters().get("charset"));
   }
View Full Code Here

Examples of javax.ws.rs.core.MediaType

   @Test
   public void testSetAsTextCustom()
   {
      propertyEditor.setAsText("application/custom");
      MediaType type = (MediaType) propertyEditor.getValue();
      assertEquals("application", type.getType());
      assertEquals("custom", type.getSubtype());
   }
View Full Code Here

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

Examples of javax.ws.rs.core.MediaType

   }

   @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

Examples of javax.ws.rs.core.MediaType

   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

Examples of javax.ws.rs.core.MediaType

   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
TOP
Copyright © 2018 www.massapi.com. 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.