]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
bf3720bb82ba0529bd31e280c499a0a92749e0aa
[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 © 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.authorization.client.test;
24
25 //import java.util.ArrayList;
26 //import java.util.List;
27 import javax.ws.rs.core.Response;
28
29 import org.collectionspace.services.client.CollectionSpaceClient;
30 import org.collectionspace.services.client.RoleClient;
31 import org.collectionspace.services.authorization.Role;
32 import org.collectionspace.services.authorization.RolesList;
33 import org.collectionspace.services.client.RoleFactory;
34 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
35 import org.jboss.resteasy.client.ClientResponse;
36
37 import org.testng.Assert;
38 import org.testng.annotations.Test;
39
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
42
43 /**
44  * RoleServiceTest, carries out tests against a
45  * deployed and running Role Service.
46  * 
47  * $LastChangedRevision: 917 $
48  * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
49  */
50 public class RoleServiceTest extends AbstractServiceTestImpl<RolesList, Role, Role, Role> {
51
52     /** The logger. */
53     private final static String CLASS_NAME = RoleServiceTest.class.getName();
54     private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
55     
56     // Instance variables specific to this test.
57     /** The known resource id. */
58     private String knownRoleName = "ROLE_USERS_MOCK-1";
59     private String knownRoleDisplayName = "ROLE_DISPLAYNAME_USERS_MOCK-1";
60     private String verifyResourceId = null;
61     private String verifyRoleName = "collections_manager_mock-1";
62 //    private List<String> allResourceIdsCreated = new ArrayList<String>();
63
64     @Override
65     public String getServiceName() { 
66         return RoleClient.SERVICE_NAME;
67     }
68     
69     @Override
70     protected String getServicePathComponent() {
71         return new RoleClient().getServicePathComponent();
72     }
73
74     /* (non-Javadoc)
75      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
76      */
77     @Override
78     protected CollectionSpaceClient getClientInstance() {
79         return new RoleClient();
80     }
81
82     /* (non-Javadoc)
83      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
84      */
85     @Override
86     public void readPaginatedList(String testName) throws Exception {
87         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
88     }
89
90     // ---------------------------------------------------------------
91     // CRUD tests : CREATE tests
92     // ---------------------------------------------------------------
93     // Success outcomes
94
95     @Override
96     public void create(String testName) throws Exception {
97         // Perform setup, such as initializing the type of service request
98         // (e.g. CREATE, DELETE), its valid and expected status codes, and
99         // its associated HTTP method name (e.g. POST, DELETE).
100         setupCreate();
101
102         // Submit the request to the service and store the response.
103         RoleClient client = new RoleClient();
104         Role role = createRoleInstance(knownRoleName,
105                 "all users are required to be in this role",
106                 true);
107         ClientResponse<Response> res = client.create(role);
108         int statusCode = res.getStatus();
109
110         // Check the status code of the response: does it match
111         // the expected response(s)?
112         //
113         // Specifically:
114         // Does it fall within the set of valid status codes?
115         // Does it exactly match the expected status code?
116         if (logger.isDebugEnabled()) {
117             logger.debug(testName + ": status = " + statusCode);
118         }
119         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
120                 invalidStatusCodeMessage(testRequestType, statusCode));
121         Assert.assertEquals(statusCode, testExpectedStatusCode);
122
123         // Store the ID returned from this create operation
124         // for additional tests below.
125         knownResourceId = extractId(res);
126         if (logger.isDebugEnabled()) {
127             logger.debug(testName + ": knownResourceId=" + knownResourceId);
128         }
129     }
130     
131     @Test(dataProvider = "testName", 
132                 dependsOnMethods = {"CRUDTests"})
133     public void createWithDisplayname(String testName) throws Exception {
134         // Perform setup, such as initializing the type of service request
135         // (e.g. CREATE, DELETE), its valid and expected status codes, and
136         // its associated HTTP method name (e.g. POST, DELETE).
137         setupCreate();
138
139         // Submit the request to the service and store the response.
140         RoleClient client = new RoleClient();
141         Role role = createRoleInstance(knownRoleName + "_" + knownRoleDisplayName,
142                 "all users are required to be in this role",
143                 true);
144         role.setDisplayName(knownRoleDisplayName);
145         ClientResponse<Response> res = client.create(role);
146         int statusCode = res.getStatus();
147
148         // Check the status code of the response: does it match
149         // the expected response(s)?
150         //
151         // Specifically:
152         // Does it fall within the set of valid status codes?
153         // Does it exactly match the expected status code?
154         if (logger.isDebugEnabled()) {
155             logger.debug(testName + ": status = " + statusCode);
156         }
157         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
158                 invalidStatusCodeMessage(testRequestType, statusCode));
159         Assert.assertEquals(statusCode, testExpectedStatusCode);
160
161         // Store the ID returned from this create operation
162         // for additional tests below.
163         String csid = extractId(res);
164         allResourceIdsCreated.add(csid);
165         if (logger.isDebugEnabled()) {
166             logger.debug(testName + ": csid=" + csid);
167         }
168     }
169     
170
171     /**
172      * Creates the for unique role.
173      *
174      * @param testName the test name
175      * @throws Exception the exception
176      */
177     @Test(dataProvider = "testName",
178                 dependsOnMethods = {"CRUDTests"})
179     public void createForUniqueRole(String testName) throws Exception {
180         setupCreate();
181
182         // Submit the request to the service and store the response.
183         RoleClient client = new RoleClient();
184         Role role = createRoleInstance(knownRoleName,
185                 "role users",
186                 true);
187         ClientResponse<Response> res = client.create(role);
188         int statusCode = res.getStatus();
189
190         if (logger.isDebugEnabled()) {
191                 logger.debug(testName + ": Role with name \"" +
192                                 knownRoleName + "\" should already exist, so this request should fail.");
193             logger.debug(testName + ": status = " + statusCode);
194             logger.debug(testName + ": " + res);
195         }
196         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
197                 invalidStatusCodeMessage(testRequestType, statusCode));
198         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
199     }
200     
201     /**
202      * Creates the for unique display name of role.
203      *
204      * @param testName the test name
205      * @throws Exception the exception
206      */
207     @Test(dataProvider = "testName",
208                 dependsOnMethods = {"createWithDisplayname"})
209     public void createForUniqueDisplayRole(String testName) throws Exception {
210         setupCreate();
211
212         // Submit the request to the service and store the response.
213         RoleClient client = new RoleClient();
214         Role role = createRoleInstance(knownRoleName + System.currentTimeMillis(),
215                 "role users with non-unique display name",
216                 true);
217         role.setDisplayName(knownRoleDisplayName);
218         ClientResponse<Response> res = client.create(role);
219         int statusCode = res.getStatus();
220
221         if (logger.isDebugEnabled()) {
222                 logger.debug(testName + ": Role with name \"" +
223                                 knownRoleName + "\" should already exist, so this request should fail.");
224             logger.debug(testName + ": status = " + statusCode);
225             logger.debug(testName + ": " + res);
226         }
227         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
228                 invalidStatusCodeMessage(testRequestType, statusCode));
229         if (statusCode != Response.Status.BAD_REQUEST.getStatusCode()) {
230             // If the test fails then we've just created a Role that we need to delete, so
231             // store the ID returned from this create operation.
232             String csid = extractId(res);
233             allResourceIdsCreated.add(csid);
234             if (logger.isDebugEnabled()) {
235                 logger.debug(testName + ": csid=" + csid);
236             }
237                 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
238         }
239     }
240
241     /**
242      * Creates the without role name.
243      *
244      * @param testName the test name
245      * @throws Exception the exception
246      */
247     @Test(dataProvider = "testName",
248                 dependsOnMethods = {"CRUDTests"})
249     public void createWithoutRoleName(String testName) throws Exception {
250         setupCreate();
251
252         // Submit the request to the service and store the response.
253         RoleClient client = new RoleClient();
254         Role role = createRoleInstance("",
255                 "role for users",
256                 false);
257         ClientResponse<Response> res = client.create(role);
258         int statusCode = res.getStatus();
259         // Does it exactly match the expected status code?
260         if (logger.isDebugEnabled()) {
261             logger.debug(testName + ": status = " + statusCode);
262         }
263         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
264                 invalidStatusCodeMessage(testRequestType, statusCode));
265         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
266     }
267
268     //to not cause uniqueness violation for role, createList is removed
269     /* (non-Javadoc)
270      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
271      */
272     @Override
273 //    @Test(dataProvider = "testName",
274 //      dependsOnMethods = {"createWithDisplayname"})
275     public void createList(String testName) throws Exception {
276         setupCreate();
277
278         // Submit the request to the service and store the response.
279         RoleClient client = new RoleClient();
280         //create a role with lowercase role name without role prefix
281         //the service should make it upper case and add the role prefix
282         Role role1 = createRoleInstance(verifyRoleName,
283                 "collection manager",
284                 true);
285         ClientResponse<Response> res = client.create(role1);
286         int statusCode = res.getStatus();
287         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
288                 invalidStatusCodeMessage(testRequestType, statusCode));
289         Assert.assertEquals(statusCode, testExpectedStatusCode);
290         verifyResourceId = extractId(res);
291         allResourceIdsCreated.add(verifyResourceId);
292
293         Role role2 = createRoleInstance("ROLE_COLLECTIONS_CURATOR_TEST",
294                 "collections curator",
295                 true);
296         res = client.create(role2);
297         statusCode = res.getStatus();
298         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
299                 invalidStatusCodeMessage(testRequestType, statusCode));
300         Assert.assertEquals(statusCode, testExpectedStatusCode);
301         Assert.assertEquals(statusCode, testExpectedStatusCode);
302         allResourceIdsCreated.add(extractId(res));
303
304         Role role3 = createRoleInstance("ROLE_MOVINGIMAGE_ADMIN_TEST",
305                 "moving image admin",
306                 true);
307         res = client.create(role3);
308         statusCode = res.getStatus();
309         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
310                 invalidStatusCodeMessage(testRequestType, statusCode));
311         Assert.assertEquals(statusCode, testExpectedStatusCode);
312         Assert.assertEquals(statusCode, testExpectedStatusCode);
313         allResourceIdsCreated.add(extractId(res));
314     }
315
316     // Failure outcomes
317     // Placeholders until the three tests below can be uncommented.
318     // See Issue CSPACE-401.
319     /* (non-Javadoc)
320      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
321      */
322     @Override
323     public void createWithEmptyEntityBody(String testName) throws Exception {
324         //FIXME: Should this test really be empty?  If so, please comment accordingly.
325     }
326
327     /* (non-Javadoc)
328      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
329      */
330     @Override
331     public void createWithMalformedXml(String testName) throws Exception {
332         //FIXME: Should this test really be empty?  If so, please comment accordingly.
333     }
334
335     /* (non-Javadoc)
336      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
337      */
338     @Override
339     public void createWithWrongXmlSchema(String testName) throws Exception {
340         //FIXME: Should this test really be empty?  If so, please comment accordingly.
341     }
342
343     // ---------------------------------------------------------------
344     // CRUD tests : READ tests
345     // ---------------------------------------------------------------
346     // Success outcomes
347     /* (non-Javadoc)
348      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
349      */
350     @Override
351 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
352 //    dependsOnMethods = {"createForUniqueRole"})
353     public void read(String testName) throws Exception {
354         // Perform setup.
355         setupRead();
356
357         // Submit the request to the service and store the response.
358         RoleClient client = new RoleClient();
359         ClientResponse<Role> res = client.read(knownResourceId);
360         int statusCode = res.getStatus();
361
362         // Check the status code of the response: does it match
363         // the expected response(s)?
364         if (logger.isDebugEnabled()) {
365             logger.debug(testName + ": status = " + statusCode);
366         }
367         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
368                 invalidStatusCodeMessage(testRequestType, statusCode));
369         Assert.assertEquals(statusCode, testExpectedStatusCode);
370
371         Role output = (Role) res.getEntity();
372         Assert.assertNotNull(output);
373     }
374
375     @Test(dataProvider = "testName",
376                 dependsOnMethods = {"CRUDTests"})
377     public void readToVerify(String testName) throws Exception {
378         // Perform setup.
379         setupRead();
380
381         // Submit the request to the service and store the response.
382         RoleClient client = new RoleClient();
383         ClientResponse<Role> res = client.read(verifyResourceId);
384         int statusCode = res.getStatus();
385
386         // Check the status code of the response: does it match
387         // the expected response(s)?
388         if (logger.isDebugEnabled()) {
389             logger.debug(testName + ": status = " + statusCode);
390         }
391         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
392                 invalidStatusCodeMessage(testRequestType, statusCode));
393         Assert.assertEquals(statusCode, testExpectedStatusCode);
394
395         Role output = (Role) res.getEntity();
396         Assert.assertNotNull(output);
397
398         //FIXME: Tenant ID of "1" should not be hard coded
399         String roleNameToVerify = "ROLE_" +
400                 "1_" +
401                 verifyRoleName.toUpperCase();
402         Assert.assertEquals(output.getRoleName(), roleNameToVerify,
403                 "RoleName fix did not work!");
404     }
405     // Failure outcomes
406     /* (non-Javadoc)
407      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
408      */
409
410     @Override
411 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
412 //    dependsOnMethods = {"read"})
413     public void readNonExistent(String testName) throws Exception {
414         // Perform setup.
415         setupReadNonExistent();
416
417         // Submit the request to the service and store the response.
418         RoleClient client = new RoleClient();
419         ClientResponse<Role> res = client.read(NON_EXISTENT_ID);
420         int statusCode = res.getStatus();
421
422         // Check the status code of the response: does it match
423         // the expected response(s)?
424         if (logger.isDebugEnabled()) {
425             logger.debug(testName + ": status = " + statusCode);
426         }
427         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
428                 invalidStatusCodeMessage(testRequestType, statusCode));
429         Assert.assertEquals(statusCode, testExpectedStatusCode);
430     }
431
432     // ---------------------------------------------------------------
433     // CRUD tests : READ_LIST tests
434     // ---------------------------------------------------------------
435     // Success outcomes
436     /* (non-Javadoc)
437      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
438      */
439     @Override
440 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
441 //    dependsOnMethods = {"createList", "read"})
442     public void readList(String testName) throws Exception {
443         // Perform setup.
444         setupReadList();
445
446         // Submit the request to the service and store the response.
447         RoleClient client = new RoleClient();
448         ClientResponse<RolesList> res = client.readList();
449         try {
450                 // Check the status code of the response: does it match
451                 // the expected response(s)?
452                 assertStatusCode(res, testName);
453                 RolesList list = res.getEntity();
454                 // Optionally output additional data about list members for debugging.
455                 boolean iterateThroughList = true;
456                 if (iterateThroughList && logger.isDebugEnabled()) {
457                     printList(testName, list);
458                 }
459         } finally {
460                 if (res != null) {
461                 res.releaseConnection();
462             }
463         }
464     }
465
466     /**
467      * Search role name.
468      *
469      * @param testName the test name
470      * @throws Exception the exception
471      */
472     @Test(dataProvider = "testName",
473                 dependsOnMethods = {"CRUDTests"})
474     public void searchRoleName(String testName) throws Exception {
475         // Perform setup.
476         setupReadList();
477
478         // Submit the request to the service and store the response.
479         RoleClient client = new RoleClient();
480         ClientResponse<RolesList> res = client.readSearchList("movingImage");
481         try {
482                 assertStatusCode(res, testName);
483                 RolesList list = res.getEntity();
484                 int EXPECTED_ITEMS = 1;
485                 if (logger.isDebugEnabled()) {
486                     logger.debug(testName + ": received = " + list.getRole().size()
487                             + " expected=" + EXPECTED_ITEMS);
488                 }
489                 Assert.assertEquals(EXPECTED_ITEMS, list.getRole().size());
490                 // Optionally output additional data about list members for debugging.
491                 boolean iterateThroughList = true;
492                 if (iterateThroughList && logger.isDebugEnabled()) {
493                     printList(testName, list);
494                 }
495         } finally {
496                 if (res != null) {
497                 res.releaseConnection();
498             }
499         }
500     }
501
502     // Failure outcomes
503     // None at present.
504     // ---------------------------------------------------------------
505     // CRUD tests : UPDATE tests
506     // ---------------------------------------------------------------
507     // Success outcomes
508     /* (non-Javadoc)
509      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
510      */
511     @Override
512 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
513 //    dependsOnMethods = {"read", "readList", "readNonExistent"})
514     public void update(String testName) throws Exception {
515         // Perform setup.
516         setupUpdate();
517
518         Role roleToUpdate = new Role();
519         roleToUpdate.setCsid(knownResourceId);
520         roleToUpdate.setRoleName(knownRoleName);
521         roleToUpdate.setDisplayName(knownRoleName);
522         
523         // Update the content of this resource.
524         roleToUpdate.setDescription("updated role description");
525         if (logger.isDebugEnabled()) {
526             logger.debug("updated object");
527             org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();            
528             logger.debug(objectAsXmlString(objectFactory.createRole(roleToUpdate),
529                     Role.class));
530         }
531         RoleClient client = new RoleClient();
532         // Submit the request to the service and store the response.
533         ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
534         int statusCode = res.getStatus();
535         // Check the status code of the response: does it match the expected response(s)?
536         if (logger.isDebugEnabled()) {
537             logger.debug(testName + ": status = " + statusCode);
538         }
539         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
540                 invalidStatusCodeMessage(testRequestType, statusCode));
541         Assert.assertEquals(statusCode, testExpectedStatusCode);
542
543
544         Role roleUpdated = (Role) res.getEntity();
545         Assert.assertNotNull(roleUpdated);
546
547         Assert.assertEquals(roleUpdated.getDescription(),
548                 roleToUpdate.getDescription(),
549                 "Data in updated object did not match submitted data.");
550     }
551     
552     @Test(dataProvider = "testName",
553                 dependsOnMethods = {"CRUDTests"})
554         public void verifyProtectionReadOnly(String testName) throws Exception {
555
556         setupCreate();
557
558         // Submit the request to the service and store the response.
559         RoleClient client = new RoleClient();
560         Role role = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
561         role.setMetadataProtection(RoleClient.IMMUTABLE);
562         role.setPermsProtection(RoleClient.IMMUTABLE);
563         ClientResponse<Response> res = client.create(role);
564         int statusCode = res.getStatus();
565         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
566                 invalidStatusCodeMessage(testRequestType, statusCode));
567         Assert.assertEquals(statusCode, testExpectedStatusCode);
568
569         // Store the ID returned from this create operation
570         // for additional tests below.
571         String testResourceId = extractId(res);
572         allResourceIdsCreated.add(testResourceId);
573         if (logger.isDebugEnabled()) {
574             logger.debug(testName + ": testResourceId=" + testResourceId);
575         }
576         setupRead();
577
578         // Submit the request to the service and store the response.
579         ClientResponse<Role> roleRes = client.read(testResourceId);
580         statusCode = roleRes.getStatus();
581
582         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
583                 invalidStatusCodeMessage(testRequestType, statusCode));
584         Assert.assertEquals(statusCode, testExpectedStatusCode);
585
586         Role roleRead = (Role) roleRes.getEntity();
587         Assert.assertNotNull(roleRead);
588         String mdProtection = roleRead.getMetadataProtection();
589         String permsProtection = roleRead.getPermsProtection();
590         if (logger.isTraceEnabled()) {
591             logger.trace(testName + ": metadataProtection=" + mdProtection);
592             logger.trace(testName + ": permsProtection=" + permsProtection);
593         }
594         Assert.assertFalse(role.getMetadataProtection().equals(mdProtection),
595                         "Role allowed create to set the metadata protection flag.");
596         Assert.assertFalse(role.getPermsProtection().equals(permsProtection),
597                         "Role allowed create to set the perms protection flag.");
598         
599         setupUpdate();
600
601         Role roleToUpdate = createRoleInstance(knownRoleName+"_PT", "Just a temp", true);
602         roleToUpdate.setMetadataProtection(RoleClient.IMMUTABLE);
603         roleToUpdate.setPermsProtection(RoleClient.IMMUTABLE);
604
605         // Submit the request to the service and store the response.
606         roleRes = client.update(testResourceId, roleToUpdate);
607         statusCode = roleRes.getStatus();
608         // Check the status code of the response: does it match the expected response(s)?
609         if (logger.isDebugEnabled()) {
610                 logger.debug(testName + ": status = " + statusCode);
611         }
612         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
613                         invalidStatusCodeMessage(testRequestType, statusCode));
614         Assert.assertEquals(statusCode, testExpectedStatusCode);
615
616
617         Role roleUpdated = (Role) roleRes.getEntity();
618         Assert.assertNotNull(roleUpdated);
619         if (logger.isDebugEnabled()) {
620             logger.debug(testName + "Updated role: ");
621             org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();            
622             logger.debug(objectAsXmlString(objectFactory.createRole(roleUpdated),
623                     Role.class));            
624         }
625
626         Assert.assertFalse(
627                         RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getMetadataProtection()),
628                         "Role allowed update of the metadata protection flag.");
629         Assert.assertFalse(
630                         RoleClient.IMMUTABLE.equalsIgnoreCase(roleUpdated.getPermsProtection()),
631                         "Role allowed update of the perms protection flag.");
632     }
633
634         @Test(dataProvider = "testName",
635                         dependsOnMethods = {"CRUDTests"})
636     public void updateNotAllowed(String testName) throws Exception {
637
638         // Perform setup.
639         setupUpdate();
640
641         Role roleToUpdate = new Role();
642         roleToUpdate.setCsid(knownResourceId);
643         // Update the content of this resource.
644         roleToUpdate.setRoleName("UPDATED-ROLE_USERS_TEST");
645         roleToUpdate.setDisplayName("UPDATED-ROLE_USERS_TEST");
646         if (logger.isDebugEnabled()) {
647             logger.debug("updated object");
648             org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();            
649             logger.debug(objectAsXmlString(objectFactory.createRole(roleToUpdate),
650                     Role.class));
651         }
652         RoleClient client = new RoleClient();
653         // Submit the request to the service and store the response.
654         ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
655         int statusCode = res.getStatus();
656         // Check the status code of the response: does it match the expected response(s)?
657         if (logger.isDebugEnabled()) {
658             logger.debug(testName + ": status = " + statusCode);
659         }
660         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
661                 invalidStatusCodeMessage(testRequestType, statusCode));
662         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
663
664     }
665
666     // Failure outcomes
667     // Placeholders until the three tests below can be uncommented.
668     // See Issue CSPACE-401.
669     /* (non-Javadoc)
670      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
671      */
672     @Override
673     public void updateWithEmptyEntityBody(String testName) throws Exception {
674         //FIXME: Should this test really be empty?  If so, please comment accordingly.
675     }
676
677     /* (non-Javadoc)
678      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
679      */
680     @Override
681     public void updateWithMalformedXml(String testName) throws Exception {
682         //FIXME: Should this test really be empty?  If so, please comment accordingly.
683     }
684
685     /* (non-Javadoc)
686      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
687      */
688     @Override
689     public void updateWithWrongXmlSchema(String testName) throws Exception {
690         //FIXME: Should this test really be empty?  If so, please comment accordingly.
691     }
692
693     /* (non-Javadoc)
694      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
695      */
696     
697     @Override
698 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
699 //    dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
700     public void updateNonExistent(String testName) throws Exception {
701         // Perform setup.
702         setupUpdateNonExistent();
703
704         // Submit the request to the service and store the response.
705         //
706         // Note: The ID used in this 'create' call may be arbitrary.
707         // The only relevant ID may be the one used in updateRole(), below.
708         RoleClient client = new RoleClient();
709         Role role = createRoleInstance("ROLE_XXX",
710                 "xxx",
711                 true);
712         ClientResponse<Role> res =
713                 client.update(NON_EXISTENT_ID, role);
714         int statusCode = res.getStatus();
715
716         // Check the status code of the response: does it match
717         // the expected response(s)?
718         if (logger.isDebugEnabled()) {
719             logger.debug(testName + ": status = " + statusCode);
720         }
721         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
722                 invalidStatusCodeMessage(testRequestType, statusCode));
723         Assert.assertEquals(statusCode, testExpectedStatusCode);
724     }
725
726     // ---------------------------------------------------------------
727     // CRUD tests : DELETE tests
728     // ---------------------------------------------------------------
729     // Success outcomes
730     /* (non-Javadoc)
731      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
732      */
733     @Override
734     public void delete(String testName) throws Exception {
735         // Do nothing since other tests like "updateNotAllowed" need the "known resource" that this test
736         // deletes.  Once all those tests get run, the "localDelete" method will call the base class' delete
737         // method that will delete the "known resource".
738     }
739     
740     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
741                 dependsOnMethods = {"updateNotAllowed", "createForUniqueRole", "createForUniqueDisplayRole"})
742     public void localDelete(String testName) throws Exception {
743         super.delete(testName);
744     }
745
746     // Failure outcomes
747     /* (non-Javadoc)
748      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
749      */
750     @Override
751 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
752 //    dependsOnMethods = {"delete"})
753     public void deleteNonExistent(String testName) throws Exception {
754         // Perform setup.
755         setupDeleteNonExistent();
756
757         // Submit the request to the service and store the response.
758         RoleClient client = new RoleClient();
759         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
760         int statusCode = res.getStatus();
761
762         // Check the status code of the response: does it match
763         // the expected response(s)?
764         if (logger.isDebugEnabled()) {
765             logger.debug(testName + ": status = " + statusCode);
766         }
767         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
768                 invalidStatusCodeMessage(testRequestType, statusCode));
769         Assert.assertEquals(statusCode, testExpectedStatusCode);
770     }
771     
772     // ---------------------------------------------------------------
773     // Search tests
774     // ---------------------------------------------------------------
775     
776     @Override
777 //    @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
778     public void searchWorkflowDeleted(String testName) throws Exception {
779         // Fixme: null test for now, overriding test in base class
780     }    
781
782     // ---------------------------------------------------------------
783     // Utility tests : tests of code used in tests above
784     // ---------------------------------------------------------------
785     /**
786      * Tests the code for manually submitting data that is used by several
787      * of the methods above.
788      * @throws Exception 
789      */
790
791     // ---------------------------------------------------------------
792     // Utility methods used by tests above
793     // ---------------------------------------------------------------
794     /**
795      * create role instance
796      * @param roleName
797      * @param description
798      * @param useRoleName
799      * @return role
800      */
801     public Role createRoleInstance(String roleName,
802             String description,
803             boolean useRoleName) {
804
805         Role role = RoleFactory.createRoleInstance(roleName,
806                         roleName, //the display name
807                         description,
808                 useRoleName);
809         if (logger.isDebugEnabled()) {
810             logger.debug("to be created, role");
811             org.collectionspace.services.authorization.ObjectFactory objectFactory = new org.collectionspace.services.authorization.ObjectFactory();            
812             logger.debug(objectAsXmlString(objectFactory.createRole(role),
813                     Role.class));
814         }
815         return role;
816
817     }
818
819     /**
820      * Prints the list.
821      *
822      * @param testName the test name
823      * @param list the list
824      * @return the int
825      */
826     protected void printList(String testName, RolesList list) {
827         for (Role role : list.getRole()) {
828             logger.debug(testName + " role csid=" + role.getCsid()
829                     + " name=" + role.getRoleName()
830                     + " desc=" + role.getDescription());
831         }
832     }
833
834         @Override
835         protected Role createInstance(String commonPartName, String identifier) {
836                 // TODO Auto-generated method stub
837                 return null;
838         }
839
840         @Override
841         protected Role updateInstance(Role commonPartObject) {
842                 // TODO Auto-generated method stub
843                 return null;
844         }
845
846         @Override
847         protected void compareUpdatedInstances(Role original, Role updated)
848                         throws Exception {
849                 // TODO Auto-generated method stub
850                 
851         }
852
853         @Override
854         protected Class<RolesList> getCommonListType() {
855                 // TODO Auto-generated method stub
856                 return null;
857         }
858
859     /*
860      * For convenience and terseness, this test method is the base of the test execution dependency chain.  Other test methods may
861      * refer to this method in their @Test annotation declarations.
862      */
863     @Override
864     @Test(dataProvider = "testName",
865                 dependsOnMethods = {
866                         "org.collectionspace.services.client.test.AbstractServiceTestImpl.baseCRUDTests"})    
867     public void CRUDTests(String testName) {
868         // Do nothing.  Simply here to for a TestNG execution order for our tests
869     }   
870 }