final Logger logger = LoggerFactory.getLogger(AbstractServiceTest.class);
- private final TestServiceClient serviceClient = new TestServiceClient();
+ // Currently used for performing several negative (failure) tests.
+ //
+ // @TODO To be replaced with RESTeasy's ClientRequest, per Issue CSPACE-386.
protected HttpClient httpClient = new HttpClient();
+ // Used (only) to obtain the base service URL.
+ private final TestServiceClient serviceClient = new TestServiceClient();
+
// The status code expected to be returned by a test method (where relevant).
int EXPECTED_STATUS_CODE = 0;
// ---------------------------------------------------------------
/**
- * Reinitializes setup values to guard against unintended reuse
- * of those values.
+ * Reinitializes setup values, to help expose any unintended reuse
+ * of those values between tests.
*/
protected void clearSetup() {
EXPECTED_STATUS_CODE = 0;
import java.util.List;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.test.ServiceRequestType;
import org.collectionspace.services.collectionobject.CollectionObject;
import org.collectionspace.services.collectionobject.CollectionObjectList;
-import java.util.Arrays;
-import java.util.Set;
-import javax.ws.rs.core.Response.Status;
-// import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.testng.Assert;
+import org.testng.annotations.Test;
/**
* CollectionObjectServiceTest, carries out tests against a
// Check the status code of the response: does it match the expected response(s)?
//
// Does it fall within the set of valid status codes?
- // Does it match the expected status code?
+ // Does it exactly match the expected status code?
verbose("create: status = " + statusCode);
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
// Perform setup.
super.setupUpdateWithWrongXmlSchema();
- // @TODO This test is currently commented out, because it returns a
- // 500 Internal Server Error status code, rather than the expected status code.
-
// Submit the request to the service and store the response.
String url = getResourceURL(knownObjectId);
PutMethod method = new PutMethod(url);
// Perform setup.
super.setupDeleteNonExistent();
- // Expected status code: 404 Not Found
- final int EXPECTED_STATUS_CODE = Response.Status.NOT_FOUND.getStatusCode();
-
- // Type of service request being tested
- final ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
-
// Submit the request to the service and store the response.
ClientResponse<Response> res =
client.deleteCollectionObject(NON_EXISTENT_ID);