]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
507d6e7cea91ddedb65c6785a218037e8301806e
[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.collectionspace.services.client.test.ServiceRequestType;
36 import org.collectionspace.services.jaxb.AbstractCommonList;
37 import org.jboss.resteasy.client.ClientResponse;
38
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
41
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
44
45 /**
46  * RoleServiceTest, carries out tests against a
47  * deployed and running Role Service.
48  * 
49  * $LastChangedRevision: 917 $
50  * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
51  */
52 public class RoleServiceTest extends AbstractServiceTestImpl {
53
54     /** The logger. */
55     private final Logger logger =
56             LoggerFactory.getLogger(RoleServiceTest.class);
57     // Instance variables specific to this test.
58     /** The known resource id. */
59     private String knownResourceId = null;
60 //    private List<String> allResourceIdsCreated = new ArrayList<String>();
61     /** The add tenant. */
62 boolean addTenant = true;
63     /*
64      * This method is called only by the parent class, AbstractServiceTestImpl
65      */
66
67     /* (non-Javadoc)
68      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
69      */
70     @Override
71     protected String getServicePathComponent() {
72         return new RoleClient().getServicePathComponent();
73     }
74
75     /* (non-Javadoc)
76      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
77      */
78     @Override
79     protected CollectionSpaceClient getClientInstance() {
80         return new RoleClient();
81     }
82     
83     /* (non-Javadoc)
84      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
85      */
86     @Override
87         protected AbstractCommonList getAbstractCommonList(
88                         ClientResponse<AbstractCommonList> response) {
89         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
90         throw new UnsupportedOperationException();
91     }
92     
93         /* (non-Javadoc)
94          * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
95          */
96         @Test(dataProvider = "testName")
97         @Override
98     public void readPaginatedList(String testName) throws Exception {
99                         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
100         }    
101  
102     // ---------------------------------------------------------------
103     // CRUD tests : CREATE tests
104     // ---------------------------------------------------------------
105     // Success outcomes
106     /* (non-Javadoc)
107      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
108      */
109     @Override
110     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
111     public void create(String testName) throws Exception {
112
113         // Perform setup, such as initializing the type of service request
114         // (e.g. CREATE, DELETE), its valid and expected status codes, and
115         // its associated HTTP method name (e.g. POST, DELETE).
116         setupCreate(testName);
117
118         // Submit the request to the service and store the response.
119         RoleClient client = new RoleClient();
120         Role role = createRoleInstance("ROLE_USERS_TEST",
121                 "all users are required to be in this role",
122                 true);
123         ClientResponse<Response> res = client.create(role);
124         int statusCode = res.getStatus();
125
126         // Check the status code of the response: does it match
127         // the expected response(s)?
128         //
129         // Specifically:
130         // Does it fall within the set of valid status codes?
131         // Does it exactly match the expected status code?
132         if (logger.isDebugEnabled()) {
133             logger.debug(testName + ": status = " + statusCode);
134         }
135         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
136                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
137         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
138
139         // Store the ID returned from this create operation
140         // for additional tests below.
141         knownResourceId = extractId(res);
142         if (logger.isDebugEnabled()) {
143             logger.debug(testName + ": knownResourceId=" + knownResourceId);
144         }
145     }
146
147     /**
148      * Creates the for unique role.
149      *
150      * @param testName the test name
151      * @throws Exception the exception
152      */
153     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
154     dependsOnMethods = {"create"})
155     public void createForUniqueRole(String testName) throws Exception {
156
157         setupCreate(testName);
158
159         // Submit the request to the service and store the response.
160         RoleClient client = new RoleClient();
161         Role role = createRoleInstance("ROLE_USERS",
162                 "role users",
163                 true);
164         ClientResponse<Response> res = client.create(role);
165         int statusCode = res.getStatus();
166
167         if (logger.isDebugEnabled()) {
168             logger.debug(testName + ": status = " + statusCode);
169         }
170         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
171                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
172         Assert.assertEquals(statusCode, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
173     }
174
175     /**
176      * Creates the without role name.
177      *
178      * @param testName the test name
179      * @throws Exception the exception
180      */
181     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
182     dependsOnMethods = {"create"})
183     public void createWithoutRoleName(String testName) throws Exception {
184
185         setupCreate(testName);
186
187         // Submit the request to the service and store the response.
188         RoleClient client = new RoleClient();
189         Role role = createRoleInstance("ROLE_USERS",
190                 "role for users",
191                 false);
192         ClientResponse<Response> res = client.create(role);
193         int statusCode = res.getStatus();
194         // Does it exactly match the expected status code?
195         if (logger.isDebugEnabled()) {
196             logger.debug(testName + ": status = " + statusCode);
197         }
198         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
199                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
200         Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
201     }
202
203     //to not cause uniqueness violation for role, createList is removed
204     /* (non-Javadoc)
205      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
206      */
207     @Override
208     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
209     dependsOnMethods = {"create"})
210     public void createList(String testName) throws Exception {
211
212         setupCreate(testName);
213
214         // Submit the request to the service and store the response.
215          RoleClient client = new RoleClient();
216        Role role1 = createRoleInstance("ROLE_COLLECTIONS_MANGER_TEST",
217                 "collection manager",
218                 true);
219         ClientResponse<Response> res = client.create(role1);
220         int statusCode = res.getStatus();
221         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
222                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
223         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
224         allResourceIdsCreated.add(extractId(res));
225
226         Role role2 = createRoleInstance("ROLE_COLLECTIONS_CURATOR_TEST",
227                 "collections curator",
228                 true);
229         res = client.create(role2);
230         statusCode = res.getStatus();
231         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
232                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
233         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
234         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
235         allResourceIdsCreated.add(extractId(res));
236
237         Role role3 = createRoleInstance("ROLE_MOVINGIMAGE_ADMIN_TEST",
238                 "moving image admin",
239                 true);
240         res = client.create(role3);
241         statusCode = res.getStatus();
242         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
243                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
244         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
245         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
246         allResourceIdsCreated.add(extractId(res));
247     }
248
249     // Failure outcomes
250     // Placeholders until the three tests below can be uncommented.
251     // See Issue CSPACE-401.
252     /* (non-Javadoc)
253      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
254      */
255     @Override
256     public void createWithEmptyEntityBody(String testName) throws Exception {
257         //FIXME: Should this test really be empty?  If so, please comment accordingly.
258     }
259
260     /* (non-Javadoc)
261      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
262      */
263     @Override
264     public void createWithMalformedXml(String testName) throws Exception {
265         //FIXME: Should this test really be empty?  If so, please comment accordingly.
266     }
267
268     /* (non-Javadoc)
269      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
270      */
271     @Override
272     public void createWithWrongXmlSchema(String testName) throws Exception {
273         //FIXME: Should this test really be empty?  If so, please comment accordingly.
274     }
275
276     // ---------------------------------------------------------------
277     // CRUD tests : READ tests
278     // ---------------------------------------------------------------
279     // Success outcomes
280     /* (non-Javadoc)
281      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
282      */
283     @Override
284     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
285     dependsOnMethods = {"create"})
286     public void read(String testName) throws Exception {
287
288         // Perform setup.
289         setupRead(testName);
290
291         // Submit the request to the service and store the response.
292         RoleClient client = new RoleClient();
293         ClientResponse<Role> res = client.read(knownResourceId);
294         int statusCode = res.getStatus();
295
296         // Check the status code of the response: does it match
297         // the expected response(s)?
298         if (logger.isDebugEnabled()) {
299             logger.debug(testName + ": status = " + statusCode);
300         }
301         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
302                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
303         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
304
305         Role output = (Role) res.getEntity();
306         Assert.assertNotNull(output);
307     }
308
309     // Failure outcomes
310     /* (non-Javadoc)
311      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
312      */
313     @Override
314     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
315     dependsOnMethods = {"read"})
316     public void readNonExistent(String testName) throws Exception {
317
318         // Perform setup.
319         setupReadNonExistent(testName);
320
321         // Submit the request to the service and store the response.
322         RoleClient client = new RoleClient();
323         ClientResponse<Role> res = client.read(NON_EXISTENT_ID);
324         int statusCode = res.getStatus();
325
326         // Check the status code of the response: does it match
327         // the expected response(s)?
328         if (logger.isDebugEnabled()) {
329             logger.debug(testName + ": status = " + statusCode);
330         }
331         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
332                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
333         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
334     }
335
336     // ---------------------------------------------------------------
337     // CRUD tests : READ_LIST tests
338     // ---------------------------------------------------------------
339     // Success outcomes
340     /* (non-Javadoc)
341      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
342      */
343     @Override
344     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
345     dependsOnMethods = {"createList", "read"})
346     public void readList(String testName) throws Exception {
347
348         // Perform setup.
349         setupReadList(testName);
350
351         // Submit the request to the service and store the response.
352         RoleClient client = new RoleClient();
353         ClientResponse<RolesList> res = client.readList();
354         RolesList list = res.getEntity();
355         int statusCode = res.getStatus();
356
357         // Check the status code of the response: does it match
358         // the expected response(s)?
359         if (logger.isDebugEnabled()) {
360             logger.debug(testName + ": status = " + statusCode);
361         }
362         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
363                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
364         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
365
366         // Optionally output additional data about list members for debugging.
367         boolean iterateThroughList = true;
368         if (iterateThroughList && logger.isDebugEnabled()) {
369             printList(testName, list);
370         }
371     }
372
373     /**
374      * Search role name.
375      *
376      * @param testName the test name
377      * @throws Exception the exception
378      */
379     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
380     dependsOnMethods = {"createList", "read"})
381     public void searchRoleName(String testName) throws Exception {
382
383         // Perform setup.
384         setupReadList(testName);
385
386         // Submit the request to the service and store the response.
387         RoleClient client = new RoleClient();
388         ClientResponse<RolesList> res = client.readSearchList("movingImage");
389         RolesList list = res.getEntity();
390         int statusCode = res.getStatus();
391         // Check the status code of the response: does it match
392         // the expected response(s)?
393         if (logger.isDebugEnabled()) {
394             logger.debug(testName + ": status = " + statusCode);
395         }
396         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
397                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
398         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
399         int EXPECTED_ITEMS = 1;
400         if (logger.isDebugEnabled()) {
401             logger.debug(testName + ": received = " + list.getRoles().size()
402                     + " expected=" + EXPECTED_ITEMS);
403         }
404         Assert.assertEquals(EXPECTED_ITEMS, list.getRoles().size());
405         // Optionally output additional data about list members for debugging.
406         boolean iterateThroughList = true;
407         if (iterateThroughList && logger.isDebugEnabled()) {
408             printList(testName, list);
409         }
410     }
411
412     // Failure outcomes
413     // None at present.
414     // ---------------------------------------------------------------
415     // CRUD tests : UPDATE tests
416     // ---------------------------------------------------------------
417     // Success outcomes
418     /* (non-Javadoc)
419      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
420      */
421     @Override
422     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
423     dependsOnMethods = {"read", "readList", "readNonExistent"})
424     public void update(String testName) throws Exception {
425
426         // Perform setup.
427         setupUpdate(testName);
428
429         Role roleToUpdate = new Role();
430         roleToUpdate.setCsid(knownResourceId);
431
432         // Update the content of this resource.
433         roleToUpdate.setRoleName("updated-role");
434         if (logger.isDebugEnabled()) {
435             logger.debug("updated object");
436             logger.debug(objectAsXmlString(roleToUpdate,
437                     Role.class));
438         }
439         RoleClient client = new RoleClient();
440         // Submit the request to the service and store the response.
441         ClientResponse<Role> res = client.update(knownResourceId, roleToUpdate);
442         int statusCode = res.getStatus();
443         // Check the status code of the response: does it match the expected response(s)?
444         if (logger.isDebugEnabled()) {
445             logger.debug(testName + ": status = " + statusCode);
446         }
447         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
448                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
449         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
450
451
452         Role roleUpdated = (Role) res.getEntity();
453         Assert.assertNotNull(roleUpdated);
454
455         Assert.assertEquals(roleUpdated.getRoleName(),
456                 roleToUpdate.getRoleName(),
457                 "Data in updated object did not match submitted data.");
458     }
459
460     // Failure outcomes
461     // Placeholders until the three tests below can be uncommented.
462     // See Issue CSPACE-401.
463     /* (non-Javadoc)
464      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
465      */
466     @Override
467     public void updateWithEmptyEntityBody(String testName) throws Exception {
468         //FIXME: Should this test really be empty?  If so, please comment accordingly.
469     }
470
471     /* (non-Javadoc)
472      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
473      */
474     @Override
475     public void updateWithMalformedXml(String testName) throws Exception {
476         //FIXME: Should this test really be empty?  If so, please comment accordingly.
477     }
478
479     /* (non-Javadoc)
480      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
481      */
482     @Override
483     public void updateWithWrongXmlSchema(String testName) throws Exception {
484         //FIXME: Should this test really be empty?  If so, please comment accordingly.
485     }
486
487     /* (non-Javadoc)
488      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
489      */
490     @Override
491     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
492     dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
493     public void updateNonExistent(String testName) throws Exception {
494
495         // Perform setup.
496         setupUpdateNonExistent(testName);
497
498         // Submit the request to the service and store the response.
499         //
500         // Note: The ID used in this 'create' call may be arbitrary.
501         // The only relevant ID may be the one used in updateRole(), below.
502         RoleClient client = new RoleClient();
503         Role role = createRoleInstance("ROLE_XXX",
504                 "xxx",
505                 true);
506         ClientResponse<Role> res =
507                 client.update(NON_EXISTENT_ID, role);
508         int statusCode = res.getStatus();
509
510         // Check the status code of the response: does it match
511         // the expected response(s)?
512         if (logger.isDebugEnabled()) {
513             logger.debug(testName + ": status = " + statusCode);
514         }
515         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
516                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
517         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
518     }
519
520     // ---------------------------------------------------------------
521     // CRUD tests : DELETE tests
522     // ---------------------------------------------------------------
523     // Success outcomes
524     /* (non-Javadoc)
525      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
526      */
527     @Override
528     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
529     dependsOnMethods = {"update"})
530     public void delete(String testName) throws Exception {
531
532         // Perform setup.
533         setupDelete(testName);
534
535         // Submit the request to the service and store the response.
536         RoleClient client = new RoleClient();
537         ClientResponse<Response> res = client.delete(knownResourceId);
538         int statusCode = res.getStatus();
539
540         // Check the status code of the response: does it match
541         // the expected response(s)?
542         if (logger.isDebugEnabled()) {
543             logger.debug(testName + ": status = " + statusCode);
544         }
545         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
546                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
547         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
548     }
549
550     // Failure outcomes
551     /* (non-Javadoc)
552      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
553      */
554     @Override
555     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
556     dependsOnMethods = {"delete"})
557     public void deleteNonExistent(String testName) throws Exception {
558
559         // Perform setup.
560         setupDeleteNonExistent(testName);
561
562         // Submit the request to the service and store the response.
563         RoleClient client = new RoleClient();
564         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
565         int statusCode = res.getStatus();
566
567         // Check the status code of the response: does it match
568         // the expected response(s)?
569         if (logger.isDebugEnabled()) {
570             logger.debug(testName + ": status = " + statusCode);
571         }
572         Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
573                 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
574         Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
575     }
576
577     // ---------------------------------------------------------------
578     // Utility tests : tests of code used in tests above
579     // ---------------------------------------------------------------
580     /**
581      * Tests the code for manually submitting data that is used by several
582      * of the methods above.
583      * @throws Exception 
584      */
585     @Test(dependsOnMethods = {"create", "read"})
586     public void testSubmitRequest() throws Exception {
587
588         // Expected status code: 200 OK
589         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
590
591         // Submit the request to the service and store the response.
592         String method = ServiceRequestType.READ.httpMethodName();
593         String url = getResourceURL(knownResourceId);
594         int statusCode = submitRequest(method, url);
595
596         // Check the status code of the response: does it match
597         // the expected response(s)?
598         if (logger.isDebugEnabled()) {
599             logger.debug("testSubmitRequest: url=" + url
600                     + " status=" + statusCode);
601         }
602         Assert.assertEquals(statusCode, EXPECTED_STATUS);
603
604     }
605
606     // ---------------------------------------------------------------
607     // Utility methods used by tests above
608     // ---------------------------------------------------------------
609     /**
610      * create role instance
611      * @param roleName
612      * @param description
613      * @param useRoleName
614      * @return role
615      */
616     public Role createRoleInstance(String roleName,
617             String description,
618             boolean useRoleName) {
619
620         Role role = RoleFactory.createRoleInstance(roleName, description,
621                 useRoleName);
622         if (logger.isDebugEnabled()) {
623             logger.debug("to be created, role");
624             logger.debug(objectAsXmlString(role, Role.class));
625         }
626         return role;
627
628     }
629
630     /**
631      * Prints the list.
632      *
633      * @param testName the test name
634      * @param list the list
635      * @return the int
636      */
637     private int printList(String testName, RolesList list) {
638
639         int i = 0;
640
641         for (Role role : list.getRoles()) {
642             logger.debug(testName + " role csid=" + role.getCsid()
643                     + " name=" + role.getRoleName()
644                     + " desc=" + role.getDescription());
645             i++;
646         }
647         return i;
648     }
649 }