Permalink
Browse files

WL-1709 Add the test for the new library code lookups.

  • Loading branch information...
buckett committed Aug 15, 2011
1 parent 28e54e5 commit fbf3521be3615f909c2c983da4cc0584f92a31a3
Showing with 198 additions and 0 deletions.
  1. +198 −0 src/test/java/uk/ac/ox/oucs/sirlouie/PrimoServiceTest.java
@@ -1,5 +1,6 @@
package uk.ac.ox.oucs.sirlouie;
+import java.io.IOException;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -8,9 +9,13 @@
import junit.framework.TestCase;
import org.json.JSONObject;
+import org.xml.sax.SAXException;
+import uk.ac.ox.oucs.sirlouie.daia.Document;
+import uk.ac.ox.oucs.sirlouie.daia.Item;
import uk.ac.ox.oucs.sirlouie.daia.ResponseBean;
import uk.ac.ox.oucs.sirlouie.primo.PrimoService;
+import uk.ac.ox.oucs.sirlouie.reply.SearLibrary;
import uk.ac.ox.oucs.sirlouie.reply.SearObject;
public class PrimoServiceTest extends TestCase {
@@ -300,6 +305,188 @@
+"{\"department\":{\"id\":\"BLL\",\"content\":\"Balliol College Library\"},"
+"\"storage\":{\"content\":\"Main Libr\"}}]}]}";
+
+ // After the library upgrade they started returning different XML.
+ private String NEW_OLIS_XML = "<SEGMENTS xmlns=\"http://www.exlibrisgroup.com/xsd/jaguar/search\">\n" +
+ " <JAGROOT>\n" +
+ " <RESULT>\n" +
+ " <DOCSET TOTALHITS=\"1\">\n" +
+ " <sear:DOC LOCAL=\"true\" xmlns=\"http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib\" xmlns:sear=\"http://www.exlibrisgroup.com/xsd/jaguar/search\">\n" +
+ " <PrimoNMBib>\n" +
+ " <record>\n" +
+ " <control>\n" +
+ " <sourcerecordid>017140770</sourcerecordid>\n" +
+ " <sourceid>oxfaleph</sourceid>\n" +
+ " <recordid>oxfaleph017140770</recordid>\n" +
+ " <originalsourceid>BIB01</originalsourceid>\n" +
+ " <ilsapiid>BIB01017140770</ilsapiid>\n" +
+ " <addsrcrecordid>017140770</addsrcrecordid>\n" +
+ " <sourceformat>MARC21</sourceformat>\n" +
+ " <sourcesystem>Aleph</sourcesystem>\n" +
+ " </control>\n" +
+ " <display>\n" +
+ " <type>book</type>\n" +
+ " <title>Linux in a nutshell</title>\n" +
+ " <creator>Siever, Ellen.</creator>\n" +
+ " <contributor>Ellen Siever</contributor>\n" +
+ " <edition>6th ed..</edition>\n" +
+ " <publisher>Sebastopol, Calif. ; Cambridge : O'Reilly</publisher>\n" +
+ " <creationdate>c2009</creationdate>\n" +
+ " <format>xxii, 917 p. ; 24 cm.</format>\n" +
+ " <identifier>$$CISBN$$V9780596154486 ; $$CISBN$$V0596154488</identifier>\n" +
+ " <subject>Operating systems (Computers); Linux</subject>\n" +
+ " <language>eng</language>\n" +
+ " <availlibrary>$$IOX$$LBODBL$$2(Box retrieval please)$$Scheck_holdings$$31$$41$$5N$$60$$XBOD50$$YBODBL</availlibrary>\n" +
+ " <lds01>Ellen Siever ... [et al.].</lds01>\n" +
+ " <lds02><![CDATA[<br><b>General Note: </b>Previous ed.: 2005.<br><b>General Note: </b>Cover title : Linux in a nutshell : a desktop quick reference.<br><b>General Note: </b>Includes index.]]></lds02>\n" +
+ " <lds04>Previous ed.: 2005. -- Cover title : Linux in a nutshell : a desktop quick reference. -- Includes index.</lds04>\n" +
+ " <lds06>Cover Title: Linux in a nutshell : a desktop quick reference</lds06>\n" +
+ " <lds15>017140770</lds15>\n" +
+ " <availinstitution>$$IOX$$Scheck_holdings</availinstitution>\n" +
+ " <availpnx>available</availpnx>\n" +
+ " <lds09>&lt;br />&lt;br />&lt;b>Short Description:&lt;/b> Focusing on Linux system essentials, this title covers programming tools, system and network administration tools, the shell, editors, LILO and GRUB boot options, and highlights the most important options for using the vast number of Linux commands. It can also help you learn Linux commands for system administration and network management.</lds09>\n" +
+ " </display>\n" +
+ " <links>\n" +
+ " <backlink>$$Taleph_backlink$$DMore bibliographic information</backlink>\n" +
+ " <thumbnail>$$Tamazon_thumb</thumbnail>\n" +
+ " <thumbnail>$$Tgoogle_thumb</thumbnail>\n" +
+ " <linktoholdings>$$Taleph_holdings</linktoholdings>\n" +
+ " <linktouc>$$Tamazon_uc$$DThis item in Amazon</linktouc>\n" +
+ " <linktouc>$$Tworldcat_isbn$$DThis item in WorldCat¨</linktouc>\n" +
+ " <linktoexcerpt>$$Tsyndetics_excerpt$$DExcerpt from item</linktoexcerpt>\n" +
+ " <lln03>$$Tgooglebsisbn</lln03>\n" +
+ " </links>\n" +
+ " <search>\n" +
+ " <creatorcontrib>Siever, Ellen.</creatorcontrib>\n" +
+ " <creatorcontrib>Ellen Siever ... [et al.].</creatorcontrib>\n" +
+ " <creatorcontrib>Ellen</creatorcontrib>\n" +
+ " <creatorcontrib>Siever, E</creatorcontrib>\n" +
+ " <creatorcontrib>Ellen Siever</creatorcontrib>\n" +
+ " <title>Linux in a nutshell /</title>\n" +
+ " <subject>Linux.</subject>\n" +
+ " <subject>Operating systems (Computers)</subject>\n" +
+ " <subject>Computers Operating systems</subject>\n" +
+ " <subject>Computer operating systems</subject>\n" +
+ " <subject>Disk operating systems</subject>\n" +
+ " <general>O'Reilly,</general>\n" +
+ " <sourceid>oxfaleph</sourceid>\n" +
+ " <recordid>oxfaleph017140770</recordid>\n" +
+ " <isbn>9780596154486</isbn>\n" +
+ " <isbn>9780596154486 (pbk.)</isbn>\n" +
+ " <isbn>0596154488</isbn>\n" +
+ " <isbn>0596154488 (pbk.)</isbn>\n" +
+ " <rsrctype>book</rsrctype>\n" +
+ " <creationdate>2009</creationdate>\n" +
+ " <creationdate>l|||</creationdate>\n" +
+ " <creationdate>|8</creationdate>\n" +
+ " <addsrcrecordid>017140770</addsrcrecordid>\n" +
+ " <addsrcrecordid>17140770</addsrcrecordid>\n" +
+ " <searchscope>oxfaleph</searchscope>\n" +
+ " <searchscope>BOD</searchscope>\n" +
+ " <searchscope>OULS</searchscope>\n" +
+ " <searchscope>OX</searchscope>\n" +
+ " <searchscope>NONOX</searchscope>\n" +
+ " <scope>oxfaleph</scope>\n" +
+ " <scope>BOD</scope>\n" +
+ " <scope>OULS</scope>\n" +
+ " <scope>OX</scope>\n" +
+ " <scope>NONOX</scope>\n" +
+ " <alttitle>Linux in a nutshell : a desktop quick reference</alttitle>\n" +
+ " <lsr01>(Box retrieval please)</lsr01>\n" +
+ " <lsr02>Previous ed.: 2005. -- Cover title : Linux in a nutshell : a desktop quick reference. -- Includes index.</lsr02>\n" +
+ " <lsr13>Sebastopol, Calif. ; Cambridge</lsr13>\n" +
+ " <lsr15>O'Reilly,</lsr15>\n" +
+ " <lsr09>&lt;br />&lt;br />&lt;b>Short Description:&lt;/b> Focusing on Linux system essentials, this title covers programming tools, system and network administration tools, the shell, editors, LILO and GRUB boot options, and highlights the most important options for using the vast number of Linux commands. It can also help you learn Linux commands for system administration and network management.</lsr09>\n" +
+ " </search>\n" +
+ " <sort>\n" +
+ " <title>Linux in a nutshell /</title>\n" +
+ " <creationdate>2009</creationdate>\n" +
+ " <author>Siever, Ellen.</author>\n" +
+ " <lso01>2009</lso01>\n" +
+ " </sort>\n" +
+ " <facets>\n" +
+ " <language>eng</language>\n" +
+ " <creationdate>2009</creationdate>\n" +
+ " <topic>Linux</topic>\n" +
+ " <topic>Operating systems (Computers)</topic>\n" +
+ " <collection>OLIS</collection>\n" +
+ " <toplevel>physical_item</toplevel>\n" +
+ " <prefilter>books</prefilter>\n" +
+ " <rsrctype>books</rsrctype>\n" +
+ " <creatorcontrib>Siever, E</creatorcontrib>\n" +
+ " <library>BODBL</library>\n" +
+ " <frbrgroupid>150606989</frbrgroupid>\n" +
+ " <frbrtype>5</frbrtype>\n" +
+ " </facets>\n" +
+ " <dedup>\n" +
+ " <c3>linuxinanutshell</c3>\n" +
+ " <c4>2009</c4>\n" +
+ " <f3>9780596154486;0596154488</f3>\n" +
+ " <f5>linuxinanutshell</f5>\n" +
+ " <f6>2009</f6>\n" +
+ " <f7>linux in a nutshell</f7>\n" +
+ " <f8>cau</f8>\n" +
+ " <f9>xxii, 917 p. ;</f9>\n" +
+ " <f10>oreilly</f10>\n" +
+ " </dedup>\n" +
+ " <frbr>\n" +
+ " <t>1</t>\n" +
+ " <k1>$$Ksiever ellen$$AA</k1>\n" +
+ " <k3>$$Klinux in a nutshell$$AT</k3>\n" +
+ " </frbr>\n" +
+ " <delivery>\n" +
+ " <institution>OX</institution>\n" +
+ " <institution>NONOX</institution>\n" +
+ " <delcategory>Physical Item</delcategory>\n" +
+ " </delivery>\n" +
+ " <ranking>\n" +
+ " <booster1>1</booster1>\n" +
+ " <booster2>1</booster2>\n" +
+ " </ranking>\n" +
+ " <addata>\n" +
+ " <aulast>Siever</aulast>\n" +
+ " <aufirst>Ellen</aufirst>\n" +
+ " <addau>Siever, Ellen</addau>\n" +
+ " <btitle>Linux in a nutshell</btitle>\n" +
+ " <addtitle>Linux in a nutshell : a desktop quick reference</addtitle>\n" +
+ " <date>2009</date>\n" +
+ " <risdate>c2009.</risdate>\n" +
+ " <isbn>9780596154486</isbn>\n" +
+ " <format>book</format>\n" +
+ " <genre>book</genre>\n" +
+ " <ristype>BOOK</ristype>\n" +
+ " <cop>Sebastopol, Calif. ; Cambridge</cop>\n" +
+ " <pub>O'Reilly</pub>\n" +
+ " </addata>\n" +
+ " </record>\n" +
+ " </PrimoNMBib>\n" +
+ " <sear:GETIT GetIt2=\"http://1.1.1.1?ctx_ver=Z39.88-2004&amp;ctx_enc=info:ofi/enc:UTF-8&amp;ctx_tim=2011-08-12T14%3A00%3A23IST&amp;url_ver=Z39.88-2004&amp;url_ctx_fmt=infofi/fmt:kev:mtx:ctx&amp;rfr_id=info:sid/primo.exlibrisgroup.com:primo3-Journal-oxfaleph&amp;rft_val_fmt=info:ofi/fmt:kev:mtx:book&amp;rft.genre=book&amp;rft.atitle=&amp;rft.jtitle=&amp;rft.btitle=Linux%20in%20a%20nutshell&amp;rft.aulast=Siever&amp;rft.auinit=&amp;rft.auinit1=&amp;rft.auinitm=&amp;rft.ausuffix=&amp;rft.au=&amp;rft.aucorp=&amp;rft.volume=&amp;rft.issue=&amp;rft.part=&amp;rft.quarter=&amp;rft.ssn=&amp;rft.spage=&amp;rft.epage=&amp;rft.pages=&amp;rft.artnum=&amp;rft.issn=&amp;rft.eissn=&amp;rft.isbn=9780596154486&amp;rft.sici=&amp;rft.coden=&amp;rft_id=info:doi/&amp;rft.object_id=&amp;rft_bat=&lt;oxfaleph>017140770&lt;/oxfaleph>&amp;rft.eisbn=&amp;rft_id=info:oai/\" GetIt1=\"OVP\" deliveryCategory=\"Physical Item\"/>\n" +
+ " <sear:LIBRARIES>\n" +
+ " <sear:LIBRARY>\n" +
+ " <sear:institution>OX</sear:institution>\n" +
+ " <sear:library>BODBL</sear:library>\n" +
+ " <sear:status>check_holdings</sear:status>\n" +
+ " <sear:collection/>\n" +
+ " <sear:callNumber>(Box retrieval please)</sear:callNumber>\n" +
+ " <sear:url>OVP</sear:url>\n" +
+ " </sear:LIBRARY>\n" +
+ " </sear:LIBRARIES>\n" +
+ " <sear:LINKS>\n" +
+ " <sear:backlink>http://aleph.sers.ox.ac.uk:8991/F?func=direct&amp;local_base=BIB01&amp;doc_number=017140770&amp;format=999</sear:backlink>\n" +
+ " <sear:thumbnail>http://images.amazon.com/images/P/9780596154486.01._SSTHUM_.jpg</sear:thumbnail>\n" +
+ " <sear:thumbnail>http://books.google.com/books?bibkeys=ISBN:9780596154486,OCLC:,LCCN:&amp;jscmd=viewapi&amp;callback=updateGBSCover</sear:thumbnail>\n" +
+ " <sear:linktoholdings>OVP</sear:linktoholdings>\n" +
+ " <sear:linktouc>http://www.amazon.co.uk/gp/search?keywords=9780596154486&amp;index=books</sear:linktouc>\n" +
+ " <sear:linktouc>http://www.worldcat.org/search?q=isbn%3A9780596154486</sear:linktouc>\n" +
+ " <sear:lln03>http://books.google.com/books?vid=ISBN9780596154486</sear:lln03>\n" +
+ " </sear:LINKS>\n" +
+ " </sear:DOC>\n" +
+ " </DOCSET>\n" +
+ " </RESULT>\n" +
+ " </JAGROOT>\n" +
+ "</SEGMENTS>\n" +
+ "";
+
/*
private String OLIS_JSON = "{\"version\":\"0.5\",\"schema\":\"http://ws.gbv.de/daia/\","
+"\"timestamp\":\"2009-06-09T15:39:52.831+02:00\","
@@ -448,5 +635,16 @@ public void testORAoJSON() {
Assert.fail("Exception caught ["+e.getLocalizedMessage()+"]");
}
}
+
+ public void testNewXmlResponse() throws SAXException, IOException {
+ // Test that the library name lookups are working.
+ Collection<SearObject> beans = PrimoService.filterResponse(nameSpaceURI, NEW_OLIS_XML);
+ assertFalse(beans.isEmpty());
+ ResponseBean response = new ResponseBean();
+ response.addSearObjects(beans);
+ Document doc = response.getDocuments().iterator().next();
+ Item item = doc.getItems().iterator().next();
+ assertEquals("Bodleian Library", item.getDepartment().getName());
+ }
}

0 comments on commit fbf3521

Please sign in to comment.