http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadOffHeapSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadOffHeapSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadOffHeapSelfTest.java
deleted file mode 100644
index fc7d299..0000000
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadOffHeapSelfTest.java
+++ /dev/null
@@ -1,39 +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.gridgain.grid.kernal.processors.cache.distributed.replicated.preloader;
-
-import org.apache.ignite.cache.*;
-
-import static org.apache.ignite.cache.GridCacheMemoryMode.*;
-
-/**
- * Tests for replicated cache {@link GridReplicatedPreloader preloader}.
- */
-public class GridCacheReplicatedPreloadOffHeapSelfTest extends 
GridCacheReplicatedPreloadSelfTest {
-    /** {@inheritDoc} */
-    @Override
-    CacheConfiguration cacheConfiguration(String gridName) {
-        CacheConfiguration cacheCfg = super.cacheConfiguration(gridName);
-
-        cacheCfg.setQueryIndexEnabled(false);
-        cacheCfg.setMemoryMode(OFFHEAP_VALUES);
-        cacheCfg.setOffHeapMaxMemory(0);
-
-        return cacheCfg;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
deleted file mode 100644
index e459f18..0000000
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ /dev/null
@@ -1,582 +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.gridgain.grid.kernal.processors.cache.distributed.replicated.preloader;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.affinity.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.events.*;
-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.spi.eventstorage.memory.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.gridgain.testframework.*;
-import org.gridgain.testframework.junits.common.*;
-
-import java.io.*;
-import java.util.*;
-
-import static org.apache.ignite.configuration.IgniteDeploymentMode.*;
-import static org.apache.ignite.cache.GridCacheMode.*;
-import static org.apache.ignite.cache.GridCachePreloadMode.*;
-import static org.apache.ignite.cache.GridCacheWriteSynchronizationMode.*;
-import static org.apache.ignite.events.IgniteEventType.*;
-
-/**
- * Tests for replicated cache preloader.
- */
-public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest 
{
-    /** */
-    private GridCachePreloadMode preloadMode = ASYNC;
-
-    /** */
-    private int batchSize = 4096;
-
-    /** */
-    private int poolSize = 2;
-
-    /** */
-    private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        stopAllGrids();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-        disco.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(disco);
-
-        cfg.setCacheConfiguration(cacheConfiguration(gridName));
-        
cfg.setPeerClassLoadingLocalClassPathExclude(GridCacheReplicatedPreloadSelfTest.class.getName(),
-            TestValue.class.getName());
-
-        cfg.setDeploymentMode(CONTINUOUS);
-
-        cfg.setUserAttributes(F.asMap("EVEN", !gridName.endsWith("0") && 
!gridName.endsWith("2")));
-
-        MemoryEventStorageSpi spi = new MemoryEventStorageSpi();
-
-        spi.setExpireCount(50_000);
-
-        cfg.setEventStorageSpi(spi);
-
-        return cfg;
-    }
-
-    /**
-     * Gets cache configuration for grid with specified name.
-     *
-     * @param gridName Grid name.
-     * @return Cache configuration.
-     */
-    CacheConfiguration cacheConfiguration(String gridName) {
-        CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
-        cacheCfg.setCacheMode(REPLICATED);
-        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
-        cacheCfg.setPreloadMode(preloadMode);
-        cacheCfg.setPreloadBatchSize(batchSize);
-        cacheCfg.setPreloadThreadPoolSize(poolSize);
-
-        return cacheCfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSingleNode() throws Exception {
-        preloadMode = SYNC;
-
-        try {
-            startGrid(1);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSingleZeroPoolSize() throws Exception {
-        preloadMode = SYNC;
-        poolSize = 0;
-
-        try {
-            startGrid(1);
-
-            assert false : "Grid should have been failed to start.";
-        }
-        catch (IgniteCheckedException e) {
-            info("Caught expected exception: " + e);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    @SuppressWarnings({"BusyWait"})
-    public void testIntegrity() throws Exception {
-        preloadMode = SYNC;
-
-        try {
-            Ignite g1 = startGrid(1);
-
-            GridCache<Integer, String> cache1 = g1.cache(null);
-
-            cache1.put(1, "val1");
-            cache1.put(2, "val2");
-
-            GridCacheEntry<Integer, String> e1 = cache1.entry(1);
-
-            assert e1 != null;
-
-            Ignite g2 = startGrid(2);
-
-            Collection<IgniteEvent> evts = null;
-
-            for (int i = 0; i < 3; i++) {
-                evts = g2.events().localQuery(F.<IgniteEvent>alwaysTrue(),
-                    EVT_CACHE_PRELOAD_STARTED, EVT_CACHE_PRELOAD_STOPPED);
-
-                if (evts.size() != 2) {
-                    info("Wrong events collection size (will retry in 1000 
ms): " + evts.size());
-
-                    Thread.sleep(1000);
-                }
-                else
-                    break;
-            }
-
-            assert evts != null && evts.size() == 2 : "Wrong events received: 
" + evts;
-
-            Iterator<IgniteEvent> iter = evts.iterator();
-
-            assertEquals(EVT_CACHE_PRELOAD_STARTED, iter.next().type());
-            assertEquals(EVT_CACHE_PRELOAD_STOPPED, iter.next().type());
-
-            GridCache<Integer, String> cache2 = g2.cache(null);
-
-            assertEquals("val1", cache2.peek(1));
-            assertEquals("val2", cache2.peek(2));
-
-            GridCacheEntry<Integer, String> e2 = cache2.entry(1);
-
-            assert e2 != null;
-            assert e2 != e1;
-            assert e2.version() != null;
-
-            assertEquals(e1.version(), e2.version());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testDeployment() throws Exception {
-        preloadMode = SYNC;
-
-        try {
-            Ignite g1 = startGrid(1);
-            Ignite g2 = startGrid(2);
-
-            GridCache<Integer, Object> cache1 = g1.cache(null);
-            GridCache<Integer, Object> cache2 = g2.cache(null);
-
-            ClassLoader ldr = new GridTestClassLoader(
-                GridCacheReplicatedPreloadSelfTest.class.getName(),
-                TestValue.class.getName(),
-                TestAffinityFunction.class.getName());
-
-            Object v1 = ldr.loadClass(TestValue.class.getName()).newInstance();
-
-            cache1.put(1, v1);
-
-            info("Stored value in cache1 [v=" + v1 + ", ldr=" + 
v1.getClass().getClassLoader() + ']');
-
-            Object v2 = cache2.get(1);
-
-            info("Read value from cache2 [v=" + v2 + ", ldr=" + 
v2.getClass().getClassLoader() + ']');
-
-            assert v2 != null;
-            assert v2.toString().equals(v1.toString());
-            assert 
!v2.getClass().getClassLoader().equals(getClass().getClassLoader());
-            assert 
v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader");
-
-            stopGrid(1);
-
-            Ignite g3 = startGrid(3);
-
-            GridCache<Integer, Object> cache3 = g3.cache(null);
-
-            Object v3 = cache3.peek(1);
-
-            assert v3 != null;
-
-            info("Read value from cache3 [v=" + v3 + ", ldr=" + 
v3.getClass().getClassLoader() + ']');
-
-            assert v3 != null;
-            assert v3.toString().equals(v1.toString());
-            assert 
!v3.getClass().getClassLoader().equals(getClass().getClassLoader());
-            assert 
v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader");
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testSync() throws Exception {
-        preloadMode = SYNC;
-        batchSize = 512;
-
-        try {
-            GridCache<Integer, String> cache1 = startGrid(1).cache(null);
-
-            int keyCnt = 1000;
-
-            for (int i = 0; i < keyCnt; i++)
-                cache1.put(i, "val" + i);
-
-            GridCache<Integer, String> cache2 = startGrid(2).cache(null);
-
-            assertEquals(keyCnt, cache2.size());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testAsync() throws Exception {
-        preloadMode = ASYNC;
-        batchSize = 256;
-
-        try {
-            GridCache<Integer, String> cache1 = startGrid(1).cache(null);
-
-            int keyCnt = 2000;
-
-            for (int i = 0; i < keyCnt; i++)
-                cache1.put(i, "val" + i);
-
-            GridCache<Integer, String> cache2 = startGrid(2).cache(null);
-
-            int size = cache2.size();
-
-            info("Size of cache2: " + size);
-
-            assert waitCacheSize(cache2, keyCnt, getTestTimeout()) : "Actual 
cache size: " + cache2.size();
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @param cache Cache.
-     * @param expSize Lower bound of expected size.
-     * @param timeout Timeout.
-     * @return {@code true} if success.
-     * @throws InterruptedException If thread was interrupted.
-     */
-    @SuppressWarnings({"BusyWait"})
-    private boolean waitCacheSize(GridCacheProjection<Integer, String> cache, 
int expSize, long timeout)
-        throws InterruptedException {
-        assert cache != null;
-        assert expSize > 0;
-        assert timeout >= 0;
-
-        long end = System.currentTimeMillis() + timeout;
-
-        while (cache.size() < expSize) {
-            Thread.sleep(50);
-
-            if (end - System.currentTimeMillis() <= 0)
-                break;
-        }
-
-        return cache.size() >= expSize;
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testBatchSize1() throws Exception {
-        preloadMode = SYNC;
-        batchSize = 1; // 1 byte but one entry should be in batch anyway.
-
-        try {
-            GridCache<Integer, String> cache1 = startGrid(1).cache(null);
-
-            int cnt = 100;
-
-            for (int i = 0; i < cnt; i++)
-                cache1.put(i, "val" + i);
-
-            GridCache<Integer, String> cache2 = startGrid(2).cache(null);
-
-            assertEquals(cnt, cache2.size());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testBatchSize1000() throws Exception {
-        preloadMode = SYNC;
-        batchSize = 1000; // 1000 bytes.
-
-        try {
-            GridCache<Integer, String> cache1 = startGrid(1).cache(null);
-
-            int cnt = 100;
-
-            for (int i = 0; i < cnt; i++)
-                cache1.put(i, "val" + i);
-
-            GridCache<Integer, String> cache2 = startGrid(2).cache(null);
-
-            assertEquals(cnt, cache2.size());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testBatchSize10000() throws Exception {
-        preloadMode = SYNC;
-        batchSize = 10000; // 10000 bytes.
-
-        try {
-            GridCache<Integer, String> cache1 = startGrid(1).cache(null);
-
-            int cnt = 100;
-
-            for (int i = 0; i < cnt; i++)
-                cache1.put(i, "val" + i);
-
-            GridCache<Integer, String> cache2 = startGrid(2).cache(null);
-
-            assertEquals(cnt, cache2.size());
-        }
-        finally {
-            stopGrid(1);
-            stopGrid(2);
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testMultipleNodes() throws Exception {
-        preloadMode = ASYNC;
-        batchSize = 256;
-
-        try {
-            int gridCnt = 4;
-
-            startGridsMultiThreaded(gridCnt);
-
-            info("Beginning data population...");
-
-            int cnt = 2500;
-
-            Map<Integer, String> map = null;
-
-            for (int i = 0; i < cnt; i++) {
-                if (i % 100 == 0) {
-                    if (map != null && !map.isEmpty()) {
-                        grid(0).cache(null).putAll(map);
-
-                        info("Put entries count: " + i);
-                    }
-
-                    map = new HashMap<>();
-                }
-
-                map.put(i, "val" + i);
-            }
-
-            if (map != null && !map.isEmpty())
-                grid(0).cache(null).putAll(map);
-
-            for (int gridIdx = 0; gridIdx < gridCnt; gridIdx++) {
-                assert grid(gridIdx).cache(null).size() == cnt : "Actual size: 
" + grid(gridIdx).cache(null).size();
-
-                info("Cache size is OK for grid index: " + gridIdx);
-            }
-
-            GridCache<Integer, String> lastCache = 
startGrid(gridCnt).cache(null);
-
-            // Let preloading start.
-            Thread.sleep(1000);
-
-            // Stop random initial node while preloading is in progress.
-            int idx = new Random().nextInt(gridCnt);
-
-            info("Stopping node with index: " + idx);
-
-            stopGrid(idx);
-
-            assert waitCacheSize(lastCache, cnt, 20 * 1000) : "Actual cache 
size: " + lastCache.size();
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testConcurrentStartSync() throws Exception {
-        preloadMode = SYNC;
-        batchSize = 10000;
-
-        try {
-            startGridsMultiThreaded(4);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If test failed.
-     */
-    public void testConcurrentStartAsync() throws Exception {
-        preloadMode = ASYNC;
-        batchSize = 10000;
-
-        try {
-            startGridsMultiThreaded(4);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     *
-     */
-    @SuppressWarnings({"PublicInnerClass"})
-    public static class TestValue implements Serializable {
-        /** */
-        private String val = "test-" + System.currentTimeMillis();
-
-        /**
-         * @return Value
-         */
-        public String getValue() {
-            return val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(TestValue.class, this);
-        }
-    }
-
-    /**
-     * Test affinity.
-     */
-    @SuppressWarnings({"PublicInnerClass"})
-    private static class TestAffinityFunction implements 
GridCacheAffinityFunction {
-        /** {@inheritDoc} */
-        @Override public int partitions() {
-            return 2;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int partition(Object key) {
-            if (key instanceof Number)
-                return ((Number)key).intValue() % 2;
-
-            return key == null ? 0 : U.safeAbs(key.hashCode() % 2);
-        }
-
-        /** {@inheritDoc} */
-        @Override public List<List<ClusterNode>> 
assignPartitions(GridCacheAffinityFunctionContext affCtx) {
-            List<List<ClusterNode>> res = new ArrayList<>(partitions());
-
-            for (int part = 0; part < partitions(); part++)
-                res.add(nodes(part, affCtx.currentTopologySnapshot()));
-
-            return res;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings({"RedundantTypeArguments"})
-        public List<ClusterNode> nodes(int part, Collection<ClusterNode> 
nodes) {
-            Collection<ClusterNode> col = new HashSet<>(nodes);
-
-            if (col.size() <= 1)
-                return new ArrayList<>(col);
-
-            for (Iterator<ClusterNode> iter = col.iterator(); iter.hasNext(); 
) {
-                ClusterNode node = iter.next();
-
-                boolean even = node.<Boolean>attribute("EVEN");
-
-                if ((even && part != 0) || (!even && part != 1))
-                    iter.remove();
-            }
-
-            return new ArrayList<>(col);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void reset() {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void removeNode(UUID nodeId) {
-            // No-op.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java
deleted file mode 100644
index 04291ae..0000000
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadStartStopEventsSelfTest.java
+++ /dev/null
@@ -1,95 +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.gridgain.grid.kernal.processors.cache.distributed.replicated.preloader;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.events.*;
-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.gridgain.testframework.junits.common.*;
-
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.cache.GridCacheMode.*;
-import static org.apache.ignite.events.IgniteEventType.*;
-
-/**
- * Tests that preload start/preload stop events are fired only once for 
replicated cache.
- */
-public class GridCacheReplicatedPreloadStartStopEventsSelfTest extends 
GridCommonAbstractTest {
-    /** */
-    private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        stopAllGrids();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
-
-        CacheConfiguration ccfg = new CacheConfiguration();
-
-        ccfg.setCacheMode(REPLICATED);
-
-        cfg.setCacheConfiguration(ccfg);
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testStartStopEvents() throws Exception {
-        Ignite ignite = startGrid(0);
-
-        final AtomicInteger preloadStartCnt = new AtomicInteger();
-        final AtomicInteger preloadStopCnt = new AtomicInteger();
-
-        ignite.events().localListen(new IgnitePredicate<IgniteEvent>() {
-            @Override public boolean apply(IgniteEvent e) {
-                if (e.type() == EVT_CACHE_PRELOAD_STARTED)
-                    preloadStartCnt.incrementAndGet();
-                else if (e.type() == EVT_CACHE_PRELOAD_STOPPED)
-                    preloadStopCnt.incrementAndGet();
-                else
-                    fail("Unexpected event type: " + e.type());
-
-                return true;
-            }
-        }, EVT_CACHE_PRELOAD_STARTED, EVT_CACHE_PRELOAD_STOPPED);
-
-        startGrid(1);
-
-        startGrid(2);
-
-        startGrid(3);
-
-        assertTrue("Unexpected start count: " + preloadStartCnt.get(), 
preloadStartCnt.get() <= 1);
-        assertTrue("Unexpected stop count: " + preloadStopCnt.get(), 
preloadStopCnt.get() <= 1);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadUndeploysTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadUndeploysTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadUndeploysTest.java
deleted file mode 100644
index 4447d7b..0000000
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadUndeploysTest.java
+++ /dev/null
@@ -1,87 +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.gridgain.grid.kernal.processors.cache.distributed.replicated.preloader;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.typedef.*;
-
-import javax.swing.*;
-import java.util.*;
-
-/**
- * Test for replicated cache preloader and concurrent undeploys.
- */
-public class GridCacheReplicatedPreloadUndeploysTest {
-    /**
-     * @param args Arguments.
-     * @throws Exception If failed.
-     */
-    public static void main(String[] args) throws Exception {
-        try (Ignite g = G.start("examples/config/example-cache.xml")) {
-            if (g.cluster().forRemotes().nodes().isEmpty()) {
-                X.print(">>> This test needs 1 remote node at start " +
-                    "and addition of 1 more node at the end.");
-
-                return;
-            }
-
-            X.println(">>> Beginning data population...");
-
-            int cnt = 10000;
-
-            Map<Integer, SampleValue> map = null;
-
-            for (int i = 0; i < cnt; i++) {
-                if (i % 200 == 0) {
-                    if (map != null && !map.isEmpty()) {
-                        g.cache("replicated").putAll(map);
-
-                        X.println(">>> Put entries count: " + i);
-                    }
-
-                    map = new HashMap<>();
-                }
-
-                map.put(i, new SampleValue());
-            }
-
-            if (map != null && !map.isEmpty()) {
-                g.cache("replicated").putAll(map);
-
-                X.println(">>> Put entries count: " + cnt);
-            }
-
-            JOptionPane.showMessageDialog(null, "Start one more node now and 
press OK " +
-                "while new node is preloading.");
-        }
-    }
-
-    /**
-     *
-     */
-    private GridCacheReplicatedPreloadUndeploysTest() {
-        // No-op.
-    }
-
-    /**
-     *
-     */
-    private static class SampleValue {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheDistributedEvictionsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheDistributedEvictionsSelfTest.java
 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheDistributedEvictionsSelfTest.java
index 1727c9c..9bb2b90 100644
--- 
a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheDistributedEvictionsSelfTest.java
+++ 
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheDistributedEvictionsSelfTest.java
@@ -21,7 +21,6 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.eviction.fifo.*;
 import org.apache.ignite.configuration.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/GridCacheFullApiSelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheFullApiSelfTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheFullApiSelfTestSuite.java
index 9a14ba9..22b254d 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheFullApiSelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheFullApiSelfTestSuite.java
@@ -20,7 +20,6 @@ package org.gridgain.testsuites;
 import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
 import org.apache.ignite.internal.processors.cache.local.*;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/GridCacheGroupLockSelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheGroupLockSelfTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheGroupLockSelfTestSuite.java
index bfb5d9e..b2e4ff6 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheGroupLockSelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheGroupLockSelfTestSuite.java
@@ -20,7 +20,6 @@ package org.gridgain.testsuites;
 import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
 
 /**
  * Group lock test suite.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/GridCacheIteratorsSelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheIteratorsSelfTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheIteratorsSelfTestSuite.java
index eaeba68..ca9453f 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheIteratorsSelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheIteratorsSelfTestSuite.java
@@ -19,7 +19,6 @@ package org.gridgain.testsuites;
 
 import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
 import org.apache.ignite.internal.processors.cache.local.*;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/GridCacheMetricsSelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheMetricsSelfTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheMetricsSelfTestSuite.java
index 59b02ae..65185d1 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheMetricsSelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheMetricsSelfTestSuite.java
@@ -19,7 +19,6 @@ package org.gridgain.testsuites;
 
 import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
 import org.apache.ignite.internal.processors.cache.local.*;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/GridCacheNearOnlySelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheNearOnlySelfTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheNearOnlySelfTestSuite.java
index 40251a3..c9ab404 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheNearOnlySelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheNearOnlySelfTestSuite.java
@@ -20,7 +20,6 @@ package org.gridgain.testsuites;
 import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
 
 /**
  * Test suite for near-only cache.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/GridCacheTxRecoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheTxRecoverySelfTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheTxRecoverySelfTestSuite.java
index e943ce9..19bc83b 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/GridCacheTxRecoverySelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/GridCacheTxRecoverySelfTestSuite.java
@@ -20,7 +20,6 @@ package org.gridgain.testsuites;
 import junit.framework.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
 
 /**
  * Tx recovery self test suite.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
 
b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
index 120a7f9..5b1bc7a 100644
--- 
a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
+++ 
b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
@@ -26,12 +26,10 @@ import org.apache.ignite.cache.store.jdbc.*;
 import org.gridgain.grid.cache.affinity.fair.*;
 import org.gridgain.grid.cache.store.*;
 import org.gridgain.grid.kernal.processors.cache.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
-import org.gridgain.grid.kernal.processors.cache.distributed.replicated.*;
-import 
org.gridgain.grid.kernal.processors.cache.distributed.replicated.preloader.*;
+import 
org.apache.ignite.internal.processors.cache.distributed.replicated.preloader.*;
 import org.apache.ignite.internal.processors.cache.local.*;
 import org.apache.ignite.internal.processors.dataload.*;
 import org.gridgain.testsuites.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
new file mode 100644
index 0000000..83cb200
--- /dev/null
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.distributed.replicated;
+
+import org.apache.ignite.configuration.*;
+
+/**
+ * Tests for fields queries.
+ */
+public class GridCacheReplicatedFieldsQueryP2PDisabledSelfTest extends 
GridCacheReplicatedFieldsQuerySelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration c = super.getConfiguration(gridName);
+
+        c.setPeerClassLoadingEnabled(false);
+
+        return c;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
new file mode 100644
index 0000000..3871a9a
--- /dev/null
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.distributed.replicated;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.lang.*;
+import org.gridgain.grid.kernal.processors.cache.*;
+import org.apache.ignite.internal.processors.query.*;
+import org.apache.ignite.internal.util.future.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.gridgain.testframework.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+import static org.apache.ignite.events.IgniteEventType.*;
+import static org.apache.ignite.cache.GridCacheMode.*;
+
+/**
+ * Tests for fields queries.
+ */
+public class GridCacheReplicatedFieldsQuerySelfTest extends 
GridCacheAbstractFieldsQuerySelfTest {
+    /** {@inheritDoc} */
+    @Override protected GridCacheMode cacheMode() {
+        return REPLICATED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeLeft() throws Exception {
+        hasCache = true;
+
+        try {
+            final Map<UUID, Map<Long, 
GridFutureAdapter<GridQueryFieldsResult>>> map =
+                
U.field(((GridKernal)grid(0)).internalCache().context().queries(), 
"fieldsQryRes");
+
+            // Ensure that iterators map empty.
+            map.clear();
+
+            Ignite g = startGrid();
+
+            GridCache<Integer, Integer> cache = g.cache(null);
+
+            GridCacheQuery<List<?>> q = 
cache.queries().createSqlFieldsQuery("select _key from Integer where _key >= " +
+                "0 order by _key");
+
+            q.pageSize(50);
+
+            ClusterGroup prj = 
g.cluster().forNodes(Arrays.asList(g.cluster().localNode(), 
grid(0).localNode()));
+
+            q = q.projection(prj);
+
+            GridCacheQueryFuture<List<?>> fut = q.execute();
+
+            assertEquals(0, fut.next().get(0));
+
+            // fut.nextX() does not guarantee the request has completed on 
remote node
+            // (we could receive page from local one), so we need to wait.
+            assertTrue(GridTestUtils.waitForCondition(new PA() {
+                @Override public boolean apply() {
+                    return map.size() == 1;
+                }
+            }, getTestTimeout()));
+
+            Map<Long, GridFutureAdapter<GridQueryFieldsResult>> futs = 
map.get(g.cluster().localNode().id());
+
+            assertEquals(1, futs.size());
+
+            final UUID nodeId = g.cluster().localNode().id();
+            final CountDownLatch latch = new CountDownLatch(1);
+
+            grid(0).events().localListen(new IgnitePredicate<IgniteEvent>() {
+                @Override public boolean apply(IgniteEvent evt) {
+                    if (((IgniteDiscoveryEvent) 
evt).eventNode().id().equals(nodeId))
+                        latch.countDown();
+
+                    return true;
+                }
+            }, EVT_NODE_LEFT);
+
+            stopGrid();
+
+            latch.await();
+
+            assertEquals(0, map.size());
+        }
+        finally {
+            // Ensure that additional node is stopped.
+            stopGrid();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLostIterator() throws Exception {
+        GridCache<Integer, Integer> cache = grid(0).cache(null);
+
+        GridCacheQueryFuture<List<?>> fut = null;
+
+        for (int i = 0; i < 
cache.configuration().getMaximumQueryIteratorCount() + 1; i++) {
+            GridCacheQuery<List<?>> q = cache.queries().createSqlFieldsQuery(
+                "select _key from Integer where _key >= 0 order by 
_key").projection(grid(0));
+
+            q.pageSize(50);
+
+            GridCacheQueryFuture<List<?>> f = q.execute();
+
+            assertEquals(0, f.next().get(0));
+
+            if (fut == null)
+                fut = f;
+        }
+
+        final GridCacheQueryFuture<List<?>> fut0 = fut;
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                int i = 0;
+
+                List<?> next;
+
+                while ((next = fut0.next()) != null)
+                    assertEquals(++i % 50, next.get(0));
+
+                return null;
+            }
+        }, IgniteException.class, null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
new file mode 100644
index 0000000..9b59faa
--- /dev/null
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.distributed.replicated;
+
+import org.apache.ignite.configuration.*;
+
+/**
+ * Tests replicated query.
+ */
+public class GridCacheReplicatedQueryP2PDisabledSelfTest extends 
GridCacheReplicatedQuerySelfTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration c = super.getConfiguration(gridName);
+
+        c.setPeerClassLoadingEnabled(false);
+
+        return c;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQuerySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQuerySelfTest.java
 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQuerySelfTest.java
new file mode 100644
index 0000000..9be8d33
--- /dev/null
+++ 
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/GridCacheReplicatedQuerySelfTest.java
@@ -0,0 +1,683 @@
+/*
+ * 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.distributed.replicated;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.kernal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.query.*;
+import org.apache.ignite.internal.util.future.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.gridgain.testframework.*;
+import org.jetbrains.annotations.*;
+import org.springframework.util.*;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.sql.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.events.IgniteEventType.*;
+import static org.apache.ignite.cache.GridCacheMode.*;
+
+/**
+ * Tests replicated query.
+ */
+public class GridCacheReplicatedQuerySelfTest extends 
GridCacheAbstractQuerySelfTest {
+    /** */
+    private static final boolean TEST_DEBUG = false;
+
+    /** Grid1. */
+    private static Ignite ignite1;
+
+    /** Grid2. */
+    private static Ignite ignite2;
+
+    /** Grid3. */
+    private static Ignite ignite3;
+
+    /** Cache1. */
+    private static GridCache<CacheKey, CacheValue> cache1;
+
+    /** Cache2. */
+    private static GridCache<CacheKey, CacheValue> cache2;
+
+    /** Cache3. */
+    private static GridCache<CacheKey, CacheValue> cache3;
+
+    /** Key serialization cnt. */
+    private static volatile int keySerCnt;
+
+    /** Key deserialization count. */
+    private static volatile int keyDesCnt;
+
+    /** Value serialization count. */
+    private static volatile int valSerCnt;
+
+    /** Value deserialization count. */
+    private static volatile int valDesCnt;
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 3;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected GridCacheMode cacheMode() {
+        return REPLICATED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        ignite1 = grid(0);
+        ignite2 = grid(1);
+        ignite3 = grid(2);
+
+        cache1 = ignite1.cache(null);
+        cache2 = ignite2.cache(null);
+        cache3 = ignite3.cache(null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientOnlyNode() throws Exception {
+        try {
+            Ignite g = startGrid("client");
+
+            GridCache<Integer, Integer> c = g.cache(null);
+
+            for (int i = 0; i < 10; i++)
+                c.putx(i, i);
+
+            // Client cache should be empty.
+            assertEquals(0, c.size());
+
+            Collection<Map.Entry<Integer, Integer>> res =
+                c.queries().createSqlQuery(Integer.class, "_key >= 5 order by 
_key").execute().get();
+
+            assertEquals(5, res.size());
+
+            Iterator<Map.Entry<Integer, Integer>> it = res.iterator();
+
+            int i = 5;
+
+            while (it.hasNext()) {
+                Map.Entry<Integer, Integer> e  = it.next();
+
+                assertEquals(i, e.getKey().intValue());
+                assertEquals(i, e.getValue().intValue());
+
+                i++;
+            }
+        }
+        finally {
+            stopGrid("client");
+        }
+    }
+
+    /**
+     * JUnit.
+     *
+     * @throws Exception If failed.
+     */
+    public void testIterator() throws Exception {
+        int keyCnt = 100;
+
+        for (int i = 0; i < keyCnt; i++)
+            cache1.put(new CacheKey(i), new CacheValue("val" + i));
+
+        assertEquals(keyCnt, cache1.size());
+        assertEquals(keyCnt, cache2.size());
+        assertEquals(keyCnt, cache3.size());
+
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> qry = 
cache1.queries().createSqlQuery(CacheValue.class,
+            "select * from CacheValue").projection(ignite.cluster());
+
+        qry.pageSize(10);
+        qry.enableDedup(false);
+
+        Iterator<Map.Entry<CacheKey, CacheValue>> iter = 
qry.execute().get().iterator();
+
+        assert iter.hasNext();
+
+        int cnt = 0;
+
+        while (iter.hasNext()) {
+            iter.next();
+
+            cnt++;
+        }
+
+        // Expect duplicates since we run query on full projection of 3 nodes 
and dedup flag is false.
+        assertEquals(keyCnt * 3, cnt);
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
+    public void testLocalQuery() throws Exception {
+        cache1.clearAll();
+
+        IgniteTx tx = cache1.txStart();
+
+        try {
+            cache1.put(new CacheKey(1), new CacheValue("1"));
+            cache1.put(new CacheKey(2), new CacheValue("2"));
+            cache1.put(new CacheKey(3), new CacheValue("3"));
+            cache1.put(new CacheKey(4), new CacheValue("4"));
+
+            tx.commit();
+
+            info("Committed transaction: " + tx);
+        }
+        catch (IgniteCheckedException e) {
+            tx.rollback();
+
+            throw e;
+        }
+
+        checkQueryResults(ignite1, cache1);
+        checkQueryResults(ignite2, cache2);
+        checkQueryResults(ignite3, cache3);
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
+    public void testDistributedQuery() throws Exception {
+        int keyCnt = 4;
+
+        final CountDownLatch latch = new CountDownLatch(keyCnt * 2);
+
+        IgnitePredicate<IgniteEvent> lsnr = new IgnitePredicate<IgniteEvent>() 
{
+            @Override public boolean apply(IgniteEvent evt) {
+                latch.countDown();
+
+                return true;
+            }
+        };
+
+        ignite2.events().localListen(lsnr, 
IgniteEventType.EVT_CACHE_OBJECT_PUT);
+        ignite3.events().localListen(lsnr, 
IgniteEventType.EVT_CACHE_OBJECT_PUT);
+
+        IgniteTx tx = cache1.txStart();
+
+        try {
+            for (int i = 1; i <= keyCnt; i++)
+                cache1.put(new CacheKey(i), new CacheValue(String.valueOf(i)));
+
+            tx.commit();
+
+            info("Committed transaction: " + tx);
+        }
+        catch (IgniteCheckedException e) {
+            tx.rollback();
+
+            throw e;
+        }
+
+        latch.await();
+
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> qry = 
cache1.queries().createSqlQuery(
+            CacheValue.class, "val > 1 and val < 
4").projection(ignite.cluster());
+
+        qry.enableDedup(false);
+
+        qry.keepAll(true);
+
+        // Distributed query.
+        assertEquals(6, qry.execute().get().size());
+
+        // Create new query, old query cannot be modified after it has been 
executed.
+        qry = cache1.queries().createSqlQuery(CacheValue.class, "val > 1 and 
val < 4");
+
+        qry = qry.projection(ignite3.cluster().forLocal());
+
+        // Tests execute on node.
+        Iterator<Map.Entry<CacheKey, CacheValue>> iter = 
qry.execute().get().iterator();
+
+        assert iter != null;
+        assert iter.hasNext();
+
+        iter.next();
+
+        assert iter.hasNext();
+
+        iter.next();
+
+        assert !iter.hasNext();
+    }
+
+    /**
+     * Returns private field {@code qryIters} of {@link GridCacheQueryManager} 
for the given grid.
+     *
+     * @param g Grid which {@link GridCacheQueryManager} should be observed.
+     * @return {@code qryIters} of {@link GridCacheQueryManager}.
+     */
+    private ConcurrentMap<UUID,
+        Map<Long, 
GridFutureAdapter<GridCloseableIterator<IgniteBiTuple<CacheKey, CacheValue>>>>>
+        distributedQueryManagerQueryItersMap(Ignite g) {
+        GridCacheContext ctx = ((GridKernal)g).internalCache().context();
+
+        Field qryItersField = 
ReflectionUtils.findField(ctx.queries().getClass(), "qryIters");
+
+        qryItersField.setAccessible(true);
+
+        return (ConcurrentMap<UUID,
+            Map<Long, 
GridFutureAdapter<GridCloseableIterator<IgniteBiTuple<CacheKey, CacheValue>>>>>)
+            ReflectionUtils.getField(qryItersField, ctx.queries());
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
+    @Override public void testReduceQuery() throws Exception {
+        int keyCnt = 4;
+
+        for (int i = 1; i <= keyCnt; i++)
+            cache1.put(new CacheKey(i), new CacheValue(String.valueOf(i)));
+
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> rdcQry =
+            cache1.queries().createSqlQuery(CacheValue.class, "val > 1 and val 
< 4");
+
+        rdcQry.keepAll(true);
+
+        Iterator<Integer> reduceIter = rdcQry.execute(new 
IgniteReducer<Map.Entry<CacheKey, CacheValue>, Integer>() {
+            /** Reducer result. */
+            private final AtomicInteger res = new AtomicInteger();
+
+            @Override public boolean collect(Map.Entry<CacheKey, CacheValue> 
e) {
+                res.addAndGet(e.getKey().getKey());
+
+                return true;
+            }
+
+            @Override public Integer reduce() {
+                return res.addAndGet(5);
+            }
+        }).get().iterator();
+
+        assert reduceIter != null;
+        assert reduceIter.hasNext();
+        assert reduceIter.next() == 10;
+        assert !reduceIter.hasNext();
+
+        // Tests reduce query where remote reducer returns null.
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> rdcQry1 =
+            cache1.queries().createSqlQuery(CacheValue.class, "val > 1 and val 
< 4");
+
+        rdcQry1.keepAll(true);
+
+        Iterator<Object> reduceIter1 = rdcQry1.execute(new 
IgniteReducer<Map.Entry<CacheKey, CacheValue>, Object>() {
+            @Override public boolean collect(Map.Entry<CacheKey, CacheValue> 
e) {
+                // No-op.
+                return true;
+            }
+
+            @Nullable @Override public Object reduce() {
+                return null;
+            }
+        }).get().iterator();
+
+        assert reduceIter1 != null;
+        assert reduceIter1.hasNext();
+        assertNull(reduceIter1.next());
+        assert !reduceIter.hasNext();
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
+    public void testToString() throws Exception {
+        int keyCnt = 4;
+
+        for (int i = 1; i <= keyCnt; i++)
+            cache1.put(new CacheKey(i), new CacheValue(String.valueOf(i)));
+
+        // Create query with key filter.
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> qry =
+            cache1.queries().createSqlQuery(CacheValue.class, "val > 
0").projection(ignite.cluster());
+
+        qry.keepAll(true);
+
+        GridCacheQueryFuture<Map.Entry<CacheKey, CacheValue>> fut = 
qry.execute();
+
+        assertEquals(keyCnt * 3, fut.get().size());
+
+        info("Query result: " + fut.get());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testLostIterator() throws Exception {
+        GridCache<Integer, Integer> cache = ignite.cache(null);
+
+        for (int i = 0; i < 1000; i++)
+            assertTrue(cache.putx(i, i));
+
+        GridCacheQueryFuture<Map.Entry<Integer, Integer>> fut = null;
+
+        for (int i = 0; i < 
cache.configuration().getMaximumQueryIteratorCount() + 1; i++) {
+            GridCacheQuery<Map.Entry<Integer, Integer>> q = 
cache.queries().createSqlQuery(Integer.class,
+                "_key >= 0 order by _key").projection(ignite.cluster());
+
+            q.pageSize(200);
+            q.enableDedup(true);
+
+            GridCacheQueryFuture<Map.Entry<Integer, Integer>> f = q.execute();
+
+            assertEquals(0, (int)f.next().getKey());
+
+            if (fut == null)
+                fut = f;
+        }
+
+        final GridCacheQueryFuture<Map.Entry<Integer, Integer>> fut0 = fut;
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                int i = 0;
+
+                Map.Entry<Integer, Integer> e;
+
+                while ((e = fut0.next()) != null)
+                    assertEquals(++i, (int)e.getKey());
+
+                return null;
+            }
+        }, IgniteException.class, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeLeft() throws Exception {
+        try {
+            Ignite g = startGrid();
+
+            GridCache<Integer, Integer> cache = g.cache(null);
+
+            for (int i = 0; i < 1000; i++)
+                assertTrue(cache.putx(i, i));
+
+            GridCacheQuery<Map.Entry<Integer, Integer>> q = 
cache.queries().createSqlQuery(Integer.class,
+                "_key >= 0 order by _key").projection(ignite.cluster());
+
+            q.pageSize(50);
+
+            
q.projection(g.cluster().forNodes(Arrays.asList(g.cluster().localNode(), 
grid(0).localNode())));
+
+            GridCacheQueryFuture<Map.Entry<Integer, Integer>> fut = 
q.execute();
+
+            assertEquals(0, (int)fut.next().getKey());
+
+            final ConcurrentMap<UUID, Map<Long, 
GridFutureAdapter<GridCloseableIterator<
+                IgniteBiTuple<Integer, Integer>>>>> map =
+                
U.field(((GridKernal)grid(0)).internalCache().context().queries(), "qryIters");
+
+            // fut.nextX() does not guarantee the request has completed on 
remote node
+            // (we could receive page from local one), so we need to wait.
+            assertTrue(GridTestUtils.waitForCondition(new PA() {
+                @Override public boolean apply() {
+                    return map.size() == 1;
+                }
+            }, getTestTimeout()));
+
+            Map<Long, 
GridFutureAdapter<GridCloseableIterator<IgniteBiTuple<Integer, Integer>>>> futs 
=
+                map.get(g.cluster().localNode().id());
+
+            assertEquals(1, futs.size());
+
+            GridCloseableIterator<IgniteBiTuple<Integer, Integer>> iter =
+                (GridCloseableIterator<IgniteBiTuple<Integer, 
Integer>>)((IgniteFuture)F.first(futs.values()).get()).get();
+
+            ResultSet rs = U.field(iter, "data");
+
+            assertFalse(rs.isClosed());
+
+            final UUID nodeId = g.cluster().localNode().id();
+            final CountDownLatch latch = new CountDownLatch(1);
+
+            grid(0).events().localListen(new IgnitePredicate<IgniteEvent>() {
+                @Override public boolean apply(IgniteEvent evt) {
+                    if 
(((IgniteDiscoveryEvent)evt).eventNode().id().equals(nodeId))
+                        latch.countDown();
+
+                    return true;
+                }
+            }, EVT_NODE_LEFT);
+
+            stopGrid();
+
+            latch.await();
+
+            assertEquals(0, map.size());
+            assertTrue(rs.isClosed());
+        }
+        finally {
+            // Ensure that additional node is stopped.
+            stopGrid();
+        }
+    }
+
+    /**
+     * @param ignite Grid.
+     * @param cache Cache.
+     * @throws Exception If check failed.
+     */
+    private void checkQueryResults(Ignite ignite, 
GridCacheProjection<CacheKey, CacheValue> cache) throws Exception {
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> qry =
+            cache.queries().createSqlQuery(CacheValue.class, "val > 1 and val 
< 4");
+
+        GridCacheQuery<Map.Entry<CacheKey, CacheValue>> q = 
qry.projection(ignite.cluster().forLocal());
+
+        Iterator<Map.Entry<CacheKey, CacheValue>> iter = 
q.execute().get().iterator();
+
+        assert iter != null;
+        assert iter.hasNext();
+
+        Map.Entry<CacheKey, CacheValue> entry = iter.next();
+
+        assert entry.getKey().equals(new CacheKey(2)) || 
entry.getKey().equals(new CacheKey(3));
+
+        assert iter.hasNext();
+
+        entry = iter.next();
+
+        assert entry.getKey().equals(new CacheKey(2)) || 
entry.getKey().equals(new CacheKey(3));
+        assert !iter.hasNext();
+
+        for (ClusterNode node : ignite.cluster().forRemotes().nodes()) {
+            q = qry.projection(ignite1.cluster().forNode(node));
+
+            iter = q.execute().get().iterator();
+
+            assert iter != null;
+            assert iter.hasNext();
+
+            entry = iter.next();
+
+            assert entry.getKey().equals(new CacheKey(2)) || 
entry.getKey().equals(new CacheKey(3));
+
+            assert iter.hasNext();
+
+            entry = iter.next();
+
+            assert entry.getKey().equals(new CacheKey(2)) || 
entry.getKey().equals(new CacheKey(3));
+            assert !iter.hasNext();
+        }
+    }
+
+    /**
+     * Cache key.
+     */
+    private static class CacheKey implements Externalizable {
+        /** Key. */
+        private int key;
+
+        /**
+         * @param key Key.
+         */
+        CacheKey(int key) {
+            this.key = key;
+        }
+
+        /**
+         *
+         */
+        public CacheKey() {
+            /* No-op. */
+        }
+
+        /**
+         * @return Key.
+         */
+        public int getKey() {
+            return key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+            key = in.readInt();
+
+            keyDesCnt++;
+
+            if (TEST_DEBUG)
+                X.println("Deserialized demo key [keyDesCnt=" + keyDesCnt + ", 
key=" + this + ']');
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
+            out.writeInt(key);
+
+            keySerCnt++;
+
+            if (TEST_DEBUG)
+                X.println("Serialized demo key [serCnt=" + keySerCnt + ", 
key=" + this + ']');
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            CacheKey cacheKey;
+
+            if (o instanceof CacheKey)
+                cacheKey = (CacheKey)o;
+            else
+                return false;
+
+            return key == cacheKey.key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(CacheKey.class, this);
+        }
+    }
+
+    /**
+     * Cache value..
+     */
+    private static class CacheValue implements Externalizable {
+        /** Value. */
+        @GridCacheQuerySqlField
+        private String val;
+
+        /**
+         * @param val Value.
+         */
+        CacheValue(String val) {
+            this.val = val;
+        }
+
+        /**
+         *
+         */
+        public CacheValue() {
+            /* No-op. */
+        }
+
+        /**
+         * @return Value.
+         */
+        public String getValue() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+            val = U.readString(in);
+
+            valDesCnt++;
+
+            if (TEST_DEBUG)
+                X.println("Deserialized demo value [valDesCnt=" + valDesCnt + 
", val=" + this + ']');
+        }
+
+        /** {@inheritDoc} */
+        @Override public void writeExternal(ObjectOutput out) throws 
IOException {
+            U.writeString(out, val);
+
+            valSerCnt++;
+
+            if (TEST_DEBUG)
+                X.println("Serialized demo value [serCnt=" + valSerCnt + ", 
val=" + this + ']');
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            CacheValue val = (CacheValue)o;
+
+            return !(this.val != null ? !this.val.equals(val.val) : val.val != 
null);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val != null ? val.hashCode() : 0;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(CacheValue.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
deleted file mode 100644
index 0b33405..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQueryP2PDisabledSelfTest.java
+++ /dev/null
@@ -1,34 +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.gridgain.grid.kernal.processors.cache.distributed.replicated;
-
-import org.apache.ignite.configuration.*;
-
-/**
- * Tests for fields queries.
- */
-public class GridCacheReplicatedFieldsQueryP2PDisabledSelfTest extends 
GridCacheReplicatedFieldsQuerySelfTest {
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        IgniteConfiguration c = super.getConfiguration(gridName);
-
-        c.setPeerClassLoadingEnabled(false);
-
-        return c;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
deleted file mode 100644
index 85306b6..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedFieldsQuerySelfTest.java
+++ /dev/null
@@ -1,157 +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.gridgain.grid.kernal.processors.cache.distributed.replicated;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.query.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.lang.*;
-import org.gridgain.grid.kernal.processors.cache.*;
-import org.apache.ignite.internal.processors.query.*;
-import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.gridgain.testframework.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-import static org.apache.ignite.events.IgniteEventType.*;
-import static org.apache.ignite.cache.GridCacheMode.*;
-
-/**
- * Tests for fields queries.
- */
-public class GridCacheReplicatedFieldsQuerySelfTest extends 
GridCacheAbstractFieldsQuerySelfTest {
-    /** {@inheritDoc} */
-    @Override protected GridCacheMode cacheMode() {
-        return REPLICATED;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return 3;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNodeLeft() throws Exception {
-        hasCache = true;
-
-        try {
-            final Map<UUID, Map<Long, 
GridFutureAdapter<GridQueryFieldsResult>>> map =
-                
U.field(((GridKernal)grid(0)).internalCache().context().queries(), 
"fieldsQryRes");
-
-            // Ensure that iterators map empty.
-            map.clear();
-
-            Ignite g = startGrid();
-
-            GridCache<Integer, Integer> cache = g.cache(null);
-
-            GridCacheQuery<List<?>> q = 
cache.queries().createSqlFieldsQuery("select _key from Integer where _key >= " +
-                "0 order by _key");
-
-            q.pageSize(50);
-
-            ClusterGroup prj = 
g.cluster().forNodes(Arrays.asList(g.cluster().localNode(), 
grid(0).localNode()));
-
-            q = q.projection(prj);
-
-            GridCacheQueryFuture<List<?>> fut = q.execute();
-
-            assertEquals(0, fut.next().get(0));
-
-            // fut.nextX() does not guarantee the request has completed on 
remote node
-            // (we could receive page from local one), so we need to wait.
-            assertTrue(GridTestUtils.waitForCondition(new PA() {
-                @Override public boolean apply() {
-                    return map.size() == 1;
-                }
-            }, getTestTimeout()));
-
-            Map<Long, GridFutureAdapter<GridQueryFieldsResult>> futs = 
map.get(g.cluster().localNode().id());
-
-            assertEquals(1, futs.size());
-
-            final UUID nodeId = g.cluster().localNode().id();
-            final CountDownLatch latch = new CountDownLatch(1);
-
-            grid(0).events().localListen(new IgnitePredicate<IgniteEvent>() {
-                @Override public boolean apply(IgniteEvent evt) {
-                    if (((IgniteDiscoveryEvent) 
evt).eventNode().id().equals(nodeId))
-                        latch.countDown();
-
-                    return true;
-                }
-            }, EVT_NODE_LEFT);
-
-            stopGrid();
-
-            latch.await();
-
-            assertEquals(0, map.size());
-        }
-        finally {
-            // Ensure that additional node is stopped.
-            stopGrid();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testLostIterator() throws Exception {
-        GridCache<Integer, Integer> cache = grid(0).cache(null);
-
-        GridCacheQueryFuture<List<?>> fut = null;
-
-        for (int i = 0; i < 
cache.configuration().getMaximumQueryIteratorCount() + 1; i++) {
-            GridCacheQuery<List<?>> q = cache.queries().createSqlFieldsQuery(
-                "select _key from Integer where _key >= 0 order by 
_key").projection(grid(0));
-
-            q.pageSize(50);
-
-            GridCacheQueryFuture<List<?>> f = q.execute();
-
-            assertEquals(0, f.next().get(0));
-
-            if (fut == null)
-                fut = f;
-        }
-
-        final GridCacheQueryFuture<List<?>> fut0 = fut;
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                int i = 0;
-
-                List<?> next;
-
-                while ((next = fut0.next()) != null)
-                    assertEquals(++i % 50, next.get(0));
-
-                return null;
-            }
-        }, IgniteException.class, null);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b89b472d/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
 
b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
deleted file mode 100644
index 066e625..0000000
--- 
a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/replicated/GridCacheReplicatedQueryP2PDisabledSelfTest.java
+++ /dev/null
@@ -1,34 +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.gridgain.grid.kernal.processors.cache.distributed.replicated;
-
-import org.apache.ignite.configuration.*;
-
-/**
- * Tests replicated query.
- */
-public class GridCacheReplicatedQueryP2PDisabledSelfTest extends 
GridCacheReplicatedQuerySelfTest {
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        IgniteConfiguration c = super.getConfiguration(gridName);
-
-        c.setPeerClassLoadingEnabled(false);
-
-        return c;
-    }
-}

Reply via email to