Repository: incubator-ignite Updated Branches: refs/heads/ignite-929 361534e85 -> ef4b77e49
ignite-929 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ef4b77e4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ef4b77e4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ef4b77e4 Branch: refs/heads/ignite-929 Commit: ef4b77e4973b450fc64249899d95aba2f27d51c6 Parents: 361534e Author: avinogradov <avinogra...@gridgain.com> Authored: Thu Jun 11 18:33:36 2015 +0300 Committer: avinogradov <avinogra...@gridgain.com> Committed: Thu Jun 11 18:33:36 2015 +0300 ---------------------------------------------------------------------- ...cheStoreSessionListenerAbstractSelfTest.java | 118 ++++++++++--------- 1 file changed, 62 insertions(+), 56 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ef4b77e4/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java index adac0b2..2b0d270 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/CacheStoreSessionListenerAbstractSelfTest.java @@ -113,12 +113,13 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm public void testAtomicCache() throws Exception { CacheConfiguration<Integer, Integer> cfg = cacheConfiguration(null, CacheAtomicityMode.ATOMIC); - try (IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg)) { - cache.loadCache(null); - cache.get(1); - cache.put(1, 1); - cache.remove(1); - } + IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg); + cache.loadCache(null); + cache.get(1); + cache.put(1, 1); + cache.remove(1); + + cache.destroy(); assertEquals(3, loadCacheCnt.get()); assertEquals(1, loadCnt.get()); @@ -133,12 +134,13 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm public void testTransactionalCache() throws Exception { CacheConfiguration<Integer, Integer> cfg = cacheConfiguration(null, CacheAtomicityMode.TRANSACTIONAL); - try (IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg)) { - cache.loadCache(null); - cache.get(1); - cache.put(1, 1); - cache.remove(1); - } + IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg); + cache.loadCache(null); + cache.get(1); + cache.put(1, 1); + cache.remove(1); + + cache.destroy(); assertEquals(3, loadCacheCnt.get()); assertEquals(1, loadCnt.get()); @@ -154,17 +156,18 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm public void testExplicitTransaction() throws Exception { CacheConfiguration<Integer, Integer> cfg = cacheConfiguration(null, CacheAtomicityMode.TRANSACTIONAL); - try (IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg)) { - try (Transaction tx = ignite(0).transactions().txStart()) { - cache.put(1, 1); - cache.put(2, 2); - cache.remove(3); - cache.remove(4); + IgniteCache<Integer, Integer> cache = ignite(0).createCache(cfg); + try (Transaction tx = ignite(0).transactions().txStart()) { + cache.put(1, 1); + cache.put(2, 2); + cache.remove(3); + cache.remove(4); - tx.commit(); - } + tx.commit(); } + cache.destroy(); + assertEquals(2, writeCnt.get()); assertEquals(2, deleteCnt.get()); assertEquals(3, reuseCnt.get()); @@ -177,20 +180,21 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm CacheConfiguration<Integer, Integer> cfg1 = cacheConfiguration("cache1", CacheAtomicityMode.TRANSACTIONAL); CacheConfiguration<Integer, Integer> cfg2 = cacheConfiguration("cache2", CacheAtomicityMode.TRANSACTIONAL); - try ( - IgniteCache<Integer, Integer> cache1 = ignite(0).createCache(cfg1); - IgniteCache<Integer, Integer> cache2 = ignite(0).createCache(cfg2) - ) { - try (Transaction tx = ignite(0).transactions().txStart()) { - cache1.put(1, 1); - cache2.put(2, 2); - cache1.remove(3); - cache2.remove(4); - - tx.commit(); - } + IgniteCache<Integer, Integer> cache1 = ignite(0).createCache(cfg1); + IgniteCache<Integer, Integer> cache2 = ignite(0).createCache(cfg2); + + try (Transaction tx = ignite(0).transactions().txStart()) { + cache1.put(1, 1); + cache2.put(2, 2); + cache1.remove(3); + cache2.remove(4); + + tx.commit(); } + cache1.destroy(); + cache2.destroy(); + assertEquals(2, writeCnt.get()); assertEquals(2, deleteCnt.get()); assertEquals(3, reuseCnt.get()); @@ -205,18 +209,19 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm CacheConfiguration<Integer, Integer> cfg1 = cacheConfiguration("cache1", CacheAtomicityMode.TRANSACTIONAL); CacheConfiguration<Integer, Integer> cfg2 = cacheConfiguration("cache2", CacheAtomicityMode.TRANSACTIONAL); - try ( - IgniteCache<Integer, Integer> cache1 = ignite(0).createCache(cfg1); - IgniteCache<Integer, Integer> cache2 = ignite(0).createCache(cfg2) - ) { - try (Transaction tx = ignite(0).transactions().txStart()) { - cache1.put(1, 1); - cache2.put(2, 2); + IgniteCache<Integer, Integer> cache1 = ignite(0).createCache(cfg1); + IgniteCache<Integer, Integer> cache2 = ignite(0).createCache(cfg2); + + try (Transaction tx = ignite(0).transactions().txStart()) { + cache1.put(1, 1); + cache2.put(2, 2); - tx.commit(); - } + tx.commit(); } + cache1.destroy(); + cache2.destroy(); + try (Connection conn = DriverManager.getConnection(URL)) { checkTable(conn, 1, false); checkTable(conn, 2, false); @@ -233,27 +238,28 @@ public abstract class CacheStoreSessionListenerAbstractSelfTest extends GridComm CacheConfiguration<Integer, Integer> cfg1 = cacheConfiguration("cache1", CacheAtomicityMode.TRANSACTIONAL); CacheConfiguration<Integer, Integer> cfg2 = cacheConfiguration("cache2", CacheAtomicityMode.TRANSACTIONAL); - try ( - IgniteCache<Integer, Integer> cache1 = ignite(0).createCache(cfg1); - IgniteCache<Integer, Integer> cache2 = ignite(0).createCache(cfg2) - ) { - try (Transaction tx = ignite(0).transactions().txStart()) { - cache1.put(1, 1); - cache2.put(2, 2); + IgniteCache<Integer, Integer> cache1 = ignite(0).createCache(cfg1); + IgniteCache<Integer, Integer> cache2 = ignite(0).createCache(cfg2); + + try (Transaction tx = ignite(0).transactions().txStart()) { + cache1.put(1, 1); + cache2.put(2, 2); - tx.commit(); + tx.commit(); - assert false : "Exception was not thrown."; - } - catch (IgniteException e) { - CacheWriterException we = X.cause(e, CacheWriterException.class); + assert false : "Exception was not thrown."; + } + catch (IgniteException e) { + CacheWriterException we = X.cause(e, CacheWriterException.class); - assertNotNull(we); + assertNotNull(we); - assertEquals("Expected failure.", we.getMessage()); - } + assertEquals("Expected failure.", we.getMessage()); } + cache1.destroy(); + cache2.destroy(); + try (Connection conn = DriverManager.getConnection(URL)) { checkTable(conn, 1, true); checkTable(conn, 2, true);