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