Package org.springframework.web.accept

Examples of org.springframework.web.accept.ContentNegotiationManager


  protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> messageConverters,
      ContentNegotiationManager manager) {

    super(messageConverters);
    this.contentNegotiationManager = (manager != null) ? manager : new ContentNegotiationManager();
  }
View Full Code Here


  public ProducesRequestCondition(String[] produces, String[] headers,
      ContentNegotiationManager manager) {

    this.expressions = new ArrayList<ProduceMediaTypeExpression>(parseExpressions(produces, headers));
    Collections.sort(this.expressions);
    this.contentNegotiationManager = (manager != null) ? manager : new ContentNegotiationManager();
  }
View Full Code Here

  private ProducesRequestCondition(Collection<ProduceMediaTypeExpression> expressions,
      ContentNegotiationManager manager) {

    this.expressions = new ArrayList<ProduceMediaTypeExpression>(expressions);
    Collections.sort(this.expressions);
    this.contentNegotiationManager = (manager != null) ? manager : new ContentNegotiationManager();
  }
View Full Code Here

  protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> messageConverters,
      ContentNegotiationManager manager, List<Object> responseBodyAdvice) {

    super(messageConverters);
    this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
    this.adviceChain = new ResponseBodyAdviceChain(responseBodyAdvice);
  }
View Full Code Here

   * @param manager used to determine requested media types
   */
  public ProducesRequestCondition(String[] produces, String[] headers, ContentNegotiationManager manager) {
    this.expressions = new ArrayList<ProduceMediaTypeExpression>(parseExpressions(produces, headers));
    Collections.sort(this.expressions);
    this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
  }
View Full Code Here

   * Private constructor with already parsed media type expressions.
   */
  private ProducesRequestCondition(Collection<ProduceMediaTypeExpression> expressions, ContentNegotiationManager manager) {
    this.expressions = new ArrayList<ProduceMediaTypeExpression>(expressions);
    Collections.sort(this.expressions);
    this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
  }
View Full Code Here

  public void resolveViewNameWithAcceptHeader() throws Exception {
    request.addHeader("Accept", "application/vnd.ms-excel");

    Map<String, MediaType> mapping = Collections.singletonMap("xls", MediaType.valueOf("application/vnd.ms-excel"));
    MappingMediaTypeFileExtensionResolver extensionsResolver = new MappingMediaTypeFileExtensionResolver(mapping);
    ContentNegotiationManager manager = new ContentNegotiationManager(new HeaderContentNegotiationStrategy());
    manager.addFileExtensionResolvers(extensionsResolver);
    viewResolver.setContentNegotiationManager(manager);

    ViewResolver viewResolverMock = mock(ViewResolver.class);
    viewResolver.setViewResolvers(Collections.singletonList(viewResolverMock));
View Full Code Here

  public void resolveViewNameWithRequestParameter() throws Exception {
    request.addParameter("format", "xls");

    Map<String, MediaType> mapping = Collections.singletonMap("xls", MediaType.valueOf("application/vnd.ms-excel"));
    ParameterContentNegotiationStrategy paramStrategy = new ParameterContentNegotiationStrategy(mapping);
    viewResolver.setContentNegotiationManager(new ContentNegotiationManager(paramStrategy));

    ViewResolver viewResolverMock = mock(ViewResolver.class);
    viewResolver.setViewResolvers(Collections.singletonList(viewResolverMock));
    viewResolver.afterPropertiesSet();
View Full Code Here

  public void resolveViewNameWithDefaultContentType() throws Exception {
    request.addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");

    MediaType mediaType = new MediaType("application", "xml");
    FixedContentNegotiationStrategy fixedStrategy = new FixedContentNegotiationStrategy(mediaType);
    viewResolver.setContentNegotiationManager(new ContentNegotiationManager(fixedStrategy));

    ViewResolver viewResolverMock1 = mock(ViewResolver.class, "viewResolver1");
    ViewResolver viewResolverMock2 = mock(ViewResolver.class, "viewResolver2");
    viewResolver.setViewResolvers(Arrays.asList(viewResolverMock1, viewResolverMock2));
    viewResolver.afterPropertiesSet();
View Full Code Here

  @Test
  public void resolveViewNameAcceptHeaderSortByQuality() throws Exception {
    request.addHeader("Accept", "text/plain;q=0.5, application/json");

    viewResolver.setContentNegotiationManager(new ContentNegotiationManager(new HeaderContentNegotiationStrategy()));

    ViewResolver htmlViewResolver = mock(ViewResolver.class);
    ViewResolver jsonViewResolver = mock(ViewResolver.class);
    viewResolver.setViewResolvers(Arrays.asList(htmlViewResolver, jsonViewResolver));
View Full Code Here

TOP

Related Classes of org.springframework.web.accept.ContentNegotiationManager

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.