ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-1753 Added more test. Removed debug messages.
Date Fri, 13 Nov 2015 03:41:22 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1753-1282 77cddba9e -> 5d6970029


IGNITE-1753 Added more test. Removed debug messages.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5d697002
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5d697002
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5d697002

Branch: refs/heads/ignite-1753-1282
Commit: 5d69700295f533d9147dfcb1430ff6ad7352b9f0
Parents: 77cddba
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Nov 13 10:41:37 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Nov 13 10:41:37 2015 +0700

----------------------------------------------------------------------
 .../store/jdbc/CacheAbstractJdbcStore.java      |  2 -
 .../CacheJdbcPojoStoreAbstractSelfTest.java     | 77 ++++++++++++++++++--
 2 files changed, 69 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5d697002/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index 8d16550..03ac436 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -328,8 +328,6 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K,
V>,
      * @throws SQLException In case of error.
      */
     protected Connection connection() throws SQLException {
-        log.debug("Open connection");
-
         CacheStoreSession ses = session();
 
         if (ses.transaction() != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5d697002/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
index e476280..0f40bd9 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.cache.store.jdbc;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
@@ -87,8 +88,15 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
         stmt.executeUpdate("DROP TABLE IF EXISTS Organization");
         stmt.executeUpdate("DROP TABLE IF EXISTS Person");
 
-        stmt.executeUpdate("CREATE TABLE Organization (id integer PRIMARY KEY, name varchar(50),
city varchar(50))");
-        stmt.executeUpdate("CREATE TABLE Person (id integer PRIMARY KEY, org_id integer,
name varchar(50))");
+        stmt.executeUpdate("CREATE TABLE Organization (" +
+            " id INTEGER PRIMARY KEY," +
+            " name VARCHAR(50)," +
+            " city VARCHAR(50))");
+
+        stmt.executeUpdate("CREATE TABLE Person (" +
+            " id INTEGER PRIMARY KEY," +
+            " org_id INTEGER," +
+            " name VARCHAR(50))");
 
         conn.commit();
 
@@ -311,14 +319,69 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     }
 
     /**
+     * Check put in cache and store it in db.
+     *
+     * @throws Exception If failed.
+     */
+    private void checkPut() throws Exception {
+        IgniteCache<PersonKey, Person> c1 = grid().cache(null);
+
+        Connection conn = getConnection();
+        try {
+            PreparedStatement stmt = conn.prepareStatement("SELECT ID, ORG_ID, NAME FROM
PERSON WHERE ID = ?");
+
+            stmt.setInt(1, -1);
+
+            ResultSet rs = stmt.executeQuery();
+
+            assertFalse("Unexpected non empty result set", rs.next());
+
+            U.closeQuiet(rs);
+
+            // Test put-insert.
+            PersonKey key = new PersonKey(-1);
+
+            c1.put(key, new Person(-1, -2, "Person-to-test-put-insert", 999));
+
+            rs = stmt.executeQuery();
+
+            assertTrue("Unexpected empty result set", rs.next());
+
+            assertEquals(-1, rs.getInt(1));
+            assertEquals(-2, rs.getInt(2));
+            assertEquals("Person-to-test-put-insert", rs.getString(3));
+
+            assertFalse("Unexpected more data in result set", rs.next());
+
+            U.closeQuiet(rs);
+
+            // Test put-update.
+            c1.put(key, new Person(-1, -3, "Person-to-test-put-update", 999));
+
+            rs = stmt.executeQuery();
+
+            assertTrue("Unexpected empty result set", rs.next());
+
+            assertEquals(-1, rs.getInt(1));
+            assertEquals(-3, rs.getInt(2));
+            assertEquals("Person-to-test-put-update", rs.getString(3));
+
+            assertFalse("Unexpected more data in result set", rs.next());
+
+            U.closeQuiet(rs);
+        }
+        finally {
+            U.closeQuiet(conn);
+        }
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testPut() throws Exception {
         startTestGrid(false, false, false, false);
 
-        IgniteCache<PersonKey, Person> c1 = grid().cache(null);
-
-        c1.put(new PersonKey(999), new Person(999, 777, "tx-person", 999));
+        checkPut();
     }
 
     /**
@@ -327,8 +390,6 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
     public void testPutTx() throws Exception {
         startTestGrid(false, false, false, true);
 
-        IgniteCache<PersonKey, Person> c1 = grid().cache(null);
-
-        c1.put(new PersonKey(999), new Person(999, 777, "tx-person", 999));
+        checkPut();
     }
 }


Mime
View raw message