File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
main/java/org/wiremock/spring/internal Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ public WireMockServer createWireMockServer(
4545
4646 final int serverHttpPort = portResolver .getServerHttpPortProperty (options );
4747 final boolean httpEnabled = serverHttpPort != PORT_DISABLED ;
48+ serverOptions .httpDisabled (!httpEnabled );
4849 if (httpEnabled ) {
4950 serverOptions .port (serverHttpPort );
5051 }
Original file line number Diff line number Diff line change @@ -88,18 +88,21 @@ private void configureWireMockForDefaultInstance(final ExtensionContext extensio
8888 }
8989 }
9090 if (wiremock != null ) {
91+ final boolean isHttps = wiremock .isHttpsEnabled ();
92+ final int port = isHttps ? wiremock .httpsPort () : wiremock .port ();
93+
9194 LOGGER .info (
9295 "Configuring WireMock for default instance, '"
9396 + wireMockName
9497 + "' on '"
95- + wiremock . port ()
98+ + port
9699 + "'." );
97100 final String host = "localhost" ;
98- if (wiremock . isHttpsEnabled () ) {
101+ if (isHttps ) {
99102 WireMock .configureFor (
100- WireMock .create ().https ().host (host ).port (wiremock . httpsPort () ).build ());
103+ WireMock .create ().https ().host (host ).port (port ).build ());
101104 } else {
102- WireMock .configureFor (WireMock .create ().http ().host (host ).port (wiremock . port () ).build ());
105+ WireMock .configureFor (WireMock .create ().http ().host (host ).port (port ).build ());
103106 }
104107 }
105108 }
Original file line number Diff line number Diff line change 55import static com .github .tomakehurst .wiremock .client .WireMock .anyUrl ;
66import static com .github .tomakehurst .wiremock .client .WireMock .get ;
77import static org .assertj .core .api .Assertions .assertThat ;
8+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
89
910import com .github .tomakehurst .wiremock .WireMockServer ;
1011import com .github .tomakehurst .wiremock .client .WireMock ;
@@ -59,4 +60,10 @@ void testDefaultClient() {
5960
6061 assertThat (WireMock .findAll (anyRequestedFor (anyUrl ()))).hasSize (1 );
6162 }
63+
64+ @ Test
65+ void testHttpDisabled () {
66+ assertThat (wiremock .isHttpEnabled ()).isFalse ();
67+ assertThatThrownBy (() -> wiremock .port ()).isExactlyInstanceOf (IllegalStateException .class );
68+ }
6269}
You can’t perform that action at this time.
0 commit comments