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 Fixing tests, created GridTestUtils.storeFactory()
Date Tue, 17 Mar 2015 17:45:49 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-45 7c92c9c71 -> 33c3d4348


# IGNITE-45 Fixing tests, created GridTestUtils.storeFactory()


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

Branch: refs/heads/ignite-45
Commit: 33c3d43482935c5f3eb567f2e565e235b457ec6d
Parents: 7c92c9c
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Tue Mar 17 20:43:48 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Tue Mar 17 20:45:08 2015 +0300

----------------------------------------------------------------------
 ...eJdbcStoreAbstractMultithreadedSelfTest.java |  4 +-
 .../GridCacheAbstractLocalStoreSelfTest.java    |  6 +-
 ...heAbstractTransformWriteThroughSelfTest.java |  3 +-
 .../near/GridCacheNearMultiNodeSelfTest.java    |  3 +-
 .../ignite/testframework/GridTestUtils.java     | 74 +++++++++++++++++++-
 5 files changed, 80 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33c3d434/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 6675616..2977ac8 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
@@ -27,6 +27,7 @@ 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 org.jetbrains.annotations.*;
@@ -35,7 +36,6 @@ import org.springframework.beans.factory.xml.*;
 import org.springframework.context.support.*;
 import org.springframework.core.io.*;
 
-import javax.cache.configuration.*;
 import java.net.*;
 import java.sql.*;
 import java.util.*;
@@ -155,7 +155,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T
extends Cach
                     cfgUrl + ", err=" + e.getMessage() + ']', e);
         }
 
-        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/33c3d434/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 54c9316..a0950ef 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(new FactoryBuilder.SingletonFactory<CacheStore>(LOCAL_STORE_1));
+            cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(LOCAL_STORE_1));
         else if (gridName.endsWith("2"))
-            cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<CacheStore>(LOCAL_STORE_2));
+            cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(LOCAL_STORE_2));
         else
-            cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<CacheStore>(LOCAL_STORE_3));
+            cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(LOCAL_STORE_3));
 
         cacheCfg.setWriteThrough(true);
         cacheCfg.setReadThrough(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33c3d434/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 ef62b10..45e24db 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
@@ -25,6 +25,7 @@ import org.apache.ignite.marshaller.optimized.*;
 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.*;
 
@@ -116,7 +117,7 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends
Gri
 
         cacheCfg.setCacheMode(PARTITIONED);
         cacheCfg.setBackups(1);
-        cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(store));
         cacheCfg.setReadThrough(true);
         cacheCfg.setWriteThrough(true);
         cacheCfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33c3d434/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 51732df..be80e81 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
@@ -32,6 +32,7 @@ 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 org.jetbrains.annotations.*;
@@ -95,7 +96,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest
{
         CacheConfiguration cacheCfg = defaultCacheConfiguration();
 
         cacheCfg.setCacheMode(PARTITIONED);
-        cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
+        cacheCfg.setCacheStoreFactory(GridTestUtils.storeFactory(store));
         cacheCfg.setReadThrough(true);
         cacheCfg.setWriteThrough(true);
         cacheCfg.setLoadPreviousValue(true);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/33c3d434/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 9a0a117..badcb70 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
@@ -20,6 +20,7 @@ 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.*;
@@ -37,6 +38,7 @@ 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.*;
@@ -1482,14 +1484,14 @@ public final class GridTestUtils {
     public static void runGC() {
         System.gc();
 
-        ReferenceQueue queue = new ReferenceQueue();
+        ReferenceQueue<byte[]> queue = new ReferenceQueue<>();
 
-        List<SoftReference> refs = new ArrayList<>();
+        Collection<SoftReference<byte[]>> refs = new ArrayList<>();
 
         while (true) {
             byte[] bytes = new byte[128 * 1024];
 
-            refs.add(new SoftReference(bytes, queue));
+            refs.add(new SoftReference<>(bytes, queue));
 
             if (queue.poll() != null)
                 break;
@@ -1504,4 +1506,70 @@ 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);
+    }
+
+    /**
+     *
+     */
+    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;
+        }
+    }
+
 }


Mime
View raw message