Package com.github.tomakehurst.wiremock.testsupport

Examples of com.github.tomakehurst.wiremock.testsupport.WireMockResponse.content()


        .willReturn(aResponse()
        .proxiedFrom(TARGET_SERVICE_BASE_URL)));
   
    WireMockResponse response = testClient.get("/proxied/resource?param=value");
   
    assertThat(response.content(), is("Proxied content"));
    assertThat(response.firstHeader("Content-Type"), is("text/plain"));
  }
 
  @Test
  public void successfullyPostsResponseToOtherServiceViaProxy() {
View Full Code Here


  public void servesFileFromFilesDir() {
    writeFileToFilesDir("test-1.xml", "<content>Blah</content>");
    startRunner();
    WireMockResponse response = testClient.get("/test-1.xml");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("<content>Blah</content>"));
    assertThat(response.firstHeader("Content-Type"), is("application/xml"));
  }
 
  @Test
  public void servesFileFromSpecifiedRecordingsPath() {
View Full Code Here

    String differentRoot = FILE_SOURCE_ROOT + separator + "differentRoot";
    writeFile(differentRoot + separator + underFiles("test-1.xml"), "<content>Blah</content>");
    startRunner("--root-dir", differentRoot);
    WireMockResponse response = testClient.get("/test-1.xml");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("<content>Blah</content>"));
    assertThat(response.firstHeader("Content-Type"), is("application/xml"));
  }

  @Test
  public void servesFileAsJsonWhenNoFileExtension() {
View Full Code Here

  public void servesFileAsJsonWhenNoFileExtension() {
    writeFileToFilesDir("json/12345", "{ \"key\": \"value\" }");
    startRunner();
    WireMockResponse response = testClient.get("/json/12345");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("{ \"key\": \"value\" }"));
    assertThat(response.firstHeader("Content-Type"), is("application/json"));
  }
 
  @Test
  public void shouldNotSend302WhenPathIsDirAndTrailingSlashNotPresent() {
View Full Code Here

  public void shouldNotSend302WhenPathIsDirAndTrailingSlashNotPresent() {
      writeFileToFilesDir("json/wire & mock directory/index.json", "{ \"key\": \"index page value\" }");
      startRunner();
        WireMockResponse response = testClient.get("/json/wire%20&%20mock%20directory");
        assertThat(response.statusCode(), is(200));
        assertThat(response.content(), is("{ \"key\": \"index page value\" }"));
  }
 
  @Test
  public void servesJsonIndexFileWhenTrailingSlashPresent() {
    writeFileToFilesDir("json/23456/index.json", "{ \"key\": \"new value\" }");
View Full Code Here

  public void servesJsonIndexFileWhenTrailingSlashPresent() {
    writeFileToFilesDir("json/23456/index.json", "{ \"key\": \"new value\" }");
    startRunner();
    WireMockResponse response = testClient.get("/json/23456/");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("{ \"key\": \"new value\" }"));
    assertThat(response.firstHeader("Content-Type"), is("application/json"));
  }
 
  @Test
  public void servesXmlIndexFileWhenTrailingSlashPresent() {
View Full Code Here

  public void servesXmlIndexFileWhenTrailingSlashPresent() {
    writeFileToFilesDir("json/34567/index.xml", "<blob>BLAB</blob>");
    startRunner();
    WireMockResponse response = testClient.get("/json/34567/");
    assertThat(response.statusCode(), is(200));
    assertThat(response.content(), is("<blob>BLAB</blob>"));
    assertThat(response.firstHeader("Content-Type"), is("application/xml"));
  }
 
  @Test
  public void doesNotServeFileFromFilesDirWhenNotGET() {
View Full Code Here

        resetToDefault();

        // Check the mapping now exists
        response = testClient.get("/some/url");
        assertThat(response.statusCode(), is(200));
        assertThat(response.content(), is("Response to /some/url"));
    }

    @Test
    public void doesNotDuplicateMappingsAlreadyPersistedToFileSystem() {
        // Check the mapping we're about to add isn't already there
View Full Code Here

  private void getAndAssertUnderlyingExceptionInstanceClass(String url, Class<?> expectedClass) {
    boolean thrown = false;
    try {
      WireMockResponse response = testClient.get(url);
      response.content();
    } catch (Exception e) {
      assertThat(e.getCause(), instanceOf(expectedClass));
      thrown = true;
    }
   
View Full Code Here

  }
 
  @Test
  public void servesBakedInStubResponse() {
    WireMockResponse response = testClient.get("/wiremock/api/mytest");
    assertThat(response.content(), containsString("YES"));
  }
 
  @Test
  public void acceptsAndReturnsStubMapping() {
    givenThat(get(urlEqualTo("/war/stub")).willReturn(
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.