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.account.client.test;
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.UUID;
28 import javax.ws.rs.core.Response;
30 import org.apache.commons.codec.binary.Base64;
31 import org.collectionspace.services.client.AccountClient;
32 import org.collectionspace.services.account.AccountsCommon;
33 import org.collectionspace.services.account.AccountsCommonList;
34 import org.collectionspace.services.account.Status;
35 import org.collectionspace.services.client.test.AbstractServiceTest;
36 import org.collectionspace.services.client.test.ServiceRequestType;
37 import org.jboss.resteasy.client.ClientResponse;
39 import org.testng.Assert;
40 import org.testng.annotations.Test;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
46 * AccountServiceTest, carries out tests against a
47 * deployed and running Account Service.
49 * $LastChangedRevision: 917 $
50 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
52 public class AccountServiceTest extends AbstractServiceTest {
54 private final Logger logger =
55 LoggerFactory.getLogger(AccountServiceTest.class);
56 // Instance variables specific to this test.
57 private AccountClient client = new AccountClient();
58 private String knownResourceId = null;
59 private String resource1Id = null;
60 private String resource2Id = null;
63 * This method is called only by the parent class, AbstractServiceTest
66 protected String getServicePathComponent() {
67 return client.getServicePathComponent();
70 // ---------------------------------------------------------------
71 // CRUD tests : CREATE tests
72 // ---------------------------------------------------------------
75 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class)
76 public void create(String testName) throws Exception {
78 // Perform setup, such as initializing the type of service request
79 // (e.g. CREATE, DELETE), its valid and expected status codes, and
80 // its associated HTTP method name (e.g. POST, DELETE).
81 setupCreate(testName);
83 // Submit the request to the service and store the response.
84 AccountsCommon account =
85 createAccountInstance("barney", "hithere08", "barney@dinoland.com", true, true, true);
86 ClientResponse<Response> res = client.create(account);
87 int statusCode = res.getStatus();
89 // Check the status code of the response: does it match
90 // the expected response(s)?
93 // Does it fall within the set of valid status codes?
94 // Does it exactly match the expected status code?
95 if (logger.isDebugEnabled()) {
96 logger.debug(testName + ": status = " + statusCode);
98 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
99 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
100 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
102 // Store the ID returned from this create operation
103 // for additional tests below.
104 knownResourceId = extractId(res);
105 if (logger.isDebugEnabled()) {
106 logger.debug(testName + ": knownResourceId=" + knownResourceId);
110 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
111 dependsOnMethods = {"create"})
112 public void createWithoutTenant(String testName) throws Exception {
114 setupCreate(testName);
116 // Submit the request to the service and store the response.
117 AccountsCommon account =
118 createAccountInstance("babybop", "hithere08", "babybop@dinoland.com", false, true, true);
119 ClientResponse<Response> res = client.create(account);
120 int statusCode = res.getStatus();
121 // Does it exactly match the expected status code?
122 if (logger.isDebugEnabled()) {
123 logger.debug(testName + ": status = " + statusCode);
125 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
126 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
127 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
131 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
132 dependsOnMethods = {"create"})
133 public void createWithoutUser(String testName) throws Exception {
135 setupCreate(testName);
137 // Submit the request to the service and store the response.
138 AccountsCommon account =
139 createAccountInstance("babybop", "hithere08", "babybop@dinoland.com", true, false, true);
140 ClientResponse<Response> res = client.create(account);
141 int statusCode = res.getStatus();
142 // Does it exactly match the expected status code?
143 if (logger.isDebugEnabled()) {
144 logger.debug(testName + ": status = " + statusCode);
146 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
147 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
148 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
151 //to not cause uniqueness violation for account, createList is removed
153 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
154 dependsOnMethods = {"create"})
155 public void createList(String testName) throws Exception {
157 setupCreate(testName);
158 // Submit the request to the service and store the response.
159 AccountsCommon account1 =
160 createAccountInstance("curious", "hithere08", "curious@george.com", true, true, true);
161 ClientResponse<Response> res = client.create(account1);
162 int statusCode = res.getStatus();
163 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
164 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
165 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
166 resource1Id = extractId(res);
168 AccountsCommon account2 =
169 createAccountInstance("tom", "hithere09", "tom@jerry.com", true, true, true);
170 res = client.create(account2);
171 statusCode = res.getStatus();
172 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
173 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
174 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
175 resource2Id = extractId(res);
179 // Placeholders until the three tests below can be uncommented.
180 // See Issue CSPACE-401.
182 public void createWithEmptyEntityBody(String testName) throws Exception {
186 public void createWithMalformedXml(String testName) throws Exception {
190 public void createWithWrongXmlSchema(String testName) throws Exception {
193 // ---------------------------------------------------------------
194 // CRUD tests : READ tests
195 // ---------------------------------------------------------------
198 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
199 dependsOnMethods = {"create"})
200 public void read(String testName) throws Exception {
205 // Submit the request to the service and store the response.
206 ClientResponse<AccountsCommon> res = client.read(knownResourceId);
207 int statusCode = res.getStatus();
209 // Check the status code of the response: does it match
210 // the expected response(s)?
211 if (logger.isDebugEnabled()) {
212 logger.debug(testName + ": status = " + statusCode);
214 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
215 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
216 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
218 AccountsCommon output = (AccountsCommon) res.getEntity();
219 Assert.assertNotNull(output);
224 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
225 dependsOnMethods = {"read"})
226 public void readNonExistent(String testName) throws Exception {
229 setupReadNonExistent(testName);
231 // Submit the request to the service and store the response.
232 ClientResponse<AccountsCommon> res = client.read(NON_EXISTENT_ID);
233 int statusCode = res.getStatus();
235 // Check the status code of the response: does it match
236 // the expected response(s)?
237 if (logger.isDebugEnabled()) {
238 logger.debug(testName + ": status = " + statusCode);
240 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
241 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
242 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
245 // ---------------------------------------------------------------
246 // CRUD tests : READ_LIST tests
247 // ---------------------------------------------------------------
250 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
251 dependsOnMethods = {"createList", "read"})
252 public void readList(String testName) throws Exception {
255 setupReadList(testName);
257 // Submit the request to the service and store the response.
258 ClientResponse<AccountsCommonList> res = client.readList();
259 AccountsCommonList list = res.getEntity();
260 int statusCode = res.getStatus();
262 // Check the status code of the response: does it match
263 // the expected response(s)?
264 if (logger.isDebugEnabled()) {
265 logger.debug(testName + ": status = " + statusCode);
267 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
268 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
269 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
271 // Optionally output additional data about list members for debugging.
272 boolean iterateThroughList = true;
273 if (iterateThroughList && logger.isDebugEnabled()) {
274 printList(testName, list);
278 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
279 dependsOnMethods = {"createList", "read"})
280 public void readSearchList(String testName) throws Exception {
283 setupReadList(testName);
285 // Submit the request to the service and store the response.
286 ClientResponse<AccountsCommonList> res = client.readSearchList("tom");
287 AccountsCommonList list = res.getEntity();
288 int statusCode = res.getStatus();
290 // Check the status code of the response: does it match
291 // the expected response(s)?
292 if (logger.isDebugEnabled()) {
293 logger.debug(testName + ": status = " + statusCode);
295 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
296 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
297 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
299 // Optionally output additional data about list members for debugging.
300 boolean iterateThroughList = true;
301 if (iterateThroughList && logger.isDebugEnabled()) {
302 printList(testName, list);
308 // ---------------------------------------------------------------
309 // CRUD tests : UPDATE tests
310 // ---------------------------------------------------------------
313 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
314 dependsOnMethods = {"read", "readList", "readNonExistent"})
315 public void update(String testName) throws Exception {
318 setupUpdate(testName);
321 ClientResponse<AccountsCommon> res =
322 client.read(knownResourceId);
323 if (logger.isDebugEnabled()) {
324 logger.debug(testName + ": read status = " + res.getStatus());
326 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
328 if (logger.isDebugEnabled()) {
329 logger.debug("got object to update with ID: " + knownResourceId);
331 AccountsCommon toUpdateAccount =
332 (AccountsCommon) res.getEntity();
333 Assert.assertNotNull(toUpdateAccount);
335 // Update the content of this resource.
336 toUpdateAccount.setEmail("updated-" + toUpdateAccount.getEmail());
337 if (logger.isDebugEnabled()) {
338 logger.debug("updated object");
339 logger.debug(objectAsXmlString(toUpdateAccount,
340 AccountsCommon.class));
343 // Submit the request to the service and store the response.
344 res = client.update(knownResourceId, toUpdateAccount);
345 int statusCode = res.getStatus();
346 // Check the status code of the response: does it match the expected response(s)?
347 if (logger.isDebugEnabled()) {
348 logger.debug(testName + ": status = " + statusCode);
350 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
351 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
352 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
355 AccountsCommon updatedAccount = (AccountsCommon) res.getEntity();
356 Assert.assertNotNull(updatedAccount);
358 Assert.assertEquals(updatedAccount.getEmail(),
359 toUpdateAccount.getEmail(),
360 "Data in updated object did not match submitted data.");
363 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
364 dependsOnMethods = {"update"})
365 public void updatePassword(String testName) throws Exception {
368 setupUpdate(testName);
370 ClientResponse<AccountsCommon> res =
371 client.read(knownResourceId);
372 if (logger.isDebugEnabled()) {
373 logger.debug(testName + ": read status = " + res.getStatus());
375 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
377 if (logger.isDebugEnabled()) {
378 logger.debug(testName + ": got object to update password with ID: " + knownResourceId);
380 AccountsCommon toUpdateAccount =
381 (AccountsCommon) res.getEntity();
382 Assert.assertNotNull(toUpdateAccount);
385 toUpdateAccount.setPassword(Base64.encodeBase64("imagination".getBytes()));
386 if (logger.isDebugEnabled()) {
387 logger.debug(testName + ": updated object");
388 logger.debug(objectAsXmlString(toUpdateAccount,
389 AccountsCommon.class));
392 // Submit the request to the service and store the response.
393 res = client.update(knownResourceId, toUpdateAccount);
394 int statusCode = res.getStatus();
395 // Check the status code of the response: does it match the expected response(s)?
396 if (logger.isDebugEnabled()) {
397 logger.debug(testName + ": status = " + statusCode);
399 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
400 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
401 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
404 AccountsCommon updatedAccount = (AccountsCommon) res.getEntity();
405 Assert.assertNotNull(updatedAccount);
407 // Assert.assertEquals(updatedAccount.getPassword(),
408 // toUpdateAccount.getPassword(),
409 // "Data in updated object did not match submitted data.");
412 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
413 dependsOnMethods = {"update"})
414 public void updatePasswordWithoutUser(String testName) throws Exception {
417 setupUpdate(testName);
419 ClientResponse<AccountsCommon> res =
420 client.read(knownResourceId);
421 if (logger.isDebugEnabled()) {
422 logger.debug(testName + ": read status = " + res.getStatus());
424 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
426 if (logger.isDebugEnabled()) {
427 logger.debug(testName + " : got object to update with ID: " + knownResourceId);
429 AccountsCommon toUpdateAccount =
430 (AccountsCommon) res.getEntity();
431 Assert.assertNotNull(toUpdateAccount);
433 toUpdateAccount.setUserId(null);
435 toUpdateAccount.setPassword(Base64.encodeBase64("imagination".getBytes()));
436 if (logger.isDebugEnabled()) {
437 logger.debug(testName + " : updated object");
438 logger.debug(objectAsXmlString(toUpdateAccount,
439 AccountsCommon.class));
442 // Submit the request to the service and store the response.
443 res = client.update(knownResourceId, toUpdateAccount);
444 int statusCode = res.getStatus();
445 // Check the status code of the response: does it match the expected response(s)?
446 if (logger.isDebugEnabled()) {
447 logger.debug(testName + ": status = " + statusCode);
449 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
450 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
451 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
455 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
456 dependsOnMethods = {"updatePasswordWithoutUser"})
457 public void deactivate(String testName) throws Exception {
460 setupUpdate(testName);
462 ClientResponse<AccountsCommon> res =
463 client.read(knownResourceId);
464 if (logger.isDebugEnabled()) {
465 logger.debug(testName + ": read status = " + res.getStatus());
467 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
469 if (logger.isDebugEnabled()) {
470 logger.debug("got object to update with ID: " + knownResourceId);
472 AccountsCommon toUpdateAccount =
473 (AccountsCommon) res.getEntity();
474 Assert.assertNotNull(toUpdateAccount);
476 // Update the content of this resource.
477 toUpdateAccount.setStatus(Status.INACTIVE);
478 if (logger.isDebugEnabled()) {
479 logger.debug("updated object");
480 logger.debug(objectAsXmlString(toUpdateAccount,
481 AccountsCommon.class));
484 // Submit the request to the service and store the response.
485 res = client.update(knownResourceId, toUpdateAccount);
486 int statusCode = res.getStatus();
487 // Check the status code of the response: does it match the expected response(s)?
488 if (logger.isDebugEnabled()) {
489 logger.debug(testName + ": status = " + statusCode);
491 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
492 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
493 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
496 AccountsCommon updatedAccount = (AccountsCommon) res.getEntity();
497 Assert.assertNotNull(updatedAccount);
499 Assert.assertEquals(updatedAccount.getStatus(),
500 toUpdateAccount.getStatus(),
501 "Data in updated object did not match submitted data.");
506 // Placeholders until the three tests below can be uncommented.
507 // See Issue CSPACE-401.
509 public void updateWithEmptyEntityBody(String testName) throws Exception {
513 public void updateWithMalformedXml(String testName) throws Exception {
517 public void updateWithWrongXmlSchema(String testName) throws Exception {
521 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
522 dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
523 public void updateNonExistent(String testName) throws Exception {
526 setupUpdateNonExistent(testName);
528 // Submit the request to the service and store the response.
530 // Note: The ID used in this 'create' call may be arbitrary.
531 // The only relevant ID may be the one used in updateAccount(), below.
532 AccountsCommon account =
533 createAccountInstance("simba", "tiger", "simba@lionking.com", true, true, true);
534 ClientResponse<AccountsCommon> res =
535 client.update(NON_EXISTENT_ID, account);
536 int statusCode = res.getStatus();
538 // Check the status code of the response: does it match
539 // the expected response(s)?
540 if (logger.isDebugEnabled()) {
541 logger.debug(testName + ": status = " + statusCode);
543 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
544 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
545 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
548 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
549 dependsOnMethods = {"deactivate", "readNonExistent", "testSubmitRequest"})
550 public void updateWrongUser(String testName) throws Exception {
553 // Submit the request to the service and store the response.
555 // Note: The ID used in this 'create' call may be arbitrary.
556 // The only relevant ID may be the one used in updateAccount(), below.
557 ClientResponse<AccountsCommon> res =
558 client.read(knownResourceId);
559 if (logger.isDebugEnabled()) {
560 logger.debug(testName + ": read status = " + res.getStatus());
562 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
564 if (logger.isDebugEnabled()) {
565 logger.debug("got object to update with ID: " + knownResourceId);
567 AccountsCommon toUpdateAccount =
568 (AccountsCommon) res.getEntity();
569 Assert.assertNotNull(toUpdateAccount);
571 toUpdateAccount.setUserId("barneyFake");
572 if (logger.isDebugEnabled()) {
573 logger.debug("updated object with wrongUser");
574 logger.debug(objectAsXmlString(toUpdateAccount,
575 AccountsCommon.class));
578 res = client.update(knownResourceId, toUpdateAccount);
579 int statusCode = res.getStatus();
581 // Check the status code of the response: does it match
582 // the expected response(s)?
583 if (logger.isDebugEnabled()) {
584 logger.debug(testName + ": status = " + statusCode);
586 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
587 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
588 Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
591 // ---------------------------------------------------------------
592 // CRUD tests : DELETE tests
593 // ---------------------------------------------------------------
596 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
597 dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
598 public void delete(String testName) throws Exception {
601 setupDelete(testName);
603 // Submit the request to the service and store the response.
604 ClientResponse<Response> res = client.delete(knownResourceId);
605 int statusCode = res.getStatus();
607 // Check the status code of the response: does it match
608 // the expected response(s)?
609 if (logger.isDebugEnabled()) {
610 logger.debug(testName + ": status = " + statusCode);
612 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
613 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
614 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
617 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
618 dependsOnMethods = {"testSubmitRequest", "updateWrongUser"})
619 public void deleteList(String testName) throws Exception {
622 setupDelete(testName);
624 ClientResponse<Response> res = client.delete(resource1Id);
625 int statusCode = res.getStatus();
626 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
627 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
628 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
630 res = client.delete(resource2Id);
631 statusCode = res.getStatus();
632 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
633 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
634 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
639 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTest.class,
640 dependsOnMethods = {"delete"})
641 public void deleteNonExistent(String testName) throws Exception {
644 setupDeleteNonExistent(testName);
646 // Submit the request to the service and store the response.
647 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
648 int statusCode = res.getStatus();
650 // Check the status code of the response: does it match
651 // the expected response(s)?
652 if (logger.isDebugEnabled()) {
653 logger.debug(testName + ": status = " + statusCode);
655 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
656 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
657 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
660 // ---------------------------------------------------------------
661 // Utility tests : tests of code used in tests above
662 // ---------------------------------------------------------------
664 * Tests the code for manually submitting data that is used by several
665 * of the methods above.
667 @Test(dependsOnMethods = {"create", "read"})
668 public void testSubmitRequest() throws Exception {
670 // Expected status code: 200 OK
671 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
673 // Submit the request to the service and store the response.
674 String method = ServiceRequestType.READ.httpMethodName();
675 String url = getResourceURL(knownResourceId);
676 int statusCode = submitRequest(method, url);
678 // Check the status code of the response: does it match
679 // the expected response(s)?
680 if (logger.isDebugEnabled()) {
681 logger.debug("testSubmitRequest: url=" + url
682 + " status=" + statusCode);
684 Assert.assertEquals(statusCode, EXPECTED_STATUS);
688 // ---------------------------------------------------------------
689 // Utility methods used by tests above
690 // ---------------------------------------------------------------
692 * createAccountInstance
693 * @param tenant fillup tenant
694 * @param user to fill up user
695 * @param password to fill up password
697 private AccountsCommon createAccountInstance(String screenName,
698 String passwd, String email, boolean tenant, boolean user, boolean password) {
700 AccountsCommon account = new AccountsCommon();
701 account.setScreenName(screenName);
703 account.setUserId(screenName);
706 account.setPassword(Base64.encodeBase64(passwd.getBytes()));
708 account.setEmail(email);
709 account.setPhone("1234567890");
711 List<AccountsCommon.Tenant> atl = new ArrayList<AccountsCommon.Tenant>();
712 AccountsCommon.Tenant at = new AccountsCommon.Tenant();
713 at.setId(UUID.randomUUID().toString());
714 at.setName("movingimages.us");
717 AccountsCommon.Tenant at2 = new AccountsCommon.Tenant();
718 at2.setId(UUID.randomUUID().toString());
719 at2.setName("collectionspace.org");
721 account.setTenant(atl);
723 if (logger.isDebugEnabled()) {
724 logger.debug("to be created, account common");
725 logger.debug(objectAsXmlString(account,
726 AccountsCommon.class));
732 private void printList(String testName, AccountsCommonList list) {
733 List<AccountsCommonList.AccountListItem> items =
734 list.getAccountListItem();
737 for (AccountsCommonList.AccountListItem item : items) {
738 logger.debug(testName + ": list-item[" + i + "] csid="
740 logger.debug(testName + ": list-item[" + i + "] screenName="
741 + item.getScreenName());
742 logger.debug(testName + ": list-item[" + i + "] URI="