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.client.test;
25 //import java.util.ArrayList;
26 import java.util.List;
27 import javax.ws.rs.core.MediaType;
28 import javax.ws.rs.core.Response;
30 import org.collectionspace.services.client.CollectionSpaceClient;
31 import org.collectionspace.services.client.DimensionClient;
32 import org.collectionspace.services.client.DimensionFactory;
33 import org.collectionspace.services.client.PayloadInputPart;
34 import org.collectionspace.services.client.PayloadOutputPart;
35 import org.collectionspace.services.client.PoxPayloadIn;
36 import org.collectionspace.services.client.PoxPayloadOut;
37 import org.collectionspace.services.dimension.DimensionsCommon;
38 import org.collectionspace.services.dimension.DimensionsCommonList;
39 import org.collectionspace.services.jaxb.AbstractCommonList;
41 import org.jboss.resteasy.client.ClientResponse;
43 import org.testng.Assert;
44 //import org.testng.annotations.AfterClass;
45 import org.testng.annotations.Test;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
51 * DimensionServiceTest, carries out tests against a
52 * deployed and running Dimension Service.
54 * $LastChangedRevision: 917 $
55 * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $
57 public class DimensionServiceTest extends AbstractServiceTestImpl {
60 private final String CLASS_NAME = DimensionServiceTest.class.getName();
61 private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
63 // Instance variables specific to this test.
64 /** The SERVIC e_ pat h_ component. */
65 final String SERVICE_PATH_COMPONENT = "dimensions";
66 /** The known resource id. */
67 private String knownResourceId = null;
70 protected String getServiceName() {
71 return DimensionClient.SERVICE_NAME;
75 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
78 protected CollectionSpaceClient getClientInstance() {
79 return new DimensionClient();
83 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
86 protected AbstractCommonList getAbstractCommonList(
87 ClientResponse<AbstractCommonList> response) {
88 return response.getEntity(DimensionsCommonList.class);
91 // ---------------------------------------------------------------
92 // CRUD tests : CREATE tests
93 // ---------------------------------------------------------------
96 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
99 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
100 public void create(String testName) throws Exception {
102 if (logger.isDebugEnabled()) {
103 logger.debug(testBanner(testName, CLASS_NAME));
105 // Perform setup, such as initializing the type of service request
106 // (e.g. CREATE, DELETE), its valid and expected status codes, and
107 // its associated HTTP method name (e.g. POST, DELETE).
110 // Submit the request to the service and store the response.
111 DimensionClient client = new DimensionClient();
112 String identifier = createIdentifier();
113 PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
115 ClientResponse<Response> res = client.create(multipart);
117 int statusCode = res.getStatus();
119 // Check the status code of the response: does it match
120 // the expected response(s)?
123 // Does it fall within the set of valid status codes?
124 // Does it exactly match the expected status code?
125 if (logger.isDebugEnabled()) {
126 logger.debug(testName + ": status = " + statusCode);
128 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
129 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
130 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
132 // Store the ID returned from the first resource created
133 // for additional tests below.
134 if (knownResourceId == null) {
135 knownResourceId = extractId(res);
136 if (logger.isDebugEnabled()) {
137 logger.debug(testName + ": knownResourceId=" + knownResourceId);
141 // Store the IDs from every resource created by tests,
142 // so they can be deleted after tests have been run.
143 allResourceIdsCreated.add(extractId(res));
147 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
150 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
151 dependsOnMethods = {"create"})
152 public void createList(String testName) throws Exception {
153 for (int i = 0; i < 3; i++) {
159 // Placeholders until the three tests below can be uncommented.
160 // See Issue CSPACE-401.
162 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
165 public void createWithEmptyEntityBody(String testName) throws Exception {
166 //Should this really be empty?
170 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
173 public void createWithMalformedXml(String testName) throws Exception {
174 //Should this really be empty?
178 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
181 public void createWithWrongXmlSchema(String testName) throws Exception {
182 //Should this really be empty?
187 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
188 dependsOnMethods = {"create", "testSubmitRequest"})
189 public void createWithEmptyEntityBody(String testName) throws Exception {
191 if (logger.isDebugEnabled()) {
192 logger.debug(testBanner(testName, CLASS_NAME));
195 setupCreateWithEmptyEntityBody(testName, logger);
197 // Submit the request to the service and store the response.
198 String method = REQUEST_TYPE.httpMethodName();
199 String url = getServiceRootURL();
200 String mediaType = MediaType.APPLICATION_XML;
201 final String entity = "";
202 int statusCode = submitRequest(method, url, mediaType, entity);
204 // Check the status code of the response: does it match
205 // the expected response(s)?
206 if(logger.isDebugEnabled()){
207 logger.debug("createWithEmptyEntityBody url=" + url +
208 " status=" + statusCode);
210 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
211 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
212 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
216 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
217 dependsOnMethods = {"create", "testSubmitRequest"})
218 public void createWithMalformedXml(String testName) throws Exception {
220 if (logger.isDebugEnabled()) {
221 logger.debug(testBanner(testName, CLASS_NAME));
224 setupCreateWithMalformedXml();
226 // Submit the request to the service and store the response.
227 String method = REQUEST_TYPE.httpMethodName();
228 String url = getServiceRootURL();
229 String mediaType = MediaType.APPLICATION_XML;
230 final String entity = MALFORMED_XML_DATA; // Constant from base class.
231 int statusCode = submitRequest(method, url, mediaType, entity);
233 // Check the status code of the response: does it match
234 // the expected response(s)?
235 if(logger.isDebugEnabled()){
236 logger.debug(testName + ": url=" + url +
237 " status=" + statusCode);
239 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
240 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
241 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
245 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
246 dependsOnMethods = {"create", "testSubmitRequest"})
247 public void createWithWrongXmlSchema(String testName) throws Exception {
249 if (logger.isDebugEnabled()) {
250 logger.debug(testBanner(testName, CLASS_NAME));
253 setupCreateWithWrongXmlSchema();
255 // Submit the request to the service and store the response.
256 String method = REQUEST_TYPE.httpMethodName();
257 String url = getServiceRootURL();
258 String mediaType = MediaType.APPLICATION_XML;
259 final String entity = WRONG_XML_SCHEMA_DATA;
260 int statusCode = submitRequest(method, url, mediaType, entity);
262 // Check the status code of the response: does it match
263 // the expected response(s)?
264 if(logger.isDebugEnabled()){
265 logger.debug(testName + ": url=" + url +
266 " status=" + statusCode);
268 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
269 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
270 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
273 // ---------------------------------------------------------------
274 // CRUD tests : READ tests
275 // ---------------------------------------------------------------
278 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
281 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
282 dependsOnMethods = {"create"})
283 public void read(String testName) throws Exception {
285 if (logger.isDebugEnabled()) {
286 logger.debug(testBanner(testName, CLASS_NAME));
291 // Submit the request to the service and store the response.
292 DimensionClient client = new DimensionClient();
293 ClientResponse<String> res = client.read(knownResourceId);
294 int statusCode = res.getStatus();
296 // Check the status code of the response: does it match
297 // the expected response(s)?
298 if (logger.isDebugEnabled()) {
299 logger.debug(testName + ": status = " + statusCode);
301 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
302 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
303 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
305 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
306 PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
307 DimensionsCommon dimensionsCommon = null;
308 if (payloadInputPart != null) {
309 dimensionsCommon = (DimensionsCommon) payloadInputPart.getBody();
311 Assert.assertNotNull(dimensionsCommon);
316 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
319 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
320 dependsOnMethods = {"read"})
321 public void readNonExistent(String testName) throws Exception {
323 if (logger.isDebugEnabled()) {
324 logger.debug(testBanner(testName, CLASS_NAME));
327 setupReadNonExistent();
329 // Submit the request to the service and store the response.
330 DimensionClient client = new DimensionClient();
331 ClientResponse<String> res = client.read(NON_EXISTENT_ID);
332 int statusCode = res.getStatus();
334 // Check the status code of the response: does it match
335 // the expected response(s)?
336 if (logger.isDebugEnabled()) {
337 logger.debug(testName + ": status = " + statusCode);
339 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
340 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
341 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
344 // ---------------------------------------------------------------
345 // CRUD tests : READ_LIST tests
346 // ---------------------------------------------------------------
349 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
352 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
353 dependsOnMethods = {"read"})
354 public void readList(String testName) throws Exception {
356 if (logger.isDebugEnabled()) {
357 logger.debug(testBanner(testName, CLASS_NAME));
362 // Submit the request to the service and store the response.
363 DimensionClient client = new DimensionClient();
364 ClientResponse<DimensionsCommonList> res = client.readList();
365 DimensionsCommonList list = res.getEntity();
366 int statusCode = res.getStatus();
368 // Check the status code of the response: does it match
369 // the expected response(s)?
370 if (logger.isDebugEnabled()) {
371 logger.debug(testName + ": status = " + statusCode);
373 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
374 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
375 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
377 // Optionally output additional data about list members for debugging.
378 boolean iterateThroughList = false;
379 if (iterateThroughList && logger.isDebugEnabled()) {
380 List<DimensionsCommonList.DimensionListItem> items =
381 list.getDimensionListItem();
383 for (DimensionsCommonList.DimensionListItem item : items) {
384 logger.debug(testName + ": list-item[" + i + "] csid="
386 logger.debug(testName + ": list-item[" + i + "] objectNumber="
387 + item.getDimension());
388 logger.debug(testName + ": list-item[" + i + "] URI="
398 // ---------------------------------------------------------------
399 // CRUD tests : UPDATE tests
400 // ---------------------------------------------------------------
403 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
406 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
407 dependsOnMethods = {"read"})
408 public void update(String testName) throws Exception {
410 if (logger.isDebugEnabled()) {
411 logger.debug(testBanner(testName, CLASS_NAME));
416 // Retrieve the contents of a resource to update.
417 DimensionClient client = new DimensionClient();
418 ClientResponse<String> res =
419 client.read(knownResourceId);
420 if (logger.isDebugEnabled()) {
421 logger.debug(testName + ": read status = " + res.getStatus());
423 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
425 if (logger.isDebugEnabled()) {
426 logger.debug("got object to update with ID: " + knownResourceId);
428 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
429 PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
430 DimensionsCommon dimensionsCommon = null;
431 if (payloadInputPart != null) {
432 dimensionsCommon = (DimensionsCommon) payloadInputPart.getBody();
434 Assert.assertNotNull(dimensionsCommon);
436 // Update the content of this resource.
437 dimensionsCommon.setValue("updated-" + dimensionsCommon.getValue());
438 dimensionsCommon.setValueDate("updated-" + dimensionsCommon.getValueDate());
439 if (logger.isDebugEnabled()) {
440 logger.debug("to be updated object");
441 logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));
443 // Submit the request to the service and store the response.
444 PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
445 PayloadOutputPart commonPart = output.addPart(dimensionsCommon, MediaType.APPLICATION_XML_TYPE);
446 commonPart.setLabel(client.getCommonPartName());
448 res = client.update(knownResourceId, output);
449 int statusCode = res.getStatus();
450 // Check the status code of the response: does it match the expected response(s)?
451 if (logger.isDebugEnabled()) {
452 logger.debug(testName + ": status = " + statusCode);
454 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
455 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
456 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
458 input = new PoxPayloadIn(res.getEntity());
459 DimensionsCommon updatedDimensionsCommon =
460 (DimensionsCommon) extractPart(input,
461 client.getCommonPartName(), DimensionsCommon.class);
462 Assert.assertNotNull(updatedDimensionsCommon);
464 Assert.assertEquals(updatedDimensionsCommon.getValueDate(),
465 dimensionsCommon.getValueDate(),
466 "Data in updated object did not match submitted data.");
471 // Placeholders until the three tests below can be uncommented.
472 // See Issue CSPACE-401.
474 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
477 public void updateWithEmptyEntityBody(String testName) throws Exception {
478 //Should this really be empty?
482 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
485 public void updateWithMalformedXml(String testName) throws Exception {
486 //Should this really be empty?
490 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
493 public void updateWithWrongXmlSchema(String testName) throws Exception {
494 //Should this really be empty?
499 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
500 dependsOnMethods = {"create", "update", "testSubmitRequest"})
501 public void updateWithEmptyEntityBody(String testName) throws Exception {
503 if (logger.isDebugEnabled()) {
504 logger.debug(testBanner(testName, CLASS_NAME));
507 setupUpdateWithEmptyEntityBody();
509 // Submit the request to the service and store the response.
510 String method = REQUEST_TYPE.httpMethodName();
511 String url = getResourceURL(knownResourceId);
512 String mediaType = MediaType.APPLICATION_XML;
513 final String entity = "";
514 int statusCode = submitRequest(method, url, mediaType, entity);
516 // Check the status code of the response: does it match
517 // the expected response(s)?
518 if(logger.isDebugEnabled()){
519 logger.debug(testName + ": url=" + url +
520 " status=" + statusCode);
522 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
523 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
524 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
528 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
529 dependsOnMethods = {"create", "update", "testSubmitRequest"})
530 public void updateWithMalformedXml(String testName) throws Exception {
532 if (logger.isDebugEnabled()) {
533 logger.debug(testBanner(testName, CLASS_NAME));
536 setupUpdateWithMalformedXml(testName, logger);
538 // Submit the request to the service and store the response.
539 String method = REQUEST_TYPE.httpMethodName();
540 String url = getResourceURL(knownResourceId);
541 String mediaType = MediaType.APPLICATION_XML;
542 final String entity = MALFORMED_XML_DATA;
543 int statusCode = submitRequest(method, url, mediaType, entity);
545 // Check the status code of the response: does it match
546 // the expected response(s)?
547 if(logger.isDebugEnabled()){
548 logger.debug(testName + ": url=" + url +
549 " status=" + statusCode);
551 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
552 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
553 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
557 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
558 dependsOnMethods = {"create", "update", "testSubmitRequest"})
559 public void updateWithWrongXmlSchema(String testName) throws Exception {
561 if (logger.isDebugEnabled()) {
562 logger.debug(testBanner(testName, CLASS_NAME));
565 setupUpdateWithWrongXmlSchema(testName, logger);
567 // Submit the request to the service and store the response.
568 String method = REQUEST_TYPE.httpMethodName();
569 String url = getResourceURL(knownResourceId);
570 String mediaType = MediaType.APPLICATION_XML;
571 final String entity = WRONG_XML_SCHEMA_DATA;
572 int statusCode = submitRequest(method, url, mediaType, entity);
574 // Check the status code of the response: does it match
575 // the expected response(s)?
576 if(logger.isDebugEnabled()){
577 logger.debug(testName + ": url=" + url +
578 " status=" + statusCode);
580 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
581 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
582 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
587 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
590 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
591 dependsOnMethods = {"update", "testSubmitRequest"})
592 public void updateNonExistent(String testName) throws Exception {
594 if (logger.isDebugEnabled()) {
595 logger.debug(testBanner(testName, CLASS_NAME));
598 setupUpdateNonExistent();
600 // Submit the request to the service and store the response.
601 // Note: The ID used in this 'create' call may be arbitrary.
602 // The only relevant ID may be the one used in update(), below.
603 DimensionClient client = new DimensionClient();
604 PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
606 ClientResponse<String> res =
607 client.update(NON_EXISTENT_ID, multipart);
608 int statusCode = res.getStatus();
610 // Check the status code of the response: does it match
611 // the expected response(s)?
612 if (logger.isDebugEnabled()) {
613 logger.debug(testName + ": status = " + statusCode);
615 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
616 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
617 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
620 // ---------------------------------------------------------------
621 // CRUD tests : DELETE tests
622 // ---------------------------------------------------------------
625 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
628 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
629 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
630 public void delete(String testName) throws Exception {
632 if (logger.isDebugEnabled()) {
633 logger.debug(testBanner(testName, CLASS_NAME));
638 // Submit the request to the service and store the response.
639 DimensionClient client = new DimensionClient();
640 ClientResponse<Response> res = client.delete(knownResourceId);
641 int statusCode = res.getStatus();
643 // Check the status code of the response: does it match
644 // the expected response(s)?
645 if (logger.isDebugEnabled()) {
646 logger.debug(testName + ": status = " + statusCode);
648 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
649 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
650 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
655 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
658 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
659 dependsOnMethods = {"delete"})
660 public void deleteNonExistent(String testName) throws Exception {
662 if (logger.isDebugEnabled()) {
663 logger.debug(testBanner(testName, CLASS_NAME));
666 setupDeleteNonExistent();
668 // Submit the request to the service and store the response.
669 DimensionClient client = new DimensionClient();
670 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
671 int statusCode = res.getStatus();
673 // Check the status code of the response: does it match
674 // the expected response(s)?
675 if (logger.isDebugEnabled()) {
676 logger.debug(testName + ": status = " + statusCode);
678 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
679 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
680 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
683 // ---------------------------------------------------------------
684 // Utility tests : tests of code used in tests above
685 // ---------------------------------------------------------------
687 * Tests the code for manually submitting data that is used by several
688 * of the methods above.
690 @Test(dependsOnMethods = {"create", "read"})
691 public void testSubmitRequest() {
693 // Expected status code: 200 OK
694 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
696 // Submit the request to the service and store the response.
697 String method = ServiceRequestType.READ.httpMethodName();
698 String url = getResourceURL(knownResourceId);
699 int statusCode = submitRequest(method, url);
701 // Check the status code of the response: does it match
702 // the expected response(s)?
703 if (logger.isDebugEnabled()) {
704 logger.debug("testSubmitRequest: url=" + url
705 + " status=" + statusCode);
707 Assert.assertEquals(statusCode, EXPECTED_STATUS);
711 // ---------------------------------------------------------------
712 // Utility methods used by tests above
713 // ---------------------------------------------------------------
715 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
718 public String getServicePathComponent() {
719 return SERVICE_PATH_COMPONENT;
723 * Creates the dimension instance.
725 * @param identifier the identifier
726 * @return the multipart output
728 private PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
729 return createDimensionInstance(commonPartName,
730 "dimensionType-" + identifier,
731 "entryNumber-" + identifier,
732 "entryDate-" + identifier);
736 * Creates the dimension instance.
738 * @param dimensionType the dimension type
739 * @param entryNumber the entry number
740 * @param entryDate the entry date
741 * @return the multipart output
743 private PoxPayloadOut createDimensionInstance(String commonPartName, String dimensionType, String entryNumber, String entryDate) {
744 DimensionsCommon dimensionsCommon = new DimensionsCommon();
745 dimensionsCommon.setDimension(dimensionType);
746 dimensionsCommon.setValue(entryNumber);
747 dimensionsCommon.setValueDate(entryDate);
748 PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(
749 commonPartName, dimensionsCommon);
751 if (logger.isDebugEnabled()) {
752 logger.debug("to be created, dimension common");
753 logger.debug(objectAsXmlString(dimensionsCommon,
754 DimensionsCommon.class));