예제 #1
0
  @Before
  public void setUpWireMock() {
    stubFor(
        get(urlEqualTo("/"))
            .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
            .willReturn(aResponse().withStatus(200)));
    stubFor(
        get(urlEqualTo("/vaaraurl"))
            .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
            .willReturn(aResponse().withStatus(400)));
    stubFor(
        post(urlEqualTo("/kivaurl"))
            .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
            .withRequestBody(containing("submission[file]"))
            .withRequestBody(containing("test.zip"))
            .willReturn(aResponse().withBody("All tests passed").withStatus(200)));
    stubFor(
        put(urlEqualTo("/putty?api_version=7&client=tmc_cli&client_version=1"))
            .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
            .willReturn(aResponse().withBody("OK").withStatus(200)));
    stubFor(
        put(urlEqualTo("/putty_with_headers?api_version=7&client=tmc_cli&client_version=1"))
            .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
            .withRequestBody(containing(new BasicNameValuePair("mark_as_read", "1").toString()))
            .willReturn(aResponse().withBody("OK").withStatus(200)));

    urlCommunicator = new UrlCommunicator(settings);
    serverAddress += wireMockRule.port();
  }
예제 #2
0
  private void wiremock(String username, String password, String courseId, String serverAddress) {
    String encodedCredentials = "Basic " + Authorization.encode(username + ":" + password);
    wireMockServer.stubFor(
        get(urlEqualTo("/user"))
            .withHeader("Authorization", equalTo(encodedCredentials))
            .willReturn(aResponse().withStatus(200)));

    wireMockServer.stubFor(
        get(urlEqualTo(new UrlHelper(settings).coursesExtension))
            .willReturn(
                aResponse()
                    .withStatus(200)
                    .withHeader("Content-Type", "text/json")
                    .withBody(
                        ExampleJson.allCoursesExample.replace(
                            "https://tmc.mooc.fi/staging", serverAddress))));

    String mockUrl = "/courses/" + courseId + ".json";
    mockUrl = new UrlHelper(settings).withParams(mockUrl);
    wireMockServer.stubFor(
        get(urlEqualTo(mockUrl))
            .willReturn(
                aResponse()
                    .withStatus(200)
                    .withHeader("Content-Type", "text/json")
                    .withBody(
                        ExampleJson.courseExample
                            .replace("https://tmc.mooc.fi/staging", serverAddress)
                            .replaceFirst("3", courseId))));

    wireMockServer.stubFor(
        get(urlMatching("/exercises/[0-9]+.zip"))
            .willReturn(
                aResponse()
                    .withStatus(200)
                    .withHeader("Content-Type", "text/json")
                    .withBodyFile("test.zip")));
  }
예제 #3
0
  @After
  public void after() throws Exception {
    if (bobPhone != null) {
      bobPhone.dispose();
    }
    if (bobSipStack != null) {
      bobSipStack.dispose();
    }

    if (aliceSipStack != null) {
      aliceSipStack.dispose();
    }
    if (alicePhone != null) {
      alicePhone.dispose();
    }
    Thread.sleep(3000);
    wireMockRule.resetRequests();
    Thread.sleep(2000);
  }
  @Before
  public void setupTest() {
    testDataDir = new File("src/test/test-data");
    if (!testDataDir.isDirectory())
      fail("Request test data directory " + testDataDir.getAbsolutePath() + " not found!");

    fusionApiPort = wireMockRule.port();
    fusionHostAndPort = "http://" + fusionHost + ":" + fusionApiPort;
    fusionPipelineEndpoint = "/api/apollo/index-pipelines/logs-default/collections/logs";
    fusionEndpoints = fusionHostAndPort + fusionPipelineEndpoint;

    // mock out the Fusion indexing pipeline endpoint and the session API endpoint
    stubFor(
        post(urlEqualTo(fusionPipelineEndpoint + "?echo=false"))
            .willReturn(aResponse().withStatus(200)));
    stubFor(
        post(urlEqualTo("/api/session?realmName=" + fusionRealm))
            .willReturn(aResponse().withStatus(200)));
  }
 @Before
 public void setup() {
   wireMockRule.stubFor(
       get(urlEqualTo("/slow-endpoint"))
           .willReturn(aResponse().withStatus(200).withBody("YAY").withFixedDelay(100)));
 }