2 * This document is a part of the source code and related artifacts
\r
3 * for CollectionSpace, an open source collections management system
\r
4 * for museums and related institutions:
\r
6 * http://www.collectionspace.org
\r
7 * http://wiki.collectionspace.org
\r
9 * Copyright (c) 2009 Regents of the University of California
\r
11 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
12 * You may not use this file except in compliance with this License.
\r
14 * You may obtain a copy of the ECL 2.0 License at
\r
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
\r
17 * Unless required by applicable law or agreed to in writing, software
\r
18 * distributed under the License is distributed on an "AS IS" BASIS,
\r
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
20 * See the License for the specific language governing permissions and
\r
21 * limitations under the License.
\r
23 package org.collectionspace.services.IntegrationTests.test;
\r
25 import org.collectionspace.services.IntegrationTests.xmlreplay.TreeWalkResults;
\r
26 import org.collectionspace.services.IntegrationTests.xmlreplay.XmlCompareJdom;
\r
27 import org.collectionspace.services.common.api.FileTools;
\r
28 import org.collectionspace.services.common.api.Tools;
\r
29 import org.testng.annotations.Test;
\r
31 import java.io.File;
\r
35 * $LastChangedRevision: $
\r
36 * $LastChangedDate: $
\r
38 public class XmlCompareJdomRepeatingTest {
\r
40 private static String getDirectory(){
\r
41 String dataDir = "src/test/resources/test-data/xmlreplay/XmlCompareJdom"; // this dir lives under service/IntegrationTests
\r
44 pwd = (new File(".")).getCanonicalPath();
\r
45 } catch (Exception e){
\r
46 System.err.println("Error trying to find current working directory: "+e);
\r
48 String thisDir = Tools.glue(pwd, "/", dataDir);
\r
52 private void testBanner(String msg){
\r
53 String BANNER ="-------------------------------------------------------";
\r
55 System.out.println(BANNER
\r
56 + R +" TEST CLASS: "+this.getClass().getName()
\r
57 + R +" TEST NAME: "+msg
\r
58 + R +" TEST DATA DIR: "+getDirectory()
\r
64 public void testLeftAndRightSame(){
\r
65 testBanner("testLeftAndRightSame");
\r
66 String dir = getDirectory();
\r
67 String expectedPartContent = FileTools.readFile(dir, "1-left.xml");
\r
68 String fromServerContent = FileTools.readFile(dir, "1-right.xml");
\r
69 String startPath = "/document/*[local-name()='relations-common-list']";
\r
70 TreeWalkResults.MatchSpec matchSpec = TreeWalkResults.MatchSpec.createDefault();
\r
71 TreeWalkResults results =
\r
72 XmlCompareJdom.compareParts(expectedPartContent,
\r
78 XmlCompareJdomTest.assertTreeWalkResults(results,1,0,0,false, matchSpec);
\r
79 // addedRight,missingRight,textMismatches,strictMatch,treesMatch
\r
83 public void testLeftAndRightSameNoStartElement(){
\r
84 testBanner("testLeftAndRightSameNoStartElement");
\r
85 String dir = getDirectory();
\r
86 String expectedPartContent = FileTools.readFile(dir, "2-left.xml");
\r
87 String fromServerContent = FileTools.readFile(dir, "2-right.xml");
\r
88 String startPath = "/document";
\r
89 TreeWalkResults.MatchSpec matchSpec = TreeWalkResults.MatchSpec.createDefault();
\r
90 TreeWalkResults results =
\r
91 XmlCompareJdom.compareParts(expectedPartContent,
\r
97 XmlCompareJdomTest.assertTreeWalkResults(results,0,0,0,true,matchSpec);
\r
98 // addedRight,missingRight,textMismatches,strictMatch,treesMatch
\r