Package org.springframework.http.converter

Examples of org.springframework.http.converter.GenericHttpMessageConverter.canRead()


            }
          }
          else if (converter instanceof GenericHttpMessageConverter) {

            GenericHttpMessageConverter genericConverter = (GenericHttpMessageConverter) converter;
            if (genericConverter.canRead(responseType, null, null)) {
              allSupportedMediaTypes.addAll(getSupportedMediaTypes(converter));
            }
          }

        }
View Full Code Here


    MediaType contentType = getContentType(response);

    for (HttpMessageConverter messageConverter : this.messageConverters) {
      if (messageConverter instanceof GenericHttpMessageConverter) {
        GenericHttpMessageConverter genericMessageConverter = (GenericHttpMessageConverter) messageConverter;
        if (genericMessageConverter.canRead(this.responseType, null, contentType)) {
          if (logger.isDebugEnabled()) {
            logger.debug("Reading [" + this.responseType + "] as \"" +
                contentType + "\" using [" + messageConverter + "]");
          }
          return (T) genericMessageConverter.read(this.responseType, null, response);
View Full Code Here

        Class<T> targetClass = (Class<T>) GenericTypeResolver.resolveType(targetType, map);

        for (HttpMessageConverter<?> converter : this.messageConverters) {
          if (converter instanceof GenericHttpMessageConverter) {
            GenericHttpMessageConverter genericConverter = (GenericHttpMessageConverter) converter;
            if (genericConverter.canRead(targetType, contextClass, contentType)) {
              if (logger.isDebugEnabled()) {
                logger.debug("Reading [" + targetType + "] as \"" +
                    contentType + "\" using [" + converter + "]");
              }
              return (T) genericConverter.read(targetType, contextClass, inputMessage);
View Full Code Here

  public void exchangeParameterizedType() throws Exception {
    GenericHttpMessageConverter converter = mock(GenericHttpMessageConverter.class);
    template.setMessageConverters(Collections.<HttpMessageConverter<?>>singletonList(converter));

    ParameterizedTypeReference<List<Integer>> intList = new ParameterizedTypeReference<List<Integer>>() {};
    given(converter.canRead(intList.getType(), null, null)).willReturn(true);
    given(converter.getSupportedMediaTypes()).willReturn(Collections.singletonList(MediaType.TEXT_PLAIN));
    given(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.POST)).willReturn(this.request);
    HttpHeaders requestHeaders = new HttpHeaders();
    given(this.request.getHeaders()).willReturn(requestHeaders);
    given(converter.canWrite(String.class, null)).willReturn(true);
View Full Code Here

    responseHeaders.setContentType(MediaType.TEXT_PLAIN);
    responseHeaders.setContentLength(10);
    given(response.getStatusCode()).willReturn(HttpStatus.OK);
    given(response.getHeaders()).willReturn(responseHeaders);
    List<Integer> expected = Collections.singletonList(42);
    given(converter.canRead(intList.getType(), null, MediaType.TEXT_PLAIN)).willReturn(true);
    given(converter.read(intList.getType(), null, response)).willReturn(expected);
    given(response.getStatusCode()).willReturn(HttpStatus.OK);
    HttpStatus status = HttpStatus.OK;
    given(response.getStatusCode()).willReturn(status);
    given(response.getStatusText()).willReturn(status.getReasonPhrase());
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.