]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4572: Services client tests more widely check response status codes prior...
authorAron Roberts <aron@socrates.berkeley.edu>
Tue, 3 Jan 2012 07:33:15 +0000 (07:33 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Tue, 3 Jan 2012 07:33:15 +0000 (07:33 +0000)
44 files changed:
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountRoleServiceTest.java
services/account/client/src/test/java/org/collectionspace/services/account/client/test/AccountServiceTest.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionRoleServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/PermissionServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RolePermissionServiceTest.java
services/authorization-mgt/client/src/test/java/org/collectionspace/services/authorization/client/test/RoleServiceTest.java
services/batch/client/src/test/java/org/collectionspace/services/client/test/BatchServiceTest.java
services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobServiceTest.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java
services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java
services/group/client/src/test/java/org/collectionspace/services/client/test/GroupServiceTest.java
services/id/client/src/test/java/org/collectionspace/services/client/test/IdServiceTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java
services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java
services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementServiceTest.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java
services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java
services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitServiceTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java
services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java
services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java
services/security/client/src/test/java/org/collectionspace/services/security/client/test/MultiTenancyTest.java
services/taxonomy/client/src/test/java/org/collectionspace/services/client/test/TaxonomyAuthorityServiceTest.java
services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java
services/workflow/client/src/test/java/org/collectionspace/services/client/test/WorkflowServiceTest.java

index ba1401788e6ecce4c19020fd0c5dd1f234bebb73..053da69a652f6d5576339a5001d6684b49791453 100644 (file)
@@ -264,17 +264,8 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         AccountRoleClient client = new AccountRoleClient();
         ClientResponse<AccountRole> res = client.read(
                 accValues.get("acc-role-user1").getAccountId());
-        int statusCode = res.getStatus();
+        assertStatusCode(res, testName);
         try {
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             AccountRole output = res.getEntity();
             Assert.assertNotNull(output);
         } finally {
@@ -330,16 +321,8 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         AccountRoleClient client = new AccountRoleClient();
         ClientResponse<AccountRole> res = client.read(
                 accValues.get("acc-role-user2").getAccountId());
-        int statusCode = res.getStatus();
+        assertStatusCode(res, testName);
         try {
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
             AccountRole output = res.getEntity();
 
             if(logger.isDebugEnabled()) {
@@ -394,16 +377,8 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         ClientResponse<AccountRole> res = roleClient.readRoleAccounts(
                        roleValues.get("ROLE_CO1").getRoleId());
-        int statusCode = res.getStatus();
+        assertStatusCode(res, testName);
         try {
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
             AccountRole output = res.getEntity();
             
             // Now verify that the role has 2 accounts associate to it.
@@ -739,10 +714,9 @@ public class AccountRoleServiceTest extends AbstractServiceTestImpl {
             AccountClient client = new AccountClient();
             ClientResponse<AccountsCommonList> res =
                     client.readSearchList(null, this.prebuiltAdminUserId, null);
+            assertStatusCode(res, "findPrebuiltAdminAccount");
             AccountsCommonList list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            
             List<AccountListItem> items = list.getAccountListItem();
             Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
             AccountListItem item = items.get(0);
index 4682f44a02791b669d0542b9bd55d86655e702fb..57f97765ad35a31d95362c9a012391315458987d 100644 (file)
@@ -474,16 +474,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         AccountsCommon output = (AccountsCommon) res.getEntity();
         Assert.assertNotNull(output);
@@ -540,17 +531,8 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AccountsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -579,17 +561,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommonList> res =
                 client.readSearchList("tom", null, null);
+        assertStatusCode(res, testName);
+        
         AccountsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         Assert.assertEquals(1, list.getAccountListItem().size());
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -618,17 +592,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommonList> res =
                 client.readSearchList(null, "tom", null);
+        assertStatusCode(res, testName);
+        
         AccountsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         Assert.assertEquals(1, list.getAccountListItem().size());
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -657,17 +623,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommonList> res =
                 client.readSearchList(null, null, "dinoland");
+        assertStatusCode(res, testName);
+        
         AccountsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         Assert.assertEquals(2, list.getAccountListItem().size());
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -696,17 +654,9 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommonList> res =
                 client.readSearchList("tom", null, "jerry");
+        assertStatusCode(res, testName);
+        
         AccountsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         Assert.assertEquals(1, list.getAccountListItem().size());
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -737,10 +687,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
@@ -763,14 +710,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         res = client.update(knownResourceId, accountToUpdate);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
         Assert.assertNotNull(accountUpdated);
@@ -798,10 +738,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
@@ -824,15 +761,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         res = client.update(knownResourceId, accountToUpdate);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
 
         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
         Assert.assertNotNull(accountUpdated);
@@ -900,10 +829,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         setupUpdate();
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
@@ -943,10 +869,8 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
             AccountClient client = new AccountClient();
             ClientResponse<AccountsCommonList> res =
                     client.readSearchList(null, this.prebuiltAdminUserId, null);
+            assertStatusCode(res, "findPrebuiltAdminAccount");
             AccountsCommonList list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
             List<AccountListItem> items = list.getAccountListItem();
             Assert.assertEquals(1, items.size(), "Found more than one Admin account!");
             AccountListItem item = items.get(0);
@@ -970,14 +894,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(prebuiltAdminCSID);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if (logger.isDebugEnabled()) {
-            logger.debug("Did get on Admin Account to update with ID: " + prebuiltAdminCSID);
-        }
+        assertStatusCode(res, testName);
         AccountsCommon accountFound = (AccountsCommon) res.getEntity();
         Assert.assertNotNull(accountFound);
 
@@ -996,15 +913,14 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         res = client.update(prebuiltAdminCSID, accountToUpdate);
         int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        // Note that the error is not returned, it is just ignored
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
+        // Comment below was not understood - but preserved in case it is
+        // important - during work on CSPACE-4572, which replaced several
+        // lines of status code checking with the call below.
+        //
+        // Note that the error is not returned, it is just ignored
+        assertStatusCode(res, testName);
+        
         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
         Assert.assertNotNull(accountUpdated);
 
@@ -1047,11 +963,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         ClientResponse<AccountsCommon> accountRes = client.read(testResourceId);
-        statusCode = accountRes.getStatus();
-
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(accountRes, testName);
 
         AccountsCommon accountRead = (AccountsCommon) accountRes.getEntity();
         Assert.assertNotNull(accountRead);
@@ -1076,15 +988,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
        // Submit the request to the service and store the response.
        accountRes = client.update(testResourceId, accountToUpdate);
-       statusCode = accountRes.getStatus();
-       // Check the status code of the response: does it match the expected response(s)?
-       if (logger.isDebugEnabled()) {
-               logger.debug(testName + ": status = " + statusCode);
-       }
-       Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-       Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(accountRes, testName);
 
        AccountsCommon accountUpdated = (AccountsCommon) accountRes.getEntity();
        Assert.assertNotNull(accountUpdated);
@@ -1121,10 +1025,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
@@ -1146,14 +1047,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         res = client.update(knownResourceId, accountToUpdate);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         AccountsCommon accountUpdated = (AccountsCommon) res.getEntity();
         Assert.assertNotNull(accountUpdated);
@@ -1248,10 +1142,7 @@ public class AccountServiceTest extends AbstractServiceTestImpl {
         // The only relevant ID may be the one used in updateAccount(), below.
         AccountClient client = new AccountClient();
         ClientResponse<AccountsCommon> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
index 09ff900c4e536b3bf327fe075afd61573037659f..21042281aa6a15c5716e4248875af82dc967b8fe 100644 (file)
@@ -235,16 +235,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest {
                // Submit the request to the service and store the response.
                AcquisitionClient acquisitionClient = new AcquisitionClient();
                ClientResponse<String> res = acquisitionClient.read(knownResourceId);
-               int statusCode = res.getStatus();
-
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                       logger.debug(testName + ".read: status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                               invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
                PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
                AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
@@ -283,14 +274,8 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest {
                // Get the auth refs and check them
                ClientResponse<AuthorityRefList> res2 =
                        acquisitionClient.getAuthorityRefs(knownResourceId);
-               statusCode = res2.getStatus();
-
-               if(logger.isDebugEnabled()){
-                       logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                               invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+                assertStatusCode(res2, testName);
+        
                AuthorityRefList list = res2.getEntity();
 
                List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index 3147e8a153846c83614b02e7bba56cf789fbf6ee..bdd1804eaebab10dc11bf0990164e4513463ef98 100644 (file)
@@ -395,17 +395,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         AcquisitionClient client = new AcquisitionClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         if(logger.isTraceEnabled()){
@@ -440,14 +431,8 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         AcquisitionClient client = new AcquisitionClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
-        if(logger.isDebugEnabled()){
-            logger.debug("got object to update with ID: " + knownResourceId);
-        }
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
 
         AcquisitionsCommon acquisition = (AcquisitionsCommon) extractPart(input,
@@ -467,14 +452,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
 
         res = client.update(knownResourceId, output);
         int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
 
         input = new PoxPayloadIn(res.getEntity());
         AcquisitionsCommon updatedAcquisition =
@@ -934,16 +912,7 @@ public class AcquisitionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         AcquisitionClient client = new AcquisitionClient();
         ClientResponse<String> res = client.read(csid);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
 
index 5fa350dbf5c0d43b9adb0d2864ae29d214386873..cf6a617606dc0f6d411adde46474ced649c33f78 100644 (file)
@@ -280,17 +280,7 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
         try {
             res = client.read(
                     permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             PermissionRole output = (PermissionRole) res.getEntity();
             Assert.assertNotNull(output);
         } finally {
@@ -353,17 +343,8 @@ public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
         try {
             res = client.read(
                     permValues.get(TEST_SERVICE_NAME + TEST_MARKER + NO_REL_SUFFIX).getPermissionId());
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
+            assertStatusCode(res, testName);
+            
             PermissionRole output = (PermissionRole) res.getEntity();
 
             String sOutput = objectAsXmlString(output, PermissionRole.class);
index 134bf6275d2726208a1ba4e26f8d6b902e240e9b..01fcbf7001385574415b93d93196d21c4b96ad33 100644 (file)
@@ -299,17 +299,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PermissionClient client = new PermissionClient();
         ClientResponse<Permission> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         Permission output = (Permission) res.getEntity();
         Assert.assertNotNull(output);
     }
@@ -365,17 +355,8 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PermissionClient client = new PermissionClient();
         ClientResponse<PermissionsList> res = client.readList();
+        assertStatusCode(res, testName);
         PermissionsList list = res.getEntity(PermissionsList.class);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -403,16 +384,8 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PermissionClient client = new PermissionClient();
         ClientResponse<PermissionsList> res = client.readSearchList("acquisition");
+        assertStatusCode(res, testName);
         PermissionsList list = res.getEntity(PermissionsList.class);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         int EXPECTED_ITEMS = 5; //seeded permissions
         int actual = list.getPermission().size();
         if (logger.isDebugEnabled()) {
@@ -462,16 +435,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         PermissionClient client = new PermissionClient();
         // Submit the request to the service and store the response.
         ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
+        assertStatusCode(res, testName);
         Permission permUpdated = (Permission) res.getEntity();
         Assert.assertNotNull(permUpdated);
 
@@ -547,15 +511,7 @@ public class PermissionServiceTest extends AbstractServiceTestImpl {
         PermissionClient client = new PermissionClient();
         // Submit the request to the service and store the response.
         ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         Permission permUpdated = (Permission) res.getEntity();
         Assert.assertNotNull(permUpdated);
         int updated_actions = permToUpdate.getAction().size();
index 1953c9ce970f2648f08d1dd698174ffead368c5b..b162c81fec20243c35cdeb0c0caf13f5d440922f 100644 (file)
@@ -272,17 +272,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl {
         ClientResponse<PermissionRole> res = null;
         try {
             res = client.read(roleValues.get(getRoleName()).getRoleId());
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             PermissionRole output = (PermissionRole) res.getEntity();
             Assert.assertNotNull(output);
         } finally {
@@ -344,16 +334,7 @@ public class RolePermissionServiceTest extends AbstractServiceTestImpl {
         try {
 
             res = client.read(roleValues.get(getRoleName() + NO_REL_SUFFIX).getRoleId());
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+            assertStatusCode(res, testName);
             PermissionRole output = (PermissionRole) res.getEntity();
 
             String sOutput = objectAsXmlString(output, PermissionRole.class);
index 6ec65bdc3a9f4e6d9bfad6844f77197e59acb5ce..1de1a5bb30b517f607db2a22be573e6a9bc62901 100644 (file)
@@ -399,17 +399,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         RoleClient client = new RoleClient();
         ClientResponse<Role> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         Role output = (Role) res.getEntity();
         Assert.assertNotNull(output);
     }
@@ -424,17 +414,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         RoleClient client = new RoleClient();
         ClientResponse<Role> res = client.read(verifyResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         Role output = (Role) res.getEntity();
         Assert.assertNotNull(output);
 
@@ -497,17 +477,8 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         RoleClient client = new RoleClient();
         ClientResponse<RolesList> res = client.readList();
+        assertStatusCode(res, testName);
         RolesList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -535,16 +506,8 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         RoleClient client = new RoleClient();
         ClientResponse<RolesList> res = client.readSearchList("movingImage");
+        assertStatusCode(res, testName);
         RolesList list = res.getEntity();
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         int EXPECTED_ITEMS = 1;
         if (logger.isDebugEnabled()) {
             logger.debug(testName + ": received = " + list.getRole().size()
@@ -594,16 +557,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
         RoleClient client = new RoleClient();
         // Submit the request to the service and store the response.
         ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
+        assertStatusCode(res, testName);
         Role roleUpdated = (Role) res.getEntity();
         Assert.assertNotNull(roleUpdated);
 
@@ -644,12 +598,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         ClientResponse<Role> roleRes = client.read(testResourceId);
-        statusCode = roleRes.getStatus();
-
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(roleRes, testName);
         Role roleRead = (Role) roleRes.getEntity();
         Assert.assertNotNull(roleRead);
         String mdProtection = roleRead.getMetadataProtection();
@@ -671,16 +620,7 @@ public class RoleServiceTest extends AbstractServiceTestImpl {
 
        // Submit the request to the service and store the response.
        roleRes = client.update(testResourceId, roleToUpdate);
-       statusCode = roleRes.getStatus();
-       // Check the status code of the response: does it match the expected response(s)?
-       if (logger.isDebugEnabled()) {
-               logger.debug(testName + ": status = " + statusCode);
-       }
-       Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-       Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-
+        assertStatusCode(roleRes, testName);
        Role roleUpdated = (Role) roleRes.getEntity();
        Assert.assertNotNull(roleUpdated);
         if (logger.isDebugEnabled()) {
index 5aeed3bbca805d8d30f10dae0cb5ffa8aa3a6c6a..f08f6b237b8736c61aeed4c8a91cc1487792b682 100644 (file)
@@ -117,12 +117,11 @@ public class BatchServiceTest extends AbstractServiceTestImpl {
         setupReadList();
         BatchClient client = new BatchClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         String bar = "\r\n\r\n=================================\r\n\r\n";
         System.out.println(bar+" res: "+res);
         AbstractCommonList  list = res.getEntity();
-
         System.out.println(bar+" list: "+list);
-        assertStatusCode(res, testName);
 
         if(logger.isTraceEnabled()){
                AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
index 902dfe5a64a13b7506a247df1331867d9156e661..381312b3a4a717510ced908fb6b458749460865b 100644 (file)
@@ -273,8 +273,8 @@ public class BlobServiceTest extends AbstractGenericServiceTestImpl<BlobsCommon>
         setupReadList();
         BlobClient client = new BlobClient();
         ClientResponse<AbstractCommonList> res = client.readList();
-        AbstractCommonList list = res.getEntity();
         assertStatusCode(res, testName);
+        AbstractCommonList list = res.getEntity();
         if (logger.isDebugEnabled()) {
             List<AbstractCommonList.ListItem> items =
                 list.getListItem();
index b84221d09a84b461902569c7cd4ea65228094d73..8bdb47822cc33311a0bd56065c9acb5bf9a3cb31 100644 (file)
@@ -707,18 +707,8 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
         //
         CollectionSpacePoxClient client = assertPoxClient();
         ClientResponse<AbstractCommonList> res = client.readIncludeDeleted(includeDeleted);
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-        //
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         //
         // Now check that list size is correct
         //
@@ -745,18 +735,8 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
                 null, /* partial terms */
                 null, /* keywords */
                 includeDeleted);
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-        //
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         result = list.getTotalItems();
 
@@ -857,7 +837,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
             // Send the search request and receive a response
             ClientResponse<AbstractCommonList> res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.FALSE);
             int result = res.getStatus();
-            Assert.assertEquals(result, STATUS_OK);
+            assertStatusCode(res, testName);
 
             AbstractCommonList list = res.getEntity();
             long itemsMatchedBySearch = list.getTotalItems();
@@ -870,7 +850,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
             // Send the search request and receive a response
             res = client.keywordSearchIncludeDeleted(KEYWORD, Boolean.TRUE);
             result = res.getStatus();
-            Assert.assertEquals(result, STATUS_OK);
+            assertStatusCode(res, testName);
 
             list = res.getEntity();
             itemsMatchedBySearch = list.getTotalItems();
@@ -1059,8 +1039,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements
         //
         AuthorityClient client = (AuthorityClient) this.getClientInstance();
         ClientResponse<String> res = client.readItemWorkflow(parentCsid, itemCsid);
-        assertStatusCode(
-                res, testName);
+        assertStatusCode(res, testName);
         logger.debug("Got object to update life cycle state with ID: " + itemCsid);
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         WorkflowCommon workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class);
index 475208f96a1e0ee6adce5c3f1e86be0b98214388..02ea7722a58288c0d8b8791e80261ddac98fdf37 100644 (file)
@@ -419,16 +419,7 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
         ClientResponse<String> res = collectionObjectClient.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".read: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         CollectionobjectsCommon collectionObject = (CollectionobjectsCommon) extractPart(input,
@@ -437,14 +428,8 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest {
 
         // Get all of the auth refs and check that the expected number is returned
         ClientResponse<AuthorityRefList> res2 = collectionObjectClient.getAuthorityRefs(knownResourceId);
-        statusCode = res2.getStatus();
-        
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res2, testName);
+
         AuthorityRefList list = res2.getEntity();
         
         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index 68653b8bb353e77382c201aeeb12844c8a522b6a..55e802adc66c7cb808d0f42ed37d3d607ec9d93d 100644 (file)
@@ -717,17 +717,8 @@ public class CollectionObjectServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         CollectionObjectClient client = new CollectionObjectClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         
         // Optionally output additional data about list members for debugging.
         // the expected response(s)?
index 9b9b0445c1a28846658dadf2c75c7a6e57edb7ef..66629c3da4c8bc3817aae05e040284a9508fb733 100644 (file)
@@ -282,16 +282,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         ContactClient client = new ContactClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         ContactsCommon contact = (ContactsCommon) extractPart(input,
@@ -344,17 +335,8 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         ContactClient client = new ContactClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = false;
@@ -384,10 +366,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         ContactClient client = new ContactClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
@@ -440,14 +419,7 @@ public class ContactServiceTest extends AbstractServiceTestImpl {
         commonPart.setLabel(client.getCommonPartName());
 
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         input = new PoxPayloadIn(res.getEntity());
         ContactsCommon updatedContact =
index 866dff8ee558abc80c258c5fe7b24aee48e93b87..75e8a5fe10686f0326519a1f6bde1b882663e567 100644 (file)
@@ -294,17 +294,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         DimensionClient client = new DimensionClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
         DimensionsCommon dimensionsCommon = null;
@@ -365,17 +355,8 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         DimensionClient client = new DimensionClient();
         ClientResponse<DimensionsCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         DimensionsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = false;
@@ -420,11 +401,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
         DimensionClient client = new DimensionClient();
         ClientResponse<String> res =
                 client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
         }
@@ -450,14 +427,7 @@ public class DimensionServiceTest extends AbstractServiceTestImpl {
 
         res = client.update(knownResourceId, output);
         int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         input = new PoxPayloadIn(res.getEntity());
         DimensionsCommon updatedDimensionsCommon =
                 (DimensionsCommon) extractPart(input,
index 86b510b5fc699d848971bda052e3a89db7f0e502..216ee7e7880fa4c1b6924a1675ae81d4e003aef7 100644 (file)
@@ -121,8 +121,8 @@ public class GroupServiceTest extends AbstractServiceTestImpl {
         setupReadList();
         GroupClient client = new GroupClient();
         ClientResponse<AbstractCommonList> res = client.readList();
-        AbstractCommonList list = res.getEntity();
         assertStatusCode(res, testName);
+        AbstractCommonList list = res.getEntity();
         if(logger.isTraceEnabled()){
                AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
         }
index d91dce6a72c7013f0b8c814231f2b3e787889188..819a9be055ad57869e406a63fed8896477effd5c 100644 (file)
@@ -146,20 +146,7 @@ public class IdServiceTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         IdClient client = new IdClient();
         ClientResponse<String> res = client.createId(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         String generatedId = res.getEntity();
         Assert.assertNotNull(generatedId);
@@ -172,7 +159,7 @@ public class IdServiceTest extends BaseServiceTest {
         // Assumes that the last part in the ID pattern generates values
         // that will always differ at each generation.
         res = client.createId(knownResourceId);
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         String secondGeneratedId = res.getEntity();
         Assert.assertNotNull(secondGeneratedId);
@@ -211,17 +198,7 @@ public class IdServiceTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         IdClient client = new IdClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         String entity = res.getEntity();
         Assert.assertNotNull(entity);
         if (logger.isDebugEnabled()) {
@@ -252,26 +229,7 @@ public class IdServiceTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         IdClient client = new IdClient();
         ClientResponse<String> res = client.readList();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
         String entity = res.getEntity();
         Assert.assertNotNull(entity);
         if (logger.isDebugEnabled()) {
index c2c377d1862b1f35a3b8b9b776c76ebee45b9172..b324cc1e1ad7489b45546e5ed8619ba3b4051cc2 100644 (file)
@@ -233,16 +233,7 @@ public class IntakeAuthRefsTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         IntakeClient intakeClient = new IntakeClient();
         ClientResponse<String> res = intakeClient.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".read: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         IntakesCommon intake = (IntakesCommon) extractPart(input,
@@ -255,14 +246,8 @@ public class IntakeAuthRefsTest extends BaseServiceTest {
         
         // Get the auth refs and check them
         ClientResponse<AuthorityRefList> res2 = intakeClient.getAuthorityRefs(knownResourceId);
-        statusCode = res2.getStatus();
+        assertStatusCode(res2, testName);
 
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         AuthorityRefList list = res2.getEntity();
         
         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index 055323dadd3975db4942fc156bbd980c18ccb131..1f354ed37b97440ae13a27fc3f91332b267726b7 100644 (file)
@@ -295,16 +295,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         IntakeClient client = new IntakeClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
@@ -401,17 +392,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         IntakeClient client = new IntakeClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -447,10 +429,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         IntakeClient client = new IntakeClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
@@ -492,15 +471,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         
         // Submit the request to the service and store the response.
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
+        
         input = new PoxPayloadIn(res.getEntity());
         IntakesCommon updatedIntake =
                 (IntakesCommon) extractPart(input,
@@ -556,14 +528,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         IntakeClient client = new IntakeClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("got object to update with ID: " + knownResourceId);
-        }
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         PayloadInputPart payloadInputPart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
         Element coreAsElement = null;
@@ -606,14 +572,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl {
         
         // Submit the request to the service and store the response.
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         input = new PoxPayloadIn(res.getEntity());
         PayloadInputPart updatedCorePart = input.getPart(COLLECTIONSPACE_CORE_SCHEMA);
index 03cf89909d41cf2b5c33f48e414dbbb5ac9df5d9..c113011d1924bc6845729ce0139ddfb633549e75 100644 (file)
@@ -247,15 +247,8 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest {
        OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();\r
        ClientResponse<AuthorityRefDocList> refDocListResp =\r
                orgAuthClient.getReferencingObjects(orgAuthCSID, currentOwnerOrgCSID);\r
+        assertStatusCode(refDocListResp, testName);\r
 \r
-        int statusCode = refDocListResp.getStatus();\r
-\r
-        if(logger.isDebugEnabled()){\r
-            logger.debug(testName + ".getReferencingObjects: status = " + statusCode);\r
-        }\r
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
         AuthorityRefDocList list = refDocListResp.getEntity();\r
 \r
         // Optionally output additional data about list members for debugging.\r
index 0cbb97b3efe5f6971a501681099ccceaa2761c4e..837177cbfb9106ce42cbc3af9154032cca594ade 100644 (file)
@@ -261,15 +261,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         ClientResponse<AuthorityRefDocList> refDocListResp =
                 personAuthClient.getReferencingObjects(personAuthCSID, currentOwnerPersonCSID);
-
-        int statusCode = refDocListResp.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ".getReferencingObjects: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(refDocListResp, testName);
 
         AuthorityRefDocList list = refDocListResp.getEntity();
         List<AuthorityRefDocList.AuthorityRefDocItem> items =
@@ -301,15 +293,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest {
         personAuthClient = new PersonAuthorityClient();
         refDocListResp =
                 personAuthClient.getReferencingObjects(personAuthCSID, depositorPersonCSID);
-
-        statusCode = refDocListResp.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ".getReferencingObjects: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(refDocListResp, testName);
 
         list = refDocListResp.getEntity();
         items = list.getAuthorityRefDocItem();
@@ -359,15 +343,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         ClientResponse<AuthorityRefDocList> refDocListResp =
                 personAuthClient.getReferencingObjects(personAuthCSID, insurerPersonCSID);
-
-        int statusCode = refDocListResp.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ".getReferencingObjects: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(refDocListResp, testName);
 
         AuthorityRefDocList list = refDocListResp.getEntity();
         List<AuthorityRefDocList.AuthorityRefDocItem> items =
index e22dbf32342f7596c883c29a30ab83dfd324d16d..69a9d1a0c5c58cdf42b92cb0a6f746096dc5caed 100644 (file)
@@ -241,16 +241,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         LoaninClient loaninClient = new LoaninClient();
         ClientResponse<String> res = loaninClient.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".read: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract the common part from the response.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -271,14 +262,7 @@ public class LoaninAuthRefsTest extends BaseServiceTest {
         // Get the auth refs and check them
         ClientResponse<AuthorityRefList> res2 =
            loaninClient.getAuthorityRefs(knownResourceId);
-        statusCode = res2.getStatus();
-
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res2, testName);
         AuthorityRefList list = res2.getEntity();
         
         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index a2820ff57907e6e64d83174f3b06c152670a26dd..d94590c839f2bfc5dcbc65a02adbad97baa5874b 100644 (file)
@@ -301,18 +301,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LoaninClient client = new LoaninClient();
         ClientResponse<String> res = client.read(knownResourceId);
+        assertStatusCode(res, testName);
         PoxPayloadIn input = null;
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
@@ -404,18 +395,8 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         AbstractCommonList list = null;
         LoaninClient client = new LoaninClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             list = res.getEntity();
         } finally {
             res.releaseConnection();
@@ -455,13 +436,9 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         LoaninClient client = new LoaninClient();
         ClientResponse<String> res = client.read(knownResourceId);
+        assertStatusCode(res, testName);
         PoxPayloadIn input = null;
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
             if (logger.isDebugEnabled()) {
                 logger.debug("got object to update with ID: " + knownResourceId);
             }
@@ -492,15 +469,8 @@ public class LoaninServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(loaninCommon, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
index 543f355d90ab1105d80992beb35e8f0a711b6afa..862551da32a63532b72258e84253938c4aba11e9 100644 (file)
@@ -236,16 +236,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         LoanoutClient loanoutClient = new LoanoutClient();
         ClientResponse<String> res = loanoutClient.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".read: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract the common part from the response.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -264,14 +255,8 @@ public class LoanoutAuthRefsTest extends BaseServiceTest {
         // Get the auth refs and check them
         ClientResponse<AuthorityRefList> res2 =
            loanoutClient.getAuthorityRefs(knownResourceId);
-        statusCode = res2.getStatus();
+        assertStatusCode(res2, testName);
 
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         AuthorityRefList list = res2.getEntity();
 
         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index 346b757f10abe97e84e8d7b27d80e972b344f455..0063f4c8c03f84e97139ce0e3fcbd499cdc7b886 100644 (file)
@@ -283,16 +283,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LoanoutClient client = new LoanoutClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Get the common part of the response and verify that it is not null.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -376,17 +367,8 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LoanoutClient client = new LoanoutClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
@@ -419,14 +401,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         LoanoutClient client = new LoanoutClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if (logger.isDebugEnabled()) {
-            logger.debug("got object to update with ID: " + knownResourceId);
-        }
+        assertStatusCode(res, testName);
 
         // Extract the common part from the response.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -462,15 +437,7 @@ public class LoanoutServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(loanoutCommon, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract the updated common part from the response.
         input = new PoxPayloadIn(res.getEntity());
index e6df03a94e7b69e7abbb1bf477c818c15d245a79..cb373ac54ad9f9949ae568c00ebe8fc0baeb5801 100644 (file)
@@ -366,17 +366,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         LocationAuthorityClient client = new LocationAuthorityClient();
        String newID = null;
         ClientResponse<String> res = client.read(knownResourceId);
+        assertStatusCode(res, testName);
         try {
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
                //FIXME: remove the following try catch once Aron fixes signatures
                try {
                    PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -414,17 +405,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
+        assertStatusCode(res, testName);
         try {
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
                //FIXME: remove the following try catch once Aron fixes signatures
                try {
                    PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -459,18 +441,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-       
                // Check whether we've received a location.
                PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
                LocationsCommon location = (LocationsCommon) extractPart(input,
@@ -507,18 +479,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-       
                // Check whether location has expected displayName.
                PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
                LocationsCommon location = (LocationsCommon) extractPart(input,
@@ -543,15 +505,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
                commonPart.setLabel(client.getItemCommonPartName());
                res.releaseConnection();
                res = client.updateItem(knownResourceId, knownItemResourceId, output);
-               statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug("updateItem: status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               assertStatusCode(res, testName);
        
                // Retrieve the updated resource and verify that its contents exist.
                input = new PoxPayloadIn(res.getEntity());
@@ -578,15 +532,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
                commonPart.setLabel(client.getItemCommonPartName());
                res.releaseConnection();
                res = client.updateItem(knownResourceId, knownItemResourceId, output);
-               statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug("updateItem: status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+               assertStatusCode(res, testName);
        
                // Retrieve the updated resource and verify that its contents exist.
                input = new PoxPayloadIn(res.getEntity());
@@ -620,24 +566,19 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
         }
-        // Perform setup.
-        // FIXME: create a setup configuration for this operation.
-       setupUpdateWithWrongXmlSchema();
+        
+        // Perform setup for read.
+        setupRead();
 
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
+        
+        // Perform setup for update.
+        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
+
         try {
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
        
                // Check whether Location has expected displayName.
                PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -654,15 +595,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
                commonPart.setLabel(client.getItemCommonPartName());
                res.releaseConnection();
                res = client.updateItem(knownResourceId, knownItemResourceId, output);
-               statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug("updateItem: status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
            } finally {
                res.releaseConnection();
            }
@@ -760,18 +693,9 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         try {
                AbstractCommonList list = res.getEntity();
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
        
                // Optionally output additional data about list members for debugging.
                if(logger.isTraceEnabled()){
@@ -829,18 +753,9 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         } else {
                Assert.fail("readItemList passed null csid and name!");
         }
+        assertStatusCode(res, testName);
         try {
                AbstractCommonList list = res.getEntity();
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match
-               // the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
        
                List<AbstractCommonList.ListItem> items =
                    list.getListItem();
@@ -899,11 +814,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         // Retrieve the contents of a resource to update.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<String> res = client.read(knownResourceId);
+        assertStatusCode(res, testName);
         try {
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": read status = " + res.getStatus());
-               }
-               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
        
                if(logger.isDebugEnabled()){
                    logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
@@ -927,16 +839,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
                commonPart.setLabel(client.getCommonPartName());
                res.releaseConnection();
                res = client.update(knownResourceId, output);
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-       
+               assertStatusCode(res, testName);
+
                // Retrieve the updated resource and verify that its contents exist.
                input = new PoxPayloadIn(res.getEntity());
                LocationauthoritiesCommon updatedLocationAuthority =
@@ -973,12 +877,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<String> res =
                 client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": read status = " + res.getStatus());
-               }
-               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-       
                if(logger.isDebugEnabled()){
                    logger.debug("got Location to update with ID: " +
                        knownItemResourceId +
@@ -1004,16 +904,8 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl { //FI
                commonPart.setLabel(client.getItemCommonPartName());
                res.releaseConnection();
                res = client.updateItem(knownResourceId, knownItemResourceId, output);
-               int statusCode = res.getStatus();
-       
-               // Check the status code of the response: does it match the expected response(s)?
-               if(logger.isDebugEnabled()){
-                   logger.debug(testName + ": status = " + statusCode);
-               }
-               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-       
+               assertStatusCode(res, testName);
+
                // Retrieve the updated resource and verify that its contents exist.
                input = new PoxPayloadIn(res.getEntity());
                LocationsCommon updatedLocation =
index 87fa5a38f999af2f5c359b03cf19c4a7659be888..b1e08d34b3d8b885adad69f50744b482631819ae 100644 (file)
@@ -253,8 +253,8 @@ public class MediaServiceTest extends AbstractServiceTestImpl {
         setupReadList();
         MediaClient client = new MediaClient();
         ClientResponse<AbstractCommonList> res = client.readList();
-        AbstractCommonList list = res.getEntity();
         assertStatusCode(res, testName);
+        AbstractCommonList list = res.getEntity();
         // Optionally output additional data about list members for debugging.
         if(logger.isTraceEnabled()){
                AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
index 351b69a4b3c968b4c6a9f659b208a14bec7b90c9..16f071a9f38ce61326880962c6e47c87517a7839 100644 (file)
@@ -210,16 +210,7 @@ public class MovementAuthRefsTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         MovementClient movementClient = new MovementClient();
         ClientResponse<String> res = movementClient.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".read: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract and return the common part of the record.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -239,14 +230,8 @@ public class MovementAuthRefsTest extends BaseServiceTest {
         // Get the auth refs and check them
         ClientResponse<AuthorityRefList> res2 =
            movementClient.getAuthorityRefs(knownResourceId);
-        statusCode = res2.getStatus();
+        assertStatusCode(res2, testName);
 
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         AuthorityRefList list = res2.getEntity();
         
         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index e2cd068b5647616043c716f7f3ca6ef23aadc719..b3370c00df52c066227e147bae6e3e0638711a81 100644 (file)
@@ -283,16 +283,7 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Get the common part of the response and verify that it is not null.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -376,17 +367,8 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         if(logger.isTraceEnabled()){
@@ -417,13 +399,8 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         MovementClient client = new MovementClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-        if(logger.isDebugEnabled()){
-            logger.debug("got object to update with ID: " + knownResourceId);
-        }
+                       assertStatusCode(res, testName);
+        assertStatusCode(res, testName);
 
         // Extract the common part from the response.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -453,17 +430,9 @@ public class MovementServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(movementCommon, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
+        assertStatusCode(res, testName);
 
-        // Check the status code of the response: does it match the expected response(s)?
-        int statusCode = res.getStatus();
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-       // Extract the updated common part from the response.
+        // Extract the updated common part from the response.
         input = new PoxPayloadIn(res.getEntity());
         payloadInputPart = input.getPart(client.getCommonPartName());
         MovementsCommon updatedMovementCommon = null;
index c2c8a795401e50b73be69fb2afe198804cd66500..47155c63535d0cd76fde05fae30601f2fea628d4 100644 (file)
@@ -711,16 +711,7 @@ public class MovementSortByTest extends BaseServiceTest {
         // Submit the request to the service and store the response.
         MovementClient client = new MovementClient();
         ClientResponse<String> res = client.read(csid);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract and return the common part of the record.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -764,17 +755,8 @@ public class MovementSortByTest extends BaseServiceTest {
 
         ClientResponse<AbstractCommonList> res =
                 client.readListSortedBy(sortFieldName);
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         return list;
 
@@ -791,17 +773,8 @@ public class MovementSortByTest extends BaseServiceTest {
 
         ClientResponse<AbstractCommonList> res =
                 client.keywordSearchSortedBy(keywords, sortFieldName);
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         return list;
 
index f0a2ba32bccebe2e3f9b070ce3e5336653d20f78..528184021e8ed236e612664acdba3079e1ff7b61 100644 (file)
@@ -182,16 +182,7 @@ public class NoteServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.\r
         NoteClient client = new NoteClient();\r
         ClientResponse<String> res = client.read(knownResourceId);\r
-        int statusCode = res.getStatus();\r
-\r
-        // Check the status code of the response: does it match\r
-        // the expected response(s)?\r
-        if(logger.isDebugEnabled()){\r
-            logger.debug(testName + ": status = " + statusCode);\r
-        }\r
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
+        assertStatusCode(res, testName);\r
 \r
         // Get the common part of the response and verify that it is not null.\r
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
@@ -249,16 +240,7 @@ public class NoteServiceTest extends AbstractServiceTestImpl {
         NoteClient client = new NoteClient();\r
         ClientResponse<NotesCommonList> res = client.readList();\r
         NotesCommonList list = res.getEntity();\r
-        int statusCode = res.getStatus();\r
-\r
-        // Check the status code of the response: does it match\r
-        // the expected response(s)?\r
-        if(logger.isDebugEnabled()){\r
-            logger.debug(testName + ": status = " + statusCode);\r
-        }\r
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),\r
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);\r
+        assertStatusCode(res, testName);\r
 \r
         // Optionally output additional data about list members for debugging.\r
         boolean iterateThroughList = false;\r
@@ -299,13 +281,7 @@ public class NoteServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.\r
         NoteClient client = new NoteClient();\r
         ClientResponse<String> res = client.read(knownResourceId);\r
-        if(logger.isDebugEnabled()){\r
-            logger.debug(testName + ": read status = " + res.getStatus());\r
-        }\r
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);\r
-        if(logger.isDebugEnabled()){\r
-            logger.debug("got object to update with ID: " + knownResourceId);\r
-        }\r
+        assertStatusCode(res, testName);\r
 \r
         // Get the common part of the response and verify that it is not null.\r
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());\r
index 5722e26c41e8722bbb14689a857512c212c03d7b..c0d4c21b91d431a3d955ccdd17c03e6ecd793ed0 100644 (file)
@@ -121,12 +121,11 @@ public class ObjectExitServiceTest extends AbstractServiceTestImpl {
         setupReadList();
         ObjectExitClient client = new ObjectExitClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         String bar = "\r\n\r\n=================================\r\n\r\n";
         System.out.println(bar+" res: "+res);
         AbstractCommonList list = res.getEntity();
-
         System.out.println(bar+" list: "+list);
-        assertStatusCode(res, testName);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = true;
index 776498d24a776b17f87ba966ca9186845da13e80..fd460b1b0de176da8fb481d79544b0ceb5e5454d 100644 (file)
@@ -363,16 +363,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
         ClientResponse<String> res =
             orgAuthClient.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".read: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
@@ -394,14 +385,8 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest {
         // and get the ID for the organization item
         ClientResponse<AuthorityRefList> res2 =
            orgAuthClient.getItemAuthorityRefs(knownResourceId, knownItemResourceId);
-        statusCode = res2.getStatus();
-
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ".getAuthorityRefs: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res2, testName);
+        
         AuthorityRefList list = res2.getEntity();
         
         List<AuthorityRefList.AuthorityRefItem> items = list.getAuthorityRefItem();
index 160e08da161947a186e6a160ab6ac7f58bb13b45..225af8b9f3830f62bd7642cc42c0d628ddb7c983 100644 (file)
@@ -553,17 +553,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         } else {
             Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
         }
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
             //FIXME: remove the following try catch once Aron fixes signatures
             try {
                 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -663,18 +654,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         } else {
             Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
         }
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Check whether we've received a organization.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
@@ -720,24 +701,14 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         OrgAuthorityClient client = new OrgAuthorityClient();
         PoxPayloadIn input = null;
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-            // Check whether organization has expected displayName.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
         }
 
+        // Check whether organization has expected displayName.
         OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
                 client.getItemCommonPartName(), OrganizationsCommon.class);
         Assert.assertNotNull(organization);
@@ -769,17 +740,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -812,17 +774,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -856,25 +809,19 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
         }
-        // Perform setup.
-        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-        // setupUpdateWithWrongXmlSchema(testName, logger);
-
+        
+        // Perform setup for read.
+        setupRead();
+        
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
-        try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+        assertStatusCode(res, testName);
+        
+        // Perform setup for update.
+        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
 
+        try {
             // Check whether organization has expected displayName.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
@@ -888,18 +835,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
             PoxPayloadOut output = new PoxPayloadOut(OrgAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
             PayloadOutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
             commonPart.setLabel(client.getItemCommonPartName());
-            res.releaseConnection();
             res = client.updateItem(knownResourceId, knownItemResourceId, output);
-            statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-        } finally {
+            assertStatusCode(res, testName);
+       } finally {
             res.releaseConnection();
         }
     }
@@ -925,18 +863,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         ClientResponse<String> res =
                 client.readContact(knownResourceId, knownItemResourceId,
                 knownContactResourceId);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Check whether we've received a contact.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             ContactsCommon contact = (ContactsCommon) extractPart(input,
@@ -1079,19 +1007,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         try {
             AbstractCommonList list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Optionally output additional data about list members for debugging.
             if (logger.isTraceEnabled()) {
                 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
@@ -1143,19 +1061,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         } else {
             Assert.fail("readItemList passed null csid and name!");
         }
+        assertStatusCode(res, testName);
         try {
             AbstractCommonList list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             List<AbstractCommonList.ListItem> items =
                     list.getListItem();
             int nItemsReturned = items.size();
@@ -1216,18 +1124,9 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         AbstractCommonList list = null;
         ClientResponse<AbstractCommonList> res =
                 client.readContactList(parentcsid, itemcsid);
+        assertStatusCode(res, testName);
         try {
             list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
             List<AbstractCommonList.ListItem> listitems =
                 list.getListItem();
@@ -1279,12 +1178,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<String> res =
                 client.read(knownResourceId);
+        assertStatusCode(res, testName);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
             if (logger.isDebugEnabled()) {
                 logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
             }
@@ -1307,15 +1202,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
             commonPart.setLabel(client.getCommonPartName());
             res.releaseConnection();
             res = client.update(knownResourceId, output);
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
 
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
@@ -1353,12 +1240,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<String> res =
                 client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
             if (logger.isDebugEnabled()) {
                 logger.debug("got Organization to update with ID: "
                         + knownItemResourceId
@@ -1391,15 +1274,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
             commonPart.setLabel(client.getItemCommonPartName());
             res.releaseConnection();
             res = client.updateItem(knownResourceId, knownItemResourceId, output);
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
 
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
@@ -1439,12 +1314,8 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<String> res =
                 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
+        assertStatusCode(res, testName);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
             if (logger.isDebugEnabled()) {
                 logger.debug("got Contact to update with ID: "
                         + knownContactResourceId
@@ -1480,15 +1351,7 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME:
             commonPart.setLabel(new ContactClient().getCommonPartName());
             res.releaseConnection();
             res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
 
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
index 662e3018c348572d5533087146a61af65b27fb91..9a9e51637c335f06ebdc2c13628c6e05c3bd2446 100644 (file)
@@ -501,19 +501,9 @@ public class PersonAuthoritySearchTest extends BaseServiceTest {
         } else {
             Assert.fail("readItemListByPartialTerm passed null csid!");
         }
+        assertStatusCode(res, testName);
         AbstractCommonList list = null;
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if(logger.isDebugEnabled()){
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             list = res.getEntity();
         } finally {
             res.releaseConnection();
index 1ef98d1210428efdc8527b8c06e2105fe8021619..adc39f7fdb3871ec534605c18ba6dbf90527e13c 100644 (file)
@@ -314,12 +314,8 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest {
             Assert.fail(testName+" passed null csid!");
         }
         AbstractCommonList list = null;
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             list = res.getEntity();
         } finally {
             res.releaseConnection();
index 3802681c07d38a221c5d503cfe0104e8182c47a4..11101e8306e301f0968b9a8f96d2904eff346d58 100644 (file)
@@ -752,16 +752,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         } else {
             Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
         }
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
             //FIXME: remove the following try catch once Aron fixes signatures
             try {
                 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -858,18 +850,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         } else {
             Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
         }
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Check whether we've received a person.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             PersonsCommon person = (PersonsCommon) extractPart(input,
@@ -915,19 +897,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PersonAuthorityClient client = new PersonAuthorityClient();
         PoxPayloadIn input = null;
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-            // Check whether person has expected displayName.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
@@ -936,16 +907,17 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PersonsCommon person = (PersonsCommon) extractPart(input,
                 client.getItemCommonPartName(), PersonsCommon.class);
         Assert.assertNotNull(person);
-        String displayName = person.getDisplayName();
+        // Check whether person has expected displayName.
         // Make sure displayName matches computed form
+        String displayName = person.getDisplayName();
         String expectedDisplayName =
                 PersonAuthorityClientUtils.prepareDefaultDisplayName(
                 TEST_FORE_NAME, null, TEST_SUR_NAME,
                 TEST_BIRTH_DATE, TEST_DEATH_DATE);
         Assert.assertFalse(displayName.equals(expectedDisplayName));
 
+        // Make sure short displayName matches computed form
         String shortDisplayName = person.getShortDisplayName();
-        // Make sure displayName matches computed form
         String expectedShortDisplayName =
                 PersonAuthorityClientUtils.prepareDefaultDisplayName(
                 TEST_FORE_NAME, null, TEST_SUR_NAME, null, null);
@@ -969,17 +941,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -1013,17 +976,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -1064,27 +1018,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
         }
-        // Perform setup.
-        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-        // setupUpdateWithWrongXmlSchema(testName);
+
+        // Perform setup for read.
+        setupRead();
 
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
-        PoxPayloadIn input = null;
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
-        try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+        assertStatusCode(res, testName);
+        
+        // Perform setup for update.
+        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
 
-            // Check whether Person has expected displayName.
+        PoxPayloadIn input = null;
+        try {
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
@@ -1102,16 +1049,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            // intentionally empty try block
         } finally {
             res.releaseConnection();
         }
@@ -1139,18 +1079,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         ClientResponse<String> res =
                 client.readContact(knownResourceId, knownItemResourceId,
                 knownContactResourceId);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Check whether we've received a contact.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -1295,24 +1225,13 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PersonAuthorityClient client = new PersonAuthorityClient();
         AbstractCommonList list = null;
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             list = res.getEntity();
         } finally {
             res.releaseConnection();
         }
 
-        // Optionally output additional data about list members for debugging.
         // Optionally output additional data about list members for debugging.
         if (logger.isTraceEnabled()) {
             AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
@@ -1358,19 +1277,9 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         } else {
             Assert.fail("readItemList passed null csid and name!");
         }
+        assertStatusCode(res, testName);
         AbstractCommonList list = null;
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             list = res.getEntity();
         } finally {
             res.releaseConnection();
@@ -1430,18 +1339,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         AbstractCommonList list = null;
         ClientResponse<AbstractCommonList> res =
                 client.readContactList(parentcsid, itemcsid);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             list = res.getEntity();
         } finally {
             res.releaseConnection();
@@ -1494,15 +1393,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PersonAuthorityClient client = new PersonAuthorityClient();
         PoxPayloadIn input = null;
         ClientResponse<String> res = client.read(knownResourceId);
+        assertStatusCode(res, testName);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-            if (logger.isDebugEnabled()) {
-                logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
-            }
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
@@ -1525,17 +1417,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PayloadOutputPart commonPart = output.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -1574,17 +1457,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PoxPayloadIn input = null;
         ClientResponse<String> res =
                 client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-            if (logger.isDebugEnabled()) {
-                logger.debug("got Person to update with ID: "
-                        + knownItemResourceId
-                        + " in PersonAuthority: " + knownResourceId);
-            }
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
@@ -1613,17 +1487,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PayloadOutputPart commonPart = output.addPart(person, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getItemCommonPartName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
         } finally {
@@ -1667,18 +1532,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PoxPayloadIn input = null;
         ClientResponse<String> res =
                 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
+        assertStatusCode(res, testName);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-            if (logger.isDebugEnabled()) {
-                logger.debug("got Contact to update with ID: "
-                        + knownContactResourceId
-                        + " in item: " + knownItemResourceId
-                        + " in parent: " + knownResourceId);
-            }
             input = new PoxPayloadIn(res.getEntity());
         } finally {
             res.releaseConnection();
@@ -1711,17 +1566,8 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM
         PayloadOutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE); //FIXME: REM - Replace with output.addPart(contact, client.getCommonPartName())
         commonPart.setLabel(client.getCommonPartName());
         res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
+        assertStatusCode(res, testName);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());;
         } finally {
index 37309dded9022b420e296921459e7ff6012d240b..6c9b3b2db069c728e3584222a1a3a4b43580f6bd 100644 (file)
@@ -384,16 +384,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         RelationClient client = new RelationClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Get the common part from the response and check that it is not null.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -457,18 +448,9 @@ public class RelationServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         RelationClient client = new RelationClient();
         ClientResponse<RelationsCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         RelationsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = false;
         if(iterateThroughList && logger.isDebugEnabled()){
@@ -509,16 +491,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl {
                                                                   pageSize,
                                                                   pageNumber);
         RelationsCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Optionally output additional data about list members for debugging.
         boolean iterateThroughList = false;
@@ -561,8 +534,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl {
         // Retrieve an existing resource that we can update.
         RelationClient client = new RelationClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        logger.debug(testName + ": read status = " + res.getStatus());
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
         logger.debug("Got object to update with ID: " + knownResourceId);
         
         // Extract the common part and verify that it is not null.
@@ -595,13 +567,7 @@ public class RelationServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(relationCommon, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-            logger.debug(testName + ": status = " + statusCode);
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract the common part of the updated resource and verify that it is not null.
         input = new PoxPayloadIn(res.getEntity());
index bfbf7a9ae67eee12aab9d745fb853f2948800d30..e09fb1903963210cec198b5400645085c45378d4 100644 (file)
@@ -193,16 +193,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         ReportClient client = new ReportClient();
         ClientResponse<String> res = client.read(knownResourceId);
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        int statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Get the common part of the response and verify that it is not null.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -274,17 +265,8 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         ReportClient client = new ReportClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         if(logger.isTraceEnabled()){
@@ -305,17 +287,8 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
        ReportClient client = new ReportClient();
        ClientResponse<AbstractCommonList> res = client.readListFiltered(
                        testDocType, "single");
+        assertStatusCode(res, testName);
        AbstractCommonList list = res.getEntity();
-       int statusCode = res.getStatus();
-
-       // Check the status code of the response: does it match
-       // the expected response(s)?
-       if (logger.isDebugEnabled()) {
-               logger.debug(testName + ": status = " + statusCode);
-       }
-       Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-       Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
        List<AbstractCommonList.ListItem> items =
                list.getListItem();
@@ -332,17 +305,8 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
                
                // Now filter for something else, and ensure it is NOT returned
        res = client.readListFiltered("Intake", "single");
+        assertStatusCode(res, testName);
        list = res.getEntity();
-       statusCode = res.getStatus();
-
-       // Check the status code of the response: does it match
-       // the expected response(s)?
-       if (logger.isDebugEnabled()) {
-               logger.debug(testName + ": status = " + statusCode);
-       }
-       Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-       Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
        items = list.getListItem();
        // We must NOT find the basic one we created
@@ -353,17 +317,8 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
                
                // Now filter for something else, and ensure it is NOT returned
        res = client.readListFiltered(testDocType, "group");
+        assertStatusCode(res, testName);
        list = res.getEntity();
-       statusCode = res.getStatus();
-
-       // Check the status code of the response: does it match
-       // the expected response(s)?
-       if (logger.isDebugEnabled()) {
-               logger.debug(testName + ": status = " + statusCode);
-       }
-       Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-       Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
        items = list.getListItem();
        // We must NOT find the basic one we created
@@ -394,10 +349,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
         // Retrieve the contents of a resource to update.
         ReportClient client = new ReportClient();
         ClientResponse<String> res = client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
         if (logger.isDebugEnabled()) {
             logger.debug("got object to update with ID: " + knownResourceId);
         }
@@ -426,15 +378,7 @@ public class ReportServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(reportCommon, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
-
-        // Check the status code of the response: does it match the expected response(s)?
-        int statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Extract the updated common part from the response.
         input = new PoxPayloadIn(res.getEntity());
index ec73d0cd7714e5fe3dc2c26d1bafb3809c4b93f6..04835922021afd79495aa7e79311dd9f3881b4a1 100644 (file)
@@ -450,16 +450,7 @@ public class AuthorizationServiceTest extends AbstractServiceTestImpl {
         //elmo allowed to read
         client.setAuth(true, "elmo2010", true, "elmo2010", true);
         ClientResponse<String> res = client.read(knownResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         DimensionsCommon dimension = (DimensionsCommon) extractPart(input,
index c24180d5d1d3f5d4e1541c824d355d461f9ec914..4d809f9879f7920a2aca3327a54d089f0237f76a 100644 (file)
@@ -422,17 +422,8 @@ public class MultiTenancyTest extends AbstractServiceTestImpl {
         DimensionClient client = new DimensionClient();
         client.setAuth(true, userName, true, userName, true);
         ClientResponse<String> res = client.read(id);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+        assertStatusCode(res, testName);
+        
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         return (DimensionsCommon) extractPart(input,
                 client.getCommonPartName(), DimensionsCommon.class);
index f535c0901aa819e349c7e137590ca65ca44650bf..4ed239c7f130a555c93064787ebec1e0537d34db 100644 (file)
@@ -370,16 +370,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         String newID = null;
         ClientResponse<String> res = client.read(knownResourceId);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
             //FIXME: remove the following try catch once Aron fixes signatures
             try {
                 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -415,16 +406,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
         ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
             //FIXME: remove the following try catch once Aron fixes signatures
             try {
                 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -459,17 +441,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             // Check whether we've received an authority item record.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             TaxonCommon taxon = (TaxonCommon) extractPart(input,
@@ -518,17 +490,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             // Check whether taxon has expected displayName.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             TaxonCommon taxon = (TaxonCommon) extractPart(input,
@@ -553,16 +515,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
             commonPart.setLabel(client.getItemCommonPartName());
             res.releaseConnection();
             res = client.updateItem(knownResourceId, knownItemResourceId, output);
-            statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
             TaxonCommon updatedTaxon =
@@ -588,16 +541,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
             commonPart.setLabel(client.getItemCommonPartName());
             res.releaseConnection();
             res = client.updateItem(knownResourceId, knownItemResourceId, output);
-            statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
             updatedTaxon =
@@ -630,25 +574,19 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
         }
-        // Perform setup.
-        // FIXME: create a setup configuration for this operation.
-        setupUpdateWithWrongXmlSchema();
+
+        // Perform setup for read.
+        setupRead();
 
         // Submit the request to the service and store the response.
         TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
+        assertStatusCode(res, testName);
+        
+        // Perform setup for update.
+        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
+        
         try {
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
             // Check whether Taxonomy has expected displayName.
             PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
             TaxonCommon taxon = (TaxonCommon) extractPart(input,
@@ -664,15 +602,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
             commonPart.setLabel(client.getItemCommonPartName());
             res.releaseConnection();
             res = client.updateItem(knownResourceId, knownItemResourceId, output);
-            statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug("updateItem: status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
         } finally {
             res.releaseConnection();
         }
@@ -769,18 +699,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
         ClientResponse<AbstractCommonList> res = client.readList();
         try {
+            assertStatusCode(res, testName);
                AbstractCommonList list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             // Optionally output additional data about list members for debugging.
             if(logger.isTraceEnabled()){
                AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
@@ -838,18 +758,8 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
             Assert.fail("readItemList passed null csid and name!");
         }
         try {
+            assertStatusCode(res, testName);
                AbstractCommonList list = res.getEntity();
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match
-            // the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
             List<AbstractCommonList.ListItem> items =
                     list.getListItem();
             int nItemsReturned = items.size();
@@ -980,11 +890,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
         ClientResponse<String> res =
                 client.readItem(knownResourceId, knownItemResourceId);
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": read status = " + res.getStatus());
-            }
-            Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
+            assertStatusCode(res, testName);
             if (logger.isDebugEnabled()) {
                 logger.debug("got Taxonomy to update with ID: "
                         + knownItemResourceId
@@ -1010,15 +916,7 @@ public class TaxonomyAuthorityServiceTest extends AbstractServiceTestImpl { //FI
             commonPart.setLabel(client.getItemCommonPartName());
             res.releaseConnection();
             res = client.updateItem(knownResourceId, knownItemResourceId, output);
-            int statusCode = res.getStatus();
-
-            // Check the status code of the response: does it match the expected response(s)?
-            if (logger.isDebugEnabled()) {
-                logger.debug(testName + ": status = " + statusCode);
-            }
-            Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-            Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+            assertStatusCode(res, testName);
 
             // Retrieve the updated resource and verify that its contents exist.
             input = new PoxPayloadIn(res.getEntity());
index 79819f5be1860bf986c8f6f731da14c89ed8f8de..ad183f898b6ec59d293eed6adcbc8a6411d9118c 100644 (file)
@@ -432,16 +432,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         VocabularyClient client = new VocabularyClient();
         ClientResponse<String> res = client.readByName(knownResourceShortIdentifer);
-        int statusCode = res.getStatus();
+        assertStatusCode(res, testName);
 
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         VocabulariesCommon vocabulary = (VocabulariesCommon) extractPart(input,
                 client.getCommonPartName(), VocabulariesCommon.class);
@@ -463,15 +455,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
     // Submit the request to the service and store the response.
     ClientResponse<PoxPayloadIn> res = client.read(knownResourceId);
     int statusCode = res.getStatus();
+    assertStatusCode(res, testName);
 
-    // Check the status code of the response: does it match
-    // the expected response(s)?
-    if(logger.isDebugEnabled()){
-    logger.debug(testName + ": status = " + statusCode);
-    }
-    Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-    invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-    Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
     //FIXME: remove the following try catch once Aron fixes signatures
     try {
     PoxPayloadIn input = (PoxPayloadIn) res.getEntity();
@@ -496,16 +481,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         VocabularyClient client = new VocabularyClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Check whether we've received a vocabulary item.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -523,23 +499,17 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         if (logger.isDebugEnabled()) {
             logger.debug(testBanner(testName, CLASS_NAME));
         }
-        // Perform setup.
-        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
-        // setupUpdateWithWrongXmlSchema(testName);
 
+        // Perform setup for read.
+        setupRead();
+        
         // Submit the request to the service and store the response.
         VocabularyClient client = new VocabularyClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+        assertStatusCode(res, testName);
+        
+        // Perform setup for update.
+        testSetup(STATUS_BAD_REQUEST, ServiceRequestType.UPDATE);
 
         // Check whether Person has expected displayName.
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
@@ -554,7 +524,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(vitem, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartItemName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
+        int statusCode = res.getStatus();
 
         // Check the status code of the response: does it match the expected response(s)?
         if (logger.isDebugEnabled()) {
@@ -654,17 +624,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         VocabularyClient client = new VocabularyClient();
         ClientResponse<AbstractCommonList> res = client.readList();
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         // Optionally output additional data about list members for debugging.
         if(logger.isTraceEnabled()){
@@ -699,17 +660,8 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         } else {
             Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");
         }
+        assertStatusCode(res, testName);
         AbstractCommonList list = res.getEntity();
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug("  " + testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
 
         List<AbstractCommonList.ListItem> items = list.getListItem();
         int nItemsReturned = items.size();
@@ -746,10 +698,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         VocabularyClient client = new VocabularyClient();
         ClientResponse<String> res =
                 client.read(knownResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got Vocabulary to update with ID: " + knownResourceId);
@@ -773,15 +722,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(vocabulary, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartName());
         res = client.update(knownResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug("update: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Retrieve the updated resource and verify that its contents exist.
         input = new PoxPayloadIn(res.getEntity());
@@ -810,10 +751,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         VocabularyClient client = new VocabularyClient();
         ClientResponse<String> res =
                 client.readItem(knownResourceId, knownItemResourceId);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         if (logger.isDebugEnabled()) {
             logger.debug("got VocabularyItem to update with ID: "
@@ -838,15 +776,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(vocabularyItem, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartItemName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug("updateItem: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Retrieve the updated resource and verify that its contents exist.
         input = new PoxPayloadIn(res.getEntity());
@@ -874,17 +804,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         VocabularyClient client = new VocabularyClient();
         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + " read Vocab:" + knownResourceId + "/Item:"
-                    + knownItemResourceId + " status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+        assertStatusCode(res, testName);
 
         PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
         VocabularyitemsCommon vitem = (VocabularyitemsCommon) extractPart(input,
@@ -901,15 +821,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl {
         PayloadOutputPart commonPart = output.addPart(vitem, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(client.getCommonPartItemName());
         res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        assertStatusCode(res, testName);
 
         // Retrieve the updated resource and verify that the parent did not change
         res = client.readItem(knownResourceId, knownItemResourceId);
index acc25f13c5b6938ba72326eaa8ebd83bb292f5a8..c007ea5a61fd3dd1c89edc584fa151769b54a8e0 100644 (file)
@@ -103,8 +103,8 @@ public class WorkflowServiceTest extends AbstractServiceTestImpl {
 //        setupReadList();
 //        WorkflowClient client = new WorkflowClient();
 //        ClientResponse<AbstractCommonList> res = client.readList();
-//        AbstractCommonList list = res.getEntity();
 //        assertStatusCode(res, testName);
+//        AbstractCommonList list = res.getEntity();
 //        if (logger.isDebugEnabled()) {
 //            List<AbstractCommonList.ListItem> items =
 //                list.getListItem();