]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
00e3d04214a5747a1a55f3c4fc540b4c4a65b2e2
[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 permRoles 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.Collection;
27 import java.util.Hashtable;
28 import java.util.List;
29 import javax.ws.rs.core.Response;
30 import org.collectionspace.services.authorization.EffectType;
31
32 import org.collectionspace.services.authorization.Permission;
33 import org.collectionspace.services.authorization.PermissionAction;
34 import org.collectionspace.services.authorization.PermissionRole;
35 import org.collectionspace.services.authorization.PermissionValue;
36 import org.collectionspace.services.authorization.Role;
37 import org.collectionspace.services.authorization.RoleValue;
38 import org.collectionspace.services.client.CollectionSpaceClient;
39 import org.collectionspace.services.client.PermissionClient;
40 import org.collectionspace.services.client.PermissionFactory;
41 import org.collectionspace.services.client.PermissionRoleClient;
42 import org.collectionspace.services.client.PermissionRoleFactory;
43 import org.collectionspace.services.client.RoleClient;
44 import org.collectionspace.services.client.RoleFactory;
45 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
46 import org.collectionspace.services.client.test.ServiceRequestType;
47 import org.collectionspace.services.jaxb.AbstractCommonList;
48 import org.jboss.resteasy.client.ClientResponse;
49
50 import org.testng.Assert;
51 import org.testng.annotations.Test;
52
53 import org.slf4j.Logger;
54 import org.slf4j.LoggerFactory;
55 import org.testng.annotations.AfterClass;
56 import org.testng.annotations.BeforeClass;
57
58 /**
59  * PermissionServiceTest, carries out tests against a
60  * deployed and running Permission, Role and PermissionRole Services.
61  * 
62  * $LastChangedRevision: 917 $
63  * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
64  */
65 public class PermissionRoleServiceTest extends AbstractServiceTestImpl {
66
67     /** The Constant logger. */
68     private final static String CLASS_NAME = PermissionRoleServiceTest.class.getName();
69     private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
70     
71     // Instance variables specific to this test.
72     /** The known resource id. */
73     private String knownResourceId = null;
74     /** The all resource ids created. */
75     private List<String> allResourceIdsCreated = new ArrayList<String>();
76     final private static String TEST_MARKER = "_PermissionRoleServiceTest";
77     final private static String TEST_SERVICE_NAME = "fakeservice";
78     /** The perm values. */
79     private Hashtable<String, PermissionValue> permValues = new Hashtable<String, PermissionValue>();
80     /** The role values. */
81     private Hashtable<String, RoleValue> roleValues = new Hashtable<String, RoleValue>();
82     /*
83      * This method is called only by the parent class, AbstractServiceTestImpl
84      */
85
86     /* (non-Javadoc)
87      * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
88      */
89     @Override
90     protected String getServicePathComponent() {
91         return new PermissionRoleClient().getServicePathComponent();
92     }
93
94     /**
95      * Seed data.
96      */
97     @BeforeClass(alwaysRun = true)
98     public void seedData() {
99         String ra = TEST_SERVICE_NAME + TEST_MARKER;
100         String accPermId = createPermission(ra, EffectType.PERMIT);
101         PermissionValue pva = new PermissionValue();
102         pva.setResourceName(ra);
103         pva.setPermissionId(accPermId);
104         permValues.put(pva.getResourceName(), pva);
105
106 //        String rc = "collectionobjects";
107 //        String coPermId = createPermission(rc, EffectType.DENY);
108 //        PermissionValue pvc = new PermissionValue();
109 //        pvc.setResourceName(rc);
110 //        pvc.setPermissionId(coPermId);
111 //        permValues.put(pvc.getResourceName(), pvc);
112 //
113 //        String ri = "intakes";
114 //        String iPermId = createPermission(ri, EffectType.DENY);
115 //        PermissionValue pvi = new PermissionValue();
116 //        pvi.setResourceName(ri);
117 //        pvi.setPermissionId(iPermId);
118 //        permValues.put(pvi.getResourceName(), pvi);
119
120         String rn1 = "ROLE_CO1" + TEST_MARKER;
121         String r1RoleId = createRole(rn1);
122         RoleValue rv1 = new RoleValue();
123         rv1.setRoleId(r1RoleId);
124         rv1.setRoleName(rn1);
125         roleValues.put(rv1.getRoleName(), rv1);
126
127         String rn2 = "ROLE_CO2" + TEST_MARKER;
128         String r2RoleId = createRole(rn2);
129         RoleValue rv2 = new RoleValue();
130         rv2.setRoleId(r2RoleId);
131         rv2.setRoleName(rn2);
132         roleValues.put(rv2.getRoleName(), rv2);
133     }
134
135     /* (non-Javadoc)
136      * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
137      */
138     @Override
139     protected CollectionSpaceClient getClientInstance() {
140         return new PermissionRoleClient();
141     }
142
143     /* (non-Javadoc)
144      * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
145      */
146     @Override
147     protected AbstractCommonList getAbstractCommonList(
148             ClientResponse<AbstractCommonList> response) {
149         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
150         throw new UnsupportedOperationException();
151     }
152
153     /* (non-Javadoc)
154      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
155      */
156     @Test(dataProvider = "testName")
157     @Override
158     public void readPaginatedList(String testName) throws Exception {
159         //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
160     }
161     // ---------------------------------------------------------------
162     // CRUD tests : CREATE tests
163     // ---------------------------------------------------------------
164     // Success outcomes
165     /* (non-Javadoc)
166      * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
167      */
168
169     @Override
170     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
171     public void create(String testName) throws Exception {
172
173         if (logger.isDebugEnabled()) {
174             logger.debug(testBanner(testName, CLASS_NAME));
175         }
176         
177         // Perform setup, such as initializing the type of service request
178         // (e.g. CREATE, DELETE), its valid and expected status codes, and
179         // its associated HTTP method name (e.g. POST, DELETE).
180         setupCreate();
181
182         // Submit the request to the service and store the response.
183         PermissionValue pv = permValues.get(TEST_SERVICE_NAME + TEST_MARKER);
184         PermissionRole permRole = createPermissionRoleInstance(pv,
185                 roleValues.values(), true, true);
186         PermissionRoleClient client = new PermissionRoleClient();
187         ClientResponse<Response> res = null;
188         try {
189             res = client.create(pv.getPermissionId(), permRole);
190             int statusCode = res.getStatus();
191
192             if (logger.isDebugEnabled()) {
193                 logger.debug(testName + ": status = " + statusCode);
194             }
195             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
196                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
197             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
198             res.releaseConnection();
199             // Store the ID returned from this create operation
200             // for additional tests below.
201             //this is is not important in case of this relationship
202             knownResourceId = extractId(res);
203             if (logger.isDebugEnabled()) {
204                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
205             }
206         } finally {
207             if (res != null) {
208                 res.releaseConnection();
209             }
210         }
211     }
212
213     //to not cause uniqueness violation for permRole, createList is removed
214     /* (non-Javadoc)
215      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
216      */
217     @Override
218     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
219     dependsOnMethods = {"create"})
220     public void createList(String testName) throws Exception {
221         //Should this really be empty?
222     }
223
224     // Failure outcomes
225     // Placeholders until the three tests below can be uncommented.
226     // See Issue CSPACE-401.
227     /* (non-Javadoc)
228      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
229      */
230     @Override
231     public void createWithEmptyEntityBody(String testName) throws Exception {
232         //Should this really be empty?
233     }
234
235     /* (non-Javadoc)
236      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
237      */
238     @Override
239     public void createWithMalformedXml(String testName) throws Exception {
240         //Should this really be empty?
241     }
242
243     /* (non-Javadoc)
244      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
245      */
246     @Override
247     public void createWithWrongXmlSchema(String testName) throws Exception {
248         //Should this really be empty?
249     }
250
251     // ---------------------------------------------------------------
252     // CRUD tests : READ tests
253     // ---------------------------------------------------------------
254     // Success outcomes
255     /* (non-Javadoc)
256      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
257      */
258     @Override
259     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
260     dependsOnMethods = {"create"})
261     public void read(String testName) throws Exception {
262
263         if (logger.isDebugEnabled()) {
264             logger.debug(testBanner(testName, CLASS_NAME));
265         }
266         // Perform setup.
267         setupRead();
268
269         // Submit the request to the service and store the response.
270         PermissionRoleClient client = new PermissionRoleClient();
271         ClientResponse<PermissionRole> res = null;
272         try {
273             res = client.read(
274                     permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId(), "123");
275             int statusCode = res.getStatus();
276
277             // Check the status code of the response: does it match
278             // the expected response(s)?
279             if (logger.isDebugEnabled()) {
280                 logger.debug(testName + ": status = " + statusCode);
281             }
282             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
283                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
284             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
285
286             PermissionRole output = (PermissionRole) res.getEntity();
287             Assert.assertNotNull(output);
288         } finally {
289             if (res != null) {
290                 res.releaseConnection();
291             }
292         }
293
294     }
295
296     // Failure outcomes
297     /* (non-Javadoc)
298      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
299      */
300     @Override
301     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
302     public void readNonExistent(String testName) throws Exception {
303
304         if (logger.isDebugEnabled()) {
305             logger.debug(testBanner(testName, CLASS_NAME));
306         }
307         // Perform setup.
308         setupReadNonExistent();
309
310         // Submit the request to the service and store the response.
311         PermissionRoleClient client = new PermissionRoleClient();
312         ClientResponse<PermissionRole> res = null;
313         try {
314             res = client.read(NON_EXISTENT_ID, "123");
315             int statusCode = res.getStatus();
316
317             // Check the status code of the response: does it match
318             // the expected response(s)?
319             if (logger.isDebugEnabled()) {
320                 logger.debug(testName + ": status = " + statusCode);
321             }
322             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
323                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
324             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
325         } finally {
326             if (res != null) {
327                 res.releaseConnection();
328             }
329         }
330     }
331
332     // ---------------------------------------------------------------
333     // CRUD tests : READ_LIST tests
334     // ---------------------------------------------------------------
335     // Success outcomes
336     /* (non-Javadoc)
337      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
338      */
339     @Override
340     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
341     dependsOnMethods = {"createList", "read"})
342     public void readList(String testName) throws Exception {
343         //Should this really be empty?
344     }
345
346     // Failure outcomes
347     // None at present.
348     // ---------------------------------------------------------------
349     // CRUD tests : UPDATE tests
350     // ---------------------------------------------------------------
351     // Success outcomes
352     /* (non-Javadoc)
353      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
354      */
355     @Override
356     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
357     dependsOnMethods = {"read", "readList", "readNonExistent"})
358     public void update(String testName) throws Exception {
359         //Should this really be empty?
360     }
361
362     // Failure outcomes
363     // Placeholders until the three tests below can be uncommented.
364     // See Issue CSPACE-401.
365     /* (non-Javadoc)
366      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
367      */
368     @Override
369     public void updateWithEmptyEntityBody(String testName) throws Exception {
370         //Should this really be empty?
371     }
372
373     /* (non-Javadoc)
374      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
375      */
376     @Override
377     public void updateWithMalformedXml(String testName) throws Exception {
378         //Should this really be empty?
379     }
380
381     /* (non-Javadoc)
382      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
383      */
384     @Override
385     public void updateWithWrongXmlSchema(String testName) throws Exception {
386         //Should this really be empty?
387     }
388
389     /* (non-Javadoc)
390      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
391      */
392     @Override
393     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
394     dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
395     public void updateNonExistent(String testName) throws Exception {
396         //Should this really be empty?
397     }
398
399     // ---------------------------------------------------------------
400     // CRUD tests : DELETE tests
401     // ---------------------------------------------------------------
402     // Success outcomes
403     /* (non-Javadoc)
404      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
405      */
406     @Override
407     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
408     dependsOnMethods = {"read"})
409     public void delete(String testName) throws Exception {
410
411         if (logger.isDebugEnabled()) {
412             logger.debug(testBanner(testName, CLASS_NAME));
413         }
414         // Perform setup.
415         setupDelete();
416
417         // Submit the request to the service and store the response.
418         PermissionRoleClient client = new PermissionRoleClient();
419         ClientResponse<Response> res = null;
420         try {
421             res = client.delete(
422                     permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId(), "123");
423             int statusCode = res.getStatus();
424
425             // Check the status code of the response: does it match
426             // the expected response(s)?
427             if (logger.isDebugEnabled()) {
428                 logger.debug(testName + ": status = " + statusCode);
429             }
430             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
431                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
432             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
433         } finally {
434             if (res != null) {
435                 res.releaseConnection();
436             }
437         }
438     }
439
440     // Failure outcomes
441     /* (non-Javadoc)
442      * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
443      */
444     @Override
445     @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
446     public void deleteNonExistent(String testName) throws Exception {
447         //ignoring this test as the service side returns 200 now even if it does
448         //not find a record in the db
449     }
450
451     // ---------------------------------------------------------------
452     // Utility tests : tests of code used in tests above
453     // ---------------------------------------------------------------
454     /**
455      * Tests the code for manually submitting data that is used by several
456      * of the methods above.
457      * @throws Exception 
458      */
459     @Test(dependsOnMethods = {"create"})
460     public void testSubmitRequest() throws Exception {
461
462         // Expected status code: 200 OK
463         final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
464
465         // Submit the request to the service and store the response.
466         String method = ServiceRequestType.READ.httpMethodName();
467         String url = getResourceURL(permValues.get(TEST_SERVICE_NAME + TEST_MARKER).getPermissionId());
468         int statusCode = submitRequest(method, url);
469
470         // Check the status code of the response: does it match
471         // the expected response(s)?
472         if (logger.isDebugEnabled()) {
473             logger.debug("testSubmitRequest: url=" + url
474                     + " status=" + statusCode);
475         }
476         Assert.assertEquals(statusCode, EXPECTED_STATUS);
477
478
479     }
480
481     // ---------------------------------------------------------------
482     // Utility methods used by tests above
483     // ---------------------------------------------------------------
484     /**
485      * create permRolerole instance
486      * @param pv permissionvalue
487      * @param rvs rolevalue array
488      * @param usePermId 
489      * @param useRoleId
490      * @return PermissionRole
491      */
492     public static PermissionRole createPermissionRoleInstance(PermissionValue pv,
493             Collection<RoleValue> rvs,
494             boolean usePermId,
495             boolean useRoleId) {
496
497         List<RoleValue> rvls = new ArrayList<RoleValue>();
498         rvls.addAll(rvs);
499         PermissionRole permRole = PermissionRoleFactory.createPermissionRoleInstance(
500                 pv, rvls, usePermId, useRoleId);
501         if (logger.isDebugEnabled()) {
502             logger.debug("to be created, permRole");
503             logger.debug(objectAsXmlString(permRole, PermissionRole.class));
504         }
505         return permRole;
506     }
507
508     /**
509      * Clean up.
510      */
511     @AfterClass(alwaysRun = true)
512     @Override
513     public void cleanUp() {
514         setupDelete();
515         String noTest = System.getProperty("noTestCleanup");
516         if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
517             if (logger.isDebugEnabled()) {
518                 logger.debug("Skipping Cleanup phase ...");
519             }
520             return;
521         }
522         if (logger.isDebugEnabled()) {
523             logger.debug("Cleaning up temporary resources created for testing ...");
524         }
525
526         PermissionRoleClient client = new PermissionRoleClient();
527         for (String resourceId : allResourceIdsCreated) {
528
529             ClientResponse<Response> res = client.delete(resourceId, "123");
530             int statusCode = res.getStatus();
531             try {
532                 if (logger.isDebugEnabled()) {
533                     logger.debug("cleanup: delete relationships for permission id="
534                             + resourceId + " status=" + statusCode);
535                 }
536                 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
537                         invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
538                 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
539             } finally {
540                 res.releaseConnection();
541             }
542         }
543
544         for (PermissionValue pv : permValues.values()) {
545             deletePermission(pv.getPermissionId());
546         }
547         for (RoleValue rv : roleValues.values()) {
548             deleteRole(rv.getRoleId());
549         }
550     }
551
552     /**
553      * Creates the permission.
554      *
555      * @param resName the res name
556      * @param effect the effect
557      * @return the string
558      */
559     private String createPermission(String resName, EffectType effect) {
560         if (logger.isDebugEnabled()) {
561             logger.debug(testBanner("createPermission"));
562         }
563         setupCreate();
564         PermissionClient permClient = new PermissionClient();
565         List<PermissionAction> actions = PermissionFactory.createDefaultActions();
566         Permission permission = PermissionFactory.createPermissionInstance(resName,
567                 "default permissions for " + resName,
568                 actions, effect, true, true, true);
569         String id = null;
570         ClientResponse<Response> res = null;
571         try {
572             res = permClient.create(permission);
573
574             int statusCode = res.getStatus();
575             if (logger.isDebugEnabled()) {
576                 logger.debug("createPermission: resName=" + resName
577                         + " status = " + statusCode);
578             }
579             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
580                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
581             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
582             id = extractId(res);
583         } finally {
584             if (res != null) {
585                 res.releaseConnection();
586             }
587         }
588         return id;
589     }
590
591     /**
592      * Delete permission.
593      *
594      * @param permId the perm id
595      */
596     private void deletePermission(String permId) {
597         if (logger.isDebugEnabled()) {
598             logger.debug(testBanner("deletePermission"));
599         }
600         setupDelete();
601         PermissionClient permClient = new PermissionClient();
602         ClientResponse<Response> res = null;
603         try {
604             res = permClient.delete(permId);
605             int statusCode = res.getStatus();
606             if (logger.isDebugEnabled()) {
607                 logger.debug("deletePermission: delete permission id="
608                         + permId + " status=" + statusCode);
609             }
610             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
611                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
612             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
613         } finally {
614             res.releaseConnection();
615         }
616
617     }
618
619     /**
620      * Creates the role.
621      *
622      * @param roleName the role name
623      * @return the string
624      */
625     private String createRole(String roleName) {
626         if (logger.isDebugEnabled()) {
627             logger.debug(testBanner("createRole"));
628         }
629         setupCreate();
630         RoleClient roleClient = new RoleClient();
631
632         Role role = RoleFactory.createRoleInstance(roleName,
633                 "role for " + roleName, true);
634         ClientResponse<Response> res = null;
635         String id = null;
636         try {
637             res = roleClient.create(role);
638             int statusCode = res.getStatus();
639             if (logger.isDebugEnabled()) {
640                 logger.debug("createRole: name=" + roleName
641                         + " status = " + statusCode);
642             }
643             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
644                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
645             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
646
647             id = extractId(res);
648         } finally {
649             res.releaseConnection();
650         }
651         return id;
652     }
653
654     /**
655      * Delete role.
656      *
657      * @param roleId the role id
658      */
659     private void deleteRole(String roleId) {
660         if (logger.isDebugEnabled()) {
661             logger.debug(testBanner("deleteRole"));
662         }
663         setupDelete();
664         RoleClient roleClient = new RoleClient();
665         ClientResponse<Response> res = null;
666         try {
667             res = roleClient.delete(roleId);
668             int statusCode = res.getStatus();
669             if (logger.isDebugEnabled()) {
670                 logger.debug("deleteRole: delete role id=" + roleId
671                         + " status=" + statusCode);
672             }
673             Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
674                     invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
675             Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
676         } finally {
677             res.releaseConnection();
678         }
679     }
680 }