Package org.springframework.http

Examples of org.springframework.http.MediaType


    }
    return bucketKeyPair;
  }

  protected MediaType extractMediaType(Object value) {
    MediaType mediaType = (value instanceof byte[] ? MediaType.APPLICATION_OCTET_STREAM : MediaType.APPLICATION_JSON);
    if (null != value && value.getClass().getAnnotations().length > 0) {
      KeyValueStoreMetaData meta = value.getClass()
          .getAnnotation(KeyValueStoreMetaData.class);
      if (null != meta) {
        // Use the media type specified on the annotation.
View Full Code Here


  @OAuth2ContextConfiguration(ResourceOwner.class)
  public void testTokenObtainedWithHeaderAuthentication() throws Exception {
    assertEquals(HttpStatus.OK, http.getStatusCode("/admin/beans"));
    int expiry = context.getAccessToken().getExpiresIn();
    assertTrue("Expiry not overridden in config: " + expiry, expiry < 1000);
    assertEquals(new MediaType("application", "json", Charset.forName("UTF-8")), tokenEndpointResponse.getHeaders()
        .getContentType());
  }
View Full Code Here

    for (MediaType acceptedMediaType : acceptedMediaTypes) {
      for (HttpMessageConverter messageConverter : messageConverters) {
        if (messageConverter.canWrite(returnValueType, acceptedMediaType)) {
          messageConverter.write(returnValue, acceptedMediaType, outputMessage);
          if (logger.isDebugEnabled()) {
            MediaType contentType = outputMessage.getHeaders().getContentType();
            if (contentType == null) {
              contentType = acceptedMediaType;
            }
            logger.debug("Written [" + returnValue + "] as \"" + contentType + "\" using ["
                + messageConverter + "]");
View Full Code Here

  @OAuth2ContextConfiguration(ResourceOwner.class)
  public void testTokenObtainedWithHeaderAuthentication() throws Exception {
    assertEquals(HttpStatus.OK, http.getStatusCode("/admin/beans"));
    int expiry = context.getAccessToken().getExpiresIn();
    assertTrue("Expiry not overridden in config: " + expiry, expiry < 1000);
    assertEquals(new MediaType("application", "json", Charset.forName("UTF-8")), tokenEndpointResponse.getHeaders()
        .getContentType());
  }
View Full Code Here

  @OAuth2ContextConfiguration(ResourceOwner.class)
  public void testTokenObtainedWithHeaderAuthentication() throws Exception {
    assertEquals(HttpStatus.OK, serverRunning.getStatusCode("/sparklr2/photos?format=json"));
    int expiry = context.getAccessToken().getExpiresIn();
    assertTrue("Expiry not overridden in config: " + expiry, expiry < 1000);
    assertEquals(new MediaType("application", "json", Charset.forName("UTF-8")), tokenEndpointResponse.getHeaders()
        .getContentType());
  }
View Full Code Here

    InputStream photo = sparklrService.loadSparklrPhoto(id);
    if (photo == null) {
      throw new UnavailableException("The requested photo does not exist");
    }
    BufferedImage body;
    MediaType contentType = MediaType.IMAGE_JPEG;
    Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
    if (imageReaders.hasNext()) {
      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
View Full Code Here

    InputStream photo = sparklrService.loadSparklrPhoto(id);
    if (photo == null) {
      throw new UnavailableException("The requested photo does not exist");
    }
    BufferedImage body;
    MediaType contentType = MediaType.IMAGE_JPEG;
    Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
    if (imageReaders.hasNext()) {
      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
View Full Code Here

    InputStream photo = sparklrService.loadSparklrPhoto(id);
    if (photo == null) {
      throw new UnavailableException("The requested photo does not exist");
    }
    BufferedImage body;
    MediaType contentType = MediaType.IMAGE_JPEG;
    Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
    if (imageReaders.hasNext()) {
      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
View Full Code Here

        RestTemplate restTemplate = new RestTemplate();
        List<HttpMessageConverter<?>> mc = restTemplate.getMessageConverters();
        // Add JSON message handler
        MappingJackson2HttpMessageConverter json = new MappingJackson2HttpMessageConverter();
        List<MediaType> supportedMediaTypes = new ArrayList<MediaType>();
        supportedMediaTypes.add(new MediaType("application","json", Charset.forName("UTF-8")));
        // Add default media type in case marketplace uses incorrect MIME type, otherwise
        // Spring refuses to process it, even if its valid JSON
        supportedMediaTypes.add(new MediaType("application","octet-stream", Charset.forName("UTF-8")));
        json.setSupportedMediaTypes(supportedMediaTypes);
        mc.add(json);
        restTemplate.setMessageConverters(mc);
        return restTemplate;
    }
View Full Code Here

        // check download
        request = getPrintRequest(MapPrinterServlet.REPORT_URL + "/" + ref, HttpMethod.GET);
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());
        assertEquals(new MediaType("application", "pdf"), response.getHeaders().getContentType());
        assertTrue(response.getBody().read() >= 0);
    }
View Full Code Here

TOP

Related Classes of org.springframework.http.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.