11package org .kohsuke .github ;
22
3- import com .github .tomakehurst .wiremock .common .FileSource ;
43import com .github .tomakehurst .wiremock .core .WireMockConfiguration ;
5- import com .github .tomakehurst .wiremock .extension .Parameters ;
6- import com .github .tomakehurst .wiremock .extension .ResponseTransformer ;
7- import com .github .tomakehurst .wiremock .extension .responsetemplating .ResponseTemplateTransformer ;
8- import com .github .tomakehurst .wiremock .http .Request ;
9- import com .github .tomakehurst .wiremock .http .Response ;
104import org .apache .commons .io .IOUtils ;
11- import org .junit .After ;
125import org .junit .Assert ;
136import org .junit .Before ;
147import org .junit .Rule ;
15- import org .junit .rules .TestWatcher ;
16- import org .kohsuke .github .junit .GitHubApiWireMockRule ;
17- import org .kohsuke .github .junit .WireMockRule ;
8+ import org .kohsuke .github .junit .GitHubWireMockRule ;
189
1910import java .io .File ;
2011import java .io .FileInputStream ;
2112import java .io .IOException ;
2213import java .util .Properties ;
2314
24- import static com .github .tomakehurst .wiremock .client .WireMock .*;
2515import static org .junit .Assume .assumeFalse ;
2616import static org .junit .Assume .assumeTrue ;
2717
2818/**
2919 * @author Liam Newman
3020 */
31- public abstract class AbstractGitHubApiWireMockTest extends Assert {
21+ public abstract class AbstractGitHubWireMockTest extends Assert {
3222
3323 private final GitHubBuilder githubBuilder = createGitHubBuilder ();
3424
@@ -56,10 +46,10 @@ public abstract class AbstractGitHubApiWireMockTest extends Assert {
5646 protected final String baseRecordPath = "src/test/resources/" + baseFilesClassPath + "/wiremock" ;
5747
5848 @ Rule
59- public final GitHubApiWireMockRule githubApi ;
49+ public final GitHubWireMockRule mockGitHub ;
6050
61- public AbstractGitHubApiWireMockTest () {
62- githubApi = new GitHubApiWireMockRule (
51+ public AbstractGitHubWireMockTest () {
52+ mockGitHub = new GitHubWireMockRule (
6353 this .getWireMockOptions ()
6454 );
6555 }
@@ -103,7 +93,7 @@ private static GitHubBuilder createGitHubBuilder() {
10393 protected GitHubBuilder getGitHubBuilder () {
10494 GitHubBuilder builder = githubBuilder .clone ();
10595
106- if (!githubApi .isUseProxy ()) {
96+ if (!mockGitHub .isUseProxy ()) {
10797 // This sets the user and password to a placeholder for wiremock testing
10898 // This makes the tests believe they are running with permissions
10999 // The recorded stubs will behave like they running with permissions
@@ -117,14 +107,14 @@ protected GitHubBuilder getGitHubBuilder() {
117107 @ Before
118108 public void wireMockSetup () throws Exception {
119109 GitHubBuilder builder = getGitHubBuilder ()
120- .withEndpoint (githubApi .baseUrl ());
110+ .withEndpoint (mockGitHub . apiServer () .baseUrl ());
121111
122112 if (useDefaultGitHub ) {
123113 gitHub = builder
124114 .build ();
125115 }
126116
127- if (githubApi .isUseProxy ()) {
117+ if (mockGitHub .isUseProxy ()) {
128118 gitHubBeforeAfter = getGitHubBuilder ()
129119 .withEndpoint ("https://api.github.com/" )
130120 .build ();
@@ -134,11 +124,11 @@ public void wireMockSetup() throws Exception {
134124 }
135125
136126 protected void snapshotNotAllowed () {
137- assumeFalse ("Test contains hand written mappings. Only valid when not taking a snapshot." , githubApi .isTakeSnapshot ());
127+ assumeFalse ("Test contains hand written mappings. Only valid when not taking a snapshot." , mockGitHub .isTakeSnapshot ());
138128 }
139129
140130 protected void requireProxy (String reason ) {
141- assumeTrue ("Test only valid when proxying (-Dtest.github.useProxy to enable): " + reason , githubApi .isUseProxy ());
131+ assumeTrue ("Test only valid when proxying (-Dtest.github.useProxy to enable): " + reason , mockGitHub .isUseProxy ());
142132 }
143133
144134 protected GHUser getUser () {
0 commit comments