private CollectionObjectClient client = new CollectionObjectClient();
private String knownResourceId = null;
private List<String> allResourceIdsCreated = new ArrayList();
+ private boolean multivalue; //toggle
/*
* This method is called only by the parent class, AbstractServiceTest
int i = 0;
for (CollectionobjectsCommonList.CollectionObjectListItem item : items) {
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(testName + ": list-item[" + i + "] objectNumber=" +
- item.getObjectNumber());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
+ logger.debug(testName + ": list-item[" + i + "] csid="
+ + item.getCsid());
+ logger.debug(testName + ": list-item[" + i + "] objectNumber="
+ + item.getObjectNumber());
+ logger.debug(testName + ": list-item[" + i + "] URI="
+ + item.getUri());
i++;
}
if (logger.isDebugEnabled()) {
logger.debug("updated object");
logger.debug(objectAsXmlString(collectionObject,
- CollectionobjectsCommon.class));
+ CollectionobjectsCommon.class));
}
// Submit the request to the service and store the response.
// Check the status code of the response: does it match
// the expected response(s)?
if (logger.isDebugEnabled()) {
- logger.debug("testSubmitRequest: url=" + url +
- " status=" + statusCode);
+ logger.debug("testSubmitRequest: url=" + url
+ + " status=" + statusCode);
}
Assert.assertEquals(statusCode, EXPECTED_STATUS);
// ---------------------------------------------------------------
// Cleanup of resources created during testing
// ---------------------------------------------------------------
-
/**
* Deletes all resources created by tests, after all tests have been run.
*
* at any point during testing, even if some of those resources
* may be expected to be deleted by certain tests.
*/
- @AfterClass(alwaysRun=true)
+ @AfterClass(alwaysRun = true)
public void cleanUp() {
if (logger.isDebugEnabled()) {
logger.debug("Cleaning up temporary resources created for testing ...");
OtherNumberList onList = new OtherNumberList();
List<String> ons = onList.getOtherNumber();
ons.add("urn:org.collectionspace.id:24082390");
- ons.add("urn:org.walkerart.id:123");
+ if (multivalue) {
+ ons.add("urn:org.walkerart.id:123");
+ }
+ multivalue = !multivalue;
collectionObject.setOtherNumbers(onList);
collectionObject.setObjectNumber(objectNumber);
collectionObject.setObjectName(objectName);
collectionObject.setAge(""); //test for null string
- collectionObject.setBriefDescription("Papier mache bird mask with horns, " +
- "painted red with black and yellow spots. " +
- "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns).");
+ collectionObject.setBriefDescription("Papier mache bird mask with horns, "
+ + "painted red with black and yellow spots. "
+ + "Puerto Rico. ca. 8" high, 6" wide, projects 10" (with horns).");
MultipartOutput multipart = new MultipartOutput();
OutputPart commonPart = multipart.addPart(collectionObject,
MediaType.APPLICATION_XML_TYPE);
if (logger.isDebugEnabled()) {
logger.debug("to be created, collectionobject common");
logger.debug(objectAsXmlString(collectionObject,
- CollectionobjectsCommon.class));
+ CollectionobjectsCommon.class));
}
CollectionobjectsNaturalhistory conh = new CollectionobjectsNaturalhistory();
if (logger.isDebugEnabled()) {
logger.debug("to be created, collectionobject nhistory");
logger.debug(objectAsXmlString(conh,
- CollectionobjectsNaturalhistory.class));
+ CollectionobjectsNaturalhistory.class));
}
return multipart;
HashMap<String, Object> objectProps = new HashMap<String, Object>();
// Get a list of all elements in the document
Node root = document.getFirstChild();
- NodeList rootChildren = root.getChildNodes();
- for (int i = 0; i < rootChildren.getLength(); i++) {
- Node node = rootChildren.item(i);
+ NodeList nodeChildren = root.getChildNodes();
+ for (int i = 0; i < nodeChildren.getLength(); i++) {
+ Node node = nodeChildren.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
NodeList childNodes = node.getChildNodes();
- if (childNodes.getLength() > 1) {
- //must be multi value element
- String[] vals = getMultiValues(node);
- objectProps.put(node.getNodeName(), vals);
- } else if (childNodes.getLength() == 1) {
- objectProps.put(node.getNodeName(), getTextNodeValue(node));
+ Node cnode = childNodes.item(0);
+ if (cnode != null) {
+ if (cnode.getNodeType() == Node.TEXT_NODE) {
+ objectProps.put(node.getNodeName(), getTextNodeValue(node));
+ } else {
+ String[] vals = getMultiValues(node);
+ objectProps.put(node.getNodeName(), vals);
+ }
}
}
}
nv.name = stz.nextToken();
nv.value = stz.nextToken();
} else {
- throw new IllegalStateException("Found multi valued element " + input +
- " without qualification");
+ throw new IllegalStateException("Found multi valued element " + input
+ + " without qualification");
}
return nv;
}