-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simplifies configuration of most simple test case
- Loading branch information
1 parent
624ca56
commit 215aaff
Showing
5 changed files
with
171 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package app; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.github.tomakehurst.wiremock.client.WireMock; | ||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.wiremock.spring.ConfigureWireMock; | ||
import org.wiremock.spring.EnableWireMock; | ||
|
||
@SpringBootTest | ||
@EnableWireMock( | ||
@ConfigureWireMock( | ||
baseUrlProperties = {"customUrl", "sameCustomUrl"}, | ||
portProperties = "customPort")) | ||
class CustomPropertiesTest { | ||
|
||
@Value("${customUrl}") | ||
private String customUrl; | ||
|
||
@Value("${sameCustomUrl}") | ||
private String sameCustomUrl; | ||
|
||
@Value("${customPort}") | ||
private String customPort; | ||
|
||
@BeforeEach | ||
public void before() { | ||
WireMock.stubFor(get("/the_custom_prop_mock").willReturn(aResponse().withStatus(202))); | ||
} | ||
|
||
@Test | ||
void test() { | ||
assertThat(this.customUrl).isEqualTo(this.sameCustomUrl); | ||
|
||
RestAssured.baseURI = this.customUrl; | ||
RestAssured.when().get("/the_custom_prop_mock").then().statusCode(202); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package app; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
|
||
import com.github.tomakehurst.wiremock.client.WireMock; | ||
import io.restassured.RestAssured; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.wiremock.spring.EnableWireMock; | ||
|
||
@SpringBootTest | ||
@EnableWireMock | ||
class DefaultPropertiesTest { | ||
|
||
@Value("${wiremock.server.baseUrl}") | ||
private String wiremockUrl; | ||
|
||
@Value("${wiremock.server.port}") | ||
private String wiremockPort; | ||
|
||
@BeforeEach | ||
public void before() { | ||
WireMock.stubFor(get("/the_default_prop_mock").willReturn(aResponse().withStatus(202))); | ||
} | ||
|
||
@Test | ||
void test() { | ||
RestAssured.baseURI = this.wiremockUrl; | ||
RestAssured.when().get("/the_default_prop_mock").then().statusCode(202); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters