/** * Deletes all resources created by tests, after all tests have been run. * * <p>This cleanup method will always be run, even if one or more tests fail. For this reason, it * attempts to remove all resources created at any point during testing, even if some of those * resources may be expected to be deleted by certain tests. */ @AfterClass(alwaysRun = true) public void cleanUp() { String noTest = System.getProperty("noTestCleanup"); if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { if (logger.isDebugEnabled()) { logger.debug("Skipping Cleanup phase ..."); } return; } if (logger.isDebugEnabled()) { logger.debug("Cleaning up temporary resources created for testing ..."); } IntakeClient intakeClient = new IntakeClient(); // Note: Any non-success responses are ignored and not reported. for (String resourceId : intakeIdsCreated) { ClientResponse<Response> res = intakeClient.delete(resourceId); res.releaseConnection(); } // Delete persons before PersonAuth OrgAuthorityClient personAuthClient = new OrgAuthorityClient(); for (String resourceId : orgIdsCreated) { ClientResponse<Response> res = personAuthClient.deleteItem(orgAuthCSID, resourceId); res.releaseConnection(); } if (orgAuthCSID != null) { personAuthClient.delete(orgAuthCSID).releaseConnection(); } }