]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
3d3ff6001acfe0d065ad30b7391c9a808ace626b
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.client.test;\r
2 \r
3 import java.util.List;\r
4 \r
5 import javax.ws.rs.core.Response;\r
6 import org.jboss.resteasy.client.ClientResponse;\r
7 \r
8 import org.collectionspace.services.client.AbstractCommonListUtils;\r
9 import org.collectionspace.services.client.AuthorityClient;\r
10 import org.collectionspace.services.client.AuthorityClientImpl;\r
11 import org.collectionspace.services.client.AuthorityProxy;\r
12 import org.collectionspace.services.client.PayloadInputPart;\r
13 import org.collectionspace.services.client.PayloadOutputPart;\r
14 import org.collectionspace.services.client.PoxPayloadOut;\r
15 import org.collectionspace.services.jaxb.AbstractCommonList;\r
16 \r
17 import org.slf4j.Logger;\r
18 import org.slf4j.LoggerFactory;\r
19 import org.testng.Assert;\r
20 import org.testng.annotations.Test;\r
21 \r
22 /**\r
23  * \r
24  * @author remillet\r
25  *\r
26  * @param <AUTHORITY_COMMON_TYPE>\r
27  * @param <AUTHORITY_ITEM_TYPE>\r
28  * \r
29  * All CRUD related authority test classes should extend this class.\r
30  * \r
31  */\r
32 public abstract class AbstractAuthorityServiceTest<AUTHORITY_COMMON_TYPE, AUTHORITY_ITEM_TYPE> \r
33         extends AbstractPoxServiceTestImpl<AbstractCommonList, AUTHORITY_COMMON_TYPE> {\r
34 \r
35     private final Logger logger = LoggerFactory.getLogger(AbstractAuthorityServiceTest.class);\r
36         \r
37     protected String knownResourceShortIdentifer = null;\r
38         protected static final String READITEMS_SHORT_IDENTIFIER = "resourceWithItems"; \r
39         protected String knownAuthorityWithItems = null;\r
40         \r
41         protected String knownResourceRefName = null;\r
42     protected String knownItemResourceId = null;\r
43     protected String knownItemResourceShortIdentifer = null;    \r
44     protected int nItemsToCreateInList = 5;\r
45                 \r
46         public abstract void authorityTests(String testName);\r
47     protected abstract String createItemInAuthority(String authorityId);\r
48  \r
49     protected abstract AUTHORITY_ITEM_TYPE updateItemInstance(final AUTHORITY_ITEM_TYPE authorityItem);    \r
50     protected abstract void compareUpdatedItemInstances(AUTHORITY_ITEM_TYPE original, AUTHORITY_ITEM_TYPE updated) throws Exception;\r
51     \r
52     protected void setKnownItemResource(String id, String shortIdentifer ) {\r
53         knownItemResourceId = id;\r
54         knownItemResourceShortIdentifer = shortIdentifer;\r
55     }\r
56 \r
57     protected void setKnownResource(String id, String shortIdentifer,\r
58             String refName) {\r
59         knownResourceId = id;\r
60         knownResourceShortIdentifer = shortIdentifer;\r
61         knownResourceRefName = refName;\r
62     }\r
63 \r
64     /**\r
65      * Returns the root URL for a service.\r
66      *\r
67      * This URL consists of a base URL for all services, followed by\r
68      * a path component for the owning vocabulary, followed by the \r
69      * path component for the items.\r
70      *\r
71      * @return The root URL for a service.\r
72      */\r
73     protected String getItemServiceRootURL(String parentResourceIdentifier) {\r
74         return getResourceURL(parentResourceIdentifier) + "/" + getServicePathItemsComponent();\r
75     }\r
76 \r
77     /**\r
78      * Returns the URL of a specific resource managed by a service, and\r
79      * designated by an identifier (such as a universally unique ID, or UUID).\r
80      *\r
81      * @param  resourceIdentifier  An identifier (such as a UUID) for a resource.\r
82      *\r
83      * @return The URL of a specific resource managed by a service.\r
84      */\r
85     protected String getItemResourceURL(String parentResourceIdentifier, String resourceIdentifier) {\r
86         return getItemServiceRootURL(parentResourceIdentifier) + "/" + resourceIdentifier;\r
87     }\r
88         \r
89     /**\r
90      * For authorities we override this method so we can save the shortid.\r
91      */\r
92     @Override\r
93     protected String createWithIdentifier(String testName, String identifier) throws Exception {\r
94         String csid = createResource(testName, identifier);\r
95         // Store the ID returned from the first resource created\r
96         // for additional tests below.\r
97         if (getKnowResourceId() == null) {\r
98                 setKnownResource(csid, identifier /*shortId*/, null /*refname*/ );\r
99             if (logger.isDebugEnabled()) {\r
100                 logger.debug(testName + ": Setting knownResourceId=" + getKnowResourceId());\r
101             }\r
102         }\r
103         \r
104         return identifier;\r
105     }    \r
106     \r
107     @Test(dependsOnMethods = {"readItem", "CRUDTests"})\r
108     public void testItemSubmitRequest() {\r
109 \r
110         // Expected status code: 200 OK\r
111         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();\r
112 \r
113         // Submit the request to the service and store the response.\r
114         String method = ServiceRequestType.READ.httpMethodName();\r
115         String url = getItemResourceURL(knownResourceId, knownItemResourceId);\r
116         int statusCode = submitRequest(method, url);\r
117 \r
118         // Check the status code of the response: does it match\r
119         // the expected response(s)?\r
120         if (logger.isDebugEnabled()) {\r
121             logger.debug("testItemSubmitRequest: url=" + url\r
122                     + " status=" + statusCode);\r
123         }\r
124         Assert.assertEquals(statusCode, EXPECTED_STATUS);\r
125     }    \r
126 \r
127     \r
128     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
129         dependsOnMethods = {"readItem"})\r
130     public void verifyIgnoredUpdateWithInAuthority(String testName) throws Exception {\r
131         // Perform setup.\r
132         setupUpdate();\r
133 \r
134         // Submit the request to the service and store the response.\r
135         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = \r
136                         (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
137         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);\r
138         int statusCode = res.getStatus();\r
139 \r
140         // Check the status code of the response: does it match\r
141         // the expected response(s)?\r
142         if (logger.isDebugEnabled()) {\r
143                 logger.debug(testName + " read authority:" + knownResourceId + "/Item:"\r
144                                 + knownItemResourceId + " status = " + statusCode);\r
145         }\r
146         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
147                         invalidStatusCodeMessage(testRequestType, statusCode));\r
148         Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());\r
149 \r
150         AUTHORITY_ITEM_TYPE vitem = extractItemCommonPartValue(res);\r
151         Assert.assertNotNull(vitem);\r
152         // Try to Update with new parent vocab (use self, for test).\r
153         Assert.assertEquals(client.getInAuthority(vitem), knownResourceId,\r
154                         "VocabularyItem inAuthority does not match knownResourceId.");\r
155         client.setInAuthority(vitem, knownItemResourceId);\r
156 \r
157         // Submit the updated resource to the service and store the response.\r
158         PoxPayloadOut output = this.createItemRequestTypeInstance(vitem);\r
159         res = client.updateItem(knownResourceId, knownItemResourceId, output);\r
160         statusCode = res.getStatus();\r
161 \r
162         // Check the status code of the response: does it match the expected response(s)?\r
163         if (logger.isDebugEnabled()) {\r
164                 logger.debug(testName + ": status = " + statusCode);\r
165         }\r
166         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
167                         invalidStatusCodeMessage(testRequestType, statusCode));\r
168         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
169 \r
170         // Retrieve the updated resource and verify that the parent did not change\r
171         res = client.readItem(knownResourceId, knownItemResourceId);\r
172         AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);\r
173         Assert.assertNotNull(updatedVocabularyItem);\r
174 \r
175         // Verify that the updated resource received the correct data.\r
176         Assert.assertEquals(client.getInAuthority(updatedVocabularyItem),\r
177                         knownResourceId,\r
178                         "VocabularyItem allowed update to the parent (inAuthority).");\r
179     }\r
180     \r
181     @Test(dataProvider = "testName",\r
182                 dependsOnMethods = {"CRUDTests"})\r
183     public void createItem(String testName) {\r
184         // Perform setup.\r
185         setupCreate();\r
186 \r
187         String newID = createItemInAuthority(knownResourceId);\r
188 \r
189         // Store the ID returned from the first item resource created\r
190         // for additional tests below.\r
191         if (knownItemResourceId == null) {\r
192             knownItemResourceId = newID;\r
193             if (null != testName && logger.isDebugEnabled()) {\r
194                 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);\r
195             }\r
196         }\r
197     }\r
198     \r
199     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
200                 dependsOnMethods = {"createItem"})\r
201     public void createItemList(String testName) throws Exception {\r
202         knownAuthorityWithItems = createResource(testName, READITEMS_SHORT_IDENTIFIER);\r
203         for (int j = 0; j < nItemsToCreateInList; j++) {\r
204                 createItemInAuthority(knownAuthorityWithItems);\r
205         }\r
206     }\r
207 \r
208     /**\r
209      * Read by name.\r
210      *\r
211      * @param testName the test name\r
212      * @throws Exception the exception\r
213      */\r
214     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
215                 dependsOnMethods = {"CRUDTests"})\r
216     public void readByName(String testName) throws Exception {\r
217         // Perform setup.\r
218         setupRead();\r
219 \r
220         // Submit the request to the service and store the response.\r
221         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
222         ClientResponse<String> res = client.readByName(getKnowResourceIdentifier());\r
223         int statusCode = res.getStatus();\r
224 \r
225         // Check the status code of the response: does it match\r
226         // the expected response(s)?\r
227         if (logger.isDebugEnabled()) {\r
228             logger.debug(testName + ": status = " + statusCode);\r
229         }\r
230         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
231                 invalidStatusCodeMessage(testRequestType, statusCode));\r
232         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
233         \r
234         AUTHORITY_COMMON_TYPE commonPart = extractCommonPartValue(res);\r
235         Assert.assertNotNull(commonPart);\r
236     }\r
237     \r
238     /**\r
239      * Extracts the common part item from a service's item payload.\r
240      * \r
241      * @param res\r
242      * @return\r
243      * @throws Exception\r
244      */\r
245         public AUTHORITY_ITEM_TYPE extractItemCommonPartValue(ClientResponse<String> res) throws Exception {\r
246                 AUTHORITY_ITEM_TYPE result = null;\r
247                 \r
248         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
249                 PayloadInputPart payloadInputPart = extractPart(res, client.getItemCommonPartName());\r
250                 if (payloadInputPart != null) {\r
251                         result = (AUTHORITY_ITEM_TYPE) payloadInputPart.getBody();\r
252                 }\r
253                 Assert.assertNotNull(result,\r
254                                 "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");\r
255                 \r
256                 return result;\r
257         }\r
258     \r
259     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
260                 dependsOnMethods = {"readItem"})\r
261     public void readItemNonExistent(String testName) {\r
262         // Perform setup.\r
263         setupReadNonExistent();\r
264 \r
265         // Submit the request to the service and store the response.\r
266         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
267         ClientResponse<String> res = client.readItem(knownResourceId, NON_EXISTENT_ID);\r
268         int statusCode = res.getStatus();\r
269 \r
270         // Check the status code of the response: does it match\r
271         // the expected response(s)?\r
272         if (logger.isDebugEnabled()) {\r
273             logger.debug(testName + ": status = " + statusCode);\r
274         }\r
275         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
276                 invalidStatusCodeMessage(testRequestType, statusCode));\r
277         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
278     }\r
279         \r
280     @Test(dataProvider = "testName",\r
281                 dependsOnMethods = {"createItem"})\r
282     public void readItem(String testName) throws Exception {\r
283         // Perform setup.\r
284         setupRead();\r
285 \r
286         // Submit the request to the service and store the response.\r
287         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
288         ClientResponse<String> res = client.readItem(knownResourceId, knownItemResourceId);\r
289         int statusCode = res.getStatus();\r
290 \r
291         // Check the status code of the response: does it match\r
292         // the expected response(s)?\r
293         if (logger.isDebugEnabled()) {\r
294             logger.debug(testName + ": status = " + statusCode);\r
295         }\r
296         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
297                 invalidStatusCodeMessage(testRequestType, statusCode));\r
298         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
299 \r
300         AUTHORITY_ITEM_TYPE itemCommonPart = extractItemCommonPartValue(res);\r
301         Assert.assertNotNull(itemCommonPart);\r
302         Assert.assertEquals(client.getInAuthority(itemCommonPart), knownResourceId);\r
303         verifyReadItemInstance(itemCommonPart);\r
304     }\r
305     \r
306     protected abstract void verifyReadItemInstance(AUTHORITY_ITEM_TYPE item) throws Exception;\r
307         \r
308     @Test(dataProvider = "testName",\r
309                 dependsOnMethods = {"testItemSubmitRequest", "updateItem", "verifyIgnoredUpdateWithInAuthority"})    \r
310     public void deleteItem(String testName) throws Exception {\r
311         // Perform setup.\r
312         setupDelete();\r
313 \r
314         // Submit the request to the service and store the response.\r
315         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
316         ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);\r
317         int statusCode = res.getStatus();\r
318 \r
319         // Check the status code of the response: does it match\r
320         // the expected response(s)?\r
321         if (logger.isDebugEnabled()) {\r
322             logger.debug("delete: status = " + statusCode);\r
323         }\r
324         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
325                 invalidStatusCodeMessage(testRequestType, statusCode));\r
326         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
327     }\r
328     \r
329     protected void readItemListInt(String vcsid, String shortId, String testName) {\r
330         // Perform setup.\r
331         setupReadList();\r
332 \r
333         // Submit the request to the service and store the response.\r
334         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
335         ClientResponse<AbstractCommonList> res = null;\r
336         if (vcsid != null) {\r
337             res = client.readItemList(vcsid, null, null);\r
338         } else if (shortId != null) {\r
339             res = client.readItemListForNamedAuthority(shortId, null, null);\r
340         } else {\r
341             Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");\r
342         }\r
343         int statusCode = res.getStatus();\r
344 \r
345         // Check the status code of the response: does it match\r
346         // the expected response(s)?\r
347         if (logger.isDebugEnabled()) {\r
348             logger.debug("  " + testName + ": status = " + statusCode);\r
349         }\r
350         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
351                 invalidStatusCodeMessage(testRequestType, statusCode));\r
352         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
353 \r
354         AbstractCommonList list = res.getEntity();\r
355         List<AbstractCommonList.ListItem> items = list.getListItem();\r
356         int nItemsReturned = items.size();\r
357         long nItemsTotal = list.getTotalItems();\r
358         if (logger.isDebugEnabled()) {\r
359             logger.debug("  " + testName + ": Expected "\r
360                     + nItemsToCreateInList + " items; got: " + nItemsReturned + " of: " + nItemsTotal);\r
361         }\r
362         Assert.assertEquals(nItemsTotal, nItemsToCreateInList);\r
363 \r
364         if(logger.isTraceEnabled()){\r
365                 AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);\r
366         }\r
367     }\r
368     \r
369     @Test(dataProvider = "testName",\r
370                 dependsOnMethods = {"createItemList"})\r
371     public void readItemList(String testName) {\r
372         readItemListInt(knownAuthorityWithItems, null, testName);\r
373     }\r
374 \r
375     @Test(dataProvider = "testName",\r
376                 dependsOnMethods = {"readItem"})\r
377     public void readItemListByName(String testName) {\r
378         readItemListInt(null, READITEMS_SHORT_IDENTIFIER, testName);\r
379     }\r
380 \r
381     @Test(dataProvider = "testName",\r
382                 dependsOnMethods = {"deleteItem"})\r
383     public void deleteNonExistentItem(String testName) {\r
384         // Perform setup.\r
385         setupDeleteNonExistent();\r
386 \r
387         // Submit the request to the service and store the response.\r
388         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
389         ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);\r
390         int statusCode = res.getStatus();\r
391 \r
392         // Check the status code of the response: does it match\r
393         // the expected response(s)?\r
394         if (logger.isDebugEnabled()) {\r
395             logger.debug(testName + ": status = " + statusCode);\r
396         }\r
397         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
398                 invalidStatusCodeMessage(testRequestType, statusCode));\r
399         Assert.assertEquals(statusCode, testExpectedStatusCode);\r
400     }\r
401     \r
402     protected String getServicePathItemsComponent() {\r
403         return AuthorityClient.ITEMS;\r
404     }\r
405     \r
406         public PoxPayloadOut createItemRequestTypeInstance(AUTHORITY_ITEM_TYPE itemTypeInstance) {\r
407                 PoxPayloadOut result = null;\r
408                 \r
409         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client = (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
410         PoxPayloadOut payloadOut = new PoxPayloadOut(this.getServicePathItemsComponent());\r
411         PayloadOutputPart part = payloadOut.addPart(client.getItemCommonPartName(), itemTypeInstance);\r
412         result = payloadOut;\r
413                 \r
414                 return result;\r
415         }\r
416 \r
417         /**\r
418          * Update an Authority item.\r
419          * \r
420          * @param testName\r
421          * @throws Exception\r
422          */\r
423     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,\r
424                 dependsOnMethods = {"readItem", "CRUDTests", "verifyIgnoredUpdateWithInAuthority"})\r
425     public void updateItem(String testName) throws Exception {\r
426         // Perform setup.\r
427         setupUpdate();\r
428         AUTHORITY_ITEM_TYPE theUpdate = null;\r
429 \r
430         // Retrieve the contents of a resource to update.\r
431         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =\r
432                         (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
433         ClientResponse<String> res =\r
434                 client.readItem(knownResourceId, knownItemResourceId);\r
435         try {\r
436                 if (logger.isDebugEnabled()) {\r
437                     logger.debug(testName + ": read status = " + res.getStatus());\r
438                 }\r
439                 Assert.assertEquals(res.getStatus(), testExpectedStatusCode);\r
440         \r
441                 if (logger.isDebugEnabled()) {\r
442                     logger.debug("got Authority item to update with ID: "\r
443                             + knownItemResourceId\r
444                             + " in authority: " + knownResourceId);\r
445                 }\r
446                 AUTHORITY_ITEM_TYPE authorityItem = extractItemCommonPartValue(res);\r
447                 Assert.assertNotNull(authorityItem);\r
448 \r
449                 // Update the contents of this resource.\r
450                 theUpdate = updateItemInstance(authorityItem);\r
451                 if (logger.isDebugEnabled()) {\r
452                     logger.debug("\n\nTo be updated fields: CSID = "  + knownItemResourceId + "\n"\r
453                                 + objectAsXmlString(theUpdate));\r
454                 }\r
455         } finally {\r
456                 res.releaseConnection();\r
457         }\r
458 \r
459         // Submit the updated resource to the service and store the response.\r
460         PoxPayloadOut output = this.createItemRequestTypeInstance(theUpdate);\r
461         res = client.updateItem(knownResourceId, knownItemResourceId, output);\r
462         try {\r
463                 int statusCode = res.getStatus();\r
464         \r
465                 // Check the status code of the response: does it match the expected response(s)?\r
466                 if (logger.isDebugEnabled()) {\r
467                     logger.debug("updateItem: status = " + statusCode);\r
468                 }\r
469                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
470                         invalidStatusCodeMessage(testRequestType, statusCode));\r
471                 Assert.assertEquals(statusCode, testExpectedStatusCode);\r
472         \r
473                 // Retrieve the updated resource and verify that its contents exist.\r
474                 AUTHORITY_ITEM_TYPE updatedVocabularyItem = extractItemCommonPartValue(res);\r
475                 Assert.assertNotNull(updatedVocabularyItem);\r
476 \r
477                 compareUpdatedItemInstances(theUpdate, updatedVocabularyItem);\r
478         } finally {\r
479                 res.releaseConnection();\r
480         }\r
481     }\r
482     \r
483     protected abstract PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier);\r
484     \r
485     /* (non-Javadoc)\r
486      * @see org.collectionspace.services.client.test.ServiceTest#updateNonExistent(java.lang.String)\r
487      */\r
488     @Test(dataProvider = "testName",\r
489         dependsOnMethods = {"create", "update", "updateNonExistent"})\r
490     public void updateNonExistentItem(String testName) throws Exception {\r
491         // Perform setup.\r
492         setupUpdateNonExistent();\r
493 \r
494         // Submit the request to the service and store the response.\r
495         // Note: The ID used in this 'create' call may be arbitrary.\r
496         // The only relevant ID may be the one used in update(), below.\r
497         AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy> client =\r
498                         (AuthorityClientImpl<AUTHORITY_ITEM_TYPE, AuthorityProxy>)this.getClientInstance();\r
499         PoxPayloadOut multipart = createNonExistenceItemInstance(client.getItemCommonPartName(), NON_EXISTENT_ID);\r
500         ClientResponse<String> res =\r
501                         client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);\r
502         try {\r
503                 int statusCode = res.getStatus();\r
504         \r
505                 // Check the status code of the response: does it match\r
506                 // the expected response(s)?\r
507                 if (logger.isDebugEnabled()) {\r
508                         logger.debug(testName + ": status = " + statusCode);\r
509                 }\r
510                 Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),\r
511                                 invalidStatusCodeMessage(testRequestType, statusCode));\r
512                 Assert.assertEquals(statusCode, testExpectedStatusCode);\r
513         } finally {\r
514                 res.releaseConnection();\r
515         }\r
516     }\r
517         \r
518     //\r
519     // Methods to persuade TestNG to follow the correct test dependency path\r
520     //\r
521     \r
522     @Test(dataProvider = "testName",\r
523                 dependsOnMethods = {"createItem"})\r
524     public void baseAuthorityTests(String testName) {\r
525         // Do nothing.  Here just to setup a test dependency chain.\r
526     }\r
527     \r
528     /*\r
529      * For convenience and terseness, this test method is the base of the test execution dependency chain.  Other test methods may\r
530      * refer to this method in their @Test annotation declarations.\r
531      */\r
532     @Override\r
533     @Test(dataProvider = "testName",\r
534                 dependsOnMethods = {\r
535                         "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})    \r
536         public void CRUDTests(String testName) {\r
537                 // TODO Auto-generated method stub\r
538         }\r
539     \r
540 }\r