@Bean
  @Primary
  public WireMockServer wireMockServer() {
    WireMockServer wireMockServer =
        new WireMockServer(
            wireMockConfig()
                .port(MOCK_SERVER_PORT)); // No-args constructor will start on port 8080, no HTTPS
    wireMockServer.start();
    WireMock.configureFor(MOCK_SERVER_PORT);

    return wireMockServer;
  }
Esempio n. 2
0
 private void startWireMock() {
   wireMockServer = new WireMockServer();
   wireMockServer.start();
   wireMockServer.stubFor(
       get(urlEqualTo("/user"))
           .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
           .willReturn(aResponse().withStatus(200)));
   wireMockServer.stubFor(
       get(urlEqualTo(coursesExtension.toString()))
           .withHeader("Authorization", containing("Basic dGVzdDoxMjM0"))
           .willReturn(
               aResponse()
                   .withStatus(200)
                   .withHeader("Content-Type", "application/json")
                   .withBody(ExampleJson.allCoursesExample)));
 }
 @Override
 public void stop() {
   server.stop();
 }
Esempio n. 4
0
 /** Shuts down the server and WireMock after scenario. */
 @After
 public void closeServer() throws IOException {
   tmcCli.stopServer();
   wireMockServer.stop();
   new File(new ConfigHandler().getConfigFilePath()).delete();
 }
 @Override
 public void start() {
   configureFor("localhost", port);
   server.start();
 }