From 272a198e401b579199f39a569fae7f5143ab9797 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Wed, 8 Apr 2015 13:58:06 +0200 Subject: [PATCH] ConnectionExtended tests YAZJ-18 --- src/test/org/yaz4j/ConnectionExtendedTest.java | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/org/yaz4j/ConnectionExtendedTest.java diff --git a/src/test/org/yaz4j/ConnectionExtendedTest.java b/src/test/org/yaz4j/ConnectionExtendedTest.java new file mode 100644 index 0000000..b837d05 --- /dev/null +++ b/src/test/org/yaz4j/ConnectionExtendedTest.java @@ -0,0 +1,44 @@ +package org.yaz4j; + +import org.junit.*; +import static org.junit.Assert.*; +import org.yaz4j.exception.*; +import java.util.List; + +@SuppressWarnings("deprecation") +public class ConnectionExtendedTest { + + @Test + public void testConnection() { + ConnectionExtended con = new ConnectionExtended("z3950.indexdata.dk:210/gils", 0); + assertNotNull(con); + try { + con.setSyntax("sutrs"); + System.out.println("Open connection extended to z3950.indexdata.dk:210/gils..."); + con.connect(); + ResultSet s = con.search(new PrefixQuery("@attr 1=4 utah")); + System.out.println("Search for 'utah'..."); + assertNotNull(s); + assertEquals(s.getHitCount(), 9); + Record rec = s.getRecord(0); + assertNotNull(rec); + byte[] content = rec.getContent(); + // first SUTRS record + assertEquals(content.length, 1940); + assertEquals(content[0], 103); + assertEquals(rec.getSyntax(), "SUTRS"); + assertEquals(rec.getDatabase(), "gils"); + System.out.println("Update record.."); + Package p = con.getPackage("update"); + p.option("action", "specialUpdate"); + p.option("record", rec.render()); + p.send(); + } catch (ZoomException ze) { + assertEquals("Bib1Exception: Error Code = 223 (EsPermissionDeniedOnEsCannotModifyOrDelete)", + ze.getMessage()); + } finally { + con.close(); + } + } + +} -- 1.7.10.4