Reference Guide

Table Of Contents
ResourceTest.setDefaultMediaType(MediaType.APPLICATION_JSON);
}
// When using the inherited methods get(...), post(...), put(...) and
// delete(..) if exceptions are thrown by the Resource (REST) or if the
// returned code is different than 200 (OK) the test fail.
@Test
public void testList() {
String response = get(BASE_PATH);
String expectedResponse = "{\”switches\”:[]}";
assertResponseContains(response, expectedResponse);
}
@Test
public void testGet() {
long idMock = 1;
String path = BASE_PATH + "/" + idMock;
String response = get(path);
String expectedResponse = "{\”switch\”:{}}";
assertResponseContains(response, expectedResponse);
}
@Test
public void testAdd() {
String jsonRequest = "{\”switch\”:{}}";
String response = post(BASE_PATH, jsonRequest);
String expectedResponse = "{switch:{}}";
assertResponseContains(response, expectedResponse);
}
@Test
public void testDelete() {
long idMock = 1;
String path = BASE_PATH + "/" + idMock;
String response = delete(path);
Assert.assertTrue(response.isEmpty());
}
}
Resource Test Dependencies:
<dependency>
<groupId>com.hp.sdn</groupId>
<artifactId>sdn-common-misc</artifactId>
<version>${sdn.version}</version>
</dependency>
179