kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | cd12beaa38c0f2584650d0a96716a01d8e4ccb2bef55d1d646f1babf98e3ac65 |
|---|---|
| Author | Olivier Michallat <olim7t@users.noreply.github.com> · 2014-09-09 10:44 -07:00 |
| Committer | Olivier Michallat <olim7t@users.noreply.github.com> · 2014-09-09 10:44 -07:00 |
| Parents | 84a5d8bc69e0, 1e2046bae562 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/ConditionalUpdateTest.java +45 −0
| @@ -64,4 +64,49 @@ | ||
| 64 | 64 | |
| 65 | 65 | assertTrue(rs.wasApplied()); |
| 66 | 66 | } |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Test for #JAVA-358 - Directly expose CAS_RESULT_COLUMN. | |
| 70 | + * <p/> | |
| 71 | + * This test makes sure that the boolean flag {@code ResultSet.wasApplied()} is false when we try to insert a row | |
| 72 | + * which already exists. | |
| 73 | + * | |
| 74 | + * @see ResultSet#wasApplied() | |
| 75 | + */ | |
| 76 | + @Test(groups = "short") | |
| 77 | + public void insert_if_not_exist_should_support_wasApplied_boolean() { | |
| 78 | + // First, make sure the test table and the row exist | |
| 79 | + session.execute("CREATE TABLE IF NOT EXISTS Java358 (key int primary key, value int)"); | |
| 80 | + ResultSet rs; | |
| 81 | + rs = session.execute("INSERT INTO Java358(key, value) VALUES (42, 42) IF NOT EXISTS"); | |
| 82 | + assertTrue(rs.wasApplied()); | |
| 83 | + | |
| 84 | + // Then, make sure the flag reports correctly that we did not create a new row | |
| 85 | + rs = session.execute("INSERT INTO Java358(key, value) VALUES (42, 42) IF NOT EXISTS"); | |
| 86 | + assertFalse(rs.wasApplied()); | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * Test for #JAVA-358 - Directly expose CAS_RESULT_COLUMN. | |
| 91 | + * <p/> | |
| 92 | + * This test makes sure that the boolean flag {@code ResultSet.wasApplied()} is false when we try to delete a row | |
| 93 | + * which does not exist. | |
| 94 | + * | |
| 95 | + * @see ResultSet#wasApplied() | |
| 96 | + */ | |
| 97 | + @Test(groups = "short") | |
| 98 | + public void delete_if_not_exist_should_support_wasApplied_boolean() { | |
| 99 | + // First, make sure the test table and the row exist | |
| 100 | + session.execute("CREATE TABLE IF NOT EXISTS Java358 (key int primary key, value int)"); | |
| 101 | + session.execute("INSERT INTO Java358(key, value) VALUES (42, 42)"); | |
| 102 | + | |
| 103 | + // Then, make sure the flag reports correctly that we did delete the row | |
| 104 | + ResultSet rs; | |
| 105 | + rs = session.execute("DELETE FROM Java358 WHERE KEY=42 IF EXISTS"); | |
| 106 | + assertTrue(rs.wasApplied()); | |
| 107 | + | |
| 108 | + // Finally, make sure the flag reports correctly that we did did not delete an non-existing row | |
| 109 | + rs = session.execute("DELETE FROM Java358 WHERE KEY=42 IF EXISTS"); | |
| 110 | + assertFalse(rs.wasApplied()); | |
| 111 | + } | |
| 67 | 112 | } |