blob: d95650727c0cfb795a20c0874fa6b22b1b583cb4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.client;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.core.Options;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
/**
* Allows wiremock to be used as a JUnit 5 extension, like
* <pre>
*
* @RegisterExtension
* WireMockExtension mockServer1 = new WireMockExtension();
* </pre>
*/
public class WireMockExtension extends WireMockServer implements BeforeEachCallback, AfterEachCallback {
public WireMockExtension() {
this(WireMockConfiguration.options()
.dynamicPort()
.dynamicHttpsPort());
}
public WireMockExtension(Options options) {
super(options);
}
@Override
public void beforeEach(ExtensionContext extensionContext) {
start();
}
@Override
public void afterEach(ExtensionContext extensionContext) {
stop();
resetAll();
}
}
|