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 /** The known resource id. */
66 private String knownResourceId = null;
69 protected String getServiceName() {
70 return DimensionClient.SERVICE_NAME;
74 * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
77 protected CollectionSpaceClient getClientInstance() {
78 return new DimensionClient();
82 * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
85 protected AbstractCommonList getAbstractCommonList(
86 ClientResponse<AbstractCommonList> response) {
87 return response.getEntity(DimensionsCommonList.class);
90 // ---------------------------------------------------------------
91 // CRUD tests : CREATE tests
92 // ---------------------------------------------------------------
95 * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String)
98 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class)
99 public void create(String testName) throws Exception {
101 if (logger.isDebugEnabled()) {
102 logger.debug(testBanner(testName, CLASS_NAME));
104 // Perform setup, such as initializing the type of service request
105 // (e.g. CREATE, DELETE), its valid and expected status codes, and
106 // its associated HTTP method name (e.g. POST, DELETE).
109 // Submit the request to the service and store the response.
110 DimensionClient client = new DimensionClient();
111 String identifier = createIdentifier();
112 PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
114 ClientResponse<Response> res = client.create(multipart);
116 int statusCode = res.getStatus();
118 // Check the status code of the response: does it match
119 // the expected response(s)?
122 // Does it fall within the set of valid status codes?
123 // Does it exactly match the expected status code?
124 if (logger.isDebugEnabled()) {
125 logger.debug(testName + ": status = " + statusCode);
127 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
128 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
129 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
131 // Store the ID returned from the first resource created
132 // for additional tests below.
133 if (knownResourceId == null) {
134 knownResourceId = extractId(res);
135 if (logger.isDebugEnabled()) {
136 logger.debug(testName + ": knownResourceId=" + knownResourceId);
140 // Store the IDs from every resource created by tests,
141 // so they can be deleted after tests have been run.
142 allResourceIdsCreated.add(extractId(res));
146 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String)
149 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
150 dependsOnMethods = {"create"})
151 public void createList(String testName) throws Exception {
152 for (int i = 0; i < 3; i++) {
158 // Placeholders until the three tests below can be uncommented.
159 // See Issue CSPACE-401.
161 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String)
164 public void createWithEmptyEntityBody(String testName) throws Exception {
165 //Should this really be empty?
169 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
172 public void createWithMalformedXml(String testName) throws Exception {
173 //Should this really be empty?
177 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
180 public void createWithWrongXmlSchema(String testName) throws Exception {
181 //Should this really be empty?
186 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
187 dependsOnMethods = {"create", "testSubmitRequest"})
188 public void createWithEmptyEntityBody(String testName) throws Exception {
190 if (logger.isDebugEnabled()) {
191 logger.debug(testBanner(testName, CLASS_NAME));
194 setupCreateWithEmptyEntityBody(testName, logger);
196 // Submit the request to the service and store the response.
197 String method = REQUEST_TYPE.httpMethodName();
198 String url = getServiceRootURL();
199 String mediaType = MediaType.APPLICATION_XML;
200 final String entity = "";
201 int statusCode = submitRequest(method, url, mediaType, entity);
203 // Check the status code of the response: does it match
204 // the expected response(s)?
205 if(logger.isDebugEnabled()){
206 logger.debug("createWithEmptyEntityBody url=" + url +
207 " status=" + statusCode);
209 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
210 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
211 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
215 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
216 dependsOnMethods = {"create", "testSubmitRequest"})
217 public void createWithMalformedXml(String testName) throws Exception {
219 if (logger.isDebugEnabled()) {
220 logger.debug(testBanner(testName, CLASS_NAME));
223 setupCreateWithMalformedXml();
225 // Submit the request to the service and store the response.
226 String method = REQUEST_TYPE.httpMethodName();
227 String url = getServiceRootURL();
228 String mediaType = MediaType.APPLICATION_XML;
229 final String entity = MALFORMED_XML_DATA; // Constant from base class.
230 int statusCode = submitRequest(method, url, mediaType, entity);
232 // Check the status code of the response: does it match
233 // the expected response(s)?
234 if(logger.isDebugEnabled()){
235 logger.debug(testName + ": url=" + url +
236 " status=" + statusCode);
238 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
239 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
240 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
244 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
245 dependsOnMethods = {"create", "testSubmitRequest"})
246 public void createWithWrongXmlSchema(String testName) throws Exception {
248 if (logger.isDebugEnabled()) {
249 logger.debug(testBanner(testName, CLASS_NAME));
252 setupCreateWithWrongXmlSchema();
254 // Submit the request to the service and store the response.
255 String method = REQUEST_TYPE.httpMethodName();
256 String url = getServiceRootURL();
257 String mediaType = MediaType.APPLICATION_XML;
258 final String entity = WRONG_XML_SCHEMA_DATA;
259 int statusCode = submitRequest(method, url, mediaType, entity);
261 // Check the status code of the response: does it match
262 // the expected response(s)?
263 if(logger.isDebugEnabled()){
264 logger.debug(testName + ": url=" + url +
265 " status=" + statusCode);
267 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
268 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
269 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
272 // ---------------------------------------------------------------
273 // CRUD tests : READ tests
274 // ---------------------------------------------------------------
277 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String)
280 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
281 dependsOnMethods = {"create"})
282 public void read(String testName) throws Exception {
284 if (logger.isDebugEnabled()) {
285 logger.debug(testBanner(testName, CLASS_NAME));
290 // Submit the request to the service and store the response.
291 DimensionClient client = new DimensionClient();
292 ClientResponse<String> res = client.read(knownResourceId);
293 int statusCode = res.getStatus();
295 // Check the status code of the response: does it match
296 // the expected response(s)?
297 if (logger.isDebugEnabled()) {
298 logger.debug(testName + ": status = " + statusCode);
300 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
301 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
302 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
304 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
305 PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
306 DimensionsCommon dimensionsCommon = null;
307 if (payloadInputPart != null) {
308 dimensionsCommon = (DimensionsCommon) payloadInputPart.getBody();
310 Assert.assertNotNull(dimensionsCommon);
315 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String)
318 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
319 dependsOnMethods = {"read"})
320 public void readNonExistent(String testName) throws Exception {
322 if (logger.isDebugEnabled()) {
323 logger.debug(testBanner(testName, CLASS_NAME));
326 setupReadNonExistent();
328 // Submit the request to the service and store the response.
329 DimensionClient client = new DimensionClient();
330 ClientResponse<String> res = client.read(NON_EXISTENT_ID);
331 int statusCode = res.getStatus();
333 // Check the status code of the response: does it match
334 // the expected response(s)?
335 if (logger.isDebugEnabled()) {
336 logger.debug(testName + ": status = " + statusCode);
338 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
339 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
340 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
343 // ---------------------------------------------------------------
344 // CRUD tests : READ_LIST tests
345 // ---------------------------------------------------------------
348 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String)
351 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
352 dependsOnMethods = {"read"})
353 public void readList(String testName) throws Exception {
355 if (logger.isDebugEnabled()) {
356 logger.debug(testBanner(testName, CLASS_NAME));
361 // Submit the request to the service and store the response.
362 DimensionClient client = new DimensionClient();
363 ClientResponse<DimensionsCommonList> res = client.readList();
364 DimensionsCommonList list = res.getEntity();
365 int statusCode = res.getStatus();
367 // Check the status code of the response: does it match
368 // the expected response(s)?
369 if (logger.isDebugEnabled()) {
370 logger.debug(testName + ": status = " + statusCode);
372 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
373 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
374 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
376 // Optionally output additional data about list members for debugging.
377 boolean iterateThroughList = false;
378 if (iterateThroughList && logger.isDebugEnabled()) {
379 List<DimensionsCommonList.DimensionListItem> items =
380 list.getDimensionListItem();
382 for (DimensionsCommonList.DimensionListItem item : items) {
383 logger.debug(testName + ": list-item[" + i + "] csid="
385 logger.debug(testName + ": list-item[" + i + "] objectNumber="
386 + item.getDimension());
387 logger.debug(testName + ": list-item[" + i + "] URI="
397 // ---------------------------------------------------------------
398 // CRUD tests : UPDATE tests
399 // ---------------------------------------------------------------
402 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String)
405 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
406 dependsOnMethods = {"read"})
407 public void update(String testName) throws Exception {
409 if (logger.isDebugEnabled()) {
410 logger.debug(testBanner(testName, CLASS_NAME));
415 // Retrieve the contents of a resource to update.
416 DimensionClient client = new DimensionClient();
417 ClientResponse<String> res =
418 client.read(knownResourceId);
419 if (logger.isDebugEnabled()) {
420 logger.debug(testName + ": read status = " + res.getStatus());
422 Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
424 if (logger.isDebugEnabled()) {
425 logger.debug("got object to update with ID: " + knownResourceId);
427 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
428 PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName());
429 DimensionsCommon dimensionsCommon = null;
430 if (payloadInputPart != null) {
431 dimensionsCommon = (DimensionsCommon) payloadInputPart.getBody();
433 Assert.assertNotNull(dimensionsCommon);
435 // Update the content of this resource.
436 dimensionsCommon.setValue("updated-" + dimensionsCommon.getValue());
437 dimensionsCommon.setValueDate("updated-" + dimensionsCommon.getValueDate());
438 if (logger.isDebugEnabled()) {
439 logger.debug("to be updated object");
440 logger.debug(objectAsXmlString(dimensionsCommon, DimensionsCommon.class));
442 // Submit the request to the service and store the response.
443 PoxPayloadOut output = new PoxPayloadOut(this.getServicePathComponent());
444 PayloadOutputPart commonPart = output.addPart(dimensionsCommon, MediaType.APPLICATION_XML_TYPE);
445 commonPart.setLabel(client.getCommonPartName());
447 res = client.update(knownResourceId, output);
448 int statusCode = res.getStatus();
449 // Check the status code of the response: does it match the expected response(s)?
450 if (logger.isDebugEnabled()) {
451 logger.debug(testName + ": status = " + statusCode);
453 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
454 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
455 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
457 input = new PoxPayloadIn(res.getEntity());
458 DimensionsCommon updatedDimensionsCommon =
459 (DimensionsCommon) extractPart(input,
460 client.getCommonPartName(), DimensionsCommon.class);
461 Assert.assertNotNull(updatedDimensionsCommon);
463 Assert.assertEquals(updatedDimensionsCommon.getValueDate(),
464 dimensionsCommon.getValueDate(),
465 "Data in updated object did not match submitted data.");
470 // Placeholders until the three tests below can be uncommented.
471 // See Issue CSPACE-401.
473 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String)
476 public void updateWithEmptyEntityBody(String testName) throws Exception {
477 //Should this really be empty?
481 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String)
484 public void updateWithMalformedXml(String testName) throws Exception {
485 //Should this really be empty?
489 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String)
492 public void updateWithWrongXmlSchema(String testName) throws Exception {
493 //Should this really be empty?
498 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
499 dependsOnMethods = {"create", "update", "testSubmitRequest"})
500 public void updateWithEmptyEntityBody(String testName) throws Exception {
502 if (logger.isDebugEnabled()) {
503 logger.debug(testBanner(testName, CLASS_NAME));
506 setupUpdateWithEmptyEntityBody();
508 // Submit the request to the service and store the response.
509 String method = REQUEST_TYPE.httpMethodName();
510 String url = getResourceURL(knownResourceId);
511 String mediaType = MediaType.APPLICATION_XML;
512 final String entity = "";
513 int statusCode = submitRequest(method, url, mediaType, entity);
515 // Check the status code of the response: does it match
516 // the expected response(s)?
517 if(logger.isDebugEnabled()){
518 logger.debug(testName + ": url=" + url +
519 " status=" + statusCode);
521 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
522 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
523 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
527 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
528 dependsOnMethods = {"create", "update", "testSubmitRequest"})
529 public void updateWithMalformedXml(String testName) throws Exception {
531 if (logger.isDebugEnabled()) {
532 logger.debug(testBanner(testName, CLASS_NAME));
535 setupUpdateWithMalformedXml(testName, logger);
537 // Submit the request to the service and store the response.
538 String method = REQUEST_TYPE.httpMethodName();
539 String url = getResourceURL(knownResourceId);
540 String mediaType = MediaType.APPLICATION_XML;
541 final String entity = MALFORMED_XML_DATA;
542 int statusCode = submitRequest(method, url, mediaType, entity);
544 // Check the status code of the response: does it match
545 // the expected response(s)?
546 if(logger.isDebugEnabled()){
547 logger.debug(testName + ": url=" + url +
548 " status=" + statusCode);
550 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
551 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
552 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
556 @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class,
557 dependsOnMethods = {"create", "update", "testSubmitRequest"})
558 public void updateWithWrongXmlSchema(String testName) throws Exception {
560 if (logger.isDebugEnabled()) {
561 logger.debug(testBanner(testName, CLASS_NAME));
564 setupUpdateWithWrongXmlSchema(testName, logger);
566 // Submit the request to the service and store the response.
567 String method = REQUEST_TYPE.httpMethodName();
568 String url = getResourceURL(knownResourceId);
569 String mediaType = MediaType.APPLICATION_XML;
570 final String entity = WRONG_XML_SCHEMA_DATA;
571 int statusCode = submitRequest(method, url, mediaType, entity);
573 // Check the status code of the response: does it match
574 // the expected response(s)?
575 if(logger.isDebugEnabled()){
576 logger.debug(testName + ": url=" + url +
577 " status=" + statusCode);
579 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
580 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
581 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
586 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String)
589 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
590 dependsOnMethods = {"update", "testSubmitRequest"})
591 public void updateNonExistent(String testName) throws Exception {
593 if (logger.isDebugEnabled()) {
594 logger.debug(testBanner(testName, CLASS_NAME));
597 setupUpdateNonExistent();
599 // Submit the request to the service and store the response.
600 // Note: The ID used in this 'create' call may be arbitrary.
601 // The only relevant ID may be the one used in update(), below.
602 DimensionClient client = new DimensionClient();
603 PoxPayloadOut multipart = createDimensionInstance(client.getCommonPartName(),
605 ClientResponse<String> res =
606 client.update(NON_EXISTENT_ID, multipart);
607 int statusCode = res.getStatus();
609 // Check the status code of the response: does it match
610 // the expected response(s)?
611 if (logger.isDebugEnabled()) {
612 logger.debug(testName + ": status = " + statusCode);
614 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
615 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
616 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
619 // ---------------------------------------------------------------
620 // CRUD tests : DELETE tests
621 // ---------------------------------------------------------------
624 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String)
627 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
628 dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"})
629 public void delete(String testName) throws Exception {
631 if (logger.isDebugEnabled()) {
632 logger.debug(testBanner(testName, CLASS_NAME));
637 // Submit the request to the service and store the response.
638 DimensionClient client = new DimensionClient();
639 ClientResponse<Response> res = client.delete(knownResourceId);
640 int statusCode = res.getStatus();
642 // Check the status code of the response: does it match
643 // the expected response(s)?
644 if (logger.isDebugEnabled()) {
645 logger.debug(testName + ": status = " + statusCode);
647 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
648 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
649 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
654 * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String)
657 @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
658 dependsOnMethods = {"delete"})
659 public void deleteNonExistent(String testName) throws Exception {
661 if (logger.isDebugEnabled()) {
662 logger.debug(testBanner(testName, CLASS_NAME));
665 setupDeleteNonExistent();
667 // Submit the request to the service and store the response.
668 DimensionClient client = new DimensionClient();
669 ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
670 int statusCode = res.getStatus();
672 // Check the status code of the response: does it match
673 // the expected response(s)?
674 if (logger.isDebugEnabled()) {
675 logger.debug(testName + ": status = " + statusCode);
677 Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
678 invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
679 Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
682 // ---------------------------------------------------------------
683 // Utility tests : tests of code used in tests above
684 // ---------------------------------------------------------------
686 * Tests the code for manually submitting data that is used by several
687 * of the methods above.
689 @Test(dependsOnMethods = {"create", "read"})
690 public void testSubmitRequest() {
692 // Expected status code: 200 OK
693 final int EXPECTED_STATUS = Response.Status.OK.getStatusCode();
695 // Submit the request to the service and store the response.
696 String method = ServiceRequestType.READ.httpMethodName();
697 String url = getResourceURL(knownResourceId);
698 int statusCode = submitRequest(method, url);
700 // Check the status code of the response: does it match
701 // the expected response(s)?
702 if (logger.isDebugEnabled()) {
703 logger.debug("testSubmitRequest: url=" + url
704 + " status=" + statusCode);
706 Assert.assertEquals(statusCode, EXPECTED_STATUS);
710 // ---------------------------------------------------------------
711 // Utility methods used by tests above
712 // ---------------------------------------------------------------
714 * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent()
717 public String getServicePathComponent() {
718 return DimensionClient.SERVICE_PATH_COMPONENT;
722 * Creates the dimension instance.
724 * @param identifier the identifier
725 * @return the multipart output
727 private PoxPayloadOut createDimensionInstance(String commonPartName, String identifier) {
728 return createDimensionInstance(commonPartName,
729 "dimensionType-" + identifier,
730 "entryNumber-" + identifier,
731 "entryDate-" + identifier);
735 * Creates the dimension instance.
737 * @param dimensionType the dimension type
738 * @param entryNumber the entry number
739 * @param entryDate the entry date
740 * @return the multipart output
742 private PoxPayloadOut createDimensionInstance(String commonPartName, String dimensionType, String entryNumber, String entryDate) {
743 DimensionsCommon dimensionsCommon = new DimensionsCommon();
744 dimensionsCommon.setDimension(dimensionType);
745 dimensionsCommon.setValue(entryNumber);
746 dimensionsCommon.setValueDate(entryDate);
747 PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(
748 commonPartName, dimensionsCommon);
750 if (logger.isDebugEnabled()) {
751 logger.debug("to be created, dimension common");
752 logger.debug(objectAsXmlString(dimensionsCommon,
753 DimensionsCommon.class));