Files
java-tutorials/spring-jersey/src/test/java/com/baeldung/client/JerseyClientLiveTest.java
T
Saptarshi Basu 4fe878d6d4 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
2017-01-31 00:47:23 -07:00

54 lines
1.4 KiB
Java

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");
}
}