From: Laramie Crocker Date: Sat, 20 Nov 2010 00:17:17 +0000 (+0000) Subject: CSPACE-2666 added ObjectExit tests with dom-walk X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=e5cd7ba15205417d78a84d3d9e7b9e2a2e720ede;p=tmp%2Fjakarta-migration.git CSPACE-2666 added ObjectExit tests with dom-walk --- diff --git a/services/IntegrationTests/pom.xml b/services/IntegrationTests/pom.xml index c9d8da899..57de764ad 100644 --- a/services/IntegrationTests/pom.xml +++ b/services/IntegrationTests/pom.xml @@ -117,6 +117,12 @@ commons-jexl 2.0.1 + + jdom + jdom + 1.0 + provided + diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/PayloadLogger.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/PayloadLogger.java new file mode 100755 index 000000000..b1259ee61 --- /dev/null +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/PayloadLogger.java @@ -0,0 +1,536 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + * + * http://www.collectionspace.org + * http://wiki.collectionspace.org + * + * Copyright (c) 2009 Regents of the University of California + * + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.collectionspace.services.IntegrationTests.xmlreplay; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +public class PayloadLogger{ + + public static void saveReport(){ + reporter.writeTable(); + } + + private static Reporter reporter = new Reporter(); + + private static volatile int ID = 1000; + public String getID(){ + return ""+ID; + } + + private static String DD = "--"; + private static String LABEL="LABEL: "; + + static class Reporter { + public Reporter(){ + table.append("\r\n"); + } + public static final String START = ""; + + public void writeTable(){ + table.append("
"; + public static final String SEP = ""; + public static final String END = "
"); + saveFile("./xml/", "results.html", table.toString()); + } + + private StringBuffer table = new StringBuffer(); + + public synchronized void finished(HttpTraffic traffic){ + String direction = traffic.isRequest ? + "==>" + : + " <=="; + table.append(START) + .append(direction) + .append(SEP) + .append(traffic==null ? "null" : traffic.toRow(SEP, this)) + .append(END); + } + + public synchronized void finished(List trafficList){ + for (HttpTraffic traffic: trafficList){ + finished(traffic); + } + } + + public static String link(String desc, String url){ + return ""+desc+""; + } + public static final String newline = "
\r\n"; + + } + + + static class HttpTraffic { + public HttpTraffic(){ + payloads = new ArrayList(); + } + public List payloads; + public String method = ""; + public String url = ""; + public String queryParams = ""; + public String message = ""; + public int responseCode = 0; + public String boundary = ""; + public String location = ""; + public long contentLength = -1; + public boolean isRequest = true; + public boolean extra = false; + public String ID = "0"; + public int nexti = 0; + + public Part getPart(String label){ + for (Part part : payloads){ + if (part.label.equalsIgnoreCase(label)){ + return part; + } + } + return null; + } + + public String toRow(String sep, Reporter reporter){ + StringBuffer b = new StringBuffer(); + for (Part part : payloads){ + String name = part.label; + if (part.filename.length()==0){ + continue; + } + if (name.trim().length()<=0){ + name = ID; + } + name = name+" ("+part.filetype+')'; + String link = reporter.link(name, part.filename); + b.append(link) + .append(reporter.newline); + } + String parts = b.toString(); + if (isRequest){ + return ID+sep + +method+sep + +url+sep + +queryParams+sep + +sep + +parts; + } else { + return ID+sep + +responseCode+sep + +message+sep + +location+sep + +contentLength+sep + +url + +parts; + } + } + } + + static class Part { + public Part(String boundary){ + this.boundary = boundary; + } + public boolean isMultipart(){ + return boundary.length()>0; + } + public String toString(){ + return "Part:"+label+";"; + } + public String filename = ""; + public String filetype = ""; + public String boundary; + public StringBuffer buffer = new StringBuffer(); + public String getContent(){ + return buffer.toString(); + } + public String label = ""; + public int readPart(String[]lines, int i){ + String line = ""; + boolean readingPartHeaders = true; + while(readingPartHeaders){ + line = killTrailingWS(lines[i]); + if (line.toUpperCase().startsWith(LABEL)){ + this.label = line.substring(LABEL.length()).trim(); + } else if (line.trim().length()==0){ + readingPartHeaders = false; + } + i++; + } + while (i 2) { + System.err.println("WARNING: too many tokens after boundary= on Content-Type: header line: " + headerLine); + } + } + return boundary; + } + + /** places the boundary on the HttpTraffic in parameter object if boundary found in header "Content-Type:". + * @return the index of the NEXT line the caller should read. */ + protected static int readHeaders(HttpTraffic traffic, String[]lines, int i){ + int lineCount = lines.length; + String line, lineUP; + // Now read headers until we are ready for payload or parts. + while (i 2){ + System.err.println("WARNING: too many tokens after boundary= on Content-Type: header line: "+line); + } + } else if (lineUP.startsWith("LOCATION: ")){ + traffic.location = killTrailingWS(line.substring("LOCATION: ".length())); + } else if (lineUP.startsWith("CONTENT-LENGTH: ")){ + traffic.contentLength = Integer.parseInt(killTrailingWS(line.substring("CONTENT-LENGTH: ".length()))); + } + i++; + } + } + return i; + } + + + // 0 1 2 3 + // a b c \r + + private static String killTrailingWS(String s){ + int i = s.length(); + while (i>0){ + char c = s.charAt(i-1); + if (c=='\r' || c=='\n' || c==' '){ + i--; + continue; + } else { + break; + } + } + return s.substring(0, i); + } + + public static HttpTraffic readPayloads(String fullPayload, String boundary, long contentLength){ + HttpTraffic traffic = new HttpTraffic(); + traffic.contentLength = contentLength; + traffic.boundary = boundary; + String [] lines = fullPayload.split("\\n", -1); + readPayloads(traffic, lines, 0); + return traffic; + } + + protected static int readPayloads(HttpTraffic traffic, String[]lines, int i){ + if (traffic.boundary.length()<=0){ //END of headers, and no boundary, so read remaining and return. + if (traffic.contentLength == 0){ + return i; + } + Part part = new Part(""); + traffic.payloads.add(part); + i = part.readRemaining(lines, i, traffic.contentLength); + return i; + } + int lineCount = lines.length; + String line; + while (i0){ + // System.err.println("********** Skipping line: "+line); //either parser error, or something is outside of a boundary. + //} + //i++; + } + } + return i; + } + + + private HttpTraffic parseForward(String forward, int nexti){ + HttpTraffic forwardTraffic = new HttpTraffic(); + forwardTraffic.isRequest = true; + forwardTraffic.ID = getID(); + //String[] lines = forward.split("\\r\\n", -1); + String[] lines = forward.split("\\n", -1); + int lineCount = lines.length; + String line; + int i = nexti; + + // Read the first line, and figure out if GET, POST, etc., and the URI + line = lines[i]; + while (line.trim().length()==0){ + i++; + if (i>=lineCount-1){ + return null; + } + line = lines[i]; + } + String[] tokens = line.split(" ", -1); + forwardTraffic.method = tokens[0]; + String urlString = tokens[1]; + String[] urlHalves = urlString.split("\\?", -1); //look for a query string of the form /foo/bar?param=baz and break on question mark. + forwardTraffic.url = urlHalves[0]; + if (urlHalves.length > 1){ + forwardTraffic.queryParams = urlHalves[1]; + } + i++; + + //if (forwardTraffic.method.equals("GET")|| forwardTraffic.method.equals("DELETE")){ + // return forwardTraffic; + //} + // Now read headers until we are ready for payload or parts. + i = readHeaders(forwardTraffic, lines, i); + + /* + if ( (i=lineCount){ + return null; + } + line = lines[i]; + + // Read the first line, and figure out response code, message. + while (i=lineCount){ + reverseTraffic.nexti = -1; + } + return reverseTraffic; + } + + private List handleTcpDump(String dump){ + int i = 0; + int trafficID = 0; + List trafficList = new ArrayList(); + while (i>-1){ + trafficID++; + HttpTraffic forward = parseForward(dump, i); + if (forward==null) break; + i = forward.nexti; + forward.ID = ""+trafficID; + if (forward.payloads.size()>0){ + saveForwardFiles(forward); + } + trafficList.add(forward); + + HttpTraffic reverse = parseReverse(dump, i); + if (reverse==null) break; + reverse.ID = ""+trafficID; + i = reverse.nexti; + if (reverse.payloads.size()>0){ + saveReverseFiles(reverse); + } + trafficList.add(reverse); + } + return trafficList; + } + + public static File saveFile(String dir, String relativeName, String content){ + File result = null; + PrintWriter writer; + try{ + result = new File(dir, relativeName); + writer = new PrintWriter(new FileOutputStream(result)); + }catch (Exception e){ + System.out.println("Can't write to file in saveFile: " + relativeName + " \r\n" + e); + return null; + } + writer.write(content); + writer.close(); + return result; + } + + private void saveForwardFiles(HttpTraffic fr){ + for (Part part : fr.payloads){ + String body = part.buffer.toString(); + if (body.trim().length()==0){ + continue; + } + String filename = fr.ID+'_'+fr.method+'_'+fr.url.replaceAll("/", "_")+'_'+part.label+".xml"; + filename = filename.replaceAll("/", "_"); + System.out.println("trying to save file: "+filename+" :: "+fr); + part.filename = filename; + saveFile("./xml", filename, body); + } + } + + private void saveReverseFiles(HttpTraffic fr){ + for (Part part : fr.payloads){ + String body = part.buffer.toString(); + if (body.trim().length()==0){ + continue; + } + String filename = fr.ID+'_'+fr.method+'_'+fr.url.replaceAll("/", "_"); + if (part.label.length()==0){ + if (body.trim().startsWith(" process(String httpSessionTraffic){ + PayloadLogger pll = new PayloadLogger(); + List trafficList = pll.handleTcpDump(httpSessionTraffic); + return trafficList; + } + + public static void main(String[]args) throws Exception { + String dump = readFile(".", args[0]); + PayloadLogger pll = new PayloadLogger(); + List trafficList = pll.handleTcpDump(dump); + reporter.finished(trafficList); + saveReport(); + } + + +} \ No newline at end of file diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java index 04f8f55c5..36fb95602 100755 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/ServiceResult.java @@ -23,8 +23,12 @@ package org.collectionspace.services.IntegrationTests.xmlreplay; +import org.apache.commons.httpclient.Header; + import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * User: laramie @@ -46,7 +50,36 @@ public class ServiceResult { public String error = ""; public String fromTestID = ""; public String auth = ""; + public String boundary = ""; + public String payloadStrictness = ""; + public long contentLength = 0; + public String failureReason = ""; + public Header[] responseHeaders = new Header[0]; public List expectedCodes = new ArrayList(); + private Map partSummaries = new HashMap(); + public void addPartSummary(String label, TreeWalkResults list){ + partSummaries.put(label, list); + } + public String partsSummary(boolean detailed){ + StringBuffer buf = new StringBuffer(); + if (!isDomWalkOK()){ + if (detailed) buf.append("\r\nDOM CHECK FAILED:\r\n"); + else buf.append("; DOM CHECK FAILED:"); + } + for (Map.Entry entry : partSummaries.entrySet()) { + String key = entry.getKey(); + TreeWalkResults value = entry.getValue(); + buf.append(" label:"+key+": "); + if (detailed){ + buf.append("\r\n"); + buf.append(value.fullSummary()); + } else { + buf.append(value.miniSummary()); + } + + } + return buf.toString(); + } public boolean codeInSuccessRange(int code){ if (0<=code && code<200){ return false; @@ -55,50 +88,113 @@ public class ServiceResult { } return true; } + + public boolean isDomWalkOK(){ + if (Tools.isEmpty(payloadStrictness)){ + return true; + } + PAYLOAD_STRICTNESS strictness = PAYLOAD_STRICTNESS.valueOf(payloadStrictness); + for (Map.Entry entry : partSummaries.entrySet()) { + String key = entry.getKey(); + TreeWalkResults value = entry.getValue(); + if (value.hasDocErrors()){ + failureReason = " : DOM DOC_ERROR; "; + return false; + } + switch (strictness){ + case STRICT: + if (!value.isStrictMatch()) { + failureReason = " : DOM NOT STRICT; "; + return false; + } + break; + case ADDOK: + if (value.countFor(TreeWalkResults.TreeWalkEntry.STATUS.TEXT_DIFFERENT)>0) { + failureReason = " : DOM TEXT_DIFFERENT; "; + return false; + } + if (value.countFor(TreeWalkResults.TreeWalkEntry.STATUS.R_MISSING)>0){ + failureReason = " : DOM R_MISSING; "; + return false; + } + break; + case TEXT: + if (value.countFor(TreeWalkResults.TreeWalkEntry.STATUS.TEXT_DIFFERENT)>0) { + failureReason = " : DOM TEXT_DIFFERENT; "; + return false; + } + break; + case TREE: + if (!value.treesMatch()) { + failureReason = " : DOM TREE MISMATCH; "; + return false; + } + break; + case ZERO: + break; + } + } + return true; + } + public boolean gotExpectedResult(){ + if (Tools.notEmpty(failureReason)){ + return false; + } for (Integer oneExpected : expectedCodes){ if (responseCode == oneExpected){ - return true; + return isDomWalkOK(); } } - if (expectedCodes.size()>0 && codeInSuccessRange(responseCode)){ //none found, but result expected. + if ( expectedCodes.size()>0 && codeInSuccessRange(responseCode)){ //none found, but result expected. for (Integer oneExpected : expectedCodes){ if ( ! codeInSuccessRange(oneExpected)){ - return false; + return isDomWalkOK(); } } } - return codeInSuccessRange(responseCode); + boolean ok = codeInSuccessRange(responseCode); + if (ok) { + return isDomWalkOK(); + } + failureReason = " : STATUS CODE UNEXPECTED; "; + return false; } + //public static final String[] DUMP_OPTIONS = {"minimal", "detailed", "full"}; public static enum DUMP_OPTIONS {minimal, detailed, full}; + public static enum PAYLOAD_STRICTNESS {ZERO, ADDOK, TREE, TEXT, STRICT}; + public String toString(){ return detail(true); } public String detail(boolean includePayloads){ - return "{ServiceResult: " - + ( Tools.notEmpty(testID) ? " testID:"+testID : "" ) - + ( Tools.notEmpty(testGroupID) ? "; testGroupID:"+testGroupID : "" ) - + ( Tools.notEmpty(fromTestID) ? "; fromTestID:"+fromTestID : "" ) + return "{" + + ( gotExpectedResult() ? "SUCCESS" : "FAILURE" ) + + failureReason +"; "+method +"; "+responseCode + + ( (expectedCodes.size()>0) ? "; expectedCodes:"+expectedCodes : "" ) + + ( Tools.notEmpty(testID) ? "; testID:"+testID : "" ) + + ( Tools.notEmpty(testGroupID) ? "; testGroupID:"+testGroupID : "" ) + + ( Tools.notEmpty(fromTestID) ? "; fromTestID:"+fromTestID : "" ) + ( Tools.notEmpty(responseMessage) ? "; msg:"+responseMessage : "" ) +"; URL:"+fullURL +"; auth: "+auth + ( Tools.notEmpty(deleteURL) ? "; deleteURL:"+deleteURL : "" ) + ( Tools.notEmpty(location) ? "; location.CSID:"+location : "" ) + ( Tools.notEmpty(error) ? "; ERROR:"+error : "" ) - + ( (expectedCodes.size()>0) ? "; expectedCodes:"+expectedCodes : "" ) + "; gotExpected:"+gotExpectedResult() + ( includePayloads && Tools.notEmpty(result) ? "; result:"+result : "" ) + + ( partsSummary(true)) +"}"; } public String minimal(){ return "{" + ( gotExpectedResult() ? "SUCCESS" : "FAILURE" ) - + + failureReason + ( Tools.notEmpty(testID) ? "; "+testID : "" ) +"; "+method +"; "+responseCode @@ -107,6 +203,7 @@ public class ServiceResult { +"; URL:"+fullURL +"; auth: "+auth + ( Tools.notEmpty(error) ? "; ERROR:"+error : "" ) + + ( partsSummary(false)) +"}"; } public String dump(ServiceResult.DUMP_OPTIONS opt){ diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/TreeWalkResults.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/TreeWalkResults.java new file mode 100755 index 000000000..30130319b --- /dev/null +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/TreeWalkResults.java @@ -0,0 +1,157 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + * + * http://www.collectionspace.org + * http://wiki.collectionspace.org + * + * Copyright (c) 2009 Regents of the University of California + * + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.collectionspace.services.IntegrationTests.xmlreplay; + +import java.util.ArrayList; + +/** + * User: laramie + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class TreeWalkResults extends ArrayList { + + public static class TreeWalkEntry { + public String lpath = ""; + public String rpath = ""; + public String ltextTrimmed = ""; + public String rtextTrimmed = ""; + public String message = ""; + public String errmessage = ""; + public static enum STATUS {INFO, MATCHED, R_MISSING, R_ADDED, DOC_ERROR, TEXT_DIFFERENT}; + public STATUS status; + public String toString(){ + return + "{" + +status.name() + +(Tools.notEmpty(lpath) ? ", L.path:"+lpath : "") + +(Tools.notEmpty(rpath) ? ", R.path:"+rpath : "") + +(Tools.notEmpty(message) ? ", message:"+message : "") + +((status != STATUS.MATCHED) && Tools.notEmpty(ltextTrimmed) ? ",\r\n L.trimmed:"+ltextTrimmed : "") + +((status != STATUS.MATCHED) && Tools.notEmpty(rtextTrimmed) ? ",\r\n R.trimmed:"+rtextTrimmed : "") + +"}"; + + } + } + + public boolean hasDocErrors(){ + for (TreeWalkEntry entry : this){ + if (entry.status == TreeWalkEntry.STATUS.DOC_ERROR){ + return true; + } + } + return false; + } + + public String getErrorMessages(){ + StringBuffer buf = new StringBuffer(); + boolean first = true; + for (TreeWalkEntry entry : this){ + if ( Tools.notEmpty(entry.errmessage)){ + if (first) { + buf.append(",errors:"); + } else { + buf.append(','); + } + buf.append('\''+entry.errmessage+"\'"); + first = false; + } + } + return buf.toString(); + } + + + + public boolean isStrictMatch(){ + for (TreeWalkEntry entry : this){ + if (entry.status == TreeWalkEntry.STATUS.DOC_ERROR){ + return false; + } + if ( !( entry.status == TreeWalkEntry.STATUS.MATCHED + || entry.status == TreeWalkEntry.STATUS.INFO)){ + return false; + } + } + return true; + } + public int getMismatchCount(){ + int c = 0; + for (TreeWalkEntry entry : this){ + if ( entry.status == TreeWalkEntry.STATUS.DOC_ERROR + || entry.status != TreeWalkEntry.STATUS.MATCHED + || entry.status != TreeWalkEntry.STATUS.INFO){ + c++; + } + } + return c; + } + /** For our purposes, trees match if they have the same element tree structure - no checking is done for text node changes. */ + public boolean treesMatch(){ + for (TreeWalkEntry entry : this){ + if (entry.status == TreeWalkEntry.STATUS.DOC_ERROR + || entry.status == TreeWalkEntry.STATUS.R_MISSING + || entry.status == TreeWalkEntry.STATUS.R_ADDED ){ + return false; + } + } + return true; + } + + public int countFor(TreeWalkEntry.STATUS status){ + int count = 0; + for (TreeWalkEntry entry : this){ + if (entry.status.equals(status)){ + count++; + } + } + return count; + } + + public String miniSummary(){ + //MATCHED, INFO, R_MISSING, R_ADDED, TEXT_DIFFERENT}; + StringBuffer buf = new StringBuffer(); + buf.append("{"); + boolean nextline = false; + for (TreeWalkEntry.STATUS st : TreeWalkEntry.STATUS.values()){ + if (nextline) buf.append(','); + buf.append(st.name()+':'+countFor(st)); + nextline = true; + } + buf.append(getErrorMessages()); + buf.append("}"); + return buf.toString(); + } + + public String fullSummary(){ + StringBuffer buf = new StringBuffer(); + for (TreeWalkResults.TreeWalkEntry entry : this){ + buf.append(entry.toString()).append("\r\n"); + } + return buf.toString(); + } + + + public String leftID; + public String rightID; +} \ No newline at end of file diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlCompareJdom.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlCompareJdom.java new file mode 100755 index 000000000..18d510657 --- /dev/null +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlCompareJdom.java @@ -0,0 +1,184 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + * + * http://www.collectionspace.org + * http://wiki.collectionspace.org + * + * Copyright (c) 2009 Regents of the University of California + * + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.IntegrationTests.xmlreplay; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jaxen.XPath; +import org.jaxen.jdom.JDOMXPath; + + +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.collectionspace.services.IntegrationTests.xmlreplay.TreeWalkResults.TreeWalkEntry; + +/** + * User: laramie + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class XmlCompareJdom { + +private static final String DEFAULT_SAX_DRIVER_CLASS = "org.apache.xerces.parsers.SAXParser"; + + public static org.jdom.Document getDocumentFromContent(String source) throws IOException, JDOMException { + org.jdom.Document doc; + SAXBuilder builder; + builder = new SAXBuilder(); + builder.setValidation(false); //has no effect, I think. + doc = builder.build(new StringReader(source)); + return doc; + } + + public static TreeWalkResults compareParts(String expectedContent, String leftID, String actualPartContent, String rightID){ + TreeWalkResults list = new TreeWalkResults(); + try { + + list.leftID = leftID; + list.rightID = rightID; + TreeWalkResults.TreeWalkEntry infoentry = new TreeWalkResults.TreeWalkEntry(); + infoentry.status = TreeWalkResults.TreeWalkEntry.STATUS.INFO; + infoentry.message = "\r\n LEFT file: "+leftID+"\r\n RIGHT file: "+rightID; + list.add(infoentry); + if (Tools.isEmpty(expectedContent)){ + TreeWalkEntry entry = new TreeWalkEntry(); + entry.status = TreeWalkEntry.STATUS.DOC_ERROR; + entry.errmessage = "L dom was empty."; + list.add(entry); + } else if (Tools.isEmpty(actualPartContent)){ + TreeWalkEntry entry = new TreeWalkEntry(); + entry.errmessage = "R dom was empty."; + entry.status = TreeWalkEntry.STATUS.DOC_ERROR; + list.add(entry); + } else { + Document expected = getDocumentFromContent(expectedContent); + Document actual = getDocumentFromContent(actualPartContent); + treeWalk(expected, actual, list); + } + } catch (Throwable t){ + String msg = "ERROR in XmlReplay.compareParts(): "+t; + System.out.println(msg); + TreeWalkEntry entry = new TreeWalkEntry(); + entry.status = TreeWalkEntry.STATUS.DOC_ERROR; + entry.errmessage = msg; + list.add(entry); + } + return list; + } + + public static List select(Element element, String xpathExpression) throws Exception { + XPath xpath = new JDOMXPath(xpathExpression); + return xpath.selectNodes(element); + } + + public static Object selectSingleNode(Element element, String xpathExpression) throws Exception { + XPath xpath = new JDOMXPath(xpathExpression); + return xpath.selectSingleNode(element); + } + + + + + public static boolean treeWalk(Document left, Document right, TreeWalkResults list) throws Exception { + boolean res = treeWalk(left.getRootElement(), right.getRootElement(), "/", list); + return res; + } + + public static boolean treeWalk(Element left, Element right, String parentPath, TreeWalkResults msgList) throws Exception { + String SPACE = " "; + if (left == null && right == null){ + return true; + } + if (left == null){ + return false; + } + if (right == null){ + return false; + } + List l = left.getChildren(); + Map foundRightMap = new HashMap(); + boolean result = true; + for (Object o : l) { + if (!(o instanceof Element)){ + continue; + } + Element leftChild = (Element)o; + String leftChildName = leftChild.getName(); + if (Tools.isEmpty(leftChildName)){ + continue; + } + String leftChildPath = Tools.glue(parentPath, "/", leftChildName); + Element rightChild = (Element)selectSingleNode(right,leftChildName); + if (rightChild == null){ + TreeWalkEntry entry = new TreeWalkEntry(); + entry.lpath = leftChildPath; + entry.status = TreeWalkEntry.STATUS.R_MISSING; + msgList.add(entry); + continue; + } + foundRightMap.put(leftChildName, "OK"); + String leftChildTextTrim = leftChild.getText().trim(); + String rightChildTextTrim = rightChild.getText().trim(); + TreeWalkEntry entry = new TreeWalkEntry(); + entry.ltextTrimmed = leftChildTextTrim; + entry.rtextTrimmed = rightChildTextTrim; + entry.lpath = leftChildPath; + entry.rpath = leftChildPath; //same + + if (leftChildTextTrim.equals(rightChildTextTrim)){ + entry.status = TreeWalkEntry.STATUS.MATCHED; + msgList.add(entry); + } else { + entry.status = TreeWalkEntry.STATUS.TEXT_DIFFERENT; + msgList.add(entry); + } + + //============ DIVE !! ===================================================== + result = result && treeWalk( leftChild, rightChild, leftChildPath, msgList); + } + for (Object r : right.getChildren()){ + if (!(r instanceof Element)){ + continue; + } + Element rightChild = (Element)r; + String rname = rightChild.getName(); + if (null==foundRightMap.get(rname)){ + String rightChildPath = Tools.glue(parentPath, "/", rname); + + TreeWalkEntry entry = new TreeWalkEntry(); + entry.rpath = rightChildPath; + entry.status = TreeWalkEntry.STATUS.R_ADDED; + msgList.add(entry); + } + } + return true; + } + +} diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java index 33f996b64..4bd05f791 100755 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplay.java @@ -2,13 +2,19 @@ package org.collectionspace.services.IntegrationTests.xmlreplay; import org.apache.commons.cli.*; +import org.apache.commons.io.FileUtils; import org.apache.commons.jexl2.JexlContext; import org.apache.commons.jexl2.JexlEngine; import org.apache.commons.jexl2.MapContext; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Node; +import org.dom4j.*; import org.dom4j.io.SAXReader; +import org.jdom.input.SAXBuilder; +import org.xml.sax.InputSource; + + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; import java.io.*; import java.util.*; @@ -88,8 +94,8 @@ public class XmlReplay { // ============== METHODS =========================================================== - public Document openMasterConfigFile(String masterFilename) throws FileNotFoundException { - Document document = getDocument(Tools.glue(basedir, "/", masterFilename)); //will check full path first, then checks relative to PWD. + public org.dom4j.Document openMasterConfigFile(String masterFilename) throws FileNotFoundException { + org.dom4j.Document document = getDocument(Tools.glue(basedir, "/", masterFilename)); //will check full path first, then checks relative to PWD. if (document == null){ throw new FileNotFoundException("XmlReplay master control file ("+masterFilename+") not found in basedir: "+basedir+". Exiting test."); } @@ -99,8 +105,8 @@ public class XmlReplay { /** specify the master config file, relative to getBaseDir(), but ignore any tests or testGroups in the master. * @return a Document object, which you don't need to use: all options will be stored in XmlReplay instance. */ - public Document readOptionsFromMasterConfigFile(String masterFilename) throws FileNotFoundException { - Document document = openMasterConfigFile(masterFilename); + public org.dom4j.Document readOptionsFromMasterConfigFile(String masterFilename) throws FileNotFoundException { + org.dom4j.Document document = openMasterConfigFile(masterFilename); protoHostPort = document.selectSingleNode("/xmlReplayMaster/protoHostPort").getText().trim(); AuthsMap authsMap = readAuths(document); setDefaultAuthsMap(authsMap); @@ -117,7 +123,7 @@ public class XmlReplay { * and setting defaults from this instance, but not sharing ServiceResult objects or maps. */ public List> runMaster(String masterFilename, boolean readOptionsFromMaster) throws Exception { List> list = new ArrayList>(); - Document document; + org.dom4j.Document document; if (readOptionsFromMaster){ document = readOptionsFromMasterConfigFile(masterFilename); } else { @@ -225,7 +231,7 @@ public class XmlReplay { } } - public static AuthsMap readAuths(Document document){ + public static AuthsMap readAuths(org.dom4j.Document document){ Map map = new HashMap(); List authNodes = document.selectNodes("//auths/auth"); for (Node auth : authNodes) { @@ -255,7 +261,7 @@ public class XmlReplay { return new Dump(); } - public static Dump readDumpOptions(Document document){ + public static Dump readDumpOptions(org.dom4j.Document document){ Dump dump = getDumpConfig(); Node dumpNode = document.selectSingleNode("//dump"); if (dumpNode != null){ @@ -284,7 +290,8 @@ public class XmlReplay { } else { result.bDoingSinglePartPayload = false; List parts = testNode.selectNodes("parts/part"); - if (parts == null || parts.size()==0){ //path is just /testGroup/test/part/ + if (parts == null || parts.size()==0){ + //path is just /testGroup/test/part/ String commonPartName = testNode.valueOf("part/label"); String testfile = testNode.valueOf("part/filename"); String fullTestFilename = xmlReplayBaseDir + '/' + testfile; @@ -293,7 +300,8 @@ public class XmlReplay { } result.partsList.add(commonPartName); result.filesList.add(fullTestFilename); - } else { // path is /testGroup/test/parts/part/ + } else { + // path is /testGroup/test/parts/part/ for (Node part : parts){ String commonPartName = part.valueOf("label"); String filename = part.valueOf("filename"); @@ -342,9 +350,8 @@ public class XmlReplay { return result; } - public static org.dom4j.Document getDocument(String xmlFileName) { - Document document = null; + org.dom4j.Document document = null; SAXReader reader = new SAXReader(); try { document = reader.read(xmlFileName); @@ -355,6 +362,57 @@ public class XmlReplay { return document; } + protected static String validateResponse(ServiceResult serviceResult, + Map serviceResultsMap, + PartsStruct expectedResponseParts){ + String OK = ""; + if (expectedResponseParts == null) return OK; + if (serviceResult == null) return OK; + if (serviceResult.result.length() == 0) return OK; + String responseDump = serviceResult.result; + //System.out.println("responseDump: "+responseDump); + PayloadLogger.HttpTraffic traffic = PayloadLogger.readPayloads(responseDump, serviceResult.boundary, serviceResult.contentLength); + try { + for (int i=0; i\r\n"+expectedPartContent); + PayloadLogger.Part partFromServer = traffic.getPart(label); + String partFromServerContent = ""; + if (partFromServer != null){ + partFromServerContent = partFromServer.getContent(); + } else { + partFromServerContent = ""; + } + //if (partFromServer!=null) { + //System.out.println("====part content from server. label-->"+label+"<-- \r\npart-->"+partFromServerContent+"<--"); + + String leftID = "{from expected part, label:"+label+" filename: "+fileName+"}"; + String rightID = "{from server, label:"+label + //+" testGroupID: "+serviceResult.testGroupID + +" fromTestID: "+serviceResult.fromTestID + +" URL: "+serviceResult.fullURL + +"}"; + TreeWalkResults list = + XmlCompareJdom.compareParts(expectedPartContent, + leftID, + partFromServerContent, + rightID); + //if (list.getMismatchCount()>0){ + serviceResult.addPartSummary(label, list); + //} + //} + } + } catch (Exception e){ + String err = "ERROR in XmlReplay.validateResponse() : "+e; + //System.out.println(err); + return err ; + } + return OK; + } + //================= runXmlReplayFile ====================================================== @@ -374,7 +432,7 @@ public class XmlReplay { List results = new ArrayList(); String controlFile = Tools.glue(xmlReplayBaseDir, "/", controlFileName); - Document document; + org.dom4j.Document document; document = getDocument(controlFile); //will check full path first, then checks relative to PWD. if (document==null){ throw new FileNotFoundException("XmlReplay control file ("+controlFileName+") not found in basedir: "+xmlReplayBaseDir+" Exiting test."); @@ -468,6 +526,13 @@ public class XmlReplay { } } + Node responseNode = testNode.selectSingleNode("response"); + PartsStruct expectedResponseParts = null; + if (responseNode!=null){ + expectedResponseParts = PartsStruct.readParts(responseNode, testID, xmlReplayBaseDir); + //System.out.println("reponse parts: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+expectedResponseParts); + } + ServiceResult serviceResult; boolean isPOST = method.equalsIgnoreCase("POST"); boolean isPUT = method.equalsIgnoreCase("PUT"); @@ -498,8 +563,11 @@ public class XmlReplay { if (pr!=null){ serviceResult = XmlReplayTransport.doDELETE(pr.deleteURL, authForTest, testIDLabel, fromTestID); serviceResult.fromTestID = fromTestID; + if (expectedCodes.size()>0){ + serviceResult.expectedCodes = expectedCodes; + } results.add(serviceResult); - if (serviceResult.gotExpectedResult()){ + if (serviceResult.gotExpectedResult()){ //gotExpectedResult depends on serviceResult.expectedCodes. serviceResultsMap.remove(fromTestID); } } else { @@ -537,6 +605,18 @@ public class XmlReplay { if (Tools.isEmpty(serviceResult.testID)) serviceResult.testID = testIDLabel; if (Tools.isEmpty(serviceResult.testGroupID)) serviceResult.testGroupID = testGroupID; + Node expectedLevel = testNode.selectSingleNode("response/expected"); + if (expectedLevel!=null){ + String level = expectedLevel.valueOf("@level"); + serviceResult.payloadStrictness = level; + } + + String vError = validateResponse(serviceResult, serviceResultsMap, expectedResponseParts); + if (Tools.notEmpty(vError)){ + serviceResult.error = vError; + serviceResult.failureReason = " : VALIDATION ERROR; "; + } + String serviceResultRow = serviceResult.dump(dump.dumpServiceResult); String leader = (dump.dumpServiceResult == ServiceResult.DUMP_OPTIONS.detailed) ? "XmlReplay:"+testIDLabel+": ": ""; System.out.println(leader+serviceResultRow+"\r\n"); diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTest.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTest.java index f05ab135b..f0b12b5c6 100755 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTest.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTest.java @@ -132,7 +132,6 @@ public class XmlReplayTest { buff.append(ROWSTARTRED+serviceResult.minimal()+ROWENDRED); } } - } buff.append(TBLEND); summary.table = buff.toString(); diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java index b86578775..3592d11cb 100755 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java +++ b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/XmlReplayTransport.java @@ -23,6 +23,7 @@ package org.collectionspace.services.IntegrationTests.xmlreplay; +import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.DeleteMethod; import org.apache.commons.httpclient.methods.GetMethod; @@ -34,6 +35,7 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -59,10 +61,19 @@ public class XmlReplayTransport { int statusCode1 = client.executeMethod(getMethod); pr.responseCode = statusCode1; + pr.fromTestID = fromTestID; pr.method = "GET"; try { pr.result = getMethod.getResponseBodyAsString(); pr.responseMessage = getMethod.getStatusText(); + Header[] headers = getMethod.getResponseHeaders(); + pr.responseHeaders = Arrays.copyOf(headers, headers.length); + Header hdr = getMethod.getResponseHeader("CONTENT-TYPE"); + if (hdr!=null){ + String hdrStr = hdr.toExternalForm(); + pr.boundary = PayloadLogger.parseBoundary(hdrStr); + } + pr.contentLength = getMethod.getResponseContentLength(); } catch (Throwable t){ //System.err.println("ERROR getting content from response: "+t); pr.error = t.toString(); @@ -77,6 +88,7 @@ public class XmlReplayTransport { ServiceResult pr = new ServiceResult(); pr.method = "DELETE"; pr.fullURL = urlString; + pr.fromTestID = fromTestID; if (Tools.isEmpty(urlString)){ pr.error = "url was empty. Check the result for fromTestID: "+fromTestID+". currentTest: "+testID; return pr; @@ -207,6 +219,8 @@ public class XmlReplayTransport { } String msg = sb.toString(); result.result = msg; + result.boundary = PayloadLogger.parseBoundary(conn.getHeaderField("CONTENT-TYPE")); + rd.close(); } catch (Throwable t){ //System.err.println("ERROR getting content from response: "+t); diff --git a/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlCompareJdomTest.java b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlCompareJdomTest.java new file mode 100755 index 000000000..c993e79dc --- /dev/null +++ b/services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/XmlCompareJdomTest.java @@ -0,0 +1,195 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + * + * http://www.collectionspace.org + * http://wiki.collectionspace.org + * + * Copyright (c) 2009 Regents of the University of California + * + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + * + * You may obtain a copy of the ECL 2.0 License at + * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.IntegrationTests.test; + +import org.collectionspace.services.IntegrationTests.xmlreplay.TreeWalkResults; +import org.collectionspace.services.IntegrationTests.xmlreplay.XmlCompareJdom; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * User: laramie + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class XmlCompareJdomTest { + + + private void testBanner(String msg){ + String BANNER ="-------------------------------------------------------"; + System.out.println(BANNER+"\r\n"+this.getClass().getName()+"\r\n"+msg+"\r\n"+BANNER); + } + private void printTreeWalkResults(TreeWalkResults list){ + for (TreeWalkResults.TreeWalkEntry entry : list){ + System.out.println(entry.toString()); + } + } + + private void assertTreeWalkResults(TreeWalkResults results, + int addedRight, + int missingRight, + int textMismatches, + boolean strictMatch, + boolean treesMatch){ + System.out.println("assertTreeWalkResults: "); + + int addedr = results.countFor(TreeWalkResults.TreeWalkEntry.STATUS.R_ADDED); + int missingr = results.countFor(TreeWalkResults.TreeWalkEntry.STATUS.R_MISSING); + int tdiff = results.countFor(TreeWalkResults.TreeWalkEntry.STATUS.TEXT_DIFFERENT); + int badCount = results.getMismatchCount(); + boolean strict = results.isStrictMatch(); + boolean treeOK = results.treesMatch(); + + String expected = " expected: addedRight:"+addedRight+",missingRight:"+missingRight+",textMismatches:"+textMismatches + +",strictMatch:"+strictMatch+",treesMatch:"+treesMatch; + + String actual = " actual: addedRight:"+addedr+",missingRight:"+missingr+",textMismatches:"+tdiff + +",strictMatch:"+strict+",treesMatch:"+treeOK; + + String exp_act = expected +"\r\n"+actual+"\r\n"; + System.out.print(exp_act); + + printTreeWalkResults(results); + + + boolean done = false; + try { + Assert.assertEquals(addedr, addedRight, "assertTreeWalkResults:R_ADDED mismatch."+exp_act); + + Assert.assertEquals(missingr, missingRight, "assertTreeWalkResults:R_MISSING mismatch."+exp_act); + + Assert.assertEquals(tdiff, textMismatches, "assertTreeWalkResults:TEXT_DIFFERENT mismatch."+exp_act); + + + Assert.assertTrue((strict==strictMatch), "assertTreeWalkResults:strictMatch mismatch."+exp_act); + + Assert.assertTrue((treeOK==treesMatch), "assertTreeWalkResults:treesMatch mismatch."+exp_act); + + System.out.println("SUCCESS: assertTreeWalkResults done.\r\n"); + done = true; + } finally { + if (!done) System.out.println("FAILURE: assertTreeWalkResults failed an assertion. See surefire report.\r\n"); + } + } + + @Test + public void testXmlCompareJdom(){ + testBanner("testXmlCompareJdom"); + TreeWalkResults results = + XmlCompareJdom.compareParts(expectedPartContent, + "expected", + partFromServer, + "from-server"); + assertTreeWalkResults(results,0,0,0,true,true); + // addedRight,missingRight,textMismatches,strictMatch,treesMatch + } + + @Test + public void testTextContentDifferent(){ + testBanner("testTextContentDifferent"); + TreeWalkResults results = + XmlCompareJdom.compareParts(expectedPartContent, + "expected", + srvHEAD+srvEN2+srvDEPOSITOR+srvFOOT, + "from-server"); + assertTreeWalkResults(results,0,0,1,false,true); + // addedRight,missingRight,textMismatches,strictMatch,treesMatch + } + + + @Test + public void testAddedR(){ + testBanner("testAddedR"); + TreeWalkResults results = + XmlCompareJdom.compareParts(expectedPartContent, + "expected", + srvHEAD+srvEN+exNEWTREE+srvDEPOSITOR+exNEW+srvFOOT, + "from-server"); + assertTreeWalkResults(results,2,0,0,false,false); + // addedRight,missingRight,textMismatches,strictMatch,treesMatch + + } + + @Test + public void testAddedL(){ + testBanner("testAddedL"); + TreeWalkResults results = + XmlCompareJdom.compareParts(exHEAD + exEN_WCH + exNEWTREE + exDEP + exNEW + exFOOT, + "expected", + partFromServer, + "from-server"); + assertTreeWalkResults(results,0,3,0,false,false); + // addedRight,missingRight,textMismatches,strictMatch,treesMatch + } + + @Test + public void testChildrenReordered(){ + testBanner("testChildrenReordered"); + TreeWalkResults results = + XmlCompareJdom.compareParts(exHEAD + exDEP + exEN + exFOOT, + "expected", + partFromServer, + "from-server"); + assertTreeWalkResults(results,0,0,0,true,true); + // addedRight,missingRight,textMismatches,strictMatch,treesMatch + } + + + // ============ expected part, will be used as LEFT tree ========================================================== + private static String exHEAD ="\r\n" + +"\r\n"; + private static String exEN =" objectexitNumber-1290026472360\r\n"; + private static String exEN_WCH =" objectexitNumber-1290026472360\r\n" + +" \r\n" + +" enChild content\r\n" + +" \r\n" + +" \r\n"; + private static String exNEWTREE =" \r\n" + +" \r\n" + +" second content\r\n" + +" \r\n" + +" \r\n"; + private static String exDEP =" urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'\r\n"; + private static String exNEW =" objectexitNumber-1290026472360\r\n"; + private static String exFOOT =""; + + private static String expectedPartContent = exHEAD + exEN + exDEP + exFOOT; + + + // ============ from-server part, will be used as RIGHT tree ========================================================== + + private static String srvHEAD = "\r\n" + +"\r\n"; + private static String srvEN = "objectexitNumber-1290026472360\r\n"; + private static String srvEN2 = "objectexitNumber-9999999999999\r\n"; + private static String srvDEPOSITOR = "urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum'\r\n"; + private static String srvFOOT = "\r\n"; + + private static String partFromServer = srvHEAD+srvEN+srvDEPOSITOR+srvFOOT; + + + +} diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml index b1ef1ed09..0e938788f 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/dev-master.xml @@ -12,6 +12,7 @@ + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/object-exit.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/object-exit.xml index 7e3c34c78..ca9e23738 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/object-exit.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/object-exit.xml @@ -3,8 +3,33 @@ YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y + YWRtaW5AY29sbGVjdGlvbnNwYWNlLm9yZzpBZG1pbmlzdHJhdG9y + + + + + POST + /cspace-services/objectexit/ + + + objectexit/oe1.xml + + + + GET + /cspace-services/objectexit/${oe1.CSID} + + + + + objectexit/res/oe2.res.xml + + + + + @@ -19,7 +44,12 @@ GET /cspace-services/objectexit/${oe1.CSID} - oe2.res.xml + + + + objectexit/res/oe2.res.xml + + POST diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe1.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe1.xml index b1daed5c3..35bf0cd42 100644 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe1.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe1.xml @@ -3,6 +3,6 @@ xmlns:ns2="http://collectionspace.org/services/objectexit" xmlns:ns3="http://collectionspace.org/services/jaxb"> urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum' - objectexitNumber-1290024274266 + objectexitNumber-1290026472360 diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe6.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe6.res.xml deleted file mode 100644 index 1485aad97..000000000 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe6.res.xml +++ /dev/null @@ -1,2 +0,0 @@ -04044currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csidobjectexitNumber-1290026473391/objectexit/c5844272-0da5-4c1f-b361c5844272-0da5-4c1f-b361objectexitNumber-1290026473626/objectexit/204b5375-5639-4dc3-8bbd204b5375-5639-4dc3-8bbdobjectexitNumber-1290026473860/objectexit/70499f68-7eba-4e63-a0ec70499f68-7eba-4e63-a0ecobjectexitNumber-1290026472360/objectexit/6f7a1e3e-5821-4ef2-bfcf6f7a1e3e-5821-4ef2-bfcf - diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe10.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe10.res.xml new file mode 100755 index 000000000..20ae40fd4 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe10.res.xml @@ -0,0 +1,9 @@ + + +ObjectexitPersonAuth +urn:cspace:org.collectionspace.demo:personauthority:name(ObjectexitPersonAuth)'ObjectexitPersonAuth' +${oe9.CSID} +ObjectexitPersonAuth +PersonAuthority + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe12.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe12.res.xml new file mode 100755 index 000000000..61e1d7447 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe12.res.xml @@ -0,0 +1,18 @@ + + +Owner + +owenCurOwner +Owen the Cur Owner + +Owen the Cur + + +true +${oe11.CSID} +true +${oe9.CSID} +urn:cspace:org.collectionspace.demo:personauthority:name(ObjectexitPersonAuth)'ObjectexitPersonAuth':person:name(owenCurOwner) +Owen the Cur Owner + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe14.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe14.res.xml new file mode 100755 index 000000000..ba4aaee50 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe14.res.xml @@ -0,0 +1,18 @@ + + +Depositor + +davenportDepositor +Davenport Depositor + +Davenport + + +true +${oe13.CSID} +true +${oe9.CSID} +urn:cspace:org.collectionspace.demo:personauthority:name(ObjectexitPersonAuth)'ObjectexitPersonAuth':person:name(davenportDepositor) +Davenport Depositor + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe16.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe16.res.xml new file mode 100755 index 000000000..d79e702f7 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe16.res.xml @@ -0,0 +1,7 @@ + + +exitDate-1290026474563 +exitNumber-1290026474563 +urn:cspace:org.collectionspace.demo:personauthority:name(ObjectexitPersonAuth)'ObjectexitPersonAuth':person:name(davenportDepositor) + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe17.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe17.res.xml new file mode 100755 index 000000000..c9f6cbc3d --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe17.res.xml @@ -0,0 +1,2 @@ +04011objectexit_common:depositorurn:cspace:org.collectionspace.demo:personauthority:name(ObjectexitPersonAuth)'ObjectexitPersonAuth':person:name(davenportDepositor)ObjectexitPersonAuth/personauthorities/urn:cspace:name(ObjectexitPersonAuth)/items/urn:cspace:name(davenportDepositor) + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe2.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe2.res.xml new file mode 100755 index 000000000..205bc1569 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe2.res.xml @@ -0,0 +1,20 @@ + + +objectexitNumber-1290026472360 + + second content + + + + + second content + + + +urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum' +objectexitNumber-1290026472360 + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe2.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe22.res.xml old mode 100644 new mode 100755 similarity index 100% rename from services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe2.res.xml rename to services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe22.res.xml diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe23.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe23.res.xml new file mode 100755 index 000000000..31e03b825 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe23.res.xml @@ -0,0 +1,6 @@ + + +updated-objectexitNumber-1290026472360 +urn:cspace:org.collectionspace.demo:orgauthority:name(TestOrgAuth):organization:name(Northern Climes Museum)'Northern Climes Museum' + + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe27.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe27.res.xml new file mode 100755 index 000000000..7c21e3e3b --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe27.res.xml @@ -0,0 +1,2 @@ +0113currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csidobjectexitNumber-1290026473391/objectexit/${oe3.CSID}${oe3.CSID} + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe28.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe28.res.xml new file mode 100755 index 000000000..7c21e3e3b --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe28.res.xml @@ -0,0 +1,2 @@ +0113currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csidobjectexitNumber-1290026473391/objectexit/${oe3.CSID}${oe3.CSID} + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe29.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe29.res.xml new file mode 100755 index 000000000..f66fb74fa --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe29.res.xml @@ -0,0 +1,2 @@ +1113currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csidobjectexitNumber-1290026473626/objectexit/${oe4.CSID}${oe4.CSID} + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe30.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe30.res.xml new file mode 100755 index 000000000..72cdfbf2b --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe30.res.xml @@ -0,0 +1,2 @@ +2113currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csidobjectexitNumber-1290026473860/objectexit/${oe5.CSID}${oe5.CSID} + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe6.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe6.res.xml new file mode 100755 index 000000000..82e7a1159 --- /dev/null +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe6.res.xml @@ -0,0 +1,5 @@ + + + 04044currentOwner|depositor|exitDate|exitMethod|exitNote|exitNumber|exitReason|packingNote|uri|csidobjectexitNumber-1290026473391/objectexit/${oe3.CSID}${oe3.CSID}objectexitNumber-1290026473626/objectexit/${oe4.CSID}${oe4.CSID}objectexitNumber-1290026473860/objectexit/${oe5.CSID}${oe5.CSID}objectexitNumber-1290026472360/objectexit/${oe1.CSID}${oe1.CSID} + diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe8.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe8.res.xml old mode 100644 new mode 100755 similarity index 100% rename from services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/oe8.res.xml rename to services/IntegrationTests/src/test/resources/test-data/xmlreplay/objectexit/res/oe8.res.xml diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/security.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/security.xml index 8ffee79f5..831c48136 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/security.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/security.xml @@ -297,7 +297,7 @@ - 403, 404,405 + 403,404,405 PUT /cspace-services/dimensions/${dimensionBigbird_POST_AfterPermrolesDeleted.CSID} diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml index 13c448c64..266689108 100755 --- a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml +++ b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/xml-replay-master.xml @@ -21,6 +21,8 @@ --> + +