]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
a9b1cf7dc0673726eda6de52f7c42d1e38e9f010
[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.io.UnsupportedEncodingException;
26 import java.net.URLEncoder;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31 import javax.ws.rs.core.Response;
32
33 import org.collectionspace.services.PersonJAXBSchema;
34 import org.collectionspace.services.client.CollectionSpaceClient;
35 import org.collectionspace.services.client.PersonAuthorityClient;
36 import org.collectionspace.services.client.PersonAuthorityClientUtils;
37 import org.collectionspace.services.client.PoxPayloadOut;
38 import org.collectionspace.services.jaxb.AbstractCommonList;
39 import org.collectionspace.services.person.PersonTermGroup;
40 import org.jboss.resteasy.client.ClientResponse;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43 import org.testng.Assert;
44 import org.testng.annotations.AfterClass;
45 import org.testng.annotations.BeforeClass;
46 import org.testng.annotations.Test;
47
48 /**
49  * PersonAuthoritySearchTest, carries out search (e.g. partial
50  * term matching) tests against a deployed and running PersonAuthority Service.
51  *
52  * $LastChangedRevision: 753 $
53  * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
54  */
55 public class PersonAuthoritySearchTest extends BaseServiceTest<AbstractCommonList> {
56
57     private final String CLASS_NAME = PersonAuthoritySearchTest.class.getName();
58     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
59     
60         @Override
61         public String getServicePathComponent() {
62                 return PersonAuthorityClient.SERVICE_PATH_COMPONENT;
63         }
64
65         @Override
66         protected String getServiceName() {
67                 return PersonAuthorityClient.SERVICE_NAME;
68         }
69     
70     final String UTF8_CHARSET_NAME = "UTF-8";
71     
72     // Test name for partial term matching: Lech Wałęsa
73     //
74     // For details regarding the łę characters in the last name, see:
75     // http://en.wikipedia.org/wiki/L_with_stroke
76     // http://en.wikipedia.org/wiki/%C4%98
77     //
78     // Forename
79     final String TEST_PARTIAL_TERM_FORE_NAME = "Lech";
80     //
81     // Surname (contains single quote character)
82     final String TEST_PARTIAL_TERM_SUR_NAME_QUOTE = "O'Hara";
83     //
84     // Surname (contains two non-USASCII range Unicode UTF-8 characters)
85     final String TEST_PARTIAL_TERM_SUR_NAME_UNICODE = "Wałęsa";
86         // Wrong: "Wa" + "\u0142" + "\u0119" + "sa";
87         // Should also work: "Wa" + '\u0142' + '\u0119' + "sa";
88         // Should also work: "Wa\u0142\u0119sa";
89     //
90     //
91     // Displayname
92     final String TEST_PARTIAL_TERM_DISPLAY_NAME_UNICODE =
93             TEST_PARTIAL_TERM_FORE_NAME + " " + TEST_PARTIAL_TERM_SUR_NAME_UNICODE;
94     //
95     // Displayname
96     final String TEST_PARTIAL_TERM_DISPLAY_NAME_QUOTE =
97             TEST_PARTIAL_TERM_FORE_NAME + " " + TEST_PARTIAL_TERM_SUR_NAME_QUOTE;
98     //
99     // shortId
100     final String TEST_SHORT_ID_UNICODE = "lechWalesa";
101     //
102     // shortId
103     final String TEST_SHORT_ID_QUOTE = "lechOHara";
104     
105     final String TEST_KWD_BIRTH_PLACE = "Popowo, Poland";
106
107     final String TEST_KWD_UTF8_STYLE = "Appliqu"+'\u00e8'+"d Arts";
108     
109     final String TEST_KWD_BIO_NOTE_NO_QUOTES = 
110         "This is a silly bionote with no so-called quotes.";
111     
112     final String TEST_KWD_BIO_NOTE_DBL_QUOTES = 
113         "This is a silly \"bionote\" for testing so called quote_handling";
114
115     final String TEST_KWD_NO_MATCH = "Foobar";
116
117     // Non-existent partial term name (first letters of each of the words
118     // in a pangram for the English alphabet).
119     private static final String TEST_PARTIAL_TERM_NON_EXISTENT = "jlmbsoq";
120
121     /** The known resource id. */
122     private String knownResourceId = null;
123     
124     /** The known resource ref name. */
125     //private String knownResourceRefName = null;
126     
127     /** The known item resource id. */
128     private String knownItemResourceId = null;
129
130     // The resource ID of an item resource used for partial term matching tests.
131     private String knownItemPartialTermResourceId = null;
132
133     private List<String> allResourceIdsCreated = new ArrayList<String>();
134     
135     /** The all item resource ids created. */
136     private Map<String, String> allItemResourceIdsCreated =
137         new HashMap<String, String>();
138
139     // The number of matches expected on each partial term.
140     final int NUM_MATCHES_EXPECTED_COMMON = 2;
141     final int NUM_MATCHES_EXPECTED_SPECIFIC = 1;
142
143     // The minimum number of characters that must be included
144     // a partial term, in order to permit matching to occur.
145     final int PARTIAL_TERM_MIN_LENGTH = 1;
146
147     /* (non-Javadoc)
148      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
149      */
150     @Override
151     protected CollectionSpaceClient getClientInstance() {
152         return new PersonAuthorityClient();
153     }
154     
155     /* (non-Javadoc)
156      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
157      */
158     @Override
159     protected AbstractCommonList getCommonList(
160                     ClientResponse<AbstractCommonList> response) {
161     return response.getEntity(AbstractCommonList.class);
162     }
163
164     private String getPartialTermCommon() {
165         return TEST_PARTIAL_TERM_FORE_NAME;
166     }
167
168     private String getPartialTermUtf8() {
169         return TEST_PARTIAL_TERM_SUR_NAME_UNICODE;
170     }
171
172     private String getPartialTermQuote() {
173         return TEST_PARTIAL_TERM_SUR_NAME_QUOTE;
174     }
175
176     private String getPartialTermNonExistent() {
177         return TEST_PARTIAL_TERM_NON_EXISTENT;
178     }
179
180     private String getPartialTermMinimumLength() {
181         String partialTerm = getPartialTermCommon();
182         if (partialTerm == null || partialTerm.trim().isEmpty()) {
183             return partialTerm;
184         }
185         if (partialTerm.length() > PARTIAL_TERM_MIN_LENGTH) {
186             return partialTerm.substring(0, PARTIAL_TERM_MIN_LENGTH);
187         } else {
188           return partialTerm;
189         }
190     }
191
192     private String getKwdTerm() {
193         return TEST_KWD_BIRTH_PLACE;
194     }
195
196     private String getKwdTermUTF8() {
197         return TEST_KWD_UTF8_STYLE;
198     }
199
200     private String getKwdTermNonExistent() {
201         return TEST_KWD_NO_MATCH;
202     }
203
204     @BeforeClass
205     public void setup() {
206         try {
207             createAuthority();
208         } catch (Exception e) {
209             Assert.fail("Could not create new Authority for search tests.", e);
210         }
211         try {
212             createItemsInAuthorityForPartialTermMatch(knownResourceId, null ); //knownResourceRefName);
213         } catch (Exception e) {
214             Assert.fail("Could not create new item in Authority for search tests.", e);
215         }
216     }
217  
218     // ---------------------------------------------------------------
219     // CRUD tests : READ_LIST tests by partial term match.
220     // ---------------------------------------------------------------
221
222     // Success outcomes
223
224     /**
225      * Reads an item list by partial term.
226      */
227     @Test(dataProvider="testName", groups = {"readListByPartialTerm"})
228     public void partialTermMatch(String testName) {
229         int numMatchesFound = 0;
230         String partialTerm = getPartialTermCommon();
231         if (logger.isDebugEnabled()) {
232             logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
233         }
234         numMatchesFound = readItemListWithFilters(testName, knownResourceId, partialTerm, null);
235         if (logger.isDebugEnabled()) {
236             logger.debug("Found " + numMatchesFound + " match(es), expected " +
237                 NUM_MATCHES_EXPECTED_COMMON + " match(es).");
238         }
239         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_COMMON);
240     }
241
242     /**
243      * Reads an item list by partial term, with a partial term that consists
244      * of an all-lowercase variation of the expected match, to test case-insensitive
245      * matching.
246      */
247     @Test(dataProvider="testName", groups = {"readListByPartialTerm"},
248                 dependsOnMethods = {"partialTermMatch"})
249     public void partialTermMatchCaseInsensitiveLowerCase(String testName) {
250         int numMatchesFound = 0;
251
252         final String partialTerm = getPartialTermCommon().toLowerCase();
253         if (logger.isDebugEnabled()) {
254             logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
255         }
256         numMatchesFound =
257                 readItemListWithFilters(testName, knownResourceId, partialTerm, null);
258                 if (logger.isDebugEnabled()) {
259         logger.debug("Found " + numMatchesFound + " match(es), expected " +
260                         NUM_MATCHES_EXPECTED_COMMON + " match(es).");
261         }
262         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_COMMON);
263     }
264
265     /**
266      * Reads an item list by partial term, with a partial term that consists
267      * of an all-uppercase variation of the expected match, to test case-insensitive
268      * matching.
269      */
270     @Test(dataProvider="testName",
271         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
272     public void partialTermMatchCaseInsensitiveUpperCase(String testName) {
273         int numMatchesFound = 0;
274
275         final String partialTerm = getPartialTermCommon().toUpperCase();
276         if (logger.isDebugEnabled()) {
277             logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
278         }
279         numMatchesFound =
280                 readItemListWithFilters(testName, knownResourceId, partialTerm, null);
281         if (logger.isDebugEnabled()) {
282             logger.debug("Found " + numMatchesFound + " match(es), expected " +
283                         NUM_MATCHES_EXPECTED_COMMON + " match(es).");
284         }
285         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_COMMON);
286     }
287
288     /**
289      * Reads an item list by partial term, with a partial term that is of
290      * the minimum character length that may be expected to be matched.
291      */
292     @Test(dataProvider="testName",
293         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
294     public void partialTermMatchMinimumLength(String testName) {
295         int numMatchesFound = 0;
296         String partialTerm = getPartialTermMinimumLength();
297         if (logger.isDebugEnabled()) {
298             logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
299         }
300         numMatchesFound = readItemListWithFilters(testName, knownResourceId, partialTerm, null);
301         // Zero matches are expected on a non-existent term.
302         if (logger.isDebugEnabled()) {
303             logger.debug("Found " + numMatchesFound + " match(es), expected " +
304                         NUM_MATCHES_EXPECTED_COMMON + " match(es).");
305         }
306         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_COMMON);
307     }
308
309     /**
310      * Reads an item list by partial term, with a partial term that contains
311      * at least one Unicode UTF-8 character (outside the USASCII range).
312      */
313     @Test(dataProvider="testName",
314         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
315     public void partialTermMatchUTF8(String testName) {
316         int numMatchesFound = 0;
317         String partialTerm = getPartialTermUtf8();
318         String ptEncoded;
319         try {
320                 ptEncoded = URLEncoder.encode(partialTerm, UTF8_CHARSET_NAME);
321         }
322         catch (UnsupportedEncodingException ex) {
323           throw new RuntimeException("Broken VM does not support UTF-8");
324         }
325         if (logger.isDebugEnabled()) {
326             logger.debug("Attempting match on partial term '" + partialTerm + "', Encoded:'"+ptEncoded+"' ...");
327         }
328         numMatchesFound =
329                 readItemListWithFilters(testName, knownResourceId, partialTerm, null);
330         if (logger.isDebugEnabled()) {
331             logger.debug("Found " + numMatchesFound + " match(es), expected " +
332                 NUM_MATCHES_EXPECTED_SPECIFIC + " match(es).");
333         }
334         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_SPECIFIC);
335     }
336     
337     /**
338      * Reads an item list by partial term, with a partial term that contains
339      * at least one Unicode UTF-8 character (outside the USASCII range).
340      */
341     @Test(dataProvider="testName",
342         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
343     public void partialTermMatchQuote(String testName) {
344         int numMatchesFound = 0;
345         String partialTerm = getPartialTermQuote();
346         if (logger.isDebugEnabled()) {
347             logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
348         }
349         numMatchesFound =
350                 readItemListWithFilters(testName, knownResourceId, partialTerm, null);
351         if (logger.isDebugEnabled()) {
352             logger.debug("Found " + numMatchesFound + " match(es), expected " +
353                 NUM_MATCHES_EXPECTED_SPECIFIC + " match(es).");
354         }
355         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_SPECIFIC);
356     }
357
358     /**
359      * Finds terms by keywords.
360      */
361     @Test(dataProvider="testName", groups = {"readListByKwdTerm"})
362     public void keywordTermMatch(String testName) {
363         int numMatchesFound = 0;
364         String kwdTerm = getKwdTerm();
365         if (logger.isDebugEnabled()) {
366             logger.debug("Attempting match on kwd term '" + kwdTerm + "' ...");
367         }
368         numMatchesFound = readItemListWithFilters(testName, knownResourceId, null, kwdTerm);
369         if (logger.isDebugEnabled()) {
370             logger.debug("Found " + numMatchesFound + " match(es), expected " +
371                     NUM_MATCHES_EXPECTED_COMMON + " match(es).");
372         }
373         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_COMMON);
374     }
375
376     /**
377      * Finds terms by keywords.
378      */
379     @Test(dataProvider="testName",
380         groups = {"readListByKwdTerm"}, dependsOnMethods = {"keywordTermMatch"})
381     public void keywordTermMatchUTF8(String testName) {
382         int numMatchesFound = 0;
383         String kwdTerm = getKwdTermUTF8();
384         if (logger.isDebugEnabled()) {
385             logger.debug("Attempting match on kwd term '" + kwdTerm + "' ...");
386         }
387         numMatchesFound = readItemListWithFilters(testName, knownResourceId, null, kwdTerm);
388         if (logger.isDebugEnabled()) {
389             logger.debug("Found " + numMatchesFound + " match(es), expected " +
390                 NUM_MATCHES_EXPECTED_COMMON + " match(es).");
391         }
392         Assert.assertEquals(numMatchesFound, NUM_MATCHES_EXPECTED_COMMON);
393     }
394
395     
396     
397     // Failure outcomes
398
399     /**
400      * Reads an item list by partial term, with a partial term that is not
401      * expected to be matched by any term in any resource.
402      */
403     @Test(dataProvider="testName",
404         groups = {"readListByPartialTerm"}, dependsOnMethods = {"partialTermMatch"})
405     public void partialTermMatchOnNonexistentTerm(String testName) {
406         int numMatchesFound = 0;
407         int ZERO_MATCHES_EXPECTED = 0;
408         String partialTerm = getPartialTermNonExistent();
409         if (logger.isDebugEnabled()) {
410             logger.debug("Attempting match on partial term '" + partialTerm + "' ...");
411         }
412         numMatchesFound = readItemListWithFilters(testName, knownResourceId, partialTerm, null);
413         // Zero matches are expected on a non-existent term.
414         if (logger.isDebugEnabled()) {
415             logger.debug("Found " + numMatchesFound + " match(es), expected " +
416                 ZERO_MATCHES_EXPECTED + " match(es).");
417         }
418         Assert.assertEquals(numMatchesFound, ZERO_MATCHES_EXPECTED);
419     }
420
421     /**
422      * Reads an item list by partial term, with a partial term that is not
423      * expected to be matched by any term in any resource.
424      */
425     @Test(dataProvider="testName", groups = {"readListByKwdTerm"},
426                 dependsOnMethods = {"keywordTermMatch"})
427     public void keywordTermMatchOnNonexistentTerm(String testName) {
428         int numMatchesFound = 0;
429         int ZERO_MATCHES_EXPECTED = 0;
430         String kwdTerm = getKwdTermNonExistent();
431         if (logger.isDebugEnabled()) {
432             logger.debug("Attempting match on kwd term '" + kwdTerm + "' ...");
433         }
434         numMatchesFound = readItemListWithFilters(testName, knownResourceId, null, kwdTerm);
435         // Zero matches are expected on a non-existent term.
436         if (logger.isDebugEnabled()) {
437             logger.debug("Found " + numMatchesFound + " match(es), expected " +
438                 ZERO_MATCHES_EXPECTED + " match(es).");
439         }
440         Assert.assertEquals(numMatchesFound, ZERO_MATCHES_EXPECTED);
441     }
442
443     /**
444      * Reads an item list by partial term or keywords, given an authority and a term.
445      * Only one of partialTerm or keywords should be specified. 
446      * If both are specified, keywords will be ignored.
447      * 
448      * @param testName Calling test name
449      * @param authorityCsid The CSID of the authority within which partial term matching
450      *     will be performed.
451      * @param partialTerm A partial term to match item resources.
452      * @param partialTerm A keyword list to match item resources.
453      * @return The number of item resources matched by the partial term.
454      */
455     private int readItemListWithFilters(String testName, 
456                 String authorityCsid, String partialTerm, String keywords) {
457
458         // Perform setup.
459         int expectedStatusCode = Response.Status.OK.getStatusCode();
460         ServiceRequestType requestType = ServiceRequestType.READ_LIST;
461         testSetup(expectedStatusCode, requestType);
462
463         // Submit the request to the service and store the response.
464         PersonAuthorityClient client = new PersonAuthorityClient();
465         ClientResponse<AbstractCommonList> res = null;
466         if (authorityCsid != null) {
467                 res = client.readItemList(authorityCsid, partialTerm, keywords);
468         } else {
469             Assert.fail("readItemListByPartialTerm passed null csid!");
470         }
471         AbstractCommonList list = null;
472         try {
473             assertStatusCode(res, testName);
474             list = res.getEntity();
475         } finally {
476                 if (res != null) {
477                 res.releaseConnection();
478             }
479         }
480
481         List<AbstractCommonList.ListItem> items = list.getListItem();
482         int nItemsReturned = items.size();
483
484         return nItemsReturned;
485     }
486     
487     // ---------------------------------------------------------------
488     // Cleanup of resources created during testing
489     // ---------------------------------------------------------------
490     
491     /**
492      * Deletes all resources created by tests, after all tests have been run.
493      *
494      * This cleanup method will always be run, even if one or more tests fail.
495      * For this reason, it attempts to remove all resources created
496      * at any point during testing, even if some of those resources
497      * may be expected to be deleted by certain tests.
498      */
499     @AfterClass(alwaysRun=true)
500     public void cleanUp() {
501         String noTest = System.getProperty("noTestCleanup");
502         if(Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
503             if (logger.isDebugEnabled()) {
504                 logger.debug("Skipping Cleanup phase ...");
505             }
506             return;
507         }
508         if (logger.isDebugEnabled()) {
509             logger.debug("Cleaning up temporary resources created for testing ...");
510         }
511         String parentResourceId;
512         String itemResourceId;
513         PersonAuthorityClient client = new PersonAuthorityClient();
514         parentResourceId = knownResourceId;
515         // Clean up item resources.
516         for (Map.Entry<String, String> entry : allItemResourceIdsCreated.entrySet()) {
517             itemResourceId = entry.getKey();
518             parentResourceId = entry.getValue();
519             // Note: Any non-success responses from the delete operation
520             // below are ignored and not reported.
521             ClientResponse<Response> res =
522                 client.deleteItem(parentResourceId, itemResourceId);
523             res.releaseConnection();
524         }
525         // Clean up authority resources.
526         for (String resourceId : allResourceIdsCreated) {
527             // Note: Any non-success responses are ignored and not reported.
528             client.delete(resourceId).releaseConnection();
529         }
530     }
531
532     // ---------------------------------------------------------------
533     // Utility methods used by tests above
534     // ---------------------------------------------------------------
535
536     // ---------------------------------------------------------------
537     // Utilities: setup routines for search tests
538     // ---------------------------------------------------------------
539
540     public void createAuthority() throws Exception {
541
542         String testName = "createAuthority";
543         if (logger.isDebugEnabled()) {
544             logger.debug(getTestBanner(testName, CLASS_NAME));
545         }
546
547         // Perform setup.
548         int expectedStatusCode = Response.Status.CREATED.getStatusCode();
549         ServiceRequestType requestType = ServiceRequestType.CREATE;
550         testSetup(expectedStatusCode, requestType);
551
552         // Submit the request to the service and store the response.
553         PersonAuthorityClient client = new PersonAuthorityClient();
554         String shortId = createIdentifier();
555         String displayName = "displayName-" + shortId;
556         //String baseRefName = PersonAuthorityClientUtils.createPersonAuthRefName(shortId, null);
557         PoxPayloadOut multipart =
558             PersonAuthorityClientUtils.createPersonAuthorityInstance(
559             displayName, shortId, client.getCommonPartName());
560
561         String newID = null;
562         ClientResponse<Response> res = client.create(multipart);
563         try {
564             assertStatusCode(res, testName);
565             newID = PersonAuthorityClientUtils.extractId(res);
566         } finally {
567                 if (res != null) {
568                 res.releaseConnection();
569             }
570         }
571         // Store the refname from the first resource created
572         // for additional tests below.
573         //knownResourceRefName = baseRefName;
574         // Store the ID returned from the first resource created
575         // for additional tests below.
576         if (knownResourceId == null){
577             knownResourceId = newID;
578             //knownResourceRefName = baseRefName;
579         }
580
581         // Store the IDs from every resource created by tests,
582         // so they can be deleted after tests have been run.
583         allResourceIdsCreated.add(newID);
584     }
585
586      /**
587      * Creates an item in the authority, used for partial term matching tests.
588      *
589      * @param authorityCsid The CSID of the Authority in which the term will be created.
590      * @param authRefName The refName of the Authority in which the term will be created.
591      */
592     private void createItemsInAuthorityForPartialTermMatch(
593                 String authorityCsid, String authRefName)
594         throws Exception {
595             
596         String testName = "createItemsInAuthorityForPartialTermMatch";
597
598         int expectedStatusCode = Response.Status.CREATED.getStatusCode();
599         ServiceRequestType requestType = ServiceRequestType.CREATE;
600         testSetup(expectedStatusCode, requestType);
601
602         // Submit the request to the service and store the response.
603         PersonAuthorityClient client = new PersonAuthorityClient();
604         Map<String, String> partialTermPersonMap = new HashMap<String,String>();
605         //
606         // Fill values for the UNICODE item
607         //
608         partialTermPersonMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, TEST_SHORT_ID_UNICODE );
609         partialTermPersonMap.put(PersonJAXBSchema.BIRTH_PLACE, TEST_KWD_BIRTH_PLACE);
610         partialTermPersonMap.put(PersonJAXBSchema.GENDER, "male");
611         partialTermPersonMap.put(PersonJAXBSchema.BIO_NOTE, TEST_KWD_BIO_NOTE_NO_QUOTES);
612         
613         List<PersonTermGroup> partialTerms = new ArrayList<PersonTermGroup>();
614         PersonTermGroup term = new PersonTermGroup();
615         term.setTermDisplayName(TEST_PARTIAL_TERM_DISPLAY_NAME_UNICODE);
616         term.setTermName(TEST_PARTIAL_TERM_DISPLAY_NAME_UNICODE);
617         term.setForeName(TEST_PARTIAL_TERM_FORE_NAME);
618         term.setSurName(TEST_PARTIAL_TERM_SUR_NAME_UNICODE);
619         partialTerms.add(term);
620
621         Map<String, List<String>> partialTermRepeatablesMap = new HashMap<String, List<String>>();
622         ArrayList<String> styles = new ArrayList<String>();
623         styles.add(TEST_KWD_UTF8_STYLE);
624         partialTermRepeatablesMap.put(PersonJAXBSchema.SCHOOLS_OR_STYLES, styles);
625
626         createItem(testName, authorityCsid, null /*authRefName*/, client, 
627                 partialTermPersonMap, partialTerms, partialTermRepeatablesMap);
628         //
629         // Adjust values for the QUOTE item
630         //
631         partialTermPersonMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, TEST_SHORT_ID_QUOTE );
632         partialTermPersonMap.put(PersonJAXBSchema.BIO_NOTE, TEST_KWD_BIO_NOTE_DBL_QUOTES);
633         
634         partialTerms.get(0).setTermDisplayName(TEST_PARTIAL_TERM_DISPLAY_NAME_QUOTE);
635         partialTerms.get(0).setSurName(TEST_PARTIAL_TERM_SUR_NAME_QUOTE);
636
637         createItem(testName, authorityCsid, null /*authRefName*/, client, 
638                 partialTermPersonMap, partialTerms, partialTermRepeatablesMap);
639     }
640     
641     private void createItem(
642                 String testName, 
643                 String authorityCsid, 
644                 String authRefName,
645                 PersonAuthorityClient client,
646                 Map<String, String> partialTermPersonMap,
647                 List<PersonTermGroup> partialTerms,
648                 Map<String, List<String>> partialTermRepeatablesMap) throws Exception {
649         PoxPayloadOut multipart =
650             PersonAuthorityClientUtils.createPersonInstance(authorityCsid, null, //authRefName, 
651                 partialTermPersonMap, partialTerms, partialTermRepeatablesMap, client.getItemCommonPartName() );
652
653         String newID = null;
654         ClientResponse<Response> res = client.createItem(authorityCsid, multipart);
655         try {
656             newID = PersonAuthorityClientUtils.extractId(res);
657         } finally {
658                 if (res != null) {
659                 res.releaseConnection();
660             }
661         }
662
663         // Store the ID returned from the first item resource created
664         // for additional tests below.
665         if (knownItemResourceId == null){
666             knownItemResourceId = newID;
667             if (logger.isDebugEnabled()) {
668                 logger.debug(testName + ": knownItemPartialTermResourceId=" + knownItemPartialTermResourceId);
669             }
670         }
671
672         // Store the IDs from any item resources created
673         // by tests, along with the IDs of their parents, so these items
674         // can be deleted after all tests have been run.
675         allItemResourceIdsCreated.put(newID, authorityCsid);
676     }
677
678 }