ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [40/50] [abbrv] incubator-ignite git commit: # IGNITE-56 Fix tests.
Date Fri, 06 Feb 2015 15:58:55 GMT
# IGNITE-56 Fix tests.


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

Branch: refs/heads/ignite-181
Commit: 2f9881d3f609d3ab2b4d28e317192fed02ff3b79
Parents: 15c3c91
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Fri Feb 6 15:57:12 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Fri Feb 6 15:57:12 2015 +0300

----------------------------------------------------------------------
 ...eJdbcStoreAbstractMultithreadedSelfTest.java |  8 +--
 .../cache/GridCacheAbstractFullApiSelfTest.java | 62 ++------------------
 .../cache/GridCacheAbstractSelfTest.java        | 37 ------------
 ...tomicClientOnlyMultiNodeFullApiSelfTest.java | 36 ------------
 ...idCacheNearOnlyMultiNodeFullApiSelfTest.java | 35 -----------
 .../near/GridPartitionedBackupLoadSelfTest.java |  2 +-
 .../junits/common/GridCommonAbstractTest.java   | 40 +++++++++++++
 7 files changed, 50 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
index 6f58679..b35cc25 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
@@ -169,7 +169,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T
extends Cach
 
             @Override public Object call() throws Exception {
                 for (int i = 0; i < TX_CNT; i++) {
-                    GridCache<Object, Object> cache = cache();
+                    IgniteCache<Object, Object> cache = jcache();
 
                     int id = rnd.nextInt(1000);
 
@@ -188,7 +188,7 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T
extends Cach
 
             @Override public Object call() throws Exception {
                 for (int i = 0; i < TX_CNT; i++) {
-                    GridCache<Object, Object> cache = cache();
+                    IgniteCache<Object, Object> cache = jcache();
 
                     int id = rnd.nextInt(1000);
 
@@ -247,9 +247,9 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T
extends Cach
 
             @Override public Object call() throws Exception {
                 for (int i = 0; i < TX_CNT; i++) {
-                    GridCache<PersonKey, Person> cache = cache();
+                    IgniteCache<PersonKey, Person> cache = jcache();
 
-                    try (IgniteTx tx = cache.txStart()) {
+                    try (IgniteTx tx = grid().transactions().txStart()) {
                         cache.put(new PersonKey(1), new Person(1, rnd.nextInt(), "Name" +
1));
                         cache.put(new PersonKey(2), new Person(2, rnd.nextInt(), "Name" +
2));
                         cache.put(new PersonKey(3), new Person(3, rnd.nextInt(), "Name" +
3));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 4b61c2d..0d66b15 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -2314,17 +2314,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
         loadAll(cache, keys, true);
 
-        for (String key : keys) {
-            assertEquals(vals.get(key), cache.localPeek(key, CachePeekMode.ONHEAP));
-
-            cache.clear(Collections.singleton(key));
-        }
-
-        for (String key : keys)
-            assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
-
-        loadAll(cache, keys, true);
-
         for (String key : keys)
             assertEquals(vals.get(key), cache.localPeek(key, CachePeekMode.ONHEAP));
     }
@@ -2472,40 +2461,6 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
     /**
      * @throws Exception In case of error.
      */
-    public void testClearKeys() throws Exception {
-        IgniteCache<String, Integer> cache = jcache();
-
-        Collection<String> keys = primaryKeysForCache(cache, 3);
-
-        for (String key : keys)
-            assertNull(cache.get(key));
-
-        String lastKey = F.last(keys);
-
-        Collection<String> subKeys = new ArrayList<>(keys);
-
-        subKeys.remove(lastKey);
-
-        Map<String, Integer> vals = new HashMap<>();
-
-        int i = 0;
-
-        for (String key : keys)
-            vals.put(key, i++);
-
-        cache.putAll(vals);
-
-        cache.clear(subKeys);
-
-        for (String key : subKeys)
-            assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
-
-        assertEquals(vals.get(lastKey), cache.localPeek(lastKey, CachePeekMode.ONHEAP));
-    }
-
-    /**
-     * @throws Exception In case of error.
-     */
     public void testGlobalClearAll() throws Exception {
         // Save entries only on their primary nodes. If we didn't do so, clearLocally() will
not remove all entries
         // because some of them were blocked due to having readers.
@@ -2675,17 +2630,9 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
         cache.put("key", 1);
 
-        IgniteTx tx = txEnabled() ? ignite.transactions().txStart() : null;
-
-        try {
-            cache.replace("key", 2);
+        cache.replace("key", 2);
 
-            assert cache.localPeek("key", CachePeekMode.ONHEAP) == 2;
-        }
-        finally {
-            if (tx != null)
-                tx.close();
-        }
+        assert cache.localPeek("key", CachePeekMode.ONHEAP) == 2;
     }
 
     /**
@@ -2716,7 +2663,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             try (IgniteTx tx = ignite.transactions().txStart(concurrency, READ_COMMITTED))
{
                 cache.remove("key");
 
-                assertNull(cache.localPeek("key", CachePeekMode.ONHEAP));
+                assertNull(cache.get("key")); // localPeek ignores transactions.
+                assertNotNull(cache.localPeek("key")); // localPeek ignores transactions.
 
                 tx.commit();
             }
@@ -2893,7 +2841,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         Thread.sleep(ttl + 100);
 
         // Expired entry should not be swapped.
-        cache.localEvict(Collections.<String>singleton(key));
+        cache.localEvict(Collections.singleton(key));
 
         assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index 3c7c43b..fe47ea9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -194,43 +194,6 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * @param cache Cache.
-     * @param keys Keys.
-     * @param replaceExistingValues Replace existing values.
-     */
-    protected static <K> void loadAll(Cache<K, ?> cache, Set<K> keys, boolean
replaceExistingValues) throws Exception {
-        final AtomicReference<Exception> ex = new AtomicReference<>();
-
-        final CountDownLatch latch = new CountDownLatch(1);
-
-        cache.loadAll(keys, replaceExistingValues, new CompletionListener() {
-            @Override public void onCompletion() {
-                latch.countDown();
-            }
-
-            @Override public void onException(Exception e) {
-                ex.set(e);
-
-                latch.countDown();
-            }
-        });
-
-        latch.await();
-
-        if (ex.get() != null)
-            throw ex.get();
-    }
-
-    /**
-     * @param cache Cache.
-     * @param key Keys.
-     * @param replaceExistingValues Replace existing values.
-     */
-    protected static <K> void load(Cache<K, ?> cache, K key, boolean replaceExistingValues)
throws Exception {
-        loadAll(cache, Collections.singleton(key), replaceExistingValues);
-    }
-
-    /**
      * Cleans up cache store.
      */
     protected void resetStore() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
index e07c27e..27903da 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest.java
@@ -133,42 +133,6 @@ public class GridCacheAtomicClientOnlyMultiNodeFullApiSelfTest extends
GridCache
     }
 
     /** {@inheritDoc} */
-    @Override public void testClearKeys() throws Exception {
-        IgniteCache<String, Integer> nearCache = jcache();
-        IgniteCache<String, Integer> primary = fullCache();
-
-        Collection<String> keys = primaryKeysForCache(primary, 3);
-
-        for (String key : keys)
-            assertNull(nearCache.get(key));
-
-        String lastKey = F.last(keys);
-
-        Collection<String> subKeys = new ArrayList<>(keys);
-
-        subKeys.remove(lastKey);
-
-        Map<String, Integer> vals = new HashMap<>(keys.size());
-
-        int i = 0;
-
-        for (String key : keys)
-            vals.put(key, i++);
-
-        nearCache.putAll(vals);
-
-        for (String subKey : subKeys)
-            nearCache.clear(Collections.singleton(subKey));
-
-        for (String key : subKeys) {
-            assertNull(nearCache.localPeek(key, CachePeekMode.ONHEAP));
-            assertNotNull(primary.localPeek(key, CachePeekMode.ONHEAP));
-        }
-
-        assertEquals(null, nearCache.localPeek(lastKey, CachePeekMode.ONHEAP));
-    }
-
-    /** {@inheritDoc} */
     @Override public void testEvictExpired() throws Exception {
         IgniteCache<String, Integer> cache = jcache();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
index 95fd9d1..f10932b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
@@ -242,41 +242,6 @@ public class GridCacheNearOnlyMultiNodeFullApiSelfTest extends GridCachePartitio
     }
 
     /** {@inheritDoc} */
-    @Override public void testClearKeys() throws Exception {
-        IgniteCache<String, Integer> nearCache = jcache();
-        IgniteCache<String, Integer> primary = fullCache();
-
-        Collection<String> keys = primaryKeysForCache(primary, 3);
-
-        for (String key : keys)
-            assertNull(nearCache.get(key));
-
-        String lastKey = F.last(keys);
-
-        Collection<String> subKeys = new ArrayList<>(keys);
-
-        subKeys.remove(lastKey);
-
-        Map<String, Integer> vals = new HashMap<>();
-
-        int i = 0;
-
-        for (String key : keys)
-            vals.put(key, i++);
-
-        nearCache.putAll(vals);
-
-        nearCache.clear(subKeys);
-
-        for (String key : subKeys) {
-            assertNull(nearCache.localPeek(key, CachePeekMode.ONHEAP));
-            assertNotNull(primary.localPeek(key, CachePeekMode.ONHEAP));
-        }
-
-        assertEquals(vals.get(lastKey), nearCache.localPeek(lastKey, CachePeekMode.ONHEAP));
-    }
-
-    /** {@inheritDoc} */
     @Override public void testGlobalClearAll() throws Exception {
         // Save entries only on their primary nodes. If we didn't do so, clearLocally() will
not remove all entries
         // because some of them were blocked due to having readers.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
index f9f6c7d..65524fc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
@@ -114,7 +114,7 @@ public class GridPartitionedBackupLoadSelfTest extends GridCommonAbstractTest
{
             if (grid(i).affinity(null).isBackup(grid(i).localNode(), 1)) {
                 assert cache.localPeek(1, CachePeekMode.ONHEAP) == 1;
 
-                assert cache.clear(Collections.singleton(1));
+                assert cache().clearLocally(1);
 
                 assert cache.localPeek(1, CachePeekMode.ONHEAP) == null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2f9881d3/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 0294b33..3b76b232 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -37,8 +37,11 @@ import org.apache.ignite.testframework.junits.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import javax.cache.integration.*;
 import javax.net.ssl.*;
 import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
 
 import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CachePreloadMode.*;
@@ -189,6 +192,43 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest
{
     }
 
     /**
+     * @param cache Cache.
+     * @param keys Keys.
+     * @param replaceExistingValues Replace existing values.
+     */
+    protected static <K> void loadAll(Cache<K, ?> cache, Set<K> keys, boolean
replaceExistingValues) throws Exception {
+        final AtomicReference<Exception> ex = new AtomicReference<>();
+
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        cache.loadAll(keys, replaceExistingValues, new CompletionListener() {
+            @Override public void onCompletion() {
+                latch.countDown();
+            }
+
+            @Override public void onException(Exception e) {
+                ex.set(e);
+
+                latch.countDown();
+            }
+        });
+
+        latch.await();
+
+        if (ex.get() != null)
+            throw ex.get();
+    }
+
+    /**
+     * @param cache Cache.
+     * @param key Keys.
+     * @param replaceExistingValues Replace existing values.
+     */
+    protected static <K> void load(Cache<K, ?> cache, K key, boolean replaceExistingValues)
throws Exception {
+        loadAll(cache, Collections.singleton(key), replaceExistingValues);
+    }
+
+    /**
      * @return Near cache.
      */
     protected <K, V> GridNearCacheAdapter<K, V> near() {


Mime
View raw message