*/
package org.collectionspace.services.client.test;
+import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.slf4j.Logger;
// Instance variables specific to this test.
private AcquisitionClient client = new AcquisitionClient();
private String knownResourceId = null;
+ private List<String> additionalResourceIds = new ArrayList();
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation for
- // additional tests below.
- knownResourceId = extractId(res);
- if(logger.isDebugEnabled()){
- logger.debug("create: knownResourceId=" + knownResourceId);
+ // Store the ID returned from the first resource created
+ // for additional tests below.
+ if (knownResourceId == null){
+ knownResourceId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ // Store the IDs from any additional resources created by tests,
+ // so they can be deleted after all tests have been run.
+ } else {
+ additionalResourceIds.add(extractId(res));
}
}
}
+ // ---------------------------------------------------------------
+ // Cleanup of resources created during testing
+ // ---------------------------------------------------------------
+
+ /**
+ * Deletes any additional resources created by tests,
+ * after all tests have been run.
+ */
+ @AfterClass
+ public void cleanUp() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up temporary resources created for testing ...");
+ }
+ for (String resourceId : additionalResourceIds) {
+ ClientResponse<Response> res = client.delete(resourceId);
+ }
+ }
+
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
*/
package org.collectionspace.services.client.test;
+import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.slf4j.Logger;
// Instance variables specific to this test.
private CollectionObjectClient client = new CollectionObjectClient();
private String knownResourceId = null;
+ private List<String> additionalResourceIds = new ArrayList();
/*
* This method is called only by the parent class, AbstractServiceTest
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation
+ // Store the ID returned from the first resource created
// for additional tests below.
- knownResourceId = extractId(res);
- if (logger.isDebugEnabled()) {
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ if (knownResourceId == null){
+ knownResourceId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ // Store the IDs from any additional resources created by tests,
+ // so they can be deleted after all tests have been run.
+ } else {
+ additionalResourceIds.add(extractId(res));
}
}
}
+ // ---------------------------------------------------------------
+ // Cleanup of resources created during testing
+ // ---------------------------------------------------------------
+
+ /**
+ * Deletes any additional resources created by tests,
+ * after all tests have been run.
+ */
+ @AfterClass
+ public void cleanUp() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up temporary resources created for testing ...");
+ }
+ for (String resourceId : additionalResourceIds) {
+ ClientResponse<Response> res = client.delete(resourceId);
+ }
+ }
+
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
*/
package org.collectionspace.services.client.test;
+import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.slf4j.Logger;
private IntakeClient client = new IntakeClient();
final String SERVICE_PATH_COMPONENT = "intakes";
private String knownResourceId = null;
+ private List<String> additionalResourceIds = new ArrayList();
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation
+ // Store the ID returned from the first resource created
// for additional tests below.
- knownResourceId = extractId(res);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ if (knownResourceId == null){
+ knownResourceId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ // Store the IDs from any additional resources created by tests,
+ // so they can be deleted after all tests have been run.
+ } else {
+ additionalResourceIds.add(extractId(res));
}
}
}
+ // ---------------------------------------------------------------
+ // Cleanup of resources created during testing
+ // ---------------------------------------------------------------
+
+ /**
+ * Deletes any additional resources created by tests,
+ * after all tests have been run.
+ */
+ @AfterClass
+ public void cleanUp() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up temporary resources created for testing ...");
+ }
+ for (String resourceId : additionalResourceIds) {
+ ClientResponse<Response> res = client.delete(resourceId);
+ }
+ }
+
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
*/
package org.collectionspace.services.client.test;
+import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.testng.Assert;
+import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.slf4j.Logger;
private RelationClient client = new RelationClient();
final String SERVICE_PATH_COMPONENT = "relations";
private String knownResourceId = null;
+ private List<String> additionalResourceIds = new ArrayList();
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- // Store the ID returned from this create operation for
- // additional tests below.
- knownResourceId = extractId(res);
- if(logger.isDebugEnabled()){
- logger.debug("create: knownResourceId=" + knownResourceId);
+ // Store the ID returned from the first resource created
+ // for additional tests below.
+ if (knownResourceId == null){
+ knownResourceId = extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug(testName + ": knownResourceId=" + knownResourceId);
+ }
+ // Store the IDs from any additional resources created by tests,
+ // so they can be deleted after all tests have been run.
+ } else {
+ additionalResourceIds.add(extractId(res));
}
}
}
+ // ---------------------------------------------------------------
+ // Cleanup of resources created during testing
+ // ---------------------------------------------------------------
+
+ /**
+ * Deletes any additional resources created by tests,
+ * after all tests have been run.
+ */
+ @AfterClass
+ public void cleanUp() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Cleaning up temporary resources created for testing ...");
+ }
+ for (String resourceId : additionalResourceIds) {
+ ClientResponse<Response> res = client.delete(resourceId);
+ }
+ }
+
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------