Add ResultSet#getRecords test
[yaz4j-moved-to-github.git] / src / test / org / yaz4j / ConnectionTest.java
index abeca8f..056039b 100644 (file)
@@ -3,6 +3,7 @@ package org.yaz4j;
 import org.junit.*;
 import static org.junit.Assert.*;
 import org.yaz4j.exception.*;
+import java.util.List;
 
 public class ConnectionTest {
 
@@ -27,6 +28,23 @@ public class ConnectionTest {
       assertEquals(content[0], 103);
       assertEquals(rec.getSyntax(), "SUTRS");
       assertEquals(rec.getDatabase(), "gils");
+      System.out.println("Read all records..");
+      // read all records
+      int i = 0;
+      for (Record r : s) {
+        assertNotNull(r);
+        System.out.println("Got "+i+" record of type "+r.getSyntax());
+        i++;
+      }
+      System.out.println("Try sorting them...");
+      s.sort("yaz", "1=4 >i 1=21 >s");
+      System.out.println("Try fetching them all at once...");
+      i = 0;
+      List<Record> all = s.getRecords(0, (int) s.getHitCount());
+      for (Record r : all) {
+        System.out.println("getRecords, rec '"+i+"'"+r.getSyntax());
+        i++;
+      }
     } catch (ZoomException ze) {
       fail(ze.getMessage());
     } finally {
@@ -34,6 +52,7 @@ public class ConnectionTest {
     }
   }
 
+
   @Test
   public void unsupportedSyntax() {
     System.out.println("Open connection to z3950.loc.gov:7090/voyager...");