ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [13/53] [abbrv] [partial] incubator-ignite git commit: # ignite-164 : GridAbstractTest -> IgniteAbstractTest - auto-renaming with all suggested options + rename all methods and fields inside AbstractTest
Date Wed, 04 Feb 2015 14:37:47 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/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
deleted file mode 100644
index 735fc2a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-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.junits.common.*;
-import org.apache.ignite.transactions.*;
-
-import javax.cache.configuration.*;
-import java.util.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheDistributionMode.*;
-import static org.apache.ignite.transactions.IgniteTxConcurrency.*;
-import static org.apache.ignite.transactions.IgniteTxIsolation.*;
-
-/**
- * Tests write-behind store with near and dht commit option.
- */
-public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridCommonAbstractTest {
-    /** Grids to start. */
-    private static final int GRID_CNT = 5;
-
-    /** Ip finder. */
-    private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** Flush frequency. */
-    public static final int WRITE_BEHIND_FLUSH_FREQ = 1000;
-
-    /** Stores per grid. */
-    private GridCacheTestStore[] stores = new GridCacheTestStore[GRID_CNT];
-
-    /** Start grid counter. */
-    private int idx;
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration c = super.getConfiguration(gridName);
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinder(ipFinder);
-
-        c.setDiscoverySpi(disco);
-
-        CacheConfiguration cc = defaultCacheConfiguration();
-
-        cc.setCacheMode(CacheMode.PARTITIONED);
-        cc.setWriteBehindEnabled(true);
-        cc.setWriteBehindFlushFrequency(WRITE_BEHIND_FLUSH_FREQ);
-        cc.setAtomicityMode(TRANSACTIONAL);
-        cc.setDistributionMode(NEAR_PARTITIONED);
-
-        CacheStore store = stores[idx] = new GridCacheTestStore();
-
-        cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store));
-        cc.setReadThrough(true);
-        cc.setWriteThrough(true);
-        cc.setLoadPreviousValue(true);
-
-        c.setCacheConfiguration(cc);
-
-        idx++;
-
-        return c;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stores = null;
-
-        super.afterTestsStopped();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void prepare() throws Exception {
-        idx = 0;
-
-        startGrids(GRID_CNT);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        stopAllGrids();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSingleWritesOnDhtNode() throws Exception {
-        checkSingleWrites();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testBatchWritesOnDhtNode() throws Exception {
-        checkBatchWrites();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testTxWritesOnDhtNode() throws Exception {
-        checkTxWrites();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void checkSingleWrites() throws Exception {
-        prepare();
-
-        GridCache<Integer, String> cache = grid(0).cache(null);
-
-        for (int i = 0; i < 100; i++)
-            cache.put(i, String.valueOf(i));
-
-        checkWrites();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void checkBatchWrites() throws Exception {
-        prepare();
-
-        Map<Integer, String> map = new HashMap<>();
-
-        for (int i = 0; i < 100; i++)
-            map.put(i, String.valueOf(i));
-
-        grid(0).cache(null).putAll(map);
-
-        checkWrites();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void checkTxWrites() throws Exception {
-        prepare();
-
-        GridCache<Object, Object> cache = grid(0).cache(null);
-
-        try (IgniteTx tx = cache.txStart(PESSIMISTIC, REPEATABLE_READ)) {
-            for (int i = 0; i < 100; i++)
-                cache.put(i, String.valueOf(i));
-
-            tx.commit();
-        }
-
-        checkWrites();
-    }
-
-    /**
-     * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If sleep was interrupted.
-     */
-    private void checkWrites() throws IgniteInterruptedCheckedException {
-        U.sleep(WRITE_BEHIND_FLUSH_FREQ * 2);
-
-        Collection<Integer> allKeys = new ArrayList<>(100);
-
-        for (int i = 0; i < GRID_CNT; i++) {
-            Map<Integer,String> map = stores[i].getMap();
-
-            assertFalse("Missing writes for node: " + i, map.isEmpty());
-
-            allKeys.addAll(map.keySet());
-
-            // Check there is no intersection.
-            for (int j = 0; j < GRID_CNT; j++) {
-                if (i == j)
-                    continue;
-
-                Collection<Integer> intersection = new HashSet<>(stores[j].getMap().keySet());
-
-                intersection.retainAll(map.keySet());
-
-                assertTrue(intersection.isEmpty());
-            }
-        }
-
-        assertEquals(100, allKeys.size());
-
-        for (int i = 0; i < 100; i++)
-            assertTrue(allKeys.contains(i));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java
deleted file mode 100644
index f9e454f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-/**
- * Tests {@link GridCacheWriteBehindStore} in partitioned configuration.
- */
-public class GridCacheWriteBehindStorePartitionedTest extends GridCacheWriteBehindStoreAbstractTest {
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return CacheMode.PARTITIONED;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java
deleted file mode 100644
index c809f90..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.*;
-
-/**
- * Tests {@link GridCacheWriteBehindStore} in grid configuration.
- */
-public class GridCacheWriteBehindStoreReplicatedTest extends GridCacheWriteBehindStoreAbstractTest {
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return CacheMode.REPLICATED;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
deleted file mode 100644
index bc43414..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jdk8.backport.*;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * This class provides basic tests for {@link GridCacheWriteBehindStore}.
- */
-public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
-    /**
-     * Tests correct store shutdown when underlying store fails,
-     *
-     * @throws Exception If failed.
-     */
-    public void testShutdownWithFailure() throws Exception {
-        final AtomicReference<Exception> err = new AtomicReference<>();
-
-        multithreadedAsync(new Runnable() {
-            @Override public void run() {
-                try {
-                    delegate.setShouldFail(true);
-
-                    initStore(2);
-
-                    try {
-                        store.write(new CacheEntryImpl<>(1, "val1"));
-                        store.write(new CacheEntryImpl<>(2, "val2"));
-                    }
-                    finally {
-                        shutdownStore();
-
-                        delegate.setShouldFail(false);
-                    }
-                }
-                catch (Exception e) {
-                    err.set(e);
-                }
-            }
-        }, 1).get();
-
-        if (err.get() != null)
-            throw err.get();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSimpleStore() throws Exception {
-        initStore(2);
-
-        try {
-            store.write(new CacheEntryImpl<>(1, "v1"));
-            store.write(new CacheEntryImpl<>(2, "v2"));
-
-            assertEquals("v1", store.load(1));
-            assertEquals("v2", store.load(2));
-            assertNull(store.load(3));
-
-            store.delete(1);
-
-            assertNull(store.load(1));
-            assertEquals("v2", store.load(2));
-            assertNull(store.load(3));
-        }
-        finally {
-            shutdownStore();
-        }
-    }
-
-    /**
-     * Check that all values written to the store will be in underlying store after timeout or due to size limits.
-     *
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings({"NullableProblems"})
-    public void testValuePropagation() throws Exception {
-        // Need to test size-based write.
-        initStore(1);
-
-        try {
-            for (int i = 0; i < CACHE_SIZE * 2; i++)
-                store.write(new CacheEntryImpl<>(i, "val" + i));
-
-            U.sleep(200);
-
-            for (int i = 0; i < CACHE_SIZE; i++) {
-                String val = delegate.load(i);
-
-                assertNotNull("Value for [key= " + i + "] was not written in store", val);
-                assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
-            }
-
-            U.sleep(FLUSH_FREQUENCY + 300);
-
-            for (int i = CACHE_SIZE; i < CACHE_SIZE * 2; i++) {
-                String val = delegate.load(i);
-
-                assertNotNull("Value for [key= " + i + "] was not written in store", val);
-                assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
-            }
-        }
-        finally {
-            shutdownStore();
-        }
-    }
-
-    /**
-     * Tests store behaviour under continuous put of the same key with different values.
-     *
-     * @throws Exception If failed
-     */
-    public void testContinuousPut() throws Exception {
-        initStore(2);
-
-        try {
-            final AtomicBoolean running = new AtomicBoolean(true);
-
-            final AtomicInteger actualPutCnt = new AtomicInteger();
-
-            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                @SuppressWarnings({"NullableProblems"})
-                @Override public void run() {
-                    try {
-                        while (running.get()) {
-                            for (int i = 0; i < CACHE_SIZE; i++) {
-                                store.write(new CacheEntryImpl<>(i, "val-0"));
-
-                                actualPutCnt.incrementAndGet();
-
-                                store.write(new CacheEntryImpl<>(i, "val" + i));
-
-                                actualPutCnt.incrementAndGet();
-                            }
-                        }
-                    }
-                    catch (Exception e) {
-                        error("Unexpected exception in put thread", e);
-
-                        assert false;
-                    }
-                }
-            }, 1, "put");
-
-            U.sleep(FLUSH_FREQUENCY * 2 + 500);
-
-            int delegatePutCnt = delegate.getPutAllCount();
-
-            running.set(false);
-
-            fut.get();
-
-            log().info(">>> [putCnt = " + actualPutCnt.get() + ", delegatePutCnt=" + delegatePutCnt + "]");
-
-            assertTrue("No puts were made to the underlying store", delegatePutCnt > 0);
-            assertTrue("Too many puts were made to the underlying store", delegatePutCnt < actualPutCnt.get() / 10);
-        }
-        finally {
-            shutdownStore();
-        }
-
-        // These checks must be done after the store shut down
-        assertEquals("Invalid store size", CACHE_SIZE, delegate.getMap().size());
-
-        for (int i = 0; i < CACHE_SIZE; i++)
-            assertEquals("Invalid value stored", "val" + i, delegate.getMap().get(i));
-    }
-
-    /**
-     * Tests that all values were put into the store will be written to the underlying store
-     * after shutdown is called.
-     *
-     * @throws Exception If failed.
-     */
-    public void testShutdown() throws Exception {
-        initStore(2);
-
-        try {
-            final AtomicBoolean running = new AtomicBoolean(true);
-
-            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                @SuppressWarnings({"NullableProblems"})
-                @Override public void run() {
-                    try {
-                        while (running.get()) {
-                            for (int i = 0; i < CACHE_SIZE; i++) {
-                                store.write(new CacheEntryImpl<>(i, "val-0"));
-
-                                store.write(new CacheEntryImpl<>(i, "val" + i));
-                            }
-                        }
-                    }
-                    catch (Exception e) {
-                        error("Unexpected exception in put thread", e);
-
-                        assert false;
-                    }
-                }
-            }, 1, "put");
-
-            U.sleep(300);
-
-            running.set(false);
-
-            fut.get();
-        }
-        finally {
-            shutdownStore();
-        }
-
-        // These checks must be done after the store shut down
-        assertEquals("Invalid store size", CACHE_SIZE, delegate.getMap().size());
-
-        for (int i = 0; i < CACHE_SIZE; i++)
-            assertEquals("Invalid value stored", "val" + i, delegate.getMap().get(i));
-    }
-
-    /**
-     * Tests that all values will be written to the underlying store
-     * right in the same order as they were put into the store.
-     *
-     * @throws Exception If failed.
-     */
-    public void testBatchApply() throws Exception {
-        delegate = new GridCacheTestStore(new ConcurrentLinkedHashMap<Integer, String>());
-
-        initStore(1);
-
-        List<Integer> intList = new ArrayList<>(CACHE_SIZE);
-
-        try {
-            for (int i = 0; i < CACHE_SIZE; i++) {
-                store.write(new CacheEntryImpl<>(i, "val" + i));
-
-                intList.add(i);
-            }
-        }
-        finally {
-            shutdownStore();
-        }
-
-        Map<Integer, String> underlyingMap = delegate.getMap();
-
-        assertTrue("Store map key set: " + underlyingMap.keySet(), F.eqOrdered(underlyingMap.keySet(), intList));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractByteArrayValuesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractByteArrayValuesSelfTest.java
new file mode 100644
index 0000000..60bba43
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractByteArrayValuesSelfTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.configuration.*;
+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.junits.common.*;
+
+/**
+ * Base class for various tests for byte array values.
+ */
+public abstract class IgniteCacheAbstractByteArrayValuesSelfTest extends IgniteCommonAbstractTest {
+    /** Regular cache name. */
+    protected static final String CACHE_REGULAR = "cache";
+
+    /** Offheap cache name. */
+    protected static final String CACHE_OFFHEAP = "cache_offheap";
+
+    /** Offheap tiered cache name. */
+    protected static final String CACHE_OFFHEAP_TIERED = "cache_offheap_tiered";
+
+    /** Key 1. */
+    protected static final Integer KEY_1 = 1;
+
+    /** Key 2. */
+    protected static final Integer KEY_2 = 2;
+
+    /** Use special key for swap test, otherwise entry with readers is not evicted. */
+    protected static final Integer SWAP_TEST_KEY = 3;
+
+    /** Shared IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc}
+     * @param igniteName*/
+    @Override protected IgniteConfiguration getConfiguration(String igniteName) throws Exception {
+        IgniteConfiguration c = super.getConfiguration(igniteName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(IP_FINDER);
+
+        c.setDiscoverySpi(disco);
+
+        return c;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllIgnites();
+    }
+
+    /**
+     * Wrap provided values into byte array.
+     *
+     * @param vals Values.
+     * @return Byte array.
+     */
+    protected byte[] wrap(int... vals) {
+        byte[] res = new byte[vals.length];
+
+        for (int i = 0; i < vals.length; i++)
+            res[i] = (byte)vals[i];
+
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFailoverSelfTest.java
new file mode 100644
index 0000000..63012ea
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFailoverSelfTest.java
@@ -0,0 +1,433 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.cluster.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CachePreloadMode.*;
+import static org.apache.ignite.transactions.IgniteTxConcurrency.*;
+import static org.apache.ignite.transactions.IgniteTxIsolation.*;
+
+/**
+ * Failover tests for cache.
+ */
+public abstract class IgniteCacheAbstractFailoverSelfTest extends IgniteCacheAbstractSelfTest {
+    /** */
+    private static final long TEST_TIMEOUT = 3 * 60 * 1000;
+
+    /** */
+    private static final String NEW_GRID_NAME = "newGrid";
+
+    /** */
+    private static final int ENTRY_CNT = 100;
+
+    /** */
+    private static final int TOP_CHANGE_CNT = 5;
+
+    /** */
+    private static final int TOP_CHANGE_THREAD_CNT = 3;
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return TEST_TIMEOUT;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    /** {@inheritDoc}
+     * @param igniteName*/
+    @Override protected IgniteConfiguration getConfiguration(String igniteName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteName);
+
+        cfg.getTransactionsConfiguration().setTxSerializableEnabled(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
+        CacheConfiguration cfg = super.cacheConfiguration(gridName);
+
+        cfg.setPreloadMode(SYNC);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        // No-op
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        // No-op
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        startIgnitesMultiThreaded(gridCount());
+
+        super.beforeTest();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllIgnites();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testTopologyChange() throws Exception {
+        testTopologyChange(null, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticReadCommittedTxTopologyChange() throws Exception {
+        testTopologyChange(OPTIMISTIC, READ_COMMITTED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticRepeatableReadTxTopologyChange() throws Exception {
+        testTopologyChange(OPTIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticSerializableTxTopologyChange() throws Exception {
+        testTopologyChange(OPTIMISTIC, SERIALIZABLE);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticReadCommittedTxTopologyChange() throws Exception {
+        testTopologyChange(PESSIMISTIC, READ_COMMITTED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticRepeatableReadTxTopologyChange() throws Exception {
+        testTopologyChange(PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticSerializableTxTopologyChange() throws Exception {
+        testTopologyChange(PESSIMISTIC, SERIALIZABLE);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(null, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticReadCommittedTxConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(OPTIMISTIC, READ_COMMITTED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticRepeatableReadTxConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(OPTIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOptimisticSerializableTxConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(OPTIMISTIC, SERIALIZABLE);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticReadCommittedTxConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(PESSIMISTIC, READ_COMMITTED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticRepeatableReadTxConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(PESSIMISTIC, REPEATABLE_READ);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPessimisticSerializableTxConstantTopologyChange() throws Exception {
+        testConstantTopologyChange(PESSIMISTIC, SERIALIZABLE);
+    }
+
+    /**
+     * @param concurrency Concurrency control.
+     * @param isolation Isolation level.
+     * @throws Exception If failed.
+     */
+    private void testTopologyChange(@Nullable IgniteTxConcurrency concurrency,
+        @Nullable IgniteTxIsolation isolation) throws Exception {
+        boolean tx = concurrency != null && isolation != null;
+
+        if (tx)
+            put(cache(), ENTRY_CNT, concurrency, isolation);
+        else
+            put(cache(), ENTRY_CNT);
+
+        Ignite g = startIgnite(NEW_GRID_NAME);
+
+        check(cache(g), ENTRY_CNT);
+
+        int half = ENTRY_CNT / 2;
+
+        if (tx) {
+            remove(cache(g), half, concurrency, isolation);
+            put(cache(g), half, concurrency, isolation);
+        }
+        else {
+            remove(cache(g), half);
+            put(cache(g), half);
+        }
+
+        stopIgnite(NEW_GRID_NAME);
+
+        check(cache(), ENTRY_CNT);
+    }
+
+    /**
+     * @param concurrency Concurrency control.
+     * @param isolation Isolation level.
+     * @throws Exception If failed.
+     */
+    private void testConstantTopologyChange(@Nullable final IgniteTxConcurrency concurrency,
+        @Nullable final IgniteTxIsolation isolation) throws Exception {
+        final boolean tx = concurrency != null && isolation != null;
+
+        if (tx)
+            put(cache(), ENTRY_CNT, concurrency, isolation);
+        else
+            put(cache(), ENTRY_CNT);
+
+        check(cache(), ENTRY_CNT);
+
+        final int half = ENTRY_CNT / 2;
+
+        IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new CA() {
+            @Override public void apply() {
+                info("Run topology change.");
+
+                try {
+                    for (int i = 0; i < TOP_CHANGE_CNT; i++) {
+                        info("Topology change " + i);
+
+                        String name = UUID.randomUUID().toString();
+
+                        try {
+                            final Ignite g = startIgnite(name);
+
+                            for (int k = half; k < ENTRY_CNT; k++)
+                                assertNotNull("Failed to get key: 'key" + k + "'", cache(g).get("key" + k));
+                        }
+                        finally {
+                            G.stop(name, false);
+                        }
+                    }
+                }
+                catch (Exception e) {
+                    throw F.wrap(e);
+                }
+            }
+        }, TOP_CHANGE_THREAD_CNT, "topology-change-thread");
+
+        while (!fut.isDone()) {
+            if (tx) {
+                remove(cache(), half, concurrency, isolation);
+                put(cache(), half, concurrency, isolation);
+            }
+            else {
+                remove(cache(), half);
+                put(cache(), half);
+            }
+        }
+
+        fut.get();
+    }
+
+    /**
+     * @param cache Cache.
+     * @param cnt Entry count.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void put(CacheProjection<String, Integer> cache, int cnt) throws Exception {
+        try {
+            for (int i = 0; i < cnt; i++)
+                assertTrue("Failed to put key: 'key" + i + "'",  cache.putx("key" + i, i));
+        }
+        catch (IgniteCheckedException e) {
+            // It is ok to fail with topology exception.
+            if (!X.hasCause(e, ClusterTopologyCheckedException.class))
+                throw e;
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param cnt Entry count.
+     * @param concurrency Concurrency control.
+     * @param isolation Isolation level.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void put(CacheProjection<String, Integer> cache, final int cnt,
+        IgniteTxConcurrency concurrency, IgniteTxIsolation isolation) throws Exception {
+        try {
+            info("Putting values to cache [0," + cnt + ')');
+
+            CU.inTx(cache, concurrency, isolation, new CIX1<CacheProjection<String, Integer>>() {
+                @Override public void applyx(CacheProjection<String, Integer> cache)
+                    throws IgniteCheckedException {
+                    for (int i = 0; i < cnt; i++)
+                        assertTrue("Failed to put key: 'key" + i + "'", cache.putx("key" + i, i));
+                }
+            });
+        }
+        catch (IgniteCheckedException e) {
+            // It is ok to fail with topology exception.
+            if (!X.hasCause(e, ClusterTopologyCheckedException.class))
+                throw e;
+            else
+                info("Failed to put values to cache due to topology exception [0," + cnt + ')');
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param cnt Entry count.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void remove(CacheProjection<String, Integer> cache, int cnt) throws Exception {
+        try {
+            for (int i = 0; i < cnt; i++)
+                cache.removex("key" + i);
+        }
+        catch (IgniteCheckedException e) {
+            // It is ok to fail with topology exception.
+            if (!X.hasCause(e, ClusterTopologyCheckedException.class))
+                throw e;
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param cnt Entry count.
+     * @param concurrency Concurrency control.
+     * @param isolation Isolation level.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void remove(CacheProjection<String, Integer> cache, final int cnt,
+        IgniteTxConcurrency concurrency, IgniteTxIsolation isolation) throws Exception {
+        try {
+            info("Removing values form cache [0," + cnt + ')');
+
+            CU.inTx(cache, concurrency, isolation, new CIX1<CacheProjection<String, Integer>>() {
+                @Override public void applyx(CacheProjection<String, Integer> cache)
+                    throws IgniteCheckedException {
+                    for (int i = 0; i < cnt; i++)
+                        cache.removex("key" + i);
+                }
+            });
+        }
+        catch (IgniteCheckedException e) {
+            // It is ok to fail with topology exception.
+            if (!X.hasCause(e, ClusterTopologyCheckedException.class))
+                throw e;
+            else
+                info("Failed to remove values from cache due to topology exception [0," + cnt + ')');
+        }
+    }
+
+    /**
+     * @param cache Cache.
+     * @param expSize Minimum expected cache size.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void check(CacheProjection<String,Integer> cache, int expSize) throws IgniteCheckedException {
+        int size;
+
+        if (cacheMode() == PARTITIONED) {
+            Collection<Integer> res = compute(cache.gridProjection()).broadcast(new IgniteCallable<Integer>() {
+                @IgniteInstanceResource
+                private Ignite g;
+
+                @Override public Integer call() {
+                    return cache(g).projection(F.<String, Integer>cachePrimary()).size();
+                }
+            });
+
+            size = 0 ;
+
+            for (Integer size0 : res)
+                size += size0;
+        }
+        else
+            size = cache.size();
+
+        assertTrue("Key set size is lesser then the expected size [size=" + size + ", expSize=" + expSize + ']',
+            size >= expSize);
+
+        for (int i = 0; i < expSize; i++)
+            assertNotNull("Failed to get value for key: 'key" + i + "'", cache.get("key" + i));
+    }
+
+    /**
+     * @param g Grid.
+     * @return Cache.
+     */
+    private CacheProjection<String,Integer> cache(Ignite g) {
+        return g.cache(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFlagsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFlagsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFlagsTest.java
new file mode 100644
index 0000000..c4f075b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFlagsTest.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.internal.*;
+
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ * Tests cache flags.
+ */
+public abstract class IgniteCacheAbstractFlagsTest extends IgniteCacheAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 6;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheWriteSynchronizationMode writeSynchronization() {
+        return FULL_ASYNC;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
+        CacheConfiguration c = super.cacheConfiguration(gridName);
+
+        if (cacheMode() == CacheMode.PARTITIONED)
+            c.setBackups(1);
+
+        return c;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected boolean swapEnabled() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheStore<?, ?> cacheStore() {
+        return null;
+    }
+
+    /**
+     * Tests SYNC_COMMIT cache flag.
+     *
+     * @throws Exception If failed.
+     */
+    public void testTestSyncCommitFlag() throws Exception {
+        for (int i = 0; i < 10; i++) {
+            final String key = "k" + i;
+            final Integer val = i;
+
+            final CountDownLatch l = new CountDownLatch(1);
+
+            final AtomicInteger cntr = new AtomicInteger();
+
+            IgniteInternalFuture<?> f = multithreadedAsync(new Callable() {
+                @Override public Object call() throws Exception {
+                    int idx = cntr.getAndIncrement() % gridCount();
+
+                    GridCache<String, Integer> c = cache(idx);
+
+                    l.await();
+
+                    assertEquals(val, c.get(key));
+
+                    return null;
+                }
+            }, gridCount() * 3);
+
+            cache(0).flagsOn(CacheFlag.SYNC_COMMIT).put(key, val);
+
+            l.countDown();
+
+            f.get();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6563e8a9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFullApiMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFullApiMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFullApiMultithreadedSelfTest.java
new file mode 100644
index 0000000..6cc745b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFullApiMultithreadedSelfTest.java
@@ -0,0 +1,403 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.testframework.*;
+
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * Multithreaded cache API tests.
+ */
+public abstract class IgniteCacheAbstractFullApiMultithreadedSelfTest extends IgniteCacheAbstractSelfTest {
+    /** */
+    private static final Random RND = new Random();
+
+    /** */
+    private static final int WRITE_THREAD_CNT = 3;
+
+    /** */
+    private static final int READ_THREAD_CNT = 3;
+
+    /** */
+    private static final String WRITE_THREAD_NAME = "write-thread";
+
+    /** */
+    private static final String READ_THREAD_NAME = "read-thread";
+
+    /** */
+    private static final int PUT_CNT = 100;
+
+    /** */
+    private final AtomicInteger cnt = new AtomicInteger();
+
+    /** */
+    private final AtomicBoolean guard = new AtomicBoolean();
+
+    /** */
+    private final Collection<Integer> set = new GridConcurrentHashSet<>();
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        cnt.set(0);
+        guard.set(false);
+        set.clear();
+    }
+
+    /**
+     * @param c Test closure.
+     * @throws Exception In case of error.
+     */
+    private void runTest(final IgniteInClosure<GridCache<String, Integer>> c) throws Exception {
+        final IgniteInternalFuture<?> fut1 = GridTestUtils.runMultiThreadedAsync(new CAX() {
+            @Override public void applyx() throws IgniteCheckedException {
+                while (true) {
+                    int i = cnt.getAndIncrement();
+
+                    if (i >= PUT_CNT)
+                        break;
+
+                    cache().put("key" + i, i);
+
+                    set.add(i);
+
+                    if (i > 10)
+                        guard.compareAndSet(false, true);
+                }
+            }
+        }, WRITE_THREAD_CNT, WRITE_THREAD_NAME);
+
+        IgniteInternalFuture<?> fut2 = GridTestUtils.runMultiThreadedAsync(new CA() {
+            @Override public void apply() {
+                GridCache<String, Integer> cache = cache();
+
+                while (!fut1.isDone())
+                    if (guard.get())
+                        c.apply(cache);
+            }
+        }, READ_THREAD_CNT, READ_THREAD_NAME);
+
+        fut1.get();
+        fut2.get();
+
+        checkConsistency();
+    }
+
+    /**
+     * @throws IgniteCheckedException If failed.
+     */
+    private void checkConsistency() throws IgniteCheckedException {
+        for (CacheEntry<String, Integer> e : cache())
+            for (int i = 1; i < gridCount(); i++) {
+                Integer val = cache(i).get(e.getKey());
+
+                if (val == null)
+                    assert e.get() == null;
+                else
+                    assert val.equals(e.get());
+            }
+    }
+
+    /**
+     * @return Random.
+     */
+    private int random() {
+        int rnd;
+
+        do
+            rnd = RND.nextInt(PUT_CNT);
+        while (!set.contains(rnd));
+
+        return rnd;
+    }
+
+    /**
+     * @param fromIncl Inclusive start of the range.
+     * @param toExcl Exclusive stop of the range.
+     * @return Range of keys.
+     */
+    private Collection<String> rangeKeys(int fromIncl, int toExcl) {
+        return F.transform(F.range(fromIncl, toExcl), new C1<Integer, String>() {
+            @Override public String apply(Integer i) {
+                return "key" + i;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testContainsKey() throws Exception {
+        runTest(new CI1<GridCache<String,Integer>>() {
+            @Override public void apply(GridCache<String, Integer> cache) {
+                assert cache.containsKey("key" + random());
+                assert !cache.containsKey("wrongKey");
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testContainsKeyFiltered() throws Exception {
+        runTest(new CI1<GridCache<String,Integer>>() {
+            @Override public void apply(GridCache<String, Integer> cache) {
+                assert cache.projection(F.<String, Integer>cacheHasPeekValue()).containsKey("key");
+                assert !cache.projection(F.<String, Integer>cacheNoPeekValue()).containsKey("key" + random());
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testContainsValue() throws Exception {
+        runTest(new CI1<GridCache<String,Integer>>() {
+            @Override public void apply(GridCache<String, Integer> cache) {
+                assert cache.containsValue(random());
+                assert !cache.containsValue(-1);
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testContainsValueFiltered() throws Exception {
+        runTest(new CI1<GridCache<String,Integer>>() {
+            @Override public void apply(GridCache<String, Integer> cache) {
+                assert cache.projection(F.<String, Integer>cacheHasPeekValue()).containsValue(random());
+                assert !cache.projection(F.<String, Integer>cacheNoPeekValue()).containsValue(random());
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testForAll() throws Exception {
+        runTest(new CI1<GridCache<String,Integer>>() {
+            @Override public void apply(GridCache<String, Integer> cache) {
+                assert cache.forAll(new P1<CacheEntry<String, Integer>>() {
+                    @Override public boolean apply(CacheEntry<String, Integer> e) {
+                        Integer val = e.peek();
+
+                        return val == null || val <= PUT_CNT;
+                    }
+                });
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testGet() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd = random();
+
+                assert cache.get("key" + rnd) == rnd;
+                assert cache.get("wrongKey") == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testGetAsync() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd = random();
+
+                assert cache.getAsync("key" + rnd).get() == rnd;
+                assert cache.getAsync("wrongKey").get() == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testGetAll() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd1 = random();
+                int rnd2 = random();
+
+                Map<String, Integer> map = cache.getAll(F.asList("key" + rnd1, "key" + rnd2));
+
+                assert map.size() == (rnd1 != rnd2 ? 2 : 1);
+                assert map.get("key" + rnd1) == rnd1;
+                assert map.get("key" + rnd2) == rnd2;
+            }
+        });
+    }
+
+   /**
+     * @throws Exception In case of error.
+     */
+    public void testGetAllAsync() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd1 = random();
+                int rnd2 = random();
+
+                Map<String, Integer> map = cache.getAllAsync(F.asList("key" + rnd1, "key" + rnd2)).get();
+
+                assert map.size() == (rnd1 != rnd2 ? 2 : 1);
+                assert map.get("key" + rnd1) == rnd1;
+                assert map.get("key" + rnd2) == rnd2;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemove() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd1 = random();
+                int rnd2 = random();
+
+                assert cache.remove("wrongKey") == null;
+                assert !cache.remove("key" + rnd1, -1);
+
+                assert cache.peek("key" + rnd1) == null || cache.peek("key" + rnd1) == rnd1;
+                assert cache.peek("key" + rnd2) == null || cache.peek("key" + rnd2) == rnd2;
+
+                assert cache.peek("key" + rnd1) == null || cache.remove("key" + rnd1) == rnd1;
+                assert cache.peek("key" + rnd2) == null || cache.remove("key" + rnd2, rnd2);
+
+                assert cache.peek("key" + rnd1) == null;
+                assert cache.peek("key" + rnd2) == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemoveAsync() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd1 = random();
+                int rnd2 = random();
+
+                assert cache.removeAsync("wrongKey").get() == null;
+                assert !cache.removeAsync("key" + rnd1, -1).get();
+
+                assert cache.peek("key" + rnd1) == null || cache.peek("key" + rnd1) == rnd1;
+                assert cache.peek("key" + rnd2) == null || cache.peek("key" + rnd2) == rnd2;
+
+                assert cache.peek("key" + rnd1) == null || cache.removeAsync("key" + rnd1).get() == rnd1;
+                assert cache.peek("key" + rnd2) == null || cache.removeAsync("key" + rnd2, rnd2).get();
+
+                assert cache.peek("key" + rnd1) == null;
+                assert cache.peek("key" + rnd2) == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemoveAll() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd = random();
+
+                cache.removeAll(rangeKeys(0, rnd));
+
+                for (int i = 0; i < rnd; i++)
+                    assert cache.peek("key" + i) == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemoveAllFiltered() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                final int rnd = random();
+
+                cache.removeAll(new P1<CacheEntry<String, Integer>>() {
+                    @Override public boolean apply(CacheEntry<String, Integer> e) {
+                        Integer val = e.peek();
+
+                        return val != null && val < rnd;
+                    }
+                });
+
+                for (int i = 0; i < rnd; i++)
+                    assert cache.peek("key" + i) == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemoveAllAsync() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                int rnd = random();
+
+                cache.removeAllAsync(rangeKeys(0, rnd)).get();
+
+                for (int i = 0; i < rnd; i++)
+                    assert cache.peek("key" + i) == null;
+            }
+        });
+    }
+
+    /**
+     * @throws Exception In case of error.
+     */
+    public void testRemoveAllAsyncFiltered() throws Exception {
+        runTest(new CIX1<GridCache<String,Integer>>() {
+            @Override public void applyx(GridCache<String, Integer> cache) throws IgniteCheckedException {
+                final int rnd = random();
+
+                cache.removeAllAsync(new P1<CacheEntry<String, Integer>>() {
+                    @Override public boolean apply(CacheEntry<String, Integer> e) {
+                        Integer val = e.peek();
+
+                        return val != null && val < rnd;
+                    }
+                }).get();
+
+                for (int i = 0; i < rnd; i++)
+                    assert cache.peek("key" + i) == null;
+            }
+        });
+    }
+}


Mime
View raw message