You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ag...@apache.org on 2017/10/26 21:50:18 UTC
[geode] branch feature/GEODE-3781 updated: Added test validation to
compare with table contents
This is an automated email from the ASF dual-hosted git repository.
agingade pushed a commit to branch feature/GEODE-3781
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/feature/GEODE-3781 by this push:
new 9e8fbf6 Added test validation to compare with table contents
9e8fbf6 is described below
commit 9e8fbf66e4fc9f6c15da3245960eb2d130a80b9b
Author: Anil <ag...@pivotal.io>
AuthorDate: Thu Oct 26 14:49:50 2017 -0700
Added test validation to compare with table contents
---
.../jdbc/JDBCAsyncWriterIntegrationTest.java | 64 ++++++++++++++++------
1 file changed, 46 insertions(+), 18 deletions(-)
diff --git a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCAsyncWriterIntegrationTest.java b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCAsyncWriterIntegrationTest.java
index 88ef4b9..42999a3 100644
--- a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCAsyncWriterIntegrationTest.java
+++ b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/JDBCAsyncWriterIntegrationTest.java
@@ -126,7 +126,7 @@ public class JDBCAsyncWriterIntegrationTest {
}
@Test
- public void canInstallJDBCAsyncWriterOnRegion() {
+ public void validateJDBCAsyncWriterTotalEvents() {
Region employees = createRegionWithJDBCAsyncWriter(regionTableName, getRequiredProperties());
PdxInstance pdx1 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp1")
.writeInt("age", 55).create();
@@ -135,16 +135,15 @@ public class JDBCAsyncWriterIntegrationTest {
employees.put("1", pdx1);
employees.put("2", pdx2);
- Awaitility.await().atMost(30, TimeUnit.SECONDS)
+ Awaitility.await().atMost(5, TimeUnit.SECONDS)
.until(() -> assertThat(jdbcWriter.getTotalEvents()).isEqualTo(2));
-
}
@Test
- public void jdbcAsyncWriterCanInsertIntoDatabase() throws Exception {
+ public void canInsertIntoTable() throws Exception {
Region employees = createRegionWithJDBCAsyncWriter(regionTableName, getRequiredProperties());
PdxInstance pdx1 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp1")
- .writeInt("age", 55).writeInt("id", 3).create();
+ .writeInt("age", 55).create();
PdxInstance pdx2 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp2")
.writeInt("age", 21).create();
employees.put("1", pdx1);
@@ -153,12 +152,38 @@ public class JDBCAsyncWriterIntegrationTest {
Awaitility.await().atMost(30, TimeUnit.SECONDS)
.until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(2));
- validateTableRowCount(2);
- printTable();
+ ResultSet rs = stmt.executeQuery("select * from " + regionTableName + " order by id asc");
+ assertThat(rs.next()).isTrue();
+ assertThat(rs.getString("id")).isEqualTo("1");
+ assertThat(rs.getString("name")).isEqualTo("Emp1");
+ assertThat(rs.getObject("age")).isEqualTo(55);
+ assertThat(rs.next()).isTrue();
+ assertThat(rs.getString("id")).isEqualTo("2");
+ assertThat(rs.getString("name")).isEqualTo("Emp2");
+ assertThat(rs.getObject("age")).isEqualTo(21);
+ assertThat(rs.next()).isFalse();
}
@Test
- public void jdbcAsyncWriterCanDestroyFromDatabase() throws Exception {
+ public void verifyThatPdxFieldNamedSameAsPrimaryKeyIsIgnored() throws Exception {
+ Region employees = createRegionWithJDBCAsyncWriter(regionTableName, getRequiredProperties());
+ PdxInstance pdx1 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp1")
+ .writeInt("age", 55).writeInt("id", 3).create();
+ employees.put("1", pdx1);
+
+ Awaitility.await().atMost(30, TimeUnit.SECONDS)
+ .until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(1));
+
+ ResultSet rs = stmt.executeQuery("select * from " + regionTableName + " order by id asc");
+ assertThat(rs.next()).isTrue();
+ assertThat(rs.getString("id")).isEqualTo("1");
+ assertThat(rs.getString("name")).isEqualTo("Emp1");
+ assertThat(rs.getObject("age")).isEqualTo(55);
+ assertThat(rs.next()).isFalse();
+ }
+
+ @Test
+ public void canDestroyFromTable() throws Exception {
Region employees = createRegionWithJDBCAsyncWriter(regionTableName, getRequiredProperties());
PdxInstance pdx1 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp1")
.writeInt("age", 55).create();
@@ -175,32 +200,35 @@ public class JDBCAsyncWriterIntegrationTest {
Awaitility.await().atMost(30, TimeUnit.SECONDS)
.until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(3));
- validateTableRowCount(1);
- printTable();
+ ResultSet rs = stmt.executeQuery("select * from " + regionTableName + " order by id asc");
+ assertThat(rs.next()).isTrue();
+ assertThat(rs.getString("id")).isEqualTo("2");
+ assertThat(rs.getString("name")).isEqualTo("Emp2");
+ assertThat(rs.getObject("age")).isEqualTo(21);
+ assertThat(rs.next()).isFalse();
}
@Test
- public void jdbcAsyncWriterCanUpdateDatabase() throws Exception {
+ public void canUpdateTable() throws Exception {
Region employees = createRegionWithJDBCAsyncWriter(regionTableName, getRequiredProperties());
PdxInstance pdx1 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp1")
.writeInt("age", 55).create();
- PdxInstance pdx2 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp2")
- .writeInt("age", 21).create();
employees.put("1", pdx1);
- employees.put("2", pdx2);
Awaitility.await().atMost(30, TimeUnit.SECONDS)
- .until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(2));
+ .until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(1));
PdxInstance pdx3 = cache.createPdxInstanceFactory("Employee").writeString("name", "Emp1")
.writeInt("age", 72).create();
employees.put("1", pdx3);
Awaitility.await().atMost(30, TimeUnit.SECONDS)
- .until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(3));
+ .until(() -> assertThat(jdbcWriter.getSuccessfulEvents()).isEqualTo(2));
- validateTableRowCount(2);
- printTable();
+ ResultSet rs = stmt.executeQuery("select * from " + regionTableName + " order by id asc");
+ assertThat(rs.next()).isTrue();
+ assertThat(rs.getObject("age")).isEqualTo(72);
+ assertThat(rs.next()).isFalse();
}
private Region createRegionWithJDBCAsyncWriter(String regionName, Properties props) {
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].