SDN Controller Programming Guide

147
public void setUp() throws Exception {
super.setUp();
// If a specific test case expects a different format, such
// format will have to be set calling this method.
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 testUpdate() {
long idMock = 1;
String path = BASE_PATH + "/" + idMock;
String jsonRequest = "{\”switch\”:{}}";
String response = put(path, jsonRequest);
String expectedResponse = "{\”switch\”:{}}";
assertResponseContains(response, expectedResponse);
}
@Test