IGNITE-208, IGNITE-207 - Fixed tests.

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

Branch: refs/heads/ignite-128
Commit: 6a90e0f772cd59b2e21d1788e68a6175d901cb67
Parents: cfa2652
Author: Alexey Goncharuk <agoncha...@gridgain.com>
Authored: Mon Feb 9 12:36:45 2015 -0800
Committer: Alexey Goncharuk <agoncha...@gridgain.com>
Committed: Mon Feb 9 12:36:45 2015 -0800

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |  6 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java | 91 +++++++++-----------
 .../cache/GridCacheAbstractSelfTest.java        | 10 ++-
 ...idCacheNearOnlyMultiNodeFullApiSelfTest.java |  5 ++
 4 files changed, 60 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6a90e0f7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 3d61ec3..cac914e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -4938,7 +4938,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
      * @param filter Filters to evaluate.
      * @return Key set.
      */
-    public Set<K> keySet(@Nullable IgnitePredicate<CacheEntry<K, V>>... 
filter) {
+    @Override public Set<K> keySet(@Nullable IgnitePredicate<CacheEntry<K, 
V>>... filter) {
         return map.keySet(filter);
     }
 
@@ -5867,7 +5867,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
     /**
      *
      */
-    protected static abstract class UpdateTimeStatClosure<T> implements 
CI1<IgniteInternalFuture<T>> {
+    protected abstract static class UpdateTimeStatClosure<T> implements 
CI1<IgniteInternalFuture<T>> {
         /** */
         protected final CacheMetricsImpl metrics;
 
@@ -5900,7 +5900,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
         /**
          * Updates statistics.
          */
-        abstract protected void updateTimeStat();
+        protected abstract void updateTimeStat();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6a90e0f7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 1445223..7d26d87 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -352,7 +352,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      * @throws Exception In case of error.
      */
     public void testGetAll() throws Exception {
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         final IgniteCache<String, Integer> cache = jcache();
 
@@ -394,7 +394,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         // Now do the same checks but within transaction.
         if (txEnabled()) {
-            tx = grid(0).transactions().txStart();
+            tx = transactions().txStart();
 
             assert cache.getAll(Collections.<String>emptySet()).isEmpty();
 
@@ -447,7 +447,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testGetTxNonExistingKey() throws Exception {
         if (txEnabled()) {
-            try (IgniteTx ignored = grid(0).transactions().txStart()) {
+            try (IgniteTx ignored = transactions().txStart()) {
                 assert jcache().get("key999123") == null;
             }
         }
@@ -525,7 +525,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testPutTx() throws Exception {
         if (txEnabled()) {
-            IgniteTx tx = grid(0).transactions().txStart();
+            IgniteTx tx = transactions().txStart();
 
             IgniteCache<String, Integer> cache = jcache();
 
@@ -1135,7 +1135,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      * @throws Exception If failed.
      */
     private void checkPut(boolean inTx) throws Exception {
-        IgniteTx tx = inTx ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = inTx ? transactions().txStart() : null;
 
         IgniteCache<String, Integer> cache = jcache();
 
@@ -1165,7 +1165,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      * @throws Exception If failed.
      */
     public void testPutAsync() throws Exception {
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         IgniteCache<String, Integer> cacheAsync = jcache().withAsync();
 
@@ -1229,8 +1229,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
     /**
      * @throws Exception In case of error.
      */
-    // TODO: IGNITE-208: Enable when fixed.
-    public void _testNullInTx() throws Exception {
+    public void testNullInTx() throws Exception {
         if (!txEnabled())
             return;
 
@@ -1242,8 +1241,8 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             assertNull(cache.get(key));
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
-                public Void call() throws Exception {
-                    IgniteTransactions txs = grid(0).transactions();
+                @Override public Void call() throws Exception {
+                    IgniteTransactions txs = transactions();
 
                     try (IgniteTx tx = txs.txStart()) {
                         cache.put(key, 1);
@@ -1264,8 +1263,8 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             assertEquals(1, (int) cache.get(key));
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
-                public Void call() throws Exception {
-                    IgniteTransactions txs = grid(0).transactions();
+                @Override public Void call() throws Exception {
+                    IgniteTransactions txs = transactions();
 
                     try (IgniteTx tx = txs.txStart()) {
                         cache.put(key, 2);
@@ -1286,10 +1285,10 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             assertEquals(2, (int)cache.get(key));
 
             GridTestUtils.assertThrows(log, new Callable<Void>() {
-                public Void call() throws Exception {
-                    IgniteTransactions txs = grid(0).transactions();
+                @Override public Void call() throws Exception {
+                    IgniteTransactions txs = transactions();
 
-                    Map<String, Integer> map = new LinkedHashMap<String, 
Integer>();
+                    Map<String, Integer> map = new LinkedHashMap<>();
 
                     map.put("k1", 1);
                     map.put("k2", 2);
@@ -1482,7 +1481,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      * @throws Exception In case of error.
      */
     public void testGetAndPutIfAbsent() throws Exception {
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         IgniteCache<String, Integer> cache = jcache();
 
@@ -1536,7 +1535,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         cache.localEvict(Collections.singleton("key2"));
 
         // Same checks inside tx.
-        tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             assertEquals((Integer)1, cache.getAndPutIfAbsent("key2", 3));
@@ -1556,7 +1555,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      * @throws Exception If failed.
      */
     public void testGetAndPutIfAbsentAsync() throws Exception {
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         IgniteCache<String, Integer> cache = jcache();
 
@@ -1604,12 +1603,12 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         cache.localEvict(Collections.singleton("key2"));
 
         // Same checks inside tx.
-        tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             cacheAsync.getAndPutIfAbsent("key2", 3);
 
-            assertEquals((Integer)1, cacheAsync.future().get());
+            assertEquals(1, cacheAsync.future().get());
 
             if (tx != null)
                 tx.commit();
@@ -1649,7 +1648,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         cache.localEvict(Collections.singleton("key2"));
 
         // Same checks inside tx.
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             assertFalse(cache.putIfAbsent("key2", 3));
@@ -1722,7 +1721,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         cache.localEvict(Arrays.asList("key2"));
 
         // Same checks inside tx.
-        IgniteTx tx = inTx ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = inTx ? transactions().txStart() : null;
 
         try {
             cacheAsync.putIfAbsent("key2", 3);
@@ -1829,7 +1828,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         cache.localEvict(Collections.singleton("key"));
 
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             assert cache.replace("key", 4, 5);
@@ -1875,7 +1874,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         cache.localEvict(Collections.singleton("key"));
 
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             assert cache.replace("key", 5);
@@ -1951,7 +1950,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         cache.localEvict(Collections.singleton("key"));
 
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             cacheAsync.replace("key", 4, 5);
@@ -1985,7 +1984,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         assert cacheAsync.<Boolean>future().get();
 
-        U.debug(log, "Finished replace.");
+        info("Finished replace.");
 
         assertEquals((Integer)2, cache.get("key"));
 
@@ -2011,7 +2010,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         cache.localEvict(Collections.singleton("key"));
 
-        IgniteTx tx = txEnabled() ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = txEnabled() ? transactions().txStart() : null;
 
         try {
             cacheAsync.replace("key", 5);
@@ -2295,7 +2294,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testRemoveAllDuplicatesTx() throws Exception {
         if (txEnabled()) {
-            try (IgniteTx tx = grid(0).transactions().txStart()) {
+            try (IgniteTx tx = transactions().txStart()) {
                 jcache().removeAll(ImmutableSet.of("key1", "key1", "key1"));
 
                 tx.commit();
@@ -2391,7 +2390,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         int key = 0;
 
-        List<Integer> keys = new ArrayList<>();
+        Collection<Integer> keys = new ArrayList<>();
 
         for (int k = 0; k < 2; k++) {
             while (!ignite.affinity(null).isPrimary(ignite.localNode(), key))
@@ -2402,7 +2401,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             key++;
         }
 
-        System.out.println(keys);
+        info("Keys: " + keys);
 
         for (Integer k : keys)
             cache.put(k, k);
@@ -3007,7 +3006,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         if (inTx) {
             // Rollback transaction for the first time.
-            IgniteTx tx = grid(0).transactions().txStart();
+            IgniteTx tx = transactions().txStart();
 
             try {
                 grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 1);
@@ -3021,7 +3020,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         }
 
         // Now commit transaction and check that ttl and expire time have been 
saved.
-        IgniteTx tx = inTx ? grid(0).transactions().txStart() : null;
+        IgniteTx tx = inTx ? transactions().txStart() : null;
 
         try {
             grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 1);
@@ -3048,7 +3047,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         // One more update from the same cache entry to ensure that expire 
time is shifted forward.
         U.sleep(100);
 
-        tx = inTx ? grid(0).transactions().txStart() : null;
+        tx = inTx ? transactions().txStart() : null;
 
         try {
             grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 2);
@@ -3073,7 +3072,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         // And one more direct update to ensure that expire time is shifted 
forward.
         U.sleep(100);
 
-        tx = inTx ? grid(0).transactions().txStart() : null;
+        tx = inTx ? transactions().txStart() : null;
 
         try {
             grid(0).jcache(null).withExpiryPolicy(expiry).put(key, 3);
@@ -3100,7 +3099,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         log.info("Put 4");
 
-        tx = inTx ? grid(0).transactions().txStart() : null;
+        tx = inTx ? transactions().txStart() : null;
 
         try {
             c.put(key, 4);
@@ -3381,11 +3380,9 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      *
      * @throws Exception If failed.
      */
-    // IGNITE-207: Enable when fixed.
-    public void _testOptimisticTxMissingKey() throws Exception {
+    public void testOptimisticTxMissingKey() throws Exception {
         if (txEnabled()) {
-
-            try (IgniteTx tx = grid(0).transactions().txStart(OPTIMISTIC, 
READ_COMMITTED)) {
+            try (IgniteTx tx = transactions().txStart(OPTIMISTIC, 
READ_COMMITTED)) {
                 // Remove missing key.
                 assertTrue(jcache().remove(UUID.randomUUID().toString()));
 
@@ -3399,11 +3396,9 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      *
      * @throws Exception If failed.
      */
-    // IGNITE-207: Enable when fixed.
-    public void _testOptimisticTxMissingKeyNoCommit() throws Exception {
+    public void testOptimisticTxMissingKeyNoCommit() throws Exception {
         if (txEnabled()) {
-
-            try (IgniteTx tx = grid(0).transactions().txStart(OPTIMISTIC, 
READ_COMMITTED)) {
+            try (IgniteTx tx = transactions().txStart(OPTIMISTIC, 
READ_COMMITTED)) {
                 // Remove missing key.
                 assertTrue(jcache().remove(UUID.randomUUID().toString()));
 
@@ -3457,7 +3452,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             });
 
             CU.inTx(ignite(0), jcache(), concurrency, isolation, new 
CIX1<IgniteCache<String, Integer>>() {
-                @Override public void applyx(IgniteCache<String, Integer> 
cache) throws IgniteCheckedException {
+                @Override public void applyx(IgniteCache<String, Integer> 
cache) {
                     for (int i = 0; i < cnt; i++)
                         assertEquals(new Integer(i), cache.get("key" + i));
                 }
@@ -3479,7 +3474,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testPessimisticTxMissingKey() throws Exception {
         if (txEnabled()) {
-            try (IgniteTx tx = grid(0).transactions().txStart(PESSIMISTIC, 
READ_COMMITTED)) {
+            try (IgniteTx tx = transactions().txStart(PESSIMISTIC, 
READ_COMMITTED)) {
                 // Remove missing key.
                 assertFalse(jcache().remove(UUID.randomUUID().toString()));
 
@@ -3495,7 +3490,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testPessimisticTxMissingKeyNoCommit() throws Exception {
         if (txEnabled()) {
-            try (IgniteTx tx = grid(0).transactions().txStart(PESSIMISTIC, 
READ_COMMITTED)) {
+            try (IgniteTx tx = transactions().txStart(PESSIMISTIC, 
READ_COMMITTED)) {
                 // Remove missing key.
                 assertFalse(jcache().remove(UUID.randomUUID().toString()));
 
@@ -3509,7 +3504,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testPessimisticTxRepeatableRead() throws Exception {
         if (txEnabled()) {
-            try (IgniteTx ignored = 
grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            try (IgniteTx ignored = transactions().txStart(PESSIMISTIC, 
REPEATABLE_READ)) {
                 jcache().put("key", 1);
 
                 assert jcache().get("key") == 1;
@@ -3522,7 +3517,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
      */
     public void testPessimisticTxRepeatableReadOnUpdate() throws Exception {
         if (txEnabled()) {
-            try (IgniteTx ignored = 
grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            try (IgniteTx ignored = transactions().txStart(PESSIMISTIC, 
REPEATABLE_READ)) {
                 jcache().put("key", 1);
 
                 assert jcache().getAndPut("key", 2) == 1;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6a90e0f7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index 7b91617..336f3b0 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -381,6 +381,13 @@ public abstract class GridCacheAbstractSelfTest extends 
GridCommonAbstractTest {
     }
 
     /**
+     * @return Transactions instance.
+     */
+    protected IgniteTransactions transactions() {
+        return grid(0).transactions();
+    }
+
+    /**
      * @param idx Index of grid.
      * @return Default cache.
      */
@@ -431,7 +438,8 @@ public abstract class GridCacheAbstractSelfTest extends 
GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     @Nullable protected <K, V> V peek(IgniteCache<K, V> cache, K key) throws 
Exception {
-        return offheapTiered(cache) ? cache.localPeek(key, CachePeekMode.SWAP) 
: cache.localPeek(key, CachePeekMode.ONHEAP);
+        return offheapTiered(cache) ? cache.localPeek(key, CachePeekMode.SWAP) 
: cache.localPeek(key,
+            CachePeekMode.ONHEAP);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6a90e0f7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
index 41a35a6..bc83d15 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
@@ -131,6 +131,11 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest 
extends GridCachePartitio
     }
 
     /** {@inheritDoc} */
+    @Override protected IgniteTransactions transactions() {
+        return grid(nearIdx).transactions();
+    }
+
+    /** {@inheritDoc} */
     @Override protected List<String> primaryKeysForCache(IgniteCache<String, 
Integer> cache, int cnt)
         throws IgniteCheckedException {
         if (cache.equals(jcache()))

Reply via email to