ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject incubator-ignite git commit: # IGNITE-45 Refactoring: move GrisTestUtils.storeFactory() to GriaAbstractTest
Date Wed, 18 Mar 2015 12:17:42 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-45 be0ddab33 -> acaf9cf3c


# IGNITE-45 Refactoring: move GrisTestUtils.storeFactory() to GriaAbstractTest


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

Branch: refs/heads/ignite-45
Commit: acaf9cf3c1d801ec3ecee38d49627e58c15c1369
Parents: be0ddab
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed Mar 18 15:17:05 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Mar 18 15:17:05 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheExpiryStoreLoadSelfTest.java     |  2 +-
 ...eJdbcStoreAbstractMultithreadedSelfTest.java |  2 +-
 .../GridCacheAbstractLocalStoreSelfTest.java    |  6 +-
 ...BehindStorePartitionedMultiNodeSelfTest.java |  2 +-
 .../IgniteTxStoreExceptionAbstractSelfTest.java |  2 +-
 ...heAbstractTransformWriteThroughSelfTest.java |  2 +-
 .../dht/GridCacheGlobalLoadTest.java            |  2 +-
 .../near/GridCacheNearMultiNodeSelfTest.java    |  2 +-
 ...ePartitionedBasicStoreMultiNodeSelfTest.java |  2 +-
 .../GridCachePartitionedLoadCacheSelfTest.java  |  2 +-
 .../ignite/testframework/GridTestUtils.java     | 76 ------------------
 .../testframework/junits/GridAbstractTest.java  | 83 +++++++++++++++++++-
 12 files changed, 94 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
index fca5132..18cd09d 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/IgniteCacheExpiryStoreLoadSelfTest.java
@@ -58,7 +58,7 @@ public class IgniteCacheExpiryStoreLoadSelfTest extends GridCacheAbstractSelfTes
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         CacheConfiguration cfg = super.cacheConfiguration(gridName);
 
-        cfg.setCacheStoreFactory(GridTestUtils.storeFactory(new TestStore()));
+        cfg.setCacheStoreFactory(storeFactory(new TestStore()));
         cfg.setReadThrough(true);
         cfg.setWriteThrough(true);
         cfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
index 3c1e7c6..a1730b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
@@ -160,7 +160,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T
extends Cach
                     cfgUrl + ", err=" + e.getMessage() + ']', e);
         }
 
-        cc.setCacheStoreFactory(GridTestUtils.storeFactory(store));
+        cc.setCacheStoreFactory(storeFactory(store));
         cc.setReadThrough(true);
         cc.setWriteThrough(true);
         cc.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
index a0950ef..5205b36 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractLocalStoreSelfTest.java
@@ -124,11 +124,11 @@ public abstract class GridCacheAbstractLocalStoreSelfTest extends GridCommonAbst
         cacheCfg.setRebalanceMode(SYNC);
 
         if (gridName.endsWith("1"))
-            cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(LOCAL_STORE_1));
+            cacheCfg.setCacheStoreFactory(storeFactory(LOCAL_STORE_1));
         else if (gridName.endsWith("2"))
-            cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(LOCAL_STORE_2));
+            cacheCfg.setCacheStoreFactory(storeFactory(LOCAL_STORE_2));
         else
-            cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(LOCAL_STORE_3));
+            cacheCfg.setCacheStoreFactory(storeFactory(LOCAL_STORE_3));
 
         cacheCfg.setWriteThrough(true);
         cacheCfg.setReadThrough(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/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 5e10085..2dc9d4d 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
@@ -76,7 +76,7 @@ public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends
GridC
 
         CacheStore store = stores[idx] = new GridCacheTestStore();
 
-        cc.setCacheStoreFactory(GridTestUtils.storeFactory(store));
+        cc.setCacheStoreFactory(storeFactory(store));
         cc.setReadThrough(true);
         cc.setWriteThrough(true);
         cc.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
index 0446eaa..01715e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
@@ -74,7 +74,7 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 
-        ccfg.setCacheStoreFactory(GridTestUtils.storeFactory(store));
+        ccfg.setCacheStoreFactory(storeFactory(store));
         ccfg.setReadThrough(true);
         ccfg.setWriteThrough(true);
         ccfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
index 45e24db..5842855 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
@@ -117,7 +117,7 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends
Gri
 
         cacheCfg.setCacheMode(PARTITIONED);
         cacheCfg.setBackups(1);
-        cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(store));
+        cacheCfg.setCacheStoreFactory(storeFactory(store));
         cacheCfg.setReadThrough(true);
         cacheCfg.setWriteThrough(true);
         cacheCfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/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 444a6c4..662d83d 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
@@ -182,7 +182,7 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected Factory<CacheStore> cacheStoreFactory() {
-        return (Factory)GridTestUtils.storeFactory(new TestStore());
+        return (Factory)storeFactory(new TestStore());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index 937e9f7..592f38a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -97,7 +97,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest
{
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 
         cacheCfg.setCacheMode(PARTITIONED);
-        cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(store));
+        cacheCfg.setCacheStoreFactory(storeFactory(store));
         cacheCfg.setReadThrough(true);
         cacheCfg.setWriteThrough(true);
         cacheCfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
index 0288c49..5e48185 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
@@ -104,7 +104,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
 
         stores.add(store);
 
-        cc.setCacheStoreFactory(GridTestUtils.storeFactory(store));
+        cc.setCacheStoreFactory(storeFactory(store));
         cc.setReadThrough(true);
         cc.setWriteThrough(true);
         cc.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/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 2f4c45a..cce9602 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
@@ -58,7 +58,7 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
 
         ccfg.setCacheMode(PARTITIONED);
         ccfg.setBackups(1);
-        ccfg.setCacheStoreFactory(GridTestUtils.storeFactory(new TestStore()));
+        ccfg.setCacheStoreFactory(storeFactory(new TestStore()));
         ccfg.setReadThrough(true);
         ccfg.setWriteThrough(true);
         ccfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 7ec499a..27c6863 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -19,8 +19,6 @@ package org.apache.ignite.testframework;
 
 import junit.framework.*;
 import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.store.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.client.ssl.*;
@@ -38,7 +36,6 @@ import org.apache.ignite.testframework.config.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
-import javax.cache.configuration.*;
 import javax.net.ssl.*;
 import java.io.*;
 import java.lang.annotation.*;
@@ -1506,77 +1503,4 @@ public final class GridTestUtils {
     public static String apacheIgniteTestPath() {
         return System.getProperty("IGNITE_TEST_PATH", U.getIgniteHome() + "/target/ignite");
     }
-
-    /**
-     *
-     */
-    public static <K, V> Factory<? extends CacheStore<K, V>> storeFactory(CacheStore<K,
V> store) {
-        return new SingletonStoreFactory<>(store);
-    }
-
-    /**
-     *
-     */
-    public static void clear() {
-        SerializableStore.serializedObj.clear();
-    }
-
-    /**
-     *
-     */
-    private static class SingletonStoreFactory<T> implements Factory<T> {
-        /** */
-        private final T store;
-
-        /**
-         * @param store Store.
-         */
-        SingletonStoreFactory(T store) {
-            this.store = store;
-        }
-
-        /** {@inheritDoc} */
-        @Override public T create() {
-            return store;
-        }
-
-        /**
-         *
-         */
-        protected Object writeReplace() throws ObjectStreamException {
-            return new SerializableStore(this);
-        }
-    }
-
-    /**
-     *
-     */
-    private static class SerializableStore implements Serializable {
-        /** */
-        private static final ConcurrentMap<UUID, Object> serializedObj = new ConcurrentHashMap<>();
-
-        /** */
-        private final UUID uuid;
-
-        /**
-         * @param o Object.
-         */
-        private SerializableStore(Object o) {
-            uuid = UUID.randomUUID();
-
-            serializedObj.put(uuid, o);
-        }
-
-        /**
-         *
-         */
-        protected Object readResolve() throws ObjectStreamException {
-            Object res = serializedObj.remove(uuid);
-
-            assert res != null;
-
-            return res;
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acaf9cf3/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 1269a9f..0d223f6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.testframework.junits;
 
 import junit.framework.*;
 import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
@@ -44,6 +45,8 @@ import org.springframework.beans.*;
 import org.springframework.context.*;
 import org.springframework.context.support.*;
 
+import javax.cache.configuration.*;
+import java.io.*;
 import java.lang.reflect.*;
 import java.net.*;
 import java.util.*;
@@ -108,6 +111,9 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /** */
+    private static final ConcurrentMap<UUID, Object> serializedObj = new ConcurrentHashMap<>();
+
+    /** */
     protected GridAbstractTest() {
         this(false);
 
@@ -1166,6 +1172,8 @@ public abstract class GridAbstractTest extends TestCase {
             afterTest();
         }
         finally {
+            serializedObj.clear();
+
             if (isLastTest()) {
                 info(">>> Stopping test class: " + getClass().getSimpleName() +
" <<<");
 
@@ -1193,7 +1201,6 @@ public abstract class GridAbstractTest extends TestCase {
                 OptimizedMarshaller.clearCache();
                 MarshallerExclusions.clearCache();
                 GridEnumCache.clear();
-                GridTestUtils.clear();
             }
 
             Thread.currentThread().setContextClassLoader(clsLdr);
@@ -1348,6 +1355,80 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * @param store Store.
+     */
+    protected <K, V> Factory<CacheStore<K, V>> storeFactory(CacheStore<K,
V> store) {
+        return new SingletonStoreFactory<>(store);
+    }
+
+    /**
+     * Returns an object that should be returned from writeReplace() method.
+     *
+     * @param obj Object that must not be changed after serialization/deserialization.
+     * @return An object to return from writeReplace()
+     */
+    protected Object supressSerialization(Object obj) {
+        SerializableProxy res = new SerializableProxy(UUID.randomUUID());
+
+        serializedObj.put(res.uuid, obj);
+
+        return res;
+    }
+
+    /**
+     *
+     */
+    private static class SerializableProxy implements Serializable {
+        /** */
+        private final UUID uuid;
+
+        /**
+         * @param uuid Uuid.
+         */
+        private SerializableProxy(UUID uuid) {
+            this.uuid = uuid;
+        }
+
+        /**
+         *
+         */
+        protected Object readResolve() throws ObjectStreamException {
+            Object res = serializedObj.get(uuid);
+
+            assert res != null;
+
+            return res;
+        }
+    }
+
+    /**
+     *
+     */
+    private class SingletonStoreFactory<T> implements Factory<T> {
+        /** */
+        private final T store;
+
+        /**
+         * @param store Store.
+         */
+        SingletonStoreFactory(T store) {
+            this.store = store;
+        }
+
+        /** {@inheritDoc} */
+        @Override public T create() {
+            return store;
+        }
+
+        /**
+         *
+         */
+        protected Object writeReplace() {
+            return supressSerialization(this);
+        }
+    }
+
+    /**
      * Test counters.
      */
     protected class TestCounters {


Mime
View raw message