Add ztest based test
authorJakub Skoczen <jakub@indexdata.dk>
Thu, 15 Apr 2010 10:08:02 +0000 (12:08 +0200)
committerJakub Skoczen <jakub@indexdata.dk>
Thu, 15 Apr 2010 10:08:02 +0000 (12:08 +0200)
Ignored when ztest is not running

src/test/org/yaz4j/ConnectionTest.java

index 826f546..f7ea9ee 100644 (file)
@@ -57,4 +57,28 @@ public class ConnectionTest {
         con.close();
       }
     }
+
+    @Test
+    /**
+     * This only works with local ztest
+     */
+    public void recordError() {
+        Connection con = new Connection("localhost:9999", 0);
+        assertNotNull(con);
+        try {
+          con.setSyntax("postscript");
+          System.out.println("Open connection to localhost:9999...");
+          con.connect();
+          ResultSet s = con.search("100", Connection.QueryType.PrefixQuery);
+          assertNotNull(s);
+          assertEquals(s.getSize(), 100);
+          Record rec = s.getRecord(0);
+          fail("We should never get here and get ZoomeException instead");
+        } catch (ZoomException ze) {
+          // we need more specific exceptions here
+          System.out.println(ze.getMessage());
+        } finally {
+          con.close();
+        }
+    }
 }