Package org.springframework.http.converter

Examples of org.springframework.http.converter.ByteArrayHttpMessageConverter


  @Test
  public void handleReturnValueStringAcceptCharset() throws Exception {
    this.servletRequest.addHeader("Accept", "text/plain;charset=UTF-8");

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();
    converters.add(new ByteArrayHttpMessageConverter());
    converters.add(new StringHttpMessageConverter());
    RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters);

    processor.writeWithMessageConverters("Foo", returnTypeString, webRequest);
View Full Code Here


      @Override
      protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) {
        GenericWebApplicationContext wac = new GenericWebApplicationContext();
        wac.registerBeanDefinition("controller", new RootBeanDefinition(RequestResponseBodyController.class));
        RootBeanDefinition adapterDef = new RootBeanDefinition(AnnotationMethodHandlerAdapter.class);
        adapterDef.getPropertyValues().add("messageConverters", new ByteArrayHttpMessageConverter());
        wac.registerBeanDefinition("handlerAdapter", adapterDef);
        wac.refresh();
        return wac;
      }
    };
View Full Code Here

  public void unsupportedRequestBody() throws ServletException, IOException {
    initServlet(new ApplicationContextInitializer<GenericWebApplicationContext>() {
      @Override
      public void initialize(GenericWebApplicationContext wac) {
        RootBeanDefinition adapterDef = new RootBeanDefinition(RequestMappingHandlerAdapter.class);
        adapterDef.getPropertyValues().add("messageConverters", new ByteArrayHttpMessageConverter());
        wac.registerBeanDefinition("handlerAdapter", adapterDef);
      }
    }, RequestResponseBodyController.class);

    MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/something");
View Full Code Here

  private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();


  /** Create a new instance of the {@link RestTemplate} using default settings. */
  public RestTemplate() {
    this.messageConverters.add(new ByteArrayHttpMessageConverter());
    this.messageConverters.add(new StringHttpMessageConverter());
    this.messageConverters.add(new FormHttpMessageConverter());
    this.messageConverters.add(new SourceHttpMessageConverter());
    if (jaxb2Present) {
      this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter());
View Full Code Here

    public void setUpUpContextAndMVC() {
        MockitoAnnotations.initMocks(this);
        mvc = MockMvcBuilders.standaloneSetup( ctrl )
            .setMessageConverters(
                new JSONMessageConverter(), new ResourceMessageConverter(),
                new YsldMessageConverter(), new ByteArrayHttpMessageConverter())
            .build();
    }
View Full Code Here

    public void setUpUpContextAndMVC() {
        MockitoAnnotations.initMocks(this);
        mvc = MockMvcBuilders.standaloneSetup( ctrl )
            .setMessageConverters(
                new JSONMessageConverter(), new ResourceMessageConverter(),
                new YsldMessageConverter(), new ByteArrayHttpMessageConverter())
            .build();
    }
View Full Code Here

    super(false);

    // See SPR-7316
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
    stringHttpMessageConverter.setWriteAcceptCharset(false);
    messageConverters = new HttpMessageConverter[]{new ByteArrayHttpMessageConverter(), stringHttpMessageConverter,
        new SourceHttpMessageConverter(), new XmlAwareFormHttpMessageConverter()};
  }
View Full Code Here

  private ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();


  /** Create a new instance of the {@link RestTemplate} using default settings. */
  public RestTemplate() {
    this.messageConverters.add(new ByteArrayHttpMessageConverter());
    this.messageConverters.add(new StringHttpMessageConverter());
    this.messageConverters.add(new ResourceHttpMessageConverter());
    this.messageConverters.add(new SourceHttpMessageConverter());
    this.messageConverters.add(new XmlAwareFormHttpMessageConverter());
    if (jaxb2Present) {
View Full Code Here

  private RequestMappingHandlerAdapter createMockRequestHandlerAdapter() {
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
    stringHttpMessageConverter.setWriteAcceptCharset(false);
    List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
    messageConverters.add(new ByteArrayHttpMessageConverter());
    messageConverters.add(stringHttpMessageConverter);
    messageConverters.add(new SourceHttpMessageConverter<Source>());
    messageConverters.add(new XmlAwareFormHttpMessageConverter());
    RequestMappingHandlerAdapter adapter = mock(RequestMappingHandlerAdapter.class);
    given(adapter.getMessageConverters()).willReturn(messageConverters);
View Full Code Here

   */
  protected FormHttpMessageConverter getFormMessageConverter() {
    FormHttpMessageConverter converter = new FormHttpMessageConverter();
    converter.setCharset(Charset.forName("UTF-8"));
    List<HttpMessageConverter<?>> partConverters = new ArrayList<HttpMessageConverter<?>>();
    partConverters.add(new ByteArrayHttpMessageConverter());
    StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(Charset.forName("UTF-8"));
    stringHttpMessageConverter.setWriteAcceptCharset(false);
    partConverters.add(stringHttpMessageConverter);
    partConverters.add(new ResourceHttpMessageConverter());   
    converter.setPartConverters(partConverters);
View Full Code Here

TOP

Related Classes of org.springframework.http.converter.ByteArrayHttpMessageConverter

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.