forked from maciejwalkowiak/wiremock-spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable mappings outside classpath (refs maciejwalkowiak#35)
- Loading branch information
1 parent
ddcc8fd
commit f8ffec2
Showing
4 changed files
with
59 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package app; | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer; | ||
import com.maciejwalkowiak.wiremock.spring.ConfigureWireMock; | ||
import com.maciejwalkowiak.wiremock.spring.EnableWireMock; | ||
import com.maciejwalkowiak.wiremock.spring.InjectWireMock; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@SpringBootTest | ||
@EnableWireMock({ | ||
@ConfigureWireMock(name = "user-client", property = "user-client.url", stubLocation = "src/test/wiremock-mappings/user-client", stubLocationOnClasspath = false) | ||
}) | ||
class StubsInDirectoryTests { | ||
|
||
@Autowired | ||
private UserClient userClient; | ||
|
||
@InjectWireMock("user-client") | ||
private WireMockServer wiremock; | ||
|
||
@Test | ||
void usesStubFiles() { | ||
User user = userClient.findOne(1L); | ||
assertThat(user).isNotNull(); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
example/src/test/wiremock-mappings/user-client/mappings/get-users.json
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,13 @@ | ||
{ | ||
"request": { | ||
"method": "GET", | ||
"url": "/1" | ||
}, | ||
"response": { | ||
"status": 200, | ||
"jsonBody": { "id": 1, "name": "Jenna" }, | ||
"headers": { | ||
"Content-Type": "application/json" | ||
} | ||
} | ||
} |
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