Examples of MockHttpInputMessage


Examples of org.springframework.http.MockHttpInputMessage

  }

  @Test
  public void read() throws IOException {
    byte[] body = this.testMsg.toByteArray();
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    inputMessage.getHeaders().setContentType(ProtobufHttpMessageConverter.PROTOBUF);
    Message result = this.converter.read(Msg.class, inputMessage);
    assertEquals(this.testMsg, result);
  }
View Full Code Here

Examples of org.springframework.http.MockHttpInputMessage

  @Test
  public void customizeUnmarshaller() throws Exception {
    byte[] body = "<myRootElement><element>a|||b</element></myRootElement>".getBytes("UTF-8");
    MyJaxb2RootElementHttpMessageConverter myConverter = new MyJaxb2RootElementHttpMessageConverter();
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    MyRootElement result = (MyRootElement) myConverter.read(MyRootElement.class, inputMessage);
    assertEquals("a", result.getElement().getField1());
    assertEquals("b", result.getElement().getField2());
  }
View Full Code Here

Examples of org.springframework.http.MockHttpInputMessage

  }

  @Test
  public void readNoContentType() throws IOException {
    byte[] body = this.testMsg.toByteArray();
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    Message result = this.converter.read(Msg.class, inputMessage);
    assertEquals(this.testMsg, result);
  }
View Full Code Here

Examples of org.springframework.http.MockHttpInputMessage

  }

  @Test
  public void read() throws IOException {
    byte[] body = new byte[]{0x1, 0x2};
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    inputMessage.getHeaders().setContentType(new MediaType("application", "octet-stream"));
    byte[] result = converter.read(byte[].class, inputMessage);
    assertArrayEquals("Invalid result", body, result);
  }
View Full Code Here

Examples of org.springframework.http.MockHttpInputMessage

  }

  @Test
  public void read() throws IOException {
    byte[] body = FileCopyUtils.copyToByteArray(getClass().getResourceAsStream("logo.jpg"));
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    inputMessage.getHeaders().setContentType(MediaType.IMAGE_JPEG);
    converter.read(Resource.class, inputMessage);
  }
View Full Code Here

Examples of org.springframework.http.MockHttpInputMessage

  @Test
  public void read() throws IOException {
    Resource logo = new ClassPathResource("logo.jpg", BufferedImageHttpMessageConverterTests.class);
    byte[] body = FileCopyUtils.copyToByteArray(logo.getInputStream());
    MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
    inputMessage.getHeaders().setContentType(new MediaType("image", "jpeg"));
    BufferedImage result = converter.read(BufferedImage.class, inputMessage);
    assertEquals("Invalid height", 500, result.getHeight());
    assertEquals("Invalid width", 750, result.getWidth());
  }
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.