Пример #1
0
  @Test
  public void testProbe() throws Exception {
    stubFor(
        options(urlEqualTo("/endpoint"))
            .willReturn(aResponse().withStatus(SC_OK).withHeader(HttpHeaders.ALLOW, "PUT")));

    endpoint.probe();

    assertThat(endpoint.isDownloadAllowed().get(), is(false));
    assertThat(endpoint.isUploadAllowed().get(), is(true));
  }
Пример #2
0
  @Test
  public void testDownload() throws Exception {
    byte[] data = {1, 2, 3};

    stubFor(get(urlEqualTo("/endpoint")).willReturn(aResponse().withStatus(SC_OK).withBody(data)));

    InputStream stream = endpoint.download();

    assertArrayEquals(data, toByteArray(stream));
  }
Пример #3
0
  @Test
  @Ignore("Works in isolation but fails when executed as part of test suite")
  public void testUpload() throws Exception {
    stubFor(
        put(urlEqualTo("/endpoint"))
            .withHeader(CONTENT_TYPE, matching("mock/type"))
            .willReturn(aResponse().withStatus(SC_NO_CONTENT)));

    File file = File.createTempFile("unit-test", ".tmp");
    endpoint.upload(file, ContentType.create("mock/type"));
  }