JAX-RS Client [BAEL-595] (#992)

* WatchService vs. Apache Commons IO Mnitoring

* Indentation fixed

* Indentation fixed

* JAX-RS API using Jersey [BAEL-558]

* JAX-RS API using Jersey [BAEL-558]

* Modifications made to remove xml

* applicationContext.xml removed

* All try catch moved to ExceptionMapper

* fixes

* review comments incorporated

* module renamed

* JAX-RS client [BAEL-595]

* jersey-core dependency removed

* assert changed to assertEquals

* messagebody readers and writers removed

* pom dependency corrected and other minor changes
This commit is contained in:
Saptarshi Basu
2017-01-31 13:17:23 +05:30
committed by Sunil Mogadati
parent 6c2ed878c0
commit 4fe878d6d4
4 changed files with 103 additions and 14 deletions
@@ -0,0 +1,53 @@
package com.baeldung.client;
import static org.junit.Assert.assertEquals;
import javax.ws.rs.core.Response;
import org.junit.Test;
import com.baeldung.client.rest.RestClient;
import com.baeldung.server.model.Employee;
public class JerseyClientLiveTest {
public static final int HTTP_CREATED = 201;
private RestClient client = new RestClient();
@Test
public void givenCorrectObject_whenCorrectJsonRequest_thenResponseCodeCreated() {
Employee emp = new Employee(6, "Johny");
Response response = client.createJsonEmployee(emp);
assertEquals(response.getStatus(), HTTP_CREATED);
}
@Test
public void givenCorrectObject_whenCorrectXmlRequest_thenResponseCodeCreated() {
Employee emp = new Employee(7, "Jacky");
Response response = client.createXmlEmployee(emp);
assertEquals(response.getStatus(), HTTP_CREATED);
}
@Test
public void givenCorrectId_whenCorrectJsonRequest_thenCorrectEmployeeRetrieved() {
int employeeId = 1;
Employee emp = client.getJsonEmployee(employeeId);
assertEquals(emp.getFirstName(), "Jane");
}
@Test
public void givenCorrectId_whenCorrectXmlRequest_thenCorrectEmployeeRetrieved() {
int employeeId = 1;
Employee emp = client.getXmlEmployee(employeeId);
assertEquals(emp.getFirstName(), "Jane");
}
}