-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from wiremock/feature/issue-75-parse-config-fr…
…om-super-class feat: parse EnableWireMock annotation in super classes (refs #75)
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 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
60 changes: 60 additions & 0 deletions
60
src/test/java/usecases/EnableWireMockOnSuperClassTest.java
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,60 @@ | ||
package usecases; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer; | ||
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; | ||
import org.wiremock.spring.InjectWireMock; | ||
|
||
@SpringBootTest | ||
@EnableWireMock({ | ||
@ConfigureWireMock(name = "base-service-1", baseUrlProperties = "base-service-1.url"), | ||
@ConfigureWireMock(name = "base-service-2", baseUrlProperties = "base-service-2.url") | ||
}) | ||
class EnableWireMockOnSuperClassTest extends EnableWireMockOnSuperClassTestSuperClass { | ||
|
||
@InjectWireMock("super-service-1") | ||
private WireMockServer superService1; | ||
|
||
@Value("${super-service-1.url}") | ||
private String superService1Url; | ||
|
||
@InjectWireMock("super-service-2") | ||
private WireMockServer superService2; | ||
|
||
@Value("${super-service-2.url}") | ||
private String superService2Url; | ||
|
||
@InjectWireMock("base-service-1") | ||
private WireMockServer baseService1; | ||
|
||
@Value("${base-service-1.url}") | ||
private String baseService1Url; | ||
|
||
@InjectWireMock("base-service-2") | ||
private WireMockServer baseService2; | ||
|
||
@Value("${base-service-2.url}") | ||
private String baseService2Url; | ||
|
||
@Test | ||
void serversConfigured() { | ||
assertThat(superService1).isNotNull(); | ||
assertThat(superService2).isNotNull(); | ||
assertThat(baseService1).isNotNull(); | ||
assertThat(baseService2).isNotNull(); | ||
|
||
assertThat(superService1Url).isNotEqualTo(superService2Url); | ||
assertThat(superService1Url).isNotEqualTo(baseService1Url); | ||
assertThat(superService1Url).isNotEqualTo(baseService2Url); | ||
|
||
assertThat(superService2Url).isNotEqualTo(baseService1Url); | ||
assertThat(superService2Url).isNotEqualTo(baseService2Url); | ||
|
||
assertThat(baseService1Url).isNotEqualTo(baseService2Url); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/java/usecases/EnableWireMockOnSuperClassTestSuperClass.java
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,10 @@ | ||
package usecases; | ||
|
||
import org.wiremock.spring.ConfigureWireMock; | ||
import org.wiremock.spring.EnableWireMock; | ||
|
||
@EnableWireMock({ | ||
@ConfigureWireMock(name = "super-service-1", baseUrlProperties = "super-service-1.url"), | ||
@ConfigureWireMock(name = "super-service-2", baseUrlProperties = "super-service-2.url") | ||
}) | ||
public class EnableWireMockOnSuperClassTestSuperClass {} |