]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5940: Fix bug that resulted in 'bare' ampersands being present in collectionsp...
authorAron Roberts <aron@socrates.berkeley.edu>
Thu, 21 Mar 2013 21:21:21 +0000 (14:21 -0700)
committerAron Roberts <aron@socrates.berkeley.edu>
Thu, 21 Mar 2013 21:21:21 +0000 (14:21 -0700)
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/import-locationitem-varexpansion.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/imports.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationauthority.res.xml
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem-varexpansion.res.xml [new file with mode: 0644]
services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem.res.xml [new file with mode: 0644]
services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java

diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/import-locationitem-varexpansion.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/import-locationitem-varexpansion.xml
new file mode 100644 (file)
index 0000000..2452609
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<imports>
+    <import service="Locations" type="Locationitem" CSID="${recordCSID}">
+        <schema xmlns:locations_common="http://collectionspace.org/services/location" 
+                name="locations_common">
+            <!--
+            Values containing Ampersand character entities are hard-coded
+            here in this file, rather than being passed in as values from
+            the XmlReplay control file, because in the control file it
+            appears we needed to double-encode them as '&amp;amp;',
+            which would complicate testing of CSPACE-5940.
+            -->
+            <locTermGroupList>
+                <locTermGroup>
+                    <termDisplayName>Wattford &amp; Gump Outbuilding</termDisplayName>
+                </locTermGroup>
+            </locTermGroupList>
+            <shortIdentifier>${shortIdentifierValue}</shortIdentifier>
+            <refName>urn:cspace:core.collectionspace.org:locationauthorities:name(${importLocationAuthorityWithVarExpansion.shortIdentifierValue})'Wattford &amp; Gump Outbuilding'</refName>
+            <inAuthority>${inAuthorityValue}</inAuthority>
+        </schema>
+    </import>
+</imports>
index 716a6961d73a87dbdff7e5293e92afcd3c0b6ee5..81187b2c8026110fbe4c4f303d983bc71c4c0b99 100644 (file)
         
                 
         <!-- Verify that a refName value provided in the body of an authority record -->
-        <!-- and is present, as well, in the collectionspace_core part's refName field. -->
+        <!-- is copied to and is present, as well, in the collectionspace_core part's -->
+        <!-- refName field. -->
         <test ID="importLocationAuthorityWithVarExpansion">
             <expectedCodes>200</expectedCodes>
             <method>POST</method>
             <method>DELETE</method>
             <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}</uri>
         </test>
+                
+        <!--
+            Verify that a refName value provided in the body of an authority
+            term (item) record is copied to and is present, as well, in the
+            collectionspace_core part's refName field.
+            
+            This also tests proper handling of entity-encoded ampersands
+            contained within display name values in refNames. 9See CSPACE-5940.)
+        -->
+<test ID="importLocationItemWithVarExpansion">
+            <expectedCodes>200</expectedCodes>
+            <method>POST</method>
+            <uri>/cspace-services/imports</uri>
+            <filename>imports/import-locationitem-varexpansion.xml</filename>
+            <vars>
+                <var ID="recordCSID">5c45cdf7-f1bd-4ff3-844d-59f40ffc5b29</var>
+                <var ID="shortIdentifierValue">wattfordandgumpoutbuilding</var>
+                <var ID="inAuthorityValue">${importLocationAuthorityWithVarExpansion.recordCSID}</var>
+            </vars>
+            <response>
+                <expected level="TEXT" />
+                <filename>imports/res/import-locationitem.res.xml</filename>
+            </response>
+        </test>
+        <test ID="verifyLocationItemWithVarExpansion">
+            <expectedCodes>200</expectedCodes>
+            <method>GET</method>
+            <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}/items/${importLocationItemWithVarExpansion.recordCSID}</uri>
+            <response>
+                <filename>imports/res/import-locationitem-varexpansion.res.xml</filename>
+                <expected level="ADDOK" />
+                <parts>
+                    <part>
+                        <label>collectionspace_core</label>
+                    </part>
+                    <part>
+                        <label>locations_common</label>
+                    </part>
+                </parts>
+                <vars>
+                    <var ID="shortIdentifierValue">${importLocationItemWithVarExpansion.shortIdentifierValue}</var>
+                    <var ID="inAuthorityValue">${importLocationItemWithVarExpansion.inAuthorityValue}</var>
+                    <var ID="uriValue">/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}/items/${importLocationItemWithVarExpansion.recordCSID}</var>
+                </vars>
+            </response>
+        </test>
+        <test ID="deleteLocationItemWithVarExpansion">
+            <expectedCodes>200</expectedCodes>
+            <method>DELETE</method>
+            <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithVarExpansion.recordCSID}/items/${importLocationItemWithVarExpansion.recordCSID}</uri>
+        </test>        
         
         <!-- Verify that a refName value is correctly generated for an authority -->
         <!-- record, when that value is not provided in the imported record, and -->
             <method>DELETE</method>
             <uri>/cspace-services/locationauthorities/${importLocationAuthorityWithGeneratedRefName.recordCSID}</uri>
         </test>
+        
                 
         <!--
             Import a record containing dollar sign and backslash character(s).
     <testGroup ID="importsTemporaryTestGroup" autoDeletePOSTS="false">
         
         <!-- Add new or changed tests here -->
-        
+                
     </testGroup>
     
     
index fa8c2619c6c72b299d2429b951c1830432d38566..62b6431eb19a9eb36cbcb7d164db6813cb5a350b 100644 (file)
@@ -2,7 +2,7 @@
 <import>
     <totalRecordsImported>1</totalRecordsImported>
     <numRecordsImported>
-        <docType>LocationAuthority</docType>
+        <docType>Locationauthority</docType>
         <numRecords>1</numRecords>
     </numRecordsImported>
 </import>
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem-varexpansion.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem-varexpansion.res.xml
new file mode 100644 (file)
index 0000000..3fd8879
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document name="locations">
+    <ns2:locations_common
+        xmlns:ns2="http://collectionspace.org/services/location">
+        <!--
+            Values containing Ampersand character entities are hard-coded
+            here in this file, rather than being passed in as values from
+            the XmlReplay control file, because in the control file it
+            appears we needed to double-encode them as '&amp;amp;',
+            which would complicate testing of CSPACE-5940.
+        -->
+        <locTermGroupList>
+            <locTermGroup>
+                <termDisplayName>Wattford &amp; Gump Outbuilding</termDisplayName>
+            </locTermGroup>
+        </locTermGroupList>
+        <shortIdentifier>${shortIdentifierValue}</shortIdentifier>
+        <inAuthority>${inAuthorityValue}</inAuthority>
+    </ns2:locations_common>
+    <ns2:collectionspace_core xmlns:ns2="http://collectionspace.org/collectionspace_core/"
+                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+        <!-- Note: This test may fail if the identifier for the core tenant changes. -->
+        <tenantId>1</tenantId>
+        <uri>${uriValue}</uri>
+        <refName>urn:cspace:core.collectionspace.org:locationauthorities:name(${importLocationAuthorityWithVarExpansion.shortIdentifierValue})'Wattford &amp; Gump Outbuilding'</refName>
+    </ns2:collectionspace_core>
+</document>
+
diff --git a/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem.res.xml b/services/IntegrationTests/src/test/resources/test-data/xmlreplay/imports/res/import-locationitem.res.xml
new file mode 100644 (file)
index 0000000..6588688
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<import>
+    <totalRecordsImported>1</totalRecordsImported>
+    <numRecordsImported>
+        <docType>Locationitem</docType>
+        <numRecords>1</numRecords>
+    </numRecordsImported>
+</import>
+
index d172814d23ee639aa0115d5e3dc1dc7cfc169912..73c85e8d66759a85399cf2a433329321146a1299 100644 (file)
@@ -176,7 +176,7 @@ public class TemplateExpander {
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("uri"),
                 getDocUri(tenantId, SERVICE_TYPE, docID, partTmpl));
         wrapperTmpl = Tools.searchAndReplace(wrapperTmpl, var("refName"),
-                getRefName(tenantId, SERVICE_TYPE, docID, partTmpl));
+                getRefName(tenantId, SERVICE_TYPE, docID, partTmpl).replace("&", "&amp;"));
 
 
         String serviceDir = outDir + '/' + docID;