From 2b787082daaaec03f38372c858764a00afc30dab Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Wed, 26 Aug 2009 23:39:20 +0000 Subject: [PATCH] CSPACE-360,CSPACE-384: Removed some unneeded import statements, and other minor code and comment cleanup. --- .../client/test/AbstractServiceTest.java | 11 +++++-- .../test/CollectionObjectServiceTest.java | 32 ++++++------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/AbstractServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/AbstractServiceTest.java index 815a467e2..dd9d18cf2 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/AbstractServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/AbstractServiceTest.java @@ -62,9 +62,14 @@ public abstract class AbstractServiceTest implements ServiceTest { 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; @@ -276,8 +281,8 @@ public abstract class AbstractServiceTest implements ServiceTest { // --------------------------------------------------------------- /** - * 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; diff --git a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java index d592c3fcf..b690bce97 100644 --- a/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java +++ b/services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java @@ -25,25 +25,22 @@ package org.collectionspace.services.client.test; 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 @@ -84,7 +81,7 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // 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)); @@ -315,9 +312,6 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // 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); @@ -386,12 +380,6 @@ public class CollectionObjectServiceTest extends AbstractServiceTest { // 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 res = client.deleteCollectionObject(NON_EXISTENT_ID); -- 2.47.3