Ray Milkey

Fix tests that were hiding the setUp() mthod in the JerseyTest framework

REST API tests were defining a set up method called setUp(), which had
the unwanted side effect of hinding the parent class' implementation.
Made the set up and tear down methods for the tests have unique names so
both will be executed.

Also fixed some javadocs while editing the files.

Change-Id: Ifaa75fe650d5909b066769e5e12cb5c834267a20
......@@ -99,7 +99,7 @@ public class ApplicationsResourceTest extends ResourceTest {
ImmutableList.of("My Feature"));
/**
* Hamcrest matcher to check that an device representation in JSON matches
* Hamcrest matcher to check that an application representation in JSON matches
* the actual device.
*/
private static class AppJsonMatcher extends TypeSafeMatcher<JsonObject> {
......@@ -143,7 +143,7 @@ public class ApplicationsResourceTest extends ResourceTest {
}
/**
* Factory to allocate an device matcher.
* Factory to allocate an application matcher.
*
* @param app application object we are looking for
* @return matcher
......@@ -152,10 +152,11 @@ public class ApplicationsResourceTest extends ResourceTest {
return new AppJsonMatcher(app);
}
@Override
/**
* Initializes test mocks and environment.
*/
@Before
public void setUp() {
public void setUpMocks() {
service = createMock(ApplicationAdminService.class);
expect(service.getId("one"))
......@@ -190,8 +191,11 @@ public class ApplicationsResourceTest extends ResourceTest {
BaseResource.setServiceDirectory(testDirectory);
}
/**
* Verifies test mocks.
*/
@After
public void shutDown() {
public void tearDownMocks() {
verify(service);
}
......
......@@ -206,8 +206,11 @@ public class DevicesResourceTest extends ResourceTest {
return new DeviceJsonArrayMatcher(device);
}
/**
* Initializes test mocks and environment.
*/
@Before
public void setUp() {
public void setUpMocks() {
mockDeviceService = createMock(DeviceService.class);
expect(mockDeviceService.isAvailable(isA(DeviceId.class)))
......@@ -226,13 +229,13 @@ public class DevicesResourceTest extends ResourceTest {
.add(CodecService.class, codecService);
BaseResource.setServiceDirectory(testDirectory);
}
/**
* Verifies test mocks.
*/
@After
public void tearDown() throws Exception {
super.tearDown();
public void tearDownMocks() {
verify(mockDeviceService);
}
......
......@@ -232,7 +232,7 @@ public class FlowsResourceTest extends ResourceTest {
* Sets up the global values for all the tests.
*/
@Before
public void setUp() {
public void setUpTest() {
// Mock device service
expect(mockDeviceService.getDevice(deviceId1))
.andReturn(device1);
......@@ -255,12 +255,9 @@ public class FlowsResourceTest extends ResourceTest {
/**
* Cleans up and verifies the mocks.
*
* @throws Exception if the super teardown fails.
*/
@After
public void tearDown() throws Exception {
super.tearDown();
public void tearDownTest() {
verify(mockFlowService);
}
......
......@@ -67,8 +67,11 @@ public class HostResourceTest extends ResourceTest {
final HostService mockHostService = createMock(HostService.class);
final HashSet<Host> hosts = new HashSet<>();
/**
* Initializes test mocks and environment.
*/
@Before
public void setUp() {
public void setUpTest() {
expect(mockHostService.getHosts()).andReturn(hosts).anyTimes();
// Register the services needed for the test
......@@ -82,9 +85,11 @@ public class HostResourceTest extends ResourceTest {
BaseResource.setServiceDirectory(testDirectory);
}
/**
* Verifies mocks.
*/
@After
public void tearDown() throws Exception {
super.tearDown();
public void tearDownTest() {
verify(mockHostService);
}
......
......@@ -252,8 +252,11 @@ public class IntentsResourceTest extends ResourceTest {
return new IntentJsonArrayMatcher(intent);
}
/**
* Initializes test mocks and environment.
*/
@Before
public void setUp() {
public void setUpTest() {
expect(mockIntentService.getIntents()).andReturn(intents).anyTimes();
// Register the services needed for the test
......@@ -270,9 +273,11 @@ public class IntentsResourceTest extends ResourceTest {
Intent.bindIdGenerator(mockGenerator);
}
/**
* Tears down and verifies test mocks and environment.
*/
@After
public void tearDown() throws Exception {
super.tearDown();
public void tearDownTest() {
verify(mockIntentService);
Intent.unbindIdGenerator(mockGenerator);
}
......
......@@ -151,9 +151,11 @@ public class LinksResourceTest extends ResourceTest {
return new LinkJsonArrayMatcher(link);
}
/**
* Initializes test mocks and environment.
*/
@Before
public void setUp() {
public void setUpTest() {
mockLinkService = createMock(LinkService.class);
// Register the services needed for the test
......@@ -167,9 +169,11 @@ public class LinksResourceTest extends ResourceTest {
BaseResource.setServiceDirectory(testDirectory);
}
/**
* Tears down and verifies test mocks and environment.
*/
@After
public void tearDown() throws Exception {
super.tearDown();
public void tearDownTest() {
verify(mockLinkService);
}
......
......@@ -129,8 +129,11 @@ public class PathsResourceTest extends ResourceTest {
return new PathJsonMatcher(path);
}
/**
* Initializes test mocks and environment.
*/
@Before
public void setUp() {
public void setUpTest() {
// Register the services needed for the test
CodecManager codecService = new CodecManager();
......@@ -143,9 +146,11 @@ public class PathsResourceTest extends ResourceTest {
BaseResource.setServiceDirectory(testDirectory);
}
/**
* Tears down test mocks and environment.
*/
@After
public void tearDown() throws Exception {
super.tearDown();
public void tearDownTest() {
verify(mockPathService);
}
......
......@@ -175,7 +175,7 @@ public class TopologyResourceTest extends ResourceTest {
* Initializes the test harness.
*/
@Before
public void setUp() {
public void setUpTest() {
TopologyService topologyService = new MockTopologyService();
CodecManager codecService = new CodecManager();
codecService.activate();
......