0
RESTEasy 웹 서비스를 호출하는 클래스를 테스트하고 싶습니다. Junit이 webservice를 호출하지 않는 것 같습니다. 서버 측에서 요청을 확인하지 못했습니다.Junit이 REST 웹 서비스를 호출하지 않습니다.
제 의도는 REST 서비스를 테스트하는 것이 아니라, EmpService
클래스를 테스트하는 것입니다. 그래서 나는 다음 JUnit 테스트 케이스를 작성했다.
public class EmpServiceTest {
@Test
public void testGetEmployees() throws Exception {
EmpService service = new EmpService();
List<Employees> employees = service.getEmployees();
Assert.assertNotNull("Employees is null", employees);
}
@Test
public void testREST() {
ClientRequest request = new ClientRequest("http://localhost:8080/rest/employees");
request.accept(MediaType.APPLICATION_JSON);
ClientResponse<Employees> response = null;
try {
response = request.get(Employees.class);
} catch (Exception e) {
e.printStackTrace();
}
Employees received = response.getEntity();
Assert.assertNotNull("Employees is null", received.getEmployees());
}
}
브라우저에서 REST 서비스를 테스트했는데 정상적으로 작동합니다. 그러나 Junit 테스트 케이스는 호출하지 못하고 오류가보고되지 않습니다. JUnit에서 직접 REST 서비스를 테스트하려고했습니다.