나는 wireMock을 사용하고 있습니다. 스텁 된 응답이 200 OK이지만 500 Internal Server Error의 일관된 응답을 얻고 있습니다.와이어 모의 모의 HTTP 반환
내가 디버깅하는 경우 연결이 항상 닫혀 있음을 알 수 있습니다. 어떤 생각이 잘못 될지 모릅니다. 또는 내가 뭘 잘못하고 있는지. http://localhost:8080/path/endPoint?id1=는 {ID1} &는 ID2 = {ID2} & 제한 = {한계} &가 =
{오프셋} 상기 호출이 오프셋 :
여기 모의하려고 테스트
public class MyControllerTest {
@Autowired
MyController myController;
String id1 = "id1";
String id2 = "id2";
Integer offset = 0;
Integer limit = 1;
int port = 8080;
protected WireMockServer wireMockServer;
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(port);
@Test
public void hosDriversHoursOfServiceGet() throws Exception {
stubFor(WireMock.get(urlEqualTo("/path/endPoint"))
.withQueryParam("id1", equalTo(id1))
.withQueryParam("id2", equalTo(id2))
.withQueryParam("limit", equalTo(limit.toString()))
.withQueryParam("offset", equalTo(offset.toString()))
.willReturn(aResponse().withStatus(200).withBody((getJsonString()))));
Response response = myController.hosDriversHoursOfServiceGet(driverId, 1, 1);
assertEquals(Integer.valueOf(1), response.getCount());
}
private String getJsonString() {
return "{\"count\":1}";
}
}
있어 MyController에서 autowired 클라이언트 클래스에서. 그것이 직접 전화가 아니기 때문에 조롱하는 것이 가능합니까?