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:
6 * http://www.collectionspace.org
7 * http://wiki.collectionspace.org
9 * Copyright © 2009 Regents of the University of California
11 * Licensed under the Educational Community License (ECL), Version 2.0.
12 * You may not use this file except in compliance with this License.
14 * You may obtain a copy of the ECL 2.0 License at
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
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.
23 package org.collectionspace.services.authorization.client.test;
25 //import java.util.ArrayList;
26 import java.util.List;
27 import javax.ws.rs.core.Response;
28 //import org.collectionspace.services.authorization.ActionType;
29 import org.collectionspace.services.authorization.EffectType;
31 import org.collectionspace.services.client.CollectionSpaceClient;
32 import org.collectionspace.services.client.PermissionClient;
33 import org.collectionspace.services.authorization.Permission;
34 import org.collectionspace.services.authorization.PermissionAction;
35 import org.collectionspace.services.authorization.PermissionsList;
36 import org.collectionspace.services.client.PermissionFactory;
37 import org.collectionspace.services.client.test.AbstractServiceTestImpl;
38 import org.collectionspace.services.client.test.ServiceRequestType;
39 import org.collectionspace.services.jaxb.AbstractCommonList;
40 import org.jboss.resteasy.client.ClientResponse;
42 import org.testng.Assert;
43 import org.testng.annotations.Test;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
49 * PermissionServiceTest, carries out tests against a
50 * deployed and running Permission Service.
52 * $LastChangedRevision: 917 $
53 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
55 public class PermissionServiceTest extends AbstractServiceTestImpl {
57 /** The Constant logger. */
58 private final static String CLASS_NAME = PermissionServiceTest.class.getName();
59 private final static Logger logger = LoggerFactory.getLogger(CLASS_NAME);
61 // Instance variables specific to this test.
62 /** The known resource id. */
63 private String knownResourceId = null;
64 private String knownResource = "accounts-test";
67 public String getServiceName() {
68 return PermissionClient.SERVICE_NAME;
72 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
75 protected String getServicePathComponent() {
76 return PermissionClient.SERVICE_PATH_COMPONENT;
80 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
83 protected CollectionSpaceClient getClientInstance() {
84 return new PermissionClient();
88 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
91 protected AbstractCommonList getAbstractCommonList(
92 ClientResponse<AbstractCommonList> response) {
93 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
94 throw new UnsupportedOperationException();
98 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readPaginatedList(java.lang.String)
100 @Test(dataProvider = "testName")
102 public void readPaginatedList(String testName) throws Exception {
103 //FIXME: http://issues.collectionspace.org/browse/CSPACE-1697
106 // ---------------------------------------------------------------
107 // CRUD tests : CREATE tests
108 // ---------------------------------------------------------------
111 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
114 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
115 public void create(String testName) throws Exception {
117 if (logger.isDebugEnabled()) {
118 logger.debug(testBanner(testName, CLASS_NAME));
120 // Perform setup, such as initializing the type of service request
121 // (e.g. CREATE, DELETE), its valid and expected status codes, and
122 // its associated HTTP method name (e.g. POST, DELETE).
125 // Submit the request to the service and store the response.
126 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
127 Permission permission = createPermissionInstance(knownResource,
128 "default permissions for account",
134 PermissionClient client = new PermissionClient();
135 ClientResponse<Response> res = client.create(permission);
136 int statusCode = res.getStatus();
138 // Check the status code of the response: does it match
139 // the expected response(s)?
142 // Does it fall within the set of valid status codes?
143 // Does it exactly match the expected status code?
144 if (logger.isDebugEnabled()) {
145 logger.debug(testName + ": status = " + statusCode);
147 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
148 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
149 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
151 // Store the ID returned from this create operation
152 // for additional tests below.
153 knownResourceId = extractId(res);
154 if (logger.isDebugEnabled()) {
155 logger.debug(testName + ": knownResourceId=" + knownResourceId);
160 * Creates the without resource name.
162 * @param testName the test name
163 * @throws Exception the exception
165 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
166 dependsOnMethods = {"create"})
167 public void createWithoutResourceName(String testName) throws Exception {
169 if (logger.isDebugEnabled()) {
170 logger.debug(testBanner(testName, CLASS_NAME));
174 // Submit the request to the service and store the response.
175 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
176 Permission permission = createPermissionInstance(null,
177 "default permissions for account",
183 PermissionClient client = new PermissionClient();
184 ClientResponse<Response> res = client.create(permission);
185 int statusCode = res.getStatus();
186 // Does it exactly match the expected status code?
187 if (logger.isDebugEnabled()) {
188 logger.debug(testName + ": status = " + statusCode);
190 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
191 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
192 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
195 //to not cause uniqueness violation for permission, createList is removed
197 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
200 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
201 dependsOnMethods = {"create"})
202 public void createList(String testName) throws Exception {
204 if (logger.isDebugEnabled()) {
205 logger.debug(testBanner(testName, CLASS_NAME));
208 // Submit the request to the service and store the response.
209 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
210 Permission permission1 = createPermissionInstance("test-objects",
211 "default permissions for test-objects",
217 PermissionClient client = new PermissionClient();
218 ClientResponse<Response> res = client.create(permission1);
219 int statusCode = res.getStatus();
220 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
221 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
222 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
223 allResourceIdsCreated.add(extractId(res));
225 Permission permission2 = createPermissionInstance("test-acquisitions",
226 "default permissions for test-acquisitions",
232 res = client.create(permission2);
233 statusCode = res.getStatus();
234 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
235 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
236 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
237 allResourceIdsCreated.add(extractId(res));
239 Permission permission3 = createPermissionInstance("test-ids",
240 "default permissions for id service",
246 res = client.create(permission3);
247 statusCode = res.getStatus();
248 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
249 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
250 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
251 allResourceIdsCreated.add(extractId(res));
255 // Placeholders until the three tests below can be uncommented.
256 // See Issue CSPACE-401.
258 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
261 public void createWithEmptyEntityBody(String testName) throws Exception {
262 //FIXME: Should this test really be empty? If so, please comment accordingly.
266 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
269 public void createWithMalformedXml(String testName) throws Exception {
270 //FIXME: Should this test really be empty? If so, please comment accordingly.
274 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
277 public void createWithWrongXmlSchema(String testName) throws Exception {
278 //FIXME: Should this test really be empty? If so, please comment accordingly.
281 // ---------------------------------------------------------------
282 // CRUD tests : READ tests
283 // ---------------------------------------------------------------
286 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
289 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
290 dependsOnMethods = {"create"})
291 public void read(String testName) throws Exception {
293 if (logger.isDebugEnabled()) {
294 logger.debug(testBanner(testName, CLASS_NAME));
299 // Submit the request to the service and store the response.
300 PermissionClient client = new PermissionClient();
301 ClientResponse<Permission> res = client.read(knownResourceId);
302 int statusCode = res.getStatus();
304 // Check the status code of the response: does it match
305 // the expected response(s)?
306 if (logger.isDebugEnabled()) {
307 logger.debug(testName + ": status = " + statusCode);
309 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
310 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
311 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
313 Permission output = (Permission) res.getEntity();
314 Assert.assertNotNull(output);
319 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
322 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
323 dependsOnMethods = {"read"})
324 public void readNonExistent(String testName) throws Exception {
326 if (logger.isDebugEnabled()) {
327 logger.debug(testBanner(testName, CLASS_NAME));
330 setupReadNonExistent();
332 // Submit the request to the service and store the response.
333 PermissionClient client = new PermissionClient();
334 ClientResponse<Permission> res = client.read(NON_EXISTENT_ID);
335 int statusCode = res.getStatus();
337 // Check the status code of the response: does it match
338 // the expected response(s)?
339 if (logger.isDebugEnabled()) {
340 logger.debug(testName + ": status = " + statusCode);
342 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
343 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
344 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
347 // ---------------------------------------------------------------
348 // CRUD tests : READ_LIST tests
349 // ---------------------------------------------------------------
352 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
355 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
356 dependsOnMethods = {"createList", "read"})
357 public void readList(String testName) throws Exception {
359 if (logger.isDebugEnabled()) {
360 logger.debug(testBanner(testName, CLASS_NAME));
365 // Submit the request to the service and store the response.
366 PermissionClient client = new PermissionClient();
367 ClientResponse<PermissionsList> res = client.readList();
368 PermissionsList list = res.getEntity();
369 int statusCode = res.getStatus();
371 // Check the status code of the response: does it match
372 // the expected response(s)?
373 if (logger.isDebugEnabled()) {
374 logger.debug(testName + ": status = " + statusCode);
376 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
377 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
378 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
380 // Optionally output additional data about list members for debugging.
381 boolean iterateThroughList = true;
382 if (iterateThroughList && logger.isDebugEnabled()) {
383 printList(testName, list);
388 * Search resource name.
390 * @param testName the test name
391 * @throws Exception the exception
393 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
394 dependsOnMethods = {"createList", "read"})
395 public void searchResourceName(String testName) throws Exception {
397 if (logger.isDebugEnabled()) {
398 logger.debug(testBanner(testName, CLASS_NAME));
403 // Submit the request to the service and store the response.
404 PermissionClient client = new PermissionClient();
405 ClientResponse<PermissionsList> res = client.readSearchList("acquisition");
406 PermissionsList list = res.getEntity();
407 int statusCode = res.getStatus();
408 // Check the status code of the response: does it match
409 // the expected response(s)?
410 if (logger.isDebugEnabled()) {
411 logger.debug(testName + ": status = " + statusCode);
413 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
414 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
415 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
416 int EXPECTED_ITEMS = 5; //seeded permissions
417 int actual = list.getPermissions().size();
418 if (logger.isDebugEnabled()) {
419 logger.debug(testName + ": received = " + actual
420 + " expected=" + EXPECTED_ITEMS);
422 // Optionally output additional data about list members for debugging.
423 boolean iterateThroughList = true;
424 if ((iterateThroughList || (EXPECTED_ITEMS != list.getPermissions().size()))
425 && logger.isDebugEnabled()) {
426 printList(testName, list);
428 Assert.assertEquals(list.getPermissions().size(), EXPECTED_ITEMS);
434 // ---------------------------------------------------------------
435 // CRUD tests : UPDATE tests
436 // ---------------------------------------------------------------
439 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
442 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
443 dependsOnMethods = {"read", "readList", "readNonExistent"})
444 public void update(String testName) throws Exception {
446 if (logger.isDebugEnabled()) {
447 logger.debug(testBanner(testName, CLASS_NAME));
452 Permission permToUpdate = new Permission();
453 permToUpdate.setCsid(knownResourceId);
454 permToUpdate.setResourceName(knownResource);
455 // Update the content of this resource.
456 permToUpdate.setDescription("updated description");
457 if (logger.isDebugEnabled()) {
458 logger.debug("updated object");
459 logger.debug(objectAsXmlString(permToUpdate,
462 PermissionClient client = new PermissionClient();
463 // Submit the request to the service and store the response.
464 ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
465 int statusCode = res.getStatus();
466 // Check the status code of the response: does it match the expected response(s)?
467 if (logger.isDebugEnabled()) {
468 logger.debug(testName + ": status = " + statusCode);
470 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
471 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
472 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
475 Permission permUpdated = (Permission) res.getEntity();
476 Assert.assertNotNull(permUpdated);
478 Assert.assertEquals(permUpdated.getDescription(),
479 permToUpdate.getDescription(),
480 "Data in updated object did not match submitted data.");
483 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
484 dependsOnMethods = {"read", "readList", "readNonExistent"})
485 public void updateNotAllowed(String testName) throws Exception {
490 Permission permToUpdate = new Permission();
491 permToUpdate.setCsid(knownResourceId);
492 // Update the content of this resource.
493 permToUpdate.setResourceName("updated-resource");
494 if (logger.isDebugEnabled()) {
495 logger.debug("updated object");
496 logger.debug(objectAsXmlString(permToUpdate,
499 PermissionClient client = new PermissionClient();
500 // Submit the request to the service and store the response.
501 ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
502 int statusCode = res.getStatus();
503 // Check the status code of the response: does it match the expected response(s)?
504 if (logger.isDebugEnabled()) {
505 logger.debug(testName + ": status = " + statusCode);
507 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
508 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
509 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
516 * @param testName the test name
517 * @throws Exception the exception
519 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
520 dependsOnMethods = {"updateNotAllowed"})
521 public void updateActions(String testName) throws Exception {
523 if (logger.isDebugEnabled()) {
524 logger.debug(testBanner(testName, CLASS_NAME));
529 Permission permToUpdate = new Permission();
530 permToUpdate.setCsid(knownResourceId);
531 permToUpdate.setResourceName(knownResource);
532 // Update the content of this resource.
533 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
534 int default_actions = actions.size();
537 int toUpdate_actions = actions.size();
538 if (logger.isDebugEnabled()) {
539 logger.debug(testName + " no. of actions default=" + default_actions
540 + " to update =" + toUpdate_actions);
542 permToUpdate.setActions(actions);
543 if (logger.isDebugEnabled()) {
544 logger.debug(testName + " updated object\n"
545 + objectAsXmlString(permToUpdate, Permission.class));
547 PermissionClient client = new PermissionClient();
548 // Submit the request to the service and store the response.
549 ClientResponse<Permission> res = client.update(knownResourceId, permToUpdate);
550 int statusCode = res.getStatus();
551 // Check the status code of the response: does it match the expected response(s)?
552 if (logger.isDebugEnabled()) {
553 logger.debug(testName + ": status = " + statusCode);
555 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
556 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
557 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
559 Permission permUpdated = (Permission) res.getEntity();
560 Assert.assertNotNull(permUpdated);
561 int updated_actions = permToUpdate.getActions().size();
562 if (logger.isDebugEnabled()) {
563 logger.debug(testName + " no. of actions to update=" + toUpdate_actions
564 + " updated =" + updated_actions);
566 Assert.assertEquals(toUpdate_actions,
568 "Data in updated object did not match submitted data.");
571 // Placeholders until the three tests below can be uncommented.
572 // See Issue CSPACE-401.
575 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
578 public void updateWithEmptyEntityBody(String testName) throws Exception {
579 //FIXME: Should this test really be empty? If so, please comment accordingly.
583 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
586 public void updateWithMalformedXml(String testName) throws Exception {
587 //FIXME: Should this test really be empty? If so, please comment accordingly.
591 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
594 public void updateWithWrongXmlSchema(String testName) throws Exception {
595 //FIXME: Should this test really be empty? If so, please comment accordingly.
599 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
602 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
603 dependsOnMethods = {"readNonExistent", "testSubmitRequest"})
604 public void updateNonExistent(String testName) throws Exception {
606 if (logger.isDebugEnabled()) {
607 logger.debug(testBanner(testName, CLASS_NAME));
610 setupUpdateNonExistent();
612 // Submit the request to the service and store the response.
614 // Note: The ID used in this 'create' call may be arbitrary.
615 // The only relevant ID may be the one used in updatePermission(), below.
616 PermissionClient client = new PermissionClient();
617 List<PermissionAction> actions = PermissionFactory.createDefaultActions();
618 Permission permission = createPermissionInstance("test-acquisitions",
619 "default permissions for test-acquisitions",
625 ClientResponse<Permission> res =
626 client.update(NON_EXISTENT_ID, permission);
627 int statusCode = res.getStatus();
629 // Check the status code of the response: does it match
630 // the expected response(s)?
631 if (logger.isDebugEnabled()) {
632 logger.debug(testName + ": status = " + statusCode);
634 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
635 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
636 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
639 // ---------------------------------------------------------------
640 // CRUD tests : DELETE tests
641 // ---------------------------------------------------------------
644 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
647 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
648 dependsOnMethods = {"update", "updateActions", "testSubmitRequest"})
649 public void delete(String testName) throws Exception {
651 if (logger.isDebugEnabled()) {
652 logger.debug(testBanner(testName, CLASS_NAME));
657 // Submit the request to the service and store the response.
658 PermissionClient client = new PermissionClient();
659 ClientResponse<Response> res = client.delete(knownResourceId);
660 int statusCode = res.getStatus();
662 // Check the status code of the response: does it match
663 // the expected response(s)?
664 if (logger.isDebugEnabled()) {
665 logger.debug(testName + ": status = " + statusCode);
667 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
668 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
669 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
674 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
677 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
678 dependsOnMethods = {"delete"})
679 public void deleteNonExistent(String testName) throws Exception {
681 if (logger.isDebugEnabled()) {
682 logger.debug(testBanner(testName, CLASS_NAME));
685 setupDeleteNonExistent();
687 // Submit the request to the service and store the response.
688 PermissionClient client = new PermissionClient();
689 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
690 int statusCode = res.getStatus();
692 // Check the status code of the response: does it match
693 // the expected response(s)?
694 if (logger.isDebugEnabled()) {
695 logger.debug(testName + ": status = " + statusCode);
697 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
698 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
699 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
702 // ---------------------------------------------------------------
704 // ---------------------------------------------------------------
707 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
708 public void searchWorkflowDeleted(String testName) throws Exception {
709 // Fixme: null test for now, overriding test in base class
712 // ---------------------------------------------------------------
713 // Utility tests : tests of code used in tests above
714 // ---------------------------------------------------------------
716 * Tests the code for manually submitting data that is used by several
717 * of the methods above.
720 @Test(dependsOnMethods = {"create"})
721 public void testSubmitRequest() throws Exception {
723 // Expected status code: 200 OK
724 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
726 // Submit the request to the service and store the response.
727 String method = ServiceRequestType.READ.httpMethodName();
728 String url = getResourceURL(knownResourceId);
729 int statusCode = submitRequest(method, url);
731 // Check the status code of the response: does it match
732 // the expected response(s)?
733 if (logger.isDebugEnabled()) {
734 logger.debug("testSubmitRequest: url=" + url
735 + " status=" + statusCode);
737 Assert.assertEquals(statusCode, EXPECTED_STATUS);
741 // ---------------------------------------------------------------
742 // Utility methods used by tests above
743 // ---------------------------------------------------------------
745 * create permission instance
746 * @param resourceName
748 * @param actionList list of actions for this permission
749 * @param effect effect of the permission
750 * @param useResourceName
755 public static Permission createPermissionInstance(String resourceName,
757 List<PermissionAction> actionList,
759 boolean useResourceName,
763 Permission permission = PermissionFactory.createPermissionInstance(resourceName,
764 description, actionList, effect,
765 useResourceName, useAction, useEffect);
767 if (logger.isDebugEnabled()) {
768 logger.debug("to be created, permission");
769 logger.debug(objectAsXmlString(permission, Permission.class));
777 * @param testName the test name
778 * @param list the list
781 private int printList(String testName, PermissionsList list) {
785 for (Permission permission : list.getPermissions()) {
786 logger.debug(testName + " permission csid=" + permission.getCsid()
787 + " name=" + permission.getResourceName()
788 + " desc=" + permission.getDescription());