diff options
author | Don Anderson <dda@ddanderson.com> | 2014-10-30 09:22:50 -0400 |
---|---|---|
committer | Don Anderson <dda@ddanderson.com> | 2014-10-30 09:22:50 -0400 |
commit | c20b47ffb74300af4decca9e69994b0de0d93f3d (patch) | |
tree | df5063d207774b63e17fef42208e95155f83305b /test/java | |
parent | 8dc722e1bd10311795267ba8a3a040b53d362d5a (diff) | |
download | mongo-c20b47ffb74300af4decca9e69994b0de0d93f3d.tar.gz |
Added test for RollbackException. refs #1295.
Diffstat (limited to 'test/java')
-rw-r--r-- | test/java/com/wiredtiger/test/ExceptionTest.java | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/test/java/com/wiredtiger/test/ExceptionTest.java b/test/java/com/wiredtiger/test/ExceptionTest.java index f81d2349757..6cb5a4c2043 100644 --- a/test/java/com/wiredtiger/test/ExceptionTest.java +++ b/test/java/com/wiredtiger/test/ExceptionTest.java @@ -47,15 +47,6 @@ import java.io.IOException; import java.io.FileNotFoundException; import java.io.PrintStream; -/* - * A simple class to share state and synchronize actions of - * two threads in the test - */ -class SharedState { - public boolean gotRollbackException = false; - public Exception otherException = null; -} - public class ExceptionTest { String uri; Connection conn; @@ -116,6 +107,56 @@ public class ExceptionTest { teardown(); } + @Test + public void except03() throws IOException { + String keyFormat = "S"; + String valueFormat = "i"; + boolean caught = false; + Session sess1 = null; + Session sess2 = null; + Cursor c1 = null; + Cursor c2 = null; + + setup("table:except03", keyFormat, valueFormat); + System.err.println("Starting"); + + try { + sess1 = conn.open_session("isolation=snapshot"); + sess2 = conn.open_session("isolation=snapshot"); + + sess1.begin_transaction(null); + sess2.begin_transaction(null); + + c1 = sess1.open_cursor("table:except03", null, null); + c2 = sess2.open_cursor("table:except03", null, null); + + c1.putKeyString("key"); + c1.putValueInt(1); + c1.insert(); + + c2.putKeyString("key"); + c2.putValueInt(2); + c2.insert(); + } + catch (WiredTigerRollbackException rbe) { + caught = true; + } + catch (Exception e) { + System.err.println("ERROR: got unexpected exception: " + e); + } + finally { + if (c1 != null) + c1.close(); + if (c2 != null) + c2.close(); + if (sess1 != null) + sess1.close(""); + if (sess2 != null) + sess2.close(""); + } + Assert.assertEquals(caught, true); + } + private void setup(String uriparam, String keyFormat, String valueFormat) { uri = uriparam; conn = wiredtiger.open("WT_HOME", "create"); |