ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [1/3] incubator-ignite git commit: IGNITE-45 - Fixing tests.
Date Wed, 18 Mar 2015 06:36:48 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-45 1708c5851 -> dada92fa7


IGNITE-45 - Fixing 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/be685c9c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/be685c9c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/be685c9c

Branch: refs/heads/ignite-45
Commit: be685c9c59d350e3edb0a35719b0851f001bf192
Parents: dab080d
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Tue Mar 17 23:07:25 2015 -0700
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Tue Mar 17 23:07:25 2015 -0700

----------------------------------------------------------------------
 .../apache/ignite/cache/CacheInterceptor.java   |   5 +-
 .../ignite/cache/CacheInterceptorAdapter.java   |   3 +
 .../cache/GridCacheLoaderWriterStore.java       |   6 +-
 .../GridCacheInterceptorAbstractSelfTest.java   | 333 ++++++++++---------
 ...ridCacheMultinodeUpdateAbstractSelfTest.java |   2 +
 ...BehindStorePartitionedMultiNodeSelfTest.java |   4 +-
 .../dht/GridCacheGlobalLoadTest.java            |   4 +-
 .../GridCachePartitionedLoadCacheSelfTest.java  |   4 +-
 .../IgniteCacheLoadAllAbstractTest.java         | 107 +++---
 ...dCacheAtomicLocalMetricsNoStoreSelfTest.java |   2 +
 10 files changed, 268 insertions(+), 202 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
index ff94f86..864cc43 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
@@ -24,6 +24,7 @@ import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import java.io.*;
 
 /**
  * Cache interceptor. Cache interceptor can be used for getting callbacks before
@@ -31,13 +32,13 @@ import javax.cache.*;
  * operations. The {@code onBefore} callbacks can also be used to change the values
  * stored in cache or preventing entries from being removed from cache.
  * <p>
- * Cache interceptor is configured via {@link org.apache.ignite.configuration.CacheConfiguration#getInterceptor()}
+ * Cache interceptor is configured via {@link CacheConfiguration#getInterceptor()}
  * configuration property.
  * <p>
  * Any grid resource from {@code org.apache.ignite.resources} package can be injected
  * into implementation of this interface.
  */
-public interface CacheInterceptor<K, V> {
+public interface CacheInterceptor<K, V> extends Serializable {
     /**
      * This method is called within {@link IgniteCache#get(Object)}
      * and similar operations to provide control over returned value.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorAdapter.java
b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorAdapter.java
index 8139d79..3419055 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptorAdapter.java
@@ -27,6 +27,9 @@ import javax.cache.*;
  * interceptor callbacks.
  */
 public class CacheInterceptorAdapter<K, V> implements CacheInterceptor<K, V>
{
+    /** */
+    private static final long serialVersionUID = 0L;
+
     /** {@inheritDoc} */
     @Nullable @Override public V onGet(K key, V val) {
         return val;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStore.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStore.java
index 30c84e9..3e25b7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStore.java
@@ -24,12 +24,16 @@ import org.jetbrains.annotations.*;
 
 import javax.cache.*;
 import javax.cache.integration.*;
+import java.io.*;
 import java.util.*;
 
 /**
  * Store implementation wrapping {@link CacheLoader} and {@link CacheWriter}.
  */
-class GridCacheLoaderWriterStore<K, V> implements CacheStore<K, V>, LifecycleAware
{
+class GridCacheLoaderWriterStore<K, V> implements CacheStore<K, V>, LifecycleAware,
Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
     /** */
     private final CacheLoader<K, V> ldr;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
index 0b8ee4a..2c64859 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
@@ -40,7 +40,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
 
 /**
- * Tests {@link org.apache.ignite.cache.CacheInterceptor}.
+ * Tests {@link CacheInterceptor}.
  */
 public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbstractSelfTest
{
     /** */
@@ -152,11 +152,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
     private void testGet(String key) throws Exception {
         // Try when value is not in cache.
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                return null;
-            }
-        };
+        interceptor.retInterceptor = new NullGetInterceptor();
 
         log.info("Get 1.");
 
@@ -170,11 +166,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         interceptor.reset();
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                return 1;
-            }
-        };
+        interceptor.retInterceptor = new OneGetInterceptor();
 
         log.info("Get 2.");
 
@@ -196,11 +188,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         // Try when value is in cache.
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                return null;
-            }
-        };
+        interceptor.retInterceptor = new NullGetInterceptor();
 
         log.info("Get 3.");
 
@@ -216,11 +204,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         interceptor.reset();
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                return (Integer)val + 1;
-            }
-        };
+        interceptor.retInterceptor = new GetIncrementInterceptor();
 
         log.info("Get 4.");
 
@@ -236,11 +220,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         interceptor.reset();
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                return (Integer)val + 1;
-            }
-        };
+        interceptor.retInterceptor = new GetIncrementInterceptor();
 
         log.info("GetAsync 1.");
 
@@ -268,11 +248,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         for (int i = 0; i < 1000; i++)
             keys.add(String.valueOf(i));
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                return null;
-            }
-        };
+        interceptor.retInterceptor = new NullGetInterceptor();
 
         IgniteCache<String, Integer> cache = jcache(0);
 
@@ -287,13 +263,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
         interceptor.reset();
 
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onGet(Object key, Object val) {
-                int k = Integer.valueOf((String)key);
-
-                return k % 2 == 0 ? null : (k * 2);
-            }
-        };
+        interceptor.retInterceptor = new GetAllInterceptor1();
 
         map = cache.getAll(keys);
 
@@ -320,27 +290,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         for (int j = 0; j < 2; j++) {
             interceptor.reset();
 
-            interceptor.retInterceptor = new InterceptorAdapter() {
-                @Nullable @Override public Object onGet(Object key, Object val) {
-                    int k = Integer.valueOf((String)key);
-
-                    switch (k % 3) {
-                        case 0:
-                            return null;
-
-                        case 1:
-                            return val;
-
-                        case 2:
-                            return k * 3;
-
-                        default:
-                            fail();
-                    }
-
-                    return null;
-                }
-            };
+            interceptor.retInterceptor = new GetAllInterceptor2();
 
             if (j == 0)
                 map = cache.getAll(keys);
@@ -435,11 +385,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      */
     private void testCancelUpdate(String key, Operation op) throws Exception {
         // Interceptor returns null to disabled update.
-        CacheInterceptor retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal)
{
-                return null;
-            }
-        };
+        CacheInterceptor retInterceptor = new NullPutInterceptor();
 
         interceptor.retInterceptor = retInterceptor;
 
@@ -517,11 +463,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      */
     private void testModifyUpdate(String key, Operation op) throws Exception {
         // Interceptor returns incremented new value.
-        CacheInterceptor retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal)
{
-                return (Integer)newVal + 1;
-            }
-        };
+        CacheInterceptor retInterceptor = new PutIncrementInterceptor();
 
         // Execute update when value is null.
 
@@ -597,11 +539,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
     @SuppressWarnings("unchecked")
     private void testCancelRemove(String key, Operation op) throws Exception {
         // Interceptor disables remove and returns null.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(true, null);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(true,
null));
 
         // Execute remove when value is null.
 
@@ -622,11 +560,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.reset();
 
         // Interceptor disables remove and changes return value.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(true, 900);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(true,
900));
 
         // Execute remove when value is null, interceptor changes return value.
 
@@ -659,11 +593,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.disabled = false;
 
         // Interceptor disables remove and returns null.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(true, null);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(true,
null));
 
         log.info("Remove 3 " + op);
 
@@ -680,11 +610,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.reset();
 
         // Interceptor disables remove and changes return value.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(true, 1000);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(true,
1000));
 
         log.info("Remove 4 " + op);
 
@@ -724,11 +650,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
     @SuppressWarnings("unchecked")
     private void testRemove(String key, Operation op) throws Exception {
         // Interceptor changes return value to null.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(false, null);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor( new IgniteBiTuple(false,
null));
 
         // Execute remove when value is null.
 
@@ -749,11 +671,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.reset();
 
         // Interceptor changes return value.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(false, 900);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(false,
900));
 
         // Execute remove when value is null.
 
@@ -786,11 +704,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.disabled = false;
 
         // Interceptor changes return value to null.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(false, null);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(false,
null));
 
         log.info("Remove 3 " + op);
 
@@ -825,11 +739,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.disabled = false;
 
         // Interceptor changes return value.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(false, 1000);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(false,
1000));
 
         log.info("Remove 4 " + op);
 
@@ -879,11 +789,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
     private void testNearNodeKey(@Nullable TransactionConcurrency txConcurrency,
         @Nullable TransactionIsolation txIsolation, @Nullable Operation op) throws Exception
{
         // Interceptor returns incremented new value.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal)
{
-                return (Integer)newVal + 1;
-            }
-        };
+        interceptor.retInterceptor = new PutIncrementInterceptor();
 
         String key1 = primaryKey(0);
         String key2 = backupKey(0);
@@ -936,11 +842,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      */
     private void testBatchUpdate(Operation op) throws Exception {
         // Interceptor returns incremented new value.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal)
{
-                return (Integer)newVal + 1;
-            }
-        };
+        interceptor.retInterceptor = new PutIncrementInterceptor();
 
         Map<String, Integer> map = new HashMap<>();
 
@@ -987,14 +889,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.reset();
 
         // Interceptor returns incremented new value, cancels update for one key.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal)
{
-                if (entry.getKey().equals(key1))
-                    return null;
-
-                return (Integer)newVal + 1;
-            }
-        };
+        interceptor.retInterceptor = new BatchPutInterceptor1(key1);
 
         map.put(key1, 100);
         map.put(key2, 200);
@@ -1060,12 +955,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         map.put(key3, 3);
 
         // Interceptor does not cancel update.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(false, 999);
-            }
-        };
-
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(false,
999));
 
         log.info("Batch remove 1: " + op);
 
@@ -1090,11 +980,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
         interceptor.reset();
 
         // Interceptor does not cancel update.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(false, 999);
-            }
-        };
+        interceptor.retInterceptor = new BeforeRemoveInterceptor(new IgniteBiTuple(false,
999));
 
         log.info("Batch remove 2: " + op);
 
@@ -1127,11 +1013,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends
GridCacheAbst
         interceptor.reset();
 
         // Interceptor cancels update for one key.
-        interceptor.retInterceptor = new InterceptorAdapter() {
-            @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
-                return new IgniteBiTuple(entry.getKey().equals(key1), 999);
-            }
-        };
+        interceptor.retInterceptor = new BatchRemoveInterceptor(key1);
 
         log.info("Batch remove 3: " + op);
 
@@ -1533,7 +1415,29 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends
GridCacheAbst
     /**
      *
      */
-    private class Interceptor implements CacheInterceptor {
+    private static class BeforeRemoveInterceptor extends InterceptorAdapter {
+        /**
+         *
+         */
+        private IgniteBiTuple ret;
+
+        /**
+         * @param ret Return value.
+         */
+        private BeforeRemoveInterceptor(IgniteBiTuple ret) {
+            this.ret = ret;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
+            return ret;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class Interceptor implements CacheInterceptor {
         /** */
         private final Map<Object, Object> getMap = new ConcurrentHashMap8<>();
 
@@ -1568,7 +1472,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
             Object ret = retInterceptor.onGet(key, val);
 
-            log.info("Get [key=" + key + ", val=" + val + ", ret=" + ret + ']');
+            System.out.println("Get [key=" + key + ", val=" + val + ", ret=" + ret + ']');
 
             if (val != null) {
                 Object old = getMap.put(key, val);
@@ -1591,7 +1495,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
             Object ret = retInterceptor.onBeforePut(entry, newVal);
 
-            log.info("Before put [key=" + entry.getKey() + ", oldVal=" + entry.getValue()+
", newVal=" + newVal 
+            System.out.println("Before put [key=" + entry.getKey() + ", oldVal=" + entry.getValue()+
", newVal=" + newVal
                 + ", ret=" + ret + ']');
 
             invokeCnt.incrementAndGet();
@@ -1613,7 +1517,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
             if (disabled)
                 return;
 
-            log.info("After put [key=" + entry.getKey() + ", val=" + entry.getValue() + ']');
+            System.out.println("After put [key=" + entry.getKey() + ", val=" + entry.getValue()
+ ']');
 
             invokeCnt.incrementAndGet();
 
@@ -1633,7 +1537,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
 
             IgniteBiTuple ret = retInterceptor.onBeforeRemove(entry);
 
-            log.info("Before remove [key=" + entry.getKey() + ", val=" + entry.getValue()
+ ", ret=" + ret + ']');
+            System.out.println("Before remove [key=" + entry.getKey() + ", val=" + entry.getValue()
+ ", ret=" + ret + ']');
 
             invokeCnt.incrementAndGet();
 
@@ -1652,7 +1556,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
             if (disabled)
                 return;
 
-            log.info("After remove [key=" + entry.getKey() + ", val=" + entry.getValue()
+ ']');
+            System.out.println("After remove [key=" + entry.getKey() + ", val=" + entry.getValue()
+ ']');
 
             invokeCnt.incrementAndGet();
 
@@ -1679,4 +1583,135 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends
GridCacheAbst
             retInterceptor = null;
         }
     }
+
+    /**
+     *
+     */
+    private static class BatchRemoveInterceptor extends InterceptorAdapter {
+        /** */
+        private final String key1;
+
+        /**
+         * @param key1 Key.
+         */
+        public BatchRemoveInterceptor(String key1) {
+            this.key1 = key1;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public IgniteBiTuple onBeforeRemove(Cache.Entry entry) {
+            return new IgniteBiTuple(entry.getKey().equals(key1), 999);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class PutIncrementInterceptor extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal) {
+            return (Integer)newVal + 1;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NullPutInterceptor extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal) {
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class NullGetInterceptor extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onGet(Object key, Object val) {
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAllInterceptor1 extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onGet(Object key, Object val) {
+            int k = Integer.valueOf((String)key);
+
+            return k % 2 == 0 ? null : (k * 2);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetAllInterceptor2 extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onGet(Object key, Object val) {
+            int k = Integer.valueOf((String)key);
+
+            switch (k % 3) {
+                case 0:
+                    return null;
+
+                case 1:
+                    return val;
+
+                case 2:
+                    return k * 3;
+
+                default:
+                    fail();
+            }
+
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class BatchPutInterceptor1 extends InterceptorAdapter {
+        /** */
+        private final String key1;
+
+        /**
+         * @param key1 Key.
+         */
+        public BatchPutInterceptor1(String key1) {
+            this.key1 = key1;
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onBeforePut(Cache.Entry entry, Object newVal) {
+            if (entry.getKey().equals(key1))
+                return null;
+
+            return (Integer)newVal + 1;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class GetIncrementInterceptor extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onGet(Object key, Object val) {
+            return (Integer)val + 1;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class OneGetInterceptor extends InterceptorAdapter {
+        /** {@inheritDoc} */
+        @Nullable @Override public Object onGet(Object key, Object val) {
+            return 1;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
index 886d8fa..3397c1c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
@@ -56,6 +56,8 @@ public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCache
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 
         ccfg.setCacheStoreFactory(null);
+        ccfg.setReadThrough(false);
+        ccfg.setWriteThrough(false);
 
         return ccfg;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
index 43b6666..5e10085 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
@@ -26,10 +26,10 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.apache.ignite.transactions.*;
 
-import javax.cache.configuration.*;
 import java.util.*;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
@@ -76,7 +76,7 @@ public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends
GridC
 
         CacheStore store = stores[idx] = new GridCacheTestStore();
 
-        cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cc.setCacheStoreFactory(GridTestUtils.storeFactory(store));
         cc.setReadThrough(true);
         cc.setWriteThrough(true);
         cc.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
index fb1c2a3..444a6c4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
@@ -24,6 +24,7 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.resources.*;
+import org.apache.ignite.testframework.*;
 import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 import org.junit.*;
@@ -38,6 +39,7 @@ import static org.apache.ignite.cache.CacheMode.*;
 /**
  * Load cache test.
  */
+@SuppressWarnings("unchecked")
 public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
     /** */
     private static ConcurrentMap<String, Object[]> map;
@@ -180,7 +182,7 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected Factory<CacheStore> cacheStoreFactory() {
-        return new TestStoreFactory();
+        return (Factory)GridTestUtils.storeFactory(new TestStore());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
index cbbb241..2f4c45a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
@@ -27,11 +27,11 @@ import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
-import javax.cache.configuration.*;
 
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
@@ -58,7 +58,7 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
 
         ccfg.setCacheMode(PARTITIONED);
         ccfg.setBackups(1);
-        ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new TestStore()));
+        ccfg.setCacheStoreFactory(GridTestUtils.storeFactory(new TestStore()));
         ccfg.setReadThrough(true);
         ccfg.setWriteThrough(true);
         ccfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java
index 8fe8d0d..e26c9eb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoadAllAbstractTest.java
@@ -38,7 +38,7 @@ public abstract class IgniteCacheLoadAllAbstractTest extends IgniteCacheAbstract
     private volatile boolean writeThrough = true;
 
     /** */
-    private ConcurrentHashMap8<Object, Object> storeMap = new ConcurrentHashMap8<>();
+    private static ConcurrentHashMap8<Object, Object> storeMap;
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
@@ -47,54 +47,18 @@ public abstract class IgniteCacheLoadAllAbstractTest extends IgniteCacheAbstract
 
         ccfg.setWriteThrough(writeThrough);
 
-        ccfg.setCacheLoaderFactory(new Factory<CacheLoader>() {
-            @Override public CacheLoader create() {
-                return new CacheLoader<Object, Object>() {
-                    @Override public Object load(Object key) throws CacheLoaderException
{
-                        return storeMap.get(key);
-                    }
-
-                    @Override public Map<Object, Object> loadAll(Iterable<?>
keys) throws CacheLoaderException {
-                        Map<Object, Object> loaded = new HashMap<>();
-
-                        for (Object key : keys) {
-                            Object val = storeMap.get(key);
+        ccfg.setCacheLoaderFactory(new CacheLoaderFactory());
 
-                            if (val != null)
-                                loaded.put(key, val);
-                        }
-
-                        return loaded;
-                    }
-                };
-            }
-        });
+        ccfg.setCacheWriterFactory(new CacheWriterFactory());
 
-        ccfg.setCacheWriterFactory(new Factory<CacheWriter>() {
-            @Override public CacheWriter create() {
-                return new CacheWriter<Object, Object>() {
-                    @Override public void write(Cache.Entry<?, ?> e) {
-                        storeMap.put(e.getKey(), e.getValue());
-                    }
-
-                    @Override public void writeAll(Collection<Cache.Entry<?, ?>>
entries) {
-                        for (Cache.Entry<?, ?> e : entries)
-                            write(e);
-                    }
-
-                    @Override public void delete(Object key) {
-                        storeMap.remove(key);
-                    }
+        return ccfg;
+    }
 
-                    @Override public void deleteAll(Collection<?> keys) {
-                        for (Object key : keys)
-                            delete(key);
-                    }
-                };
-            }
-        });
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
 
-        return ccfg;
+        storeMap = new ConcurrentHashMap8<>();
     }
 
     /** {@inheritDoc} */
@@ -234,4 +198,57 @@ public abstract class IgniteCacheLoadAllAbstractTest extends IgniteCacheAbstract
             }
         }
     }
+
+    /**
+     *
+     */
+    private static class CacheLoaderFactory implements Factory<CacheLoader> {
+        @Override public CacheLoader create() {
+            return new CacheLoader<Object, Object>() {
+                @Override public Object load(Object key) throws CacheLoaderException {
+                    return storeMap.get(key);
+                }
+
+                @Override public Map<Object, Object> loadAll(Iterable<?> keys)
throws CacheLoaderException {
+                    Map<Object, Object> loaded = new HashMap<>();
+
+                    for (Object key : keys) {
+                        Object val = storeMap.get(key);
+
+                        if (val != null)
+                            loaded.put(key, val);
+                    }
+
+                    return loaded;
+                }
+            };
+        }
+    }
+
+    /**
+     *
+     */
+    private static class CacheWriterFactory implements Factory<CacheWriter> {
+        @Override public CacheWriter create() {
+            return new CacheWriter<Object, Object>() {
+                @Override public void write(Cache.Entry<?, ?> e) {
+                    storeMap.put(e.getKey(), e.getValue());
+                }
+
+                @Override public void writeAll(Collection<Cache.Entry<?, ?>>
entries) {
+                    for (Cache.Entry<?, ?> e : entries)
+                        write(e);
+                }
+
+                @Override public void delete(Object key) {
+                    storeMap.remove(key);
+                }
+
+                @Override public void deleteAll(Collection<?> keys) {
+                    for (Object key : keys)
+                        delete(key);
+                }
+            };
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/be685c9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
index e2f953a..9827e5f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
@@ -27,6 +27,8 @@ public class GridCacheAtomicLocalMetricsNoStoreSelfTest extends GridCacheAtomicL
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 
+        ccfg.setReadThrough(false);
+        ccfg.setWriteThrough(false);
         ccfg.setCacheStoreFactory(null);
 
         return ccfg;


Mime
View raw message