]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
77e99ec059e3c17f12506178d2067a73ee43870d
[tmp/jakarta-migration.git] /
1 /**
2  * This document is a part of the source code and related artifacts
3  * for CollectionSpace, an open source collections management system
4  * for museums and related institutions:
5  *
6  * http://www.collectionspace.org
7  * http://wiki.collectionspace.org
8  *
9  * Copyright (c)) 2009 Regents of the University of California
10  *
11  * Licensed under the Educational Community License (ECL), Version 2.0.
12  * You may not use this file except in compliance with this License.
13  *
14  * You may obtain a copy of the ECL 2.0 License at
15  * https://source.collectionspace.org/collection-space/LICENSE.txt
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 package org.collectionspace.services.client.test;
24
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30 import javax.ws.rs.core.Response;
31
32 import org.collectionspace.services.client.AbstractCommonListUtils;
33 import org.collectionspace.services.client.AuthorityClient;
34 import org.collectionspace.services.client.CollectionSpaceClient;
35 import org.collectionspace.services.client.PoxPayloadIn;
36 import org.collectionspace.services.client.PoxPayloadOut;
37 import org.collectionspace.services.client.ContactClient;
38 import org.collectionspace.services.client.ContactClientUtils;
39 import org.collectionspace.services.contact.AddressGroup;
40 import org.collectionspace.services.contact.AddressGroupList;
41 import org.collectionspace.services.contact.ContactsCommon;
42 import org.collectionspace.services.client.PersonAuthorityClient;
43 import org.collectionspace.services.client.PersonAuthorityClientUtils;
44 import org.collectionspace.services.jaxb.AbstractCommonList;
45 import org.collectionspace.services.PersonJAXBSchema;
46 import org.collectionspace.services.person.PersonauthoritiesCommon;
47 import org.collectionspace.services.person.PersonTermGroup;
48 import org.collectionspace.services.person.PersonTermGroupList;
49 import org.collectionspace.services.person.PersonsCommon;
50 import org.slf4j.Logger;
51 import org.slf4j.LoggerFactory;
52 import org.testng.Assert;
53 import org.testng.annotations.AfterClass;
54 import org.testng.annotations.Test;
55
56 /**
57  * PersonAuthorityServiceTest, carries out tests against a
58  * deployed and running PersonAuthority Service.
59  *
60  * $LastChangedRevision: 753 $
61  * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
62  */
63 public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<PersonauthoritiesCommon, PersonsCommon> { //FIXME: Test classes for Vocab, Person, Org, and Location should have a base class!
64
65     /** The logger. */
66     private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName();
67     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
68     
69     /**
70      * Default constructor.  Used to set the short ID for all tests authority items
71      */
72     public PersonAuthorityServiceTest() {
73         super();
74         TEST_SHORTID = "johnWayneActor";
75     }
76     
77     @Override
78         protected String getTestAuthorityItemShortId() {
79                 return getTestAuthorityItemShortId(true); // The short ID of every person item we create should be unique
80         }
81
82     @Override
83     public String getServicePathComponent() {
84         return PersonAuthorityClient.SERVICE_PATH_COMPONENT;
85     }
86
87     @Override
88     protected String getServiceName() {
89         return PersonAuthorityClient.SERVICE_NAME;
90     }
91
92     public String getItemServicePathComponent() {
93         return AuthorityClient.ITEMS;
94     }
95     
96     /** The test forename. */
97     final String TEST_FORE_NAME = "John";
98     /** The test middle name. */
99     final String TEST_MIDDLE_NAME = null;
100     /** The test surname. */
101     final String TEST_SUR_NAME = "Wayne";
102     /** The test birthdate. */
103     final String TEST_BIRTH_DATE = "May 26, 1907";
104     /** The test death date. */
105     final String TEST_DEATH_DATE = "June 11, 1979";
106     //private String knownResourceRefName = null;
107     private String knownItemResourceShortIdentifer = null;
108     /** The known contact resource id. */
109     private String knownContactResourceId = null;
110     /** The all contact resource ids created. */
111     private Map<String, String> allContactResourceIdsCreated =
112             new HashMap<String, String>();
113
114     
115     protected void setKnownResource(String id, String shortIdentifer,
116             String refName) {
117         knownResourceId = id;
118         knownResourceShortIdentifer = shortIdentifer;
119         //knownResourceRefName = refName;
120     }
121
122     protected void setKnownItemResource(String id, String shortIdentifer) {
123         knownItemResourceId = id;
124         knownItemResourceShortIdentifer = shortIdentifer;
125     }
126
127     /* (non-Javadoc)
128      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
129      */
130     @Override
131     protected CollectionSpaceClient getClientInstance() {
132         return new PersonAuthorityClient();
133     }
134     
135         @Override
136         protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) {
137         return new PersonAuthorityClient(clientPropertiesFilename);
138         }
139
140     // ---------------------------------------------------------------
141     // CRUD tests : CREATE tests
142     // ---------------------------------------------------------------
143
144         /* (non-Javadoc)
145      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
146      */
147     @Override
148     public void create(String testName) throws Exception {
149         // Perform setup, such as initializing the type of service request
150         // (e.g. CREATE, DELETE), its valid and expected status codes, and
151         // its associated HTTP method name (e.g. POST, DELETE).
152         setupCreate();
153
154         // Submit the request to the service and store the response.
155         PersonAuthorityClient client = new PersonAuthorityClient();
156         String shortId = createIdentifier();
157         String displayName = "displayName-" + shortId;
158         //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null);
159         PoxPayloadOut multipart =
160                 PersonAuthorityClientUtils.createPersonAuthorityInstance(
161                 displayName, shortId, client.getCommonPartName());
162         // Extract the short ID since it might have been randomized by the createPersonAuthRefName() method
163         PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(multipart,
164                 client.getCommonPartName(), PersonauthoritiesCommon.class);
165         shortId = personAuthority.getShortIdentifier();
166
167         String newID = null;
168         Response res = client.create(multipart);
169         try {
170                 assertStatusCode(res, testName);
171             newID = extractId(res);
172         } finally {
173                 if (res != null) {
174                         res.close();
175                 }
176         }
177         // Save values for additional tests
178         if (knownResourceId == null) {
179             setKnownResource(newID, shortId, null ); //baseRefName);
180             if (logger.isDebugEnabled()) {
181                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
182             }
183         }
184         // Store the IDs from every resource created by tests,
185         // so they can be deleted after tests have been run.
186         allResourceIdsCreated.add(newID);
187     }
188
189     @Override
190     protected PoxPayloadOut createInstance(String identifier) {
191         PersonAuthorityClient client = new PersonAuthorityClient();
192         
193         String displayName = "displayName-" + identifier;
194         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
195                 displayName, identifier, client.getCommonPartName());
196         
197         return multipart;
198     }
199
200     @Override
201     protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) {
202         String headerLabel = new PersonAuthorityClient().getItemCommonPartName();
203         
204         HashMap<String, String> personInfo = new HashMap<String, String>();
205         String shortId = "MarkTwainAuthor" + identifier;
206         personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
207         
208         List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
209         PersonTermGroup term = new PersonTermGroup();
210         term.setTermDisplayName("Mark Twain Primary");
211         term.setTermName("MarkTwainPrimary");
212         terms.add(term);
213         
214         term = new PersonTermGroup();
215         term.setTermDisplayName("Samuel Langhorne Clemens");
216         term.setTermName("SamuelLanghorneClemens");
217         terms.add(term);        
218         
219         term = new PersonTermGroup();
220         term.setTermDisplayName("Sam Clemens");
221         term.setTermName("SamClemens");
222         terms.add(term);   
223         
224         term = new PersonTermGroup();
225         term.setTermDisplayName("Huck Fin");
226         term.setTermName("Huck Fin");
227         terms.add(term);           
228         
229         return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, terms, headerLabel);
230     }
231
232     
233     /**
234      * Creates an item in an authority, using test data.
235      *
236      * @param vcsid the vcsid
237      * @param authRefName the auth ref name
238      * @return the string
239      */
240     @Override
241     protected String createItemInAuthority(AuthorityClient client, String vcsid, String shortId) {
242
243         final String testName = "createItemInAuthority";
244         if (logger.isDebugEnabled()) {
245             logger.debug(testName + ":" + vcsid + "...");
246         }
247
248         Map<String, String> johnWayneMap = new HashMap<String, String>();
249         //
250         // Fill the property map
251         //
252         johnWayneMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
253         johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
254         johnWayneMap.put(PersonJAXBSchema.BIRTH_DATE, TEST_BIRTH_DATE);
255         johnWayneMap.put(PersonJAXBSchema.BIRTH_PLACE, "Winterset, Iowa");
256         johnWayneMap.put(PersonJAXBSchema.DEATH_DATE, TEST_DEATH_DATE);
257         johnWayneMap.put(PersonJAXBSchema.BIO_NOTE, "born Marion Robert Morrison and better"
258                 + "known by his stage name John Wayne, was an American film actor, director "
259                 + "and producer. He epitomized rugged masculinity and has become an enduring "
260                 + "American icon. He is famous for his distinctive voice, walk and height. "
261                 + "He was also known for his conservative political views and his support in "
262                 + "the 1950s for anti-communist positions.");
263
264         List<PersonTermGroup> johnWayneTerms = new ArrayList<PersonTermGroup>();
265         PersonTermGroup term = new PersonTermGroup();
266         term.setTermDisplayName("John Wayne DisplayName");
267         term.setTermName("John Wayne");
268         term.setForeName(TEST_FORE_NAME);
269         term.setSurName(TEST_SUR_NAME);
270         johnWayneTerms.add(term);
271
272         Map<String, List<String>> johnWayneRepeatablesMap = new HashMap<String, List<String>>();
273         List<String> johnWayneGroups = new ArrayList<String>();
274         johnWayneGroups.add("Irish");
275         johnWayneGroups.add("Scottish");
276         johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups);
277
278         return createItemInAuthority(client, vcsid, null /*authRefName*/, shortId, johnWayneMap, johnWayneTerms, johnWayneRepeatablesMap);
279
280     }
281
282     /**
283      * Creates an item in an authority.
284      *
285      * @param vcsid the vcsid
286      * @param authRefName the auth ref name
287      * @param itemFieldProperties a set of properties specifying the values of fields.
288      * @param itemRepeatableFieldProperties a set of properties specifying the values of repeatable fields.
289      * @return the string
290      */
291     private String createItemInAuthority(AuthorityClient client, String vcsid, String authRefName, String shortId,
292             Map<String, String> itemFieldProperties, List<PersonTermGroup> terms, Map<String, List<String>> itemRepeatableFieldProperties) {
293
294         final String testName = "createItemInAuthority";
295         if (logger.isDebugEnabled()) {
296             logger.debug(testName + ":" + vcsid + "...");
297         }
298
299         // Submit the request to the service and store the response.
300         if (client == null) {
301                 client = new PersonAuthorityClient();
302         }
303         PoxPayloadOut multipart =
304                 PersonAuthorityClientUtils.createPersonInstance(vcsid, null /*authRefName*/, itemFieldProperties,
305                 terms, itemRepeatableFieldProperties, client.getItemCommonPartName());
306         setupCreate();
307         Response res = client.createItem(vcsid, multipart);
308         String newID = null;
309         try {
310                 assertStatusCode(res, testName);
311             newID = PersonAuthorityClientUtils.extractId(res);
312         } finally {
313                 if (res != null) {
314                         res.close();
315                 }
316         }
317
318         // Store the ID returned from the first item resource created
319         // for additional tests below.
320         if (knownItemResourceId == null) {
321             setKnownItemResource(newID, shortId);
322             if (logger.isDebugEnabled()) {
323                 logger.debug(testName + ": knownItemResourceId=" + knownItemResourceId);
324             }
325         }
326         
327         if (logger.isDebugEnabled()) {
328             logger.debug(testName + " (created):" + vcsid + "/(" + newID + "," + shortId + ")");
329         }
330
331         // Store the IDs from any item resources created
332         // by tests, along with the IDs of their parents, so these items
333         // can be deleted after all tests have been run.
334         allResourceItemIdsCreated.put(newID, vcsid);
335
336         return newID;
337     }
338
339     /*
340      * This override asks for a unique identifier (short ID in the case of authority tests).
341      * 
342      * (non-Javadoc)
343      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createResource(java.lang.String, java.lang.String)
344      */
345     @Override
346     protected String createResource(String testName, String identifier) throws Exception {
347         String result = null;
348         
349         CollectionSpaceClient client = this.getClientInstance();
350         result = createResource(client, testName, identifier, true);
351         
352         return result;
353     }
354     
355     /**
356      * Creates the contact.
357      *
358      * @param testName the test name
359      */
360     @Test(dataProvider = "testName", groups = {"create"},
361                 dependsOnMethods = {"createItem"})
362     public void createContact(String testName) {
363         setupCreate();
364         createContactInItem(knownResourceId, knownItemResourceId);
365     }
366
367     /**
368      * Creates the contact in item.
369      *
370      * @param parentcsid the parentcsid
371      * @param itemcsid the itemcsid
372      * @return the string
373      */
374     private String createContactInItem(String parentcsid, String itemcsid) {
375
376         final String testName = "createContactInItem";
377         if (logger.isDebugEnabled()) {
378             logger.debug(testName + ":...");
379         }
380         // Submit the request to the service and store the response.
381         PersonAuthorityClient client = new PersonAuthorityClient();
382         String identifier = createIdentifier();
383         PoxPayloadOut multipart = ContactClientUtils.createContactInstance(parentcsid,
384                 itemcsid, identifier, new ContactClient().getCommonPartName());
385
386         setupCreate();
387         Response res = client.createContact(parentcsid, itemcsid, multipart);
388         String newID = null;
389         try {
390                 assertStatusCode(res, testName);
391             newID = PersonAuthorityClientUtils.extractId(res);
392         } finally {
393                 if (res != null) {
394                         res.close();
395                 }
396         }
397
398         // Store the ID returned from the first contact resource created
399         // for additional tests below.
400         if (knownContactResourceId == null) {
401             knownContactResourceId = newID;
402             if (logger.isDebugEnabled()) {
403                 logger.debug(testName + ": knownContactResourceId=" + knownContactResourceId);
404             }
405         }
406
407         // Store the IDs from any contact resources created
408         // by tests, along with the IDs of their parent items,
409         // so these items can be deleted after all tests have been run.
410         allContactResourceIdsCreated.put(newID, itemcsid);
411
412         return newID;
413     }
414
415     /**
416      * Attempts to create an authority with an short identifier that contains
417      * non-word characters.
418      *
419      * @param testName the test name
420      */
421     @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"})
422     public void createWithShortIdNonWordChars(String testName) throws Exception {
423         testExpectedStatusCode = STATUS_BAD_REQUEST;
424         testRequestType = ServiceRequestType.CREATE;
425         testSetup(testExpectedStatusCode, testRequestType);
426
427         // Create the payload to be included in the body of the request
428         PersonAuthorityClient client = new PersonAuthorityClient();
429         String shortId = createIdentifier() + "*" + createIdentifier();
430         String displayName = "displayName-" + shortId;
431         PoxPayloadOut multipart =
432                 PersonAuthorityClientUtils.createPersonAuthorityInstance(
433                 displayName, shortId, client.getCommonPartName());
434
435         // Submit the request to the service and store the response.
436         Response res = client.create(multipart);
437         // Check the status code of the response: does it match
438         // the expected response(s)?  We expect failure here.
439         try {
440                 assertStatusCode(res, testName);
441         } finally {
442                 if (res != null) {
443                         res.close();
444                 }
445         }
446     }
447
448     /**
449      * Attempts to create an item with an short identifier that contains
450      * non-word characters.
451      *
452      * @param testName the test name
453      */
454     @Test(dataProvider = "testName", groups = {"create", "nonWordCharsInShortId"},
455                 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractServiceTestImpl.create"})
456     public void createItemWithShortIdNonWordChars(String testName) {
457         testExpectedStatusCode = STATUS_BAD_REQUEST;
458         testRequestType = ServiceRequestType.CREATE;
459         testSetup(testExpectedStatusCode, testRequestType);
460
461         PersonAuthorityClient client = new PersonAuthorityClient();
462         // Create the payload to be included in the body of the request
463         String shortId = "7-Eleven";
464         Map<String, String> fieldProperties = new HashMap<String, String>();
465         fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
466         
467         List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
468         PersonTermGroup term = new PersonTermGroup();
469         term.setTermDisplayName(shortId);
470         term.setTermName(shortId);
471         terms.add(term);
472         
473         final Map<String, List<String>> NULL_REPEATABLE_FIELD_PROPERTIES = null;
474         PoxPayloadOut multipart =
475                 PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
476                 null /*knownResourceRefName*/, fieldProperties, terms,
477                 NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName());
478
479         // Send the request and receive a response
480         Response res = client.createItem(knownResourceId, multipart);
481         // Check the status code of the response: does it match
482         // the expected response(s)?  We expect failure here, so there will be no
483         // new ID to keep track of for later cleanup.
484         try {
485                 assertStatusCode(res, testName);
486         } finally {
487                 if (res != null) {
488                         res.close();
489                 }
490         }        
491     }
492
493     // ---------------------------------------------------------------
494     // CRUD tests : CREATE LIST tests
495     // ---------------------------------------------------------------
496     // Success outcomes
497     /* (non-Javadoc)
498      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
499      */
500     @Override
501 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
502 //    groups = {"createList"}, dependsOnGroups = {"create"})
503     public void createList(String testName) throws Exception {
504         for (int i = 0; i < nItemsToCreateInList; i++) {
505             create(testName);
506         }
507     }
508
509     /**
510      * Creates the contact list.
511      *
512      * @param testName the test name
513      * @throws Exception the exception
514      */
515     @Test(dataProvider = "testName", groups = {"createList"},
516                 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.createItemList"})
517     public void createContactList(String testName) throws Exception {
518         // Add contacts to the initially-created, known item record.
519         for (int j = 0; j < nItemsToCreateInList; j++) {
520             createContact(testName);
521         }
522     }
523
524     // ---------------------------------------------------------------
525     // CRUD tests : READ tests
526     // ---------------------------------------------------------------
527     // Success outcomes
528     /* (non-Javadoc)
529      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
530      */
531     @Override
532 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
533 //    groups = {"read"}, dependsOnGroups = {"create"})
534     public void read(String testName) throws Exception {
535         readInternal(testName, knownResourceId, null);
536     }
537
538     /**
539      * Read by name.
540      *
541      * @param testName the test name
542      * @throws Exception the exception
543      */
544     @Override
545 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
546 //    groups = {"read"}, dependsOnMethods = {"read"})
547     public void readByName(String testName) throws Exception {
548         readInternal(testName, null, knownResourceShortIdentifer);
549     }
550
551     protected void readInternal(String testName, String CSID, String shortId) {
552         // Submit the request to the service and store the response.
553         PersonAuthorityClient client = new PersonAuthorityClient();
554         Response res = null;
555         setupRead();
556         if (CSID != null) {
557             res = client.read(CSID);
558         } else if (shortId != null) {
559             res = client.readByName(shortId);
560         } else {
561             Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
562         }
563         try {
564             assertStatusCode(res, testName);
565             //FIXME: remove the following try catch once Aron fixes signatures
566             try {
567                 PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
568                 PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
569                         client.getCommonPartName(), PersonauthoritiesCommon.class);
570                 Assert.assertNotNull(personAuthority);
571             } catch (Exception e) {
572                 throw new RuntimeException(e);
573             }
574         } finally {
575                 if (res != null) {
576                 res.close();
577             }
578         }
579     }
580
581     /**
582      * Read named item.
583      *
584      * @param testName the test name
585      * @throws Exception the exception
586      */
587     @Test(dataProvider = "testName", groups = {"readItem", "readNamedItemInNamedAuth"},
588                 dependsOnMethods = {"readItemInNamedAuth"})
589     public void readNamedItem(String testName) throws Exception {
590         readItemInternal(testName, knownResourceId, null, null, knownItemResourceShortIdentifer);
591     }
592
593     /**
594      * Read item in Named Auth.
595      *
596      * @param testName the test name
597      * @throws Exception the exception
598      */
599     @Test(dataProvider = "testName", groups = {"readItem"},
600                 dependsOnMethods = {"readItem"})
601     public void readItemInNamedAuth(String testName) throws Exception {
602         readItemInternal(testName, null, knownResourceShortIdentifer, knownItemResourceId, null);
603     }
604
605     
606     /**
607      * Read Named item in Named Auth.
608      *
609      * @param testName the test name
610      * @throws Exception the exception
611      */
612     @Test(dataProvider = "testName", groups = {"readItem"},
613                 dependsOnMethods = {"readNamedItem"})
614     public void readNamedItemInNamedAuth(String testName) throws Exception {
615         readItemInternal(testName, null, knownResourceShortIdentifer, null, knownItemResourceShortIdentifer);
616     }
617
618     protected void readItemInternal(String testName,
619             String authCSID, String authShortId, String itemCSID, String itemShortId)
620             throws Exception {
621
622         if (logger.isDebugEnabled()) {
623             logger.debug("Reading:" + ((authCSID != null) ? authCSID : authShortId) + "/"
624                     + ((itemCSID != null) ? authCSID : itemShortId));
625         }
626
627         // Submit the request to the service and store the response.
628         PersonAuthorityClient client = new PersonAuthorityClient();
629         setupRead();
630         Response res = null;
631         if (authCSID != null) {
632             if (itemCSID != null) {
633                 res = client.readItem(authCSID, itemCSID);
634             } else if (itemShortId != null) {
635                 res = client.readNamedItem(authCSID, itemShortId);
636             } else {
637                 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
638             }
639         } else if (authShortId != null) {
640             if (itemCSID != null) {
641                 res = client.readItemInNamedAuthority(authShortId, itemCSID);
642             } else if (itemShortId != null) {
643                 res = client.readNamedItemInNamedAuthority(authShortId, itemShortId);
644             } else {
645                 Assert.fail("readInternal: Internal error. One of CSID or shortId must be non-null");
646             }
647         } else {
648             Assert.fail("readInternal: Internal error. One of authCSID or authShortId must be non-null");
649         }
650
651         try {
652             assertStatusCode(res, testName);
653             // Check whether we've received a person.
654             PoxPayloadIn input = new PoxPayloadIn(res.readEntity(String.class));
655             PersonsCommon person = (PersonsCommon) extractPart(input,
656                     client.getItemCommonPartName(), PersonsCommon.class);
657             Assert.assertNotNull(person);
658             boolean showFull = true;
659             if (showFull && logger.isDebugEnabled()) {
660                 logger.debug(testName + ": returned payload:");
661                 logger.debug(objectAsXmlString(person, PersonsCommon.class));
662             }
663
664             // Check that the person item is within the expected Person Authority.
665             Assert.assertEquals(person.getInAuthority(), knownResourceId);
666
667             // Verify the number and contents of values in a repeatable field,
668             // as created in the instance record used for testing.
669             List<String> groups = person.getGroups().getGroup();
670             Assert.assertTrue(groups.size() > 0);
671             Assert.assertNotNull(groups.get(0));
672         } finally {
673                 if (res != null) {
674                 res.close();
675             }
676         }
677     }
678     
679     // Note: This test depends on server-side validation logic to require
680     // a non-null (and potentially, non-empty) displayname for each term,
681     // and will fail if that validation is not present.
682
683     /**
684      * Verify illegal item display name.
685      *
686      * @param testName the test name
687      * @throws Exception the exception
688      */
689     @Test(dataProvider = "testName", groups = {"update"})
690     public void verifyIllegalItemDisplayName(String testName) throws Exception {
691         // Perform setup for read.
692         setupRead();
693
694         // Submit the request to the service and store the response.
695         PersonAuthorityClient client = new PersonAuthorityClient();
696         Response res = client.readItem(knownResourceId, knownItemResourceId);
697         PoxPayloadIn input = null;
698         try {
699             assertStatusCode(res, testName);
700             input = new PoxPayloadIn(res.readEntity(String.class));
701         } finally {
702                 if (res != null) {
703                 res.close();
704             }
705         }
706         //
707         // Make an invalid UPDATE request, without a display name
708         //
709         PersonsCommon person = (PersonsCommon) extractPart(input,
710                 client.getItemCommonPartName(), PersonsCommon.class);
711         Assert.assertNotNull(person);
712         // Try to Update with no displayName
713         PersonTermGroupList termList = person.getPersonTermGroupList();
714         Assert.assertNotNull(termList);
715         List<PersonTermGroup> terms = termList.getPersonTermGroup();
716         Assert.assertNotNull(terms);
717         Assert.assertTrue(terms.size() > 0);
718         terms.get(0).setTermDisplayName(null);
719         terms.get(0).setTermName(null);
720
721         // Submit the updated resource to the service and store the response.
722         PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
723         output.addPart(client.getItemCommonPartName(), person);
724         setupUpdateWithInvalidBody();
725         res = client.updateItem(knownResourceId, knownItemResourceId, output);
726         try {
727             assertStatusCode(res, testName);
728         } finally {
729                 if (res != null) {
730                 res.close();
731             }
732         }
733     }
734
735     /**
736      * Read contact.
737      *
738      * @param testName the test name
739      * @throws Exception the exception
740      */
741     @Test(dataProvider = "testName", groups = {"readItem"},
742                 dependsOnMethods = {"createContact", "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItem"})
743     public void readContact(String testName) throws Exception {
744         // Perform setup.
745         setupRead();
746
747         // Submit the request to the service and store the response.
748         PersonAuthorityClient client = new PersonAuthorityClient();
749         PoxPayloadIn input = null;
750         Response res = client.readContact(knownResourceId, knownItemResourceId,
751                 knownContactResourceId);
752         try {
753             assertStatusCode(res, testName);
754             // Check whether we've received a contact.
755             input = new PoxPayloadIn(res.readEntity(String.class));
756         } finally {
757                 if (res != null) {
758                 res.close();
759             }
760         }
761
762         ContactsCommon contact = (ContactsCommon) extractPart(input,
763                 new ContactClient().getCommonPartName(), ContactsCommon.class);
764         Assert.assertNotNull(contact);
765         boolean showFull = true;
766         if (showFull && logger.isDebugEnabled()) {
767             logger.debug(testName + ": returned payload:");
768             logger.debug(objectAsXmlString(contact, ContactsCommon.class));
769         }
770         Assert.assertEquals(contact.getInAuthority(), knownResourceId);
771         Assert.assertEquals(contact.getInItem(), knownItemResourceId);
772
773     }
774
775     /**
776      * Read contact non existent.
777      *
778      * @param testName the test name
779      */
780     @Test(dataProvider = "testName", groups = {"readItem"}, dependsOnMethods = {"readContact"})
781     public void readContactNonExistent(String testName) {
782         // Perform setup.
783         setupReadNonExistent();
784
785         // Submit the request to the service and store the response.
786         PersonAuthorityClient client = new PersonAuthorityClient();
787         Response res = client.readContact(knownResourceId, knownItemResourceId,
788                         NON_EXISTENT_ID);
789         try {
790             assertStatusCode(res, testName);
791         } finally {
792                 if (res != null) {
793                 res.close();
794             }
795         }
796     }
797
798     // ---------------------------------------------------------------
799     // CRUD tests : READ_LIST tests
800     // ---------------------------------------------------------------
801
802     /**
803      * Read contact list.
804      */
805     @Test(groups = {"readList"},
806                 dependsOnMethods = {"org.collectionspace.services.client.test.AbstractAuthorityServiceTest.readItemList"})
807     public void readContactList() {
808         readContactList(knownResourceId, knownItemResourceId);
809     }
810
811     /**
812      * Read contact list.
813      *
814      * @param parentcsid the parentcsid
815      * @param itemcsid the itemcsid
816      */
817     private void readContactList(String parentcsid, String itemcsid) {
818         final String testName = "readContactList";
819
820         // Perform setup.
821         setupReadList();
822
823         // Submit the request to the service and store the response.
824         PersonAuthorityClient client = new PersonAuthorityClient();
825         AbstractCommonList list = null;
826         Response res = client.readContactList(parentcsid, itemcsid);
827         try {
828             assertStatusCode(res, testName);
829             list = res.readEntity(AbstractCommonList.class);
830         } finally {
831                 if (res != null) {
832                 res.close();
833             }
834         }
835
836         List<AbstractCommonList.ListItem> listitems =
837                 list.getListItem();
838         int nItemsReturned = listitems.size();
839         // There will be one item created, associated with a
840         // known parent resource, by the createItem test.
841         //
842         // In addition, there will be 'nItemsToCreateInList'
843         // additional items created by the createItemList test,
844         // all associated with the same parent resource.
845         int nExpectedItems = nItemsToCreateInList + 1;
846         if (logger.isDebugEnabled()) {
847             logger.debug(testName + ": Expected "
848                     + nExpectedItems + " items; got: " + nItemsReturned);
849         }
850         Assert.assertEquals(nItemsReturned, nExpectedItems);
851         
852         // Optionally output additional data about list members for debugging.
853         boolean iterateThroughList = false;
854         if (iterateThroughList && logger.isDebugEnabled()) {
855             AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
856         }
857     }
858
859     // Failure outcomes
860     // There are no failure outcome tests at present.
861     // ---------------------------------------------------------------
862     // CRUD tests : UPDATE tests
863     // ---------------------------------------------------------------
864     // Success outcomes
865     /* (non-Javadoc)
866      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
867      */
868     @Override
869 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
870 //    groups = {"update"}, dependsOnGroups = {"readItem", "readList"})
871     public void update(String testName) throws Exception {
872         // Retrieve the contents of a resource to update.
873         PersonAuthorityClient client = new PersonAuthorityClient();
874         PoxPayloadIn input = null;
875         setupRead();
876         Response res = client.read(knownResourceId);
877         try {
878             assertStatusCode(res, testName);
879             if (logger.isDebugEnabled()) {
880                 logger.debug("got PersonAuthority to update with ID: " + knownResourceId);
881             }
882             input = new PoxPayloadIn(res.readEntity(String.class));
883         } finally {
884                 if (res != null) {
885                 res.close();
886             }
887         }
888
889         PersonauthoritiesCommon personAuthority = (PersonauthoritiesCommon) extractPart(input,
890                 client.getCommonPartName(), PersonauthoritiesCommon.class);
891         Assert.assertNotNull(personAuthority);
892
893         // Update the contents of this resource.
894         personAuthority.setDisplayName("updated-" + personAuthority.getDisplayName());
895         personAuthority.setVocabType("updated-" + personAuthority.getVocabType());
896         if (logger.isDebugEnabled()) {
897             logger.debug("to be updated PersonAuthority");
898             logger.debug(objectAsXmlString(personAuthority, PersonauthoritiesCommon.class));
899         }
900
901         // Submit the updated resource to the service and store the response.
902         PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_PAYLOAD_NAME);
903         output.addPart(client.getCommonPartName(), personAuthority);
904         setupUpdate();
905         res = client.update(knownResourceId, output);
906         try {
907             assertStatusCode(res, testName);
908             // Retrieve the updated resource and verify that its contents exist.
909             input = new PoxPayloadIn(res.readEntity(String.class));
910         } finally {
911                 if (res != null) {
912                 res.close();
913             }
914         }
915
916         PersonauthoritiesCommon updatedPersonAuthority =
917                 (PersonauthoritiesCommon) extractPart(input,
918                 client.getCommonPartName(), PersonauthoritiesCommon.class);
919         Assert.assertNotNull(updatedPersonAuthority);
920
921         // Verify that the updated resource received the correct data.
922         Assert.assertEquals(updatedPersonAuthority.getDisplayName(),
923                 personAuthority.getDisplayName(),
924                 "Data in updated object did not match submitted data.");
925     }
926
927     /**
928      * Update item override -see immediate superclass.
929      *
930      * @param testName the test name
931      * @throws Exception the exception
932      */
933     @Override
934     public void updateItem(String testName) throws Exception {
935         // Retrieve the contents of a resource to update.
936         PersonAuthorityClient client = new PersonAuthorityClient();
937         PoxPayloadIn input = null;
938         setupRead();
939         Response res = client.readItem(knownResourceId, knownItemResourceId);
940         try {
941             assertStatusCode(res, testName);
942             if (logger.isDebugEnabled()) {
943                 logger.debug("got Person to update with ID: "
944                         + knownItemResourceId
945                         + " in PersonAuthority: " + knownResourceId);
946             }
947             input = new PoxPayloadIn(res.readEntity(String.class));
948         } finally {
949                 if (res != null) {
950                 res.close();
951             }
952         }
953
954         PersonsCommon person = (PersonsCommon) extractPart(input,
955                 client.getItemCommonPartName(), PersonsCommon.class);
956         Assert.assertNotNull(person);
957
958         if (logger.isDebugEnabled() == true) {
959             logger.debug("About to update the following person...");
960             logger.debug(objectAsXmlString(person, PersonsCommon.class));
961         }
962
963         // Update the contents of this resource.
964         person.setCsid(null);
965         PersonTermGroupList termList = person.getPersonTermGroupList();
966         Assert.assertNotNull(termList);
967         List<PersonTermGroup> terms = termList.getPersonTermGroup();
968         Assert.assertNotNull(terms);
969         Assert.assertTrue(terms.size() > 0);
970         String foreName = terms.get(0).getForeName();
971         String updatedForeName = "updated-" + foreName;
972         terms.get(0).setForeName(updatedForeName);
973         if (logger.isDebugEnabled()) {
974             logger.debug("to be updated Person");
975             logger.debug(objectAsXmlString(person,
976                     PersonsCommon.class));
977         }
978
979         // Submit the updated resource to the service and store the response.
980         PoxPayloadOut output = new PoxPayloadOut(PersonAuthorityClient.SERVICE_ITEM_PAYLOAD_NAME);
981         output.addPart(client.getItemCommonPartName(), person);
982         setupUpdate();
983         res = client.updateItem(knownResourceId, knownItemResourceId, output);
984         try {
985             assertStatusCode(res, testName);
986             // Retrieve the updated resource and verify that its contents exist.
987             input = new PoxPayloadIn(res.readEntity(String.class));
988         } finally {
989                 if (res != null) {
990                 res.close();
991             }
992         }
993
994         PersonsCommon updatedPerson =
995                 (PersonsCommon) extractPart(input,
996                 client.getItemCommonPartName(), PersonsCommon.class);
997         Assert.assertNotNull(updatedPerson);
998
999         if (logger.isDebugEnabled() == true) {
1000             logger.debug("Updated to following person to:");
1001             logger.debug(objectAsXmlString(updatedPerson, PersonsCommon.class));
1002         }
1003
1004         // Verify that the updated resource received the correct data.
1005         PersonTermGroupList updatedTermList = person.getPersonTermGroupList();
1006         Assert.assertNotNull(updatedTermList);
1007         List<PersonTermGroup> updatedTerms = termList.getPersonTermGroup();
1008         Assert.assertNotNull(updatedTerms);
1009         Assert.assertEquals(updatedTerms.get(0).getForeName(), updatedForeName,
1010                 "Data in updated Person did not match submitted data.");
1011     }
1012
1013     /**
1014      * Update contact.
1015      *
1016      * @param testName the test name
1017      * @throws Exception the exception
1018      */
1019     @Test(dataProvider = "testName", groups = {"update"},
1020                 dependsOnMethods = {"readContact", "testContactSubmitRequest",
1021                         "org.collectionspace.services.client.test.AbstractAuthorityServiceTest.updateItem"})
1022     public void updateContact(String testName) throws Exception {
1023         String contactsCommonLabel = new ContactClient().getCommonPartName();
1024
1025         // Retrieve the contents of a resource to update.
1026         PersonAuthorityClient client = new PersonAuthorityClient();
1027         PoxPayloadIn input = null;
1028         setupRead();
1029         Response res = client.readContact(knownResourceId, knownItemResourceId,
1030                         knownContactResourceId);
1031         try {
1032             assertStatusCode(res, testName);
1033             if (logger.isDebugEnabled()) {
1034                 logger.debug("got Contact to update with ID: "
1035                         + knownContactResourceId
1036                         + " in item: " + knownItemResourceId
1037                         + " in parent: " + knownResourceId);
1038             }
1039             input = new PoxPayloadIn(res.readEntity(String.class));
1040         } finally {
1041                 if (res != null) {
1042                 res.close();
1043             }
1044         }
1045
1046         ContactsCommon contact = (ContactsCommon) extractPart(input,
1047                 contactsCommonLabel, ContactsCommon.class);
1048         Assert.assertNotNull(contact);
1049
1050         // Verify the contents of this resource
1051         AddressGroupList addressGroupList = contact.getAddressGroupList();
1052         Assert.assertNotNull(addressGroupList);
1053         List<AddressGroup> addressGroups = addressGroupList.getAddressGroup();
1054         Assert.assertNotNull(addressGroups);
1055         Assert.assertTrue(addressGroups.size() > 0);
1056         String addressPlace1 = addressGroups.get(0).getAddressPlace1();
1057         Assert.assertNotNull(addressPlace1);
1058
1059         // Update the contents of this resource.
1060         addressGroups.get(0).setAddressPlace1("updated-" + addressPlace1);
1061         contact.setAddressGroupList(addressGroupList);
1062         if (logger.isDebugEnabled()) {
1063             logger.debug("to be updated Contact");
1064             logger.debug(objectAsXmlString(contact,
1065                     ContactsCommon.class));
1066         }
1067
1068         // Submit the updated resource to the service and store the response.
1069         PoxPayloadOut output = new PoxPayloadOut(ContactClient.SERVICE_PAYLOAD_NAME);
1070         output.addPart(contactsCommonLabel, contact);
1071         setupUpdate();
1072         res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
1073         try {
1074             assertStatusCode(res, testName);
1075             // Retrieve the updated resource and verify that its contents exist.
1076             input = new PoxPayloadIn(res.readEntity(String.class));;
1077         } finally {
1078                 if (res != null) {
1079                 res.close();
1080             }
1081         }
1082         ContactsCommon updatedContact = (ContactsCommon) extractPart(input,
1083                 contactsCommonLabel, ContactsCommon.class);
1084         Assert.assertNotNull(updatedContact);
1085
1086         // Verify that the updated resource received the correct data.
1087         Assert.assertEquals(updatedContact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
1088                 contact.getAddressGroupList().getAddressGroup().get(0).getAddressPlace1(),
1089                 "Data in updated object did not match submitted data.");
1090     }
1091
1092     /**
1093      * Update non existent contact.
1094      *
1095      * @param testName the test name
1096      * @throws Exception the exception
1097      */
1098     @Test(dataProvider = "testName", groups = {"update"},
1099                 dependsOnMethods = {"updateContact", "testContactSubmitRequest"})
1100     public void updateNonExistentContact(String testName) throws Exception {
1101         // Currently a no-op test
1102     }
1103
1104     // ---------------------------------------------------------------
1105     // CRUD tests : DELETE tests
1106     // ---------------------------------------------------------------
1107     // Success outcomes
1108     // Note: delete sub-resources in ascending hierarchical order,
1109     // before deleting their parents.
1110     /**
1111      * Delete contact.
1112      *
1113      * @param testName the test name
1114      * @throws Exception the exception
1115      */
1116     @Test(dataProvider = "testName", groups = {"delete"},
1117                 dependsOnMethods = {"updateContact"})
1118     public void deleteContact(String testName) throws Exception {
1119         if (logger.isDebugEnabled()) {
1120             logger.debug("parentcsid =" + knownResourceId
1121                     + " itemcsid = " + knownItemResourceId
1122                     + " csid = " + knownContactResourceId);
1123         }
1124
1125         // Submit the request to the service and store the response.
1126         PersonAuthorityClient client = new PersonAuthorityClient();
1127         setupDelete();
1128         Response res = client.deleteContact(knownResourceId, knownItemResourceId, 
1129                         knownContactResourceId);
1130         try {
1131                 assertStatusCode(res, testName);
1132         } finally {
1133                 if (res != null) {
1134                         res.close();
1135                 }
1136         }
1137     }
1138
1139     @Override
1140     public void delete(String testName) throws Exception {
1141         // Do nothing.  See localDelete().  This ensure proper test order.
1142     }
1143     
1144     @Test(dataProvider = "testName", dependsOnMethods = {"localDeleteItem"})    
1145     public void localDelete(String testName) throws Exception {
1146         super.delete(testName);
1147     }
1148
1149     @Override
1150     public void deleteItem(String testName) throws Exception {
1151         // Do nothing.  We need to wait until after the test "localDelete" gets run.  When it does,
1152         // its dependencies will get run first and then we can call the base class' delete method.
1153     }
1154     
1155     @Test(dataProvider = "testName", groups = {"delete"},
1156         dependsOnMethods = {"verifyIllegalItemDisplayName", "testContactSubmitRequest", "deleteContact"})
1157     public void localDeleteItem(String testName) throws Exception {
1158         super.deleteItem(testName);
1159     }
1160
1161     /**
1162      * Delete non existent contact.
1163      *
1164      * @param testName the test name
1165      */
1166     @Test(dataProvider = "testName", groups = {"delete"},
1167                 dependsOnMethods = {"deleteContact"})
1168     public void deleteNonExistentContact(String testName) {
1169         // Submit the request to the service and store the response.
1170         PersonAuthorityClient client = new PersonAuthorityClient();
1171         setupDeleteNonExistent();
1172         Response res = client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
1173         try {
1174                 assertStatusCode(res, testName);
1175         } finally {
1176                 if (res != null) {
1177                         res.close();
1178                 }
1179         }
1180     }
1181
1182     /**
1183      * Test contact submit request.
1184      */
1185     @Test(dataProvider = "testName",
1186                 dependsOnMethods = {"createContact", "readContact", "testItemSubmitRequest"})
1187     public void testContactSubmitRequest(String testName) {
1188
1189         // Expected status code: 200 OK
1190         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
1191
1192         // Submit the request to the service and store the response.
1193         String method = ServiceRequestType.READ.httpMethodName();
1194         String url = getContactResourceURL(knownResourceId,
1195                 knownItemResourceId, knownContactResourceId);
1196         int statusCode = submitRequest(method, url);
1197
1198         // Check the status code of the response: does it match
1199         // the expected response(s)?
1200         if (logger.isDebugEnabled()) {
1201             logger.debug("testContactSubmitRequest: url=" + url
1202                     + " status=" + statusCode);
1203         }
1204         Assert.assertEquals(statusCode, EXPECTED_STATUS);
1205
1206     }
1207
1208     // ---------------------------------------------------------------
1209     // Cleanup of resources created during testing
1210     // ---------------------------------------------------------------
1211     /**
1212      * Deletes all resources created by tests, after all tests have been run.
1213      *
1214      * This cleanup method will always be run, even if one or more tests fail.
1215      * For this reason, it attempts to remove all resources created
1216      * at any point during testing, even if some of those resources
1217      * may be expected to be deleted by certain tests.
1218      */
1219     @AfterClass(alwaysRun = true)
1220     @Override
1221     public void cleanUp() {
1222         String noTest = System.getProperty("noTestCleanup");
1223         if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
1224             if (logger.isDebugEnabled()) {
1225                 logger.debug("Skipping Cleanup phase ...");
1226             }
1227             return;
1228         }
1229         
1230         if (logger.isDebugEnabled()) {
1231             logger.debug("Cleaning up temporary resources created for testing ...");
1232         }
1233         
1234         String parentResourceId;
1235         String itemResourceId;
1236         String contactResourceId;
1237         // Clean up contact resources.
1238         PersonAuthorityClient client = new PersonAuthorityClient();
1239         parentResourceId = this.getKnowResourceId();
1240         for (Map.Entry<String, String> entry : allContactResourceIdsCreated.entrySet()) {
1241             contactResourceId = entry.getKey();
1242             itemResourceId = entry.getValue();
1243             // Note: Any non-success responses from the delete operation
1244             // below are ignored and not reported.
1245             Response res = client.deleteContact(parentResourceId, itemResourceId,
1246                         contactResourceId);
1247             res.close();
1248         }
1249         //
1250         // Finally, clean call our superclass' cleanUp method.
1251         //
1252         super.cleanUp();
1253     }
1254
1255     // ---------------------------------------------------------------
1256     // Utility methods used by tests above
1257     // ---------------------------------------------------------------
1258     /**
1259      * Gets the contact service path component.
1260      *
1261      * @return the contact service path component
1262      */
1263     public String getContactServicePathComponent() {
1264         return ContactClient.SERVICE_PATH_COMPONENT;
1265     }
1266
1267     /**
1268      * Returns the root URL for the item service.
1269      *
1270      * This URL consists of a base URL for all services, followed by
1271      * a path component for the owning parent, followed by the
1272      * path component for the items.
1273      *
1274      * @param  parentResourceIdentifier  An identifier (such as a UUID) for the
1275      * parent authority resource of the relevant item resource.
1276      *
1277      * @return The root URL for the item service.
1278      */
1279     protected String getItemServiceRootURL(String parentResourceIdentifier) {
1280         return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
1281     }
1282
1283     /**
1284      * Returns the URL of a specific item resource managed by a service, and
1285      * designated by an identifier (such as a universally unique ID, or UUID).
1286      *
1287      * @param  parentResourceIdentifier  An identifier (such as a UUID) for the
1288      * parent authority resource of the relevant item resource.
1289      *
1290      * @param  itemResourceIdentifier  An identifier (such as a UUID) for an
1291      * item resource.
1292      *
1293      * @return The URL of a specific item resource managed by a service.
1294      */
1295     protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
1296         return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
1297     }
1298
1299     /**
1300      * Returns the root URL for the contact service.
1301      *
1302      * This URL consists of a base URL for all services, followed by
1303      * a path component for the owning authority, followed by the
1304      * path component for the owning item, followed by the path component
1305      * for the contact service.
1306      *
1307      * @param  parentResourceIdentifier  An identifier (such as a UUID) for the
1308      * parent authority resource of the relevant item resource.
1309      *
1310      * @param  itemResourceIdentifier  An identifier (such as a UUID) for an
1311      * item resource.
1312      *
1313      * @return The root URL for the contact service.
1314      */
1315     protected String getContactServiceRootURL(String parentResourceIdentifier,
1316             String itemResourceIdentifier) {
1317         return getItemResourceURL(parentResourceIdentifier, itemResourceIdentifier) + "/"
1318                 + getContactServicePathComponent();
1319     }
1320
1321     /**
1322      * Returns the URL of a specific contact resource managed by a service, and
1323      * designated by an identifier (such as a universally unique ID, or UUID).
1324      *
1325      * @param  parentResourceIdentifier  An identifier (such as a UUID) for the
1326      * parent resource of the relevant item resource.
1327      *
1328      * @param  resourceIdentifier  An identifier (such as a UUID) for an
1329      * item resource.
1330      *
1331      * @return The URL of a specific resource managed by a service.
1332      */
1333     protected String getContactResourceURL(String parentResourceIdentifier,
1334             String itemResourceIdentifier, String contactResourceIdentifier) {
1335         return getContactServiceRootURL(parentResourceIdentifier,
1336                 itemResourceIdentifier) + "/" + contactResourceIdentifier;
1337     }
1338
1339         @Override
1340         public void authorityTests(String testName) {
1341                 // TODO Auto-generated method stub
1342                 
1343         }
1344    
1345         @Override
1346         protected PersonsCommon updateItemInstance(PersonsCommon personsCommon) {
1347                             
1348             PersonTermGroupList termList = personsCommon.getPersonTermGroupList();
1349             Assert.assertNotNull(termList);
1350             List<PersonTermGroup> terms = termList.getPersonTermGroup();
1351             Assert.assertNotNull(terms);
1352             Assert.assertTrue(terms.size() > 0);
1353             terms.get(0).setTermDisplayName("updated-" + terms.get(0).getTermDisplayName());
1354             terms.get(0).setTermName("updated-" + terms.get(0).getTermName());
1355             personsCommon.setPersonTermGroupList(termList);
1356
1357             return personsCommon;
1358         }
1359
1360         @Override
1361         protected void compareUpdatedItemInstances(PersonsCommon original,
1362                         PersonsCommon updated) throws Exception {
1363             
1364             PersonTermGroupList originalTermList = original.getPersonTermGroupList();
1365             Assert.assertNotNull(originalTermList);
1366             List<PersonTermGroup> originalTerms = originalTermList.getPersonTermGroup();
1367             Assert.assertNotNull(originalTerms);
1368             Assert.assertTrue(originalTerms.size() > 0);
1369             
1370             PersonTermGroupList updatedTermList = updated.getPersonTermGroupList();
1371             Assert.assertNotNull(updatedTermList);
1372             List<PersonTermGroup> updatedTerms = updatedTermList.getPersonTermGroup();
1373             Assert.assertNotNull(updatedTerms);
1374             Assert.assertTrue(updatedTerms.size() > 0);
1375             
1376             Assert.assertEquals(updatedTerms.get(0).getTermDisplayName(),
1377                 originalTerms.get(0).getTermDisplayName(),
1378                 "Value in updated record did not match submitted data.");
1379         }
1380
1381         @Override
1382         protected PoxPayloadOut createInstance(String commonPartName,
1383                         String identifier) {
1384         String shortId = identifier;
1385         String displayName = "displayName-" + shortId;
1386         PoxPayloadOut result =
1387                 PersonAuthorityClientUtils.createPersonAuthorityInstance(
1388                 displayName, shortId, commonPartName);
1389         return result;
1390         }
1391         
1392         @Override
1393         protected PoxPayloadOut createNonExistenceInstance(String commonPartName,
1394                         String identifier) {
1395         String displayName = "displayName-NON_EXISTENT_ID";
1396         PoxPayloadOut result = PersonAuthorityClientUtils.createPersonAuthorityInstance(
1397                 displayName, "NON_EXISTENT_SHORT_ID", commonPartName);
1398         return result;
1399         }
1400         
1401     protected PoxPayloadOut createNonExistenceItemInstance(String commonPartName, String identifier) {
1402         Map<String, String> nonexMap = new HashMap<String, String>();
1403         nonexMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, "nonEX");
1404         nonexMap.put(PersonJAXBSchema.GENDER, "male");
1405         
1406         List<PersonTermGroup> terms = new ArrayList<PersonTermGroup>();
1407         PersonTermGroup term = new PersonTermGroup();
1408         term.setTermDisplayName("John Wayne");
1409         term.setTermName("John Wayne");
1410         term.setForeName("John");
1411         term.setSurName("Wayne");
1412         terms.add(term);
1413         
1414         Map<String, List<String>> nonexRepeatablesMap = new HashMap<String, List<String>>();
1415         PoxPayloadOut result =
1416                 PersonAuthorityClientUtils.createPersonInstance(NON_EXISTENT_ID,
1417                 null, //PersonAuthorityClientUtils.createPersonAuthRefName(NON_EXISTENT_ID, null),
1418                 nonexMap, terms, nonexRepeatablesMap, commonPartName);
1419         return result;
1420     }
1421                 
1422     @Override
1423         protected PersonauthoritiesCommon updateInstance(PersonauthoritiesCommon personauthoritiesCommon) {
1424                 PersonauthoritiesCommon result = new PersonauthoritiesCommon();
1425                 
1426         result.setDisplayName("updated-" + personauthoritiesCommon.getDisplayName());
1427         result.setVocabType("updated-" + personauthoritiesCommon.getVocabType());
1428         
1429                 return result;
1430         }
1431
1432         @Override
1433         protected void compareUpdatedInstances(PersonauthoritiesCommon original,
1434                         PersonauthoritiesCommon updated) throws Exception {
1435         // Verify that the updated resource received the correct data.
1436         Assert.assertEquals(updated.getDisplayName(),
1437                         original.getDisplayName(),
1438                 "Display name in updated object did not match submitted data.");
1439         }
1440
1441         @Override
1442         protected void verifyReadItemInstance(PersonsCommon item) throws Exception {
1443                 // Do nothing for now.  Add more 'read' validation checks here if applicable.
1444         }        
1445 }