summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gorrod <alexg@wiredtiger.com>2013-03-26 12:54:39 +1100
committerAlex Gorrod <alexg@wiredtiger.com>2013-03-26 12:54:39 +1100
commited3d9ff846284efff48f36b954f8e42ae73ce4ac (patch)
tree90aeb467568b2cce02dfb0ef905a9799176719db
parent06c7012160d9d450dc2351a573494b9a63ce6420 (diff)
downloadmongo-ed3d9ff846284efff48f36b954f8e42ae73ce4ac.tar.gz
Add a test case for Java cursor issue refs #493
-rw-r--r--lang/java/Makefile.am1
-rw-r--r--test/java/com/wiredtiger/test/CursorTest02.java87
-rw-r--r--test/java/com/wiredtiger/test/WiredTigerSuite.java1
3 files changed, 89 insertions, 0 deletions
diff --git a/lang/java/Makefile.am b/lang/java/Makefile.am
index 75bd3aaf0bc..6c9346af2e1 100644
--- a/lang/java/Makefile.am
+++ b/lang/java/Makefile.am
@@ -31,6 +31,7 @@ JAVA_SRC = \
JAVA_JUNIT = \
$(JAVATEST)/CursorTest.java \
+ $(JAVATEST)/CursorTest02.java \
$(JAVATEST)/PackTest.java \
$(JAVATEST)/WiredTigerSuite.java
diff --git a/test/java/com/wiredtiger/test/CursorTest02.java b/test/java/com/wiredtiger/test/CursorTest02.java
new file mode 100644
index 00000000000..8ae37012764
--- /dev/null
+++ b/test/java/com/wiredtiger/test/CursorTest02.java
@@ -0,0 +1,87 @@
+/*-
+ * Public Domain 2008-2013 WiredTiger, Inc.
+ *
+ * This is free and unencumbered software released into the public domain.
+ *
+ * Anyone is free to copy, modify, publish, use, compile, sell, or
+ * distribute this software, either in source code form or as a compiled
+ * binary, for any purpose, commercial or non-commercial, and by any
+ * means.
+ *
+ * In jurisdictions that recognize copyright laws, the author or authors
+ * of this software dedicate any and all copyright interest in the
+ * software to the public domain. We make this dedication for the benefit
+ * of the public at large and to the detriment of our heirs and
+ * successors. We intend this dedication to be an overt act of
+ * relinquishment in perpetuity of all present and future rights to this
+ * software under copyright law.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+package com.wiredtiger.test;
+
+import com.wiredtiger.db.Connection;
+import com.wiredtiger.db.Cursor;
+import com.wiredtiger.db.Session;
+import com.wiredtiger.db.WiredTigerPackingException;
+import com.wiredtiger.db.wiredtiger;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/* More advanced Cursor test cases. */
+public class CursorTest02 {
+ Connection conn;
+ Session s;
+
+ /*
+ * Test for Git issue 493:
+ * https://github.com/wiredtiger/wiredtiger/issues/493
+ */
+ @Test
+ public void cursor01()
+ throws WiredTigerPackingException {
+ String keyFormat = "S";
+ String valueFormat = "S";
+ setup(keyFormat, valueFormat, ",columns=(id,val)");
+
+ Cursor c = s.open_cursor("table:t", null, null);
+ c.putKeyString("foo");
+ c.putValueString("bar");
+ c.insert();
+ c.reset();
+ while (c.next() == 0) {
+ Assert.assertEquals(c.getKeyFormat(), keyFormat);
+ Assert.assertEquals(c.getKeyString(), "foo");
+ Assert.assertEquals(c.getValueString(), "bar");
+ }
+
+ c.close();
+ teardown();
+ }
+
+ private void setup(String keyFormat, String valueFormat, String options) {
+ conn = wiredtiger.open("WT_HOME", "create");
+ s = conn.open_session(null);
+ s.create("table:t",
+ "key_format=" + keyFormat + ",value_format=" + valueFormat);
+ }
+
+ private void teardown() {
+ s.drop("table:t", "");
+ s.close("");
+ conn.close("");
+ }
+
+}
+
diff --git a/test/java/com/wiredtiger/test/WiredTigerSuite.java b/test/java/com/wiredtiger/test/WiredTigerSuite.java
index 0bdb4308871..cbcc1b4323f 100644
--- a/test/java/com/wiredtiger/test/WiredTigerSuite.java
+++ b/test/java/com/wiredtiger/test/WiredTigerSuite.java
@@ -32,6 +32,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses( {
CursorTest.class,
+ CursorTest02.class,
PackTest.class
})