You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/06 14:07:07 UTC

[08/36] incubator-ignite git commit: ignite-646

ignite-646


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

Branch: refs/heads/ignite-695
Commit: 300cc75e8cb6546e1537081583e55e7fae165893
Parents: cdbaaba
Author: avinogradov <av...@gridgain.com>
Authored: Thu Apr 23 16:03:50 2015 +0300
Committer: avinogradov <av...@gridgain.com>
Committed: Thu Apr 23 16:03:50 2015 +0300

----------------------------------------------------------------------
 .../IgniteCacheP2pUnmarshallingErrorTest.java   | 76 +++++++++-----------
 .../IgniteCacheP2pUnmarshallingErrorTxTest.java | 16 ++---
 2 files changed, 40 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/300cc75e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
index 7edbff2..1f622bd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
@@ -100,11 +100,13 @@ public class IgniteCacheP2pUnmarshallingErrorTest extends IgniteCacheAbstractTes
 
         /** {@inheritDoc} */
         @Override public void writeExternal(ObjectOutput out) throws IOException {
-
+            out.writeObject(field);
         }
 
         /** {@inheritDoc} */
         @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+            field = (String)in.readObject();
+
             if (readCnt.decrementAndGet() <= 0) { //will throw exception on backup node only
                 throw new IOException("Class can not be unmarshalled");
             }
@@ -112,74 +114,60 @@ public class IgniteCacheP2pUnmarshallingErrorTest extends IgniteCacheAbstractTes
     }
 
     /**
-     * Test key 2. Unmarshalling always failed.
+     * Sends put atomically and handles fail.
      */
-    public static class TestKeyAlwaysFailed extends TestKey {
-        /** Test key 2. */
-        public TestKeyAlwaysFailed(String field) {
-            super(field);
-        }
+    protected void failAtomicPut() {
+        try {
+            jcache(0).put(new TestKey("1"), "");
 
-        /** Test key 2. */
-        public TestKeyAlwaysFailed() {
+            assert false : "p2p marshalling failed, but error response was not sent";
         }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            readCnt.decrementAndGet();
-            throw new IOException("Class can not be unmarshalled"); //will throw exception on primary node
+        catch (CacheException e) {
+            assert X.hasCause(e, IOException.class);
         }
 
+        assert readCnt.get() == 0; //ensure we have read count as expected.
     }
 
     /**
-     * Tests that correct response will be sent to client node in case of unmarshalling failed.
+     * Sends get atomically and handles fail.
      */
-    public void testResponseMessageOnUnmarshallingFailed() {
-        //Checking failed unmarshalling on primary node.
-        readCnt.set(1);
-
+    protected void failAtomicGet() {
         try {
-            jcache(0).put(new TestKeyAlwaysFailed("1"), ""); //put will fail at primary node.
+            jcache(0).get(new TestKey("1"));
 
             assert false : "p2p marshalling failed, but error response was not sent";
         }
         catch (CacheException e) {
             assert X.hasCause(e, IOException.class);
         }
+    }
 
-        assert readCnt.get() == 0; //put request should not be handled by backup node in case failed at primary.
-
-        try {
-            assert jcache(0).get(new TestKeyAlwaysFailed("1")) == null;
+    /**
+     * Tests that correct response will be sent to client node in case of unmarshalling failed.
+     */
+    public void testResponseMessageOnUnmarshallingFailed() {
+        //GridNearAtomicUpdateRequest unmarshalling failed test
+        readCnt.set(1);
 
-            assert false : "p2p marshalling failed, but error response was not sent";
-        }
-        catch (CacheException e) {
-            assert X.hasCause(e, IOException.class);
-        }
+        failAtomicPut();
 
-        assert grid(0).cachex().entrySet().size() == 0;
+        //GridNearGetRequest unmarshalling failed test
+        readCnt.set(1);
 
-        //Checking failed unmarshalling on backup node.
-        readCnt.set(2); //put request will be unmarshalled twice (at primary and at backup node).
+        failAtomicGet();
 
-        try {
-            jcache(0).put(new TestKey("1"), ""); //put will fail at backup node only.
+        readCnt.set(100);
 
-            assert false : "p2p marshalling failed, but error response was not sent";
-        }
-        catch (CacheException e) {
-            assert X.hasCause(e, IOException.class);
-        }
+        assert jcache(0).get(new TestKey("1")) == null;
 
-        assert readCnt.get() == 0; //put request should be handled by primary and backup node.
+        readCnt.set(2);
 
-        // Need to have no exception while unmarshalling getKeyResponse.
-        readCnt.set(3); //get response will me unmarshalled twice (request at primary node and response at client).
+        //GridDhtAtomicUpdateRequest unmarshalling failed test
+        failAtomicPut();
 
-        assert jcache(0).get(new TestKey("1")) == null;
+        readCnt.set(100);
 
-        assert grid(0).cachex().entrySet().size() == 0;
+        assert jcache(0).get(new TestKey("1")) != null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/300cc75e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTxTest.java
index cb6d444..ed3749f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTxTest.java
@@ -50,7 +50,7 @@ public class IgniteCacheP2pUnmarshallingErrorTxTest extends IgniteCacheP2pUnmars
             assert X.hasCause(e, IOException.class);
         }
 
-        assert readCnt.get() == 0; //ensure we have read counts as expected.
+        assert readCnt.get() == 0; //ensure we have read count as expected.
     }
 
     /**
@@ -63,11 +63,11 @@ public class IgniteCacheP2pUnmarshallingErrorTxTest extends IgniteCacheP2pUnmars
 
             assert false : "p2p marshalling failed, but error response was not sent";
         }
-        catch (IgniteException e) {
-            assert X.hasCause(e, IOException.class);
-        }
+//        catch (IgniteException e) {
+//            assert X.hasCause(e, IOException.class);
+//        }
 
-        assert readCnt.get() == 0; //ensure we have read counts as expected.
+        assert readCnt.get() == 0; //ensure we have read count as expected.
     }
 
     /**
@@ -84,9 +84,9 @@ public class IgniteCacheP2pUnmarshallingErrorTxTest extends IgniteCacheP2pUnmars
 //
 //        failOptimistic();
 
-//        readCnt.set(1);
-//
-//        failPessimictic();
+        readCnt.set(100);
+
+        failPessimictic();
 
     }
 }