ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/5] incubator-ignite git commit: # IGNITE-709 GridEventConsumeSelfTest must not implement Serializable.
Date Fri, 15 May 2015 17:52:59 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-709_3 ce5eb8bd2 -> 1d8ae1612


# IGNITE-709 GridEventConsumeSelfTest must not implement Serializable.


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

Branch: refs/heads/ignite-709_3
Commit: 5a983ffc77632c462a65b137d455873405374064
Parents: fd94eab
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Fri May 15 20:17:09 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Fri May 15 20:17:09 2015 +0300

----------------------------------------------------------------------
 .../continuous/GridEventConsumeSelfTest.java    | 63 ++++++++++++--------
 .../testframework/junits/GridAbstractTest.java  | 16 +++++
 2 files changed, 53 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5a983ffc/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
index 7a9bd3a..f41aaa0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
@@ -28,9 +28,11 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.marshaller.optimized.*;
 import org.apache.ignite.resources.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 
-import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -42,7 +44,7 @@ import static org.apache.ignite.internal.processors.continuous.GridContinuousPro
 /**
  * Event consume test.
  */
-public class GridEventConsumeSelfTest extends GridCommonAbstractTest implements Serializable
{
+public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
     /** */
     private static final String PRJ_PRED_CLS_NAME = "org.apache.ignite.tests.p2p.GridEventConsumeProjectionPredicate";
 
@@ -55,6 +57,9 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest implements
     /** Number of created consumes per thread in multithreaded test. */
     private static final int CONSUME_CNT = 500;
 
+    /** */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
     /** Consume latch. */
     private static volatile CountDownLatch consumeLatch;
 
@@ -71,6 +76,12 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest implements
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
+        TcpDiscoverySpi disc = new TcpDiscoverySpi();
+
+        disc.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disc);
+
         if (include)
             cfg.setUserAttributes(F.asMap("include", true));
 
@@ -80,7 +91,7 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest implements
     }
 
     /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
+    @Override protected void beforeTest() throws Exception {
         assertTrue(GRID_CNT > 1);
 
         include = true;
@@ -93,30 +104,30 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest
implements
     }
 
     /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        stopAllGrids();
-    }
-
-    /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
-        assertEquals(GRID_CNT, grid(0).cluster().nodes().size());
+        try {
+            assertEquals(GRID_CNT, grid(0).cluster().nodes().size());
 
-        for (int i = 0; i < GRID_CNT; i++) {
-            IgniteEx grid = grid(i);
+            for (int i = 0; i < GRID_CNT; i++) {
+                IgniteEx grid = grid(i);
 
-            GridContinuousProcessor proc = grid.context().continuous();
+                GridContinuousProcessor proc = grid.context().continuous();
 
-            try {
-                if (!noAutoUnsubscribe)
-                    assertEquals(0, U.<Map>field(proc, "rmtInfos").size());
-            }
-            finally {
-                U.<Map>field(proc, "rmtInfos").clear();
-            }
+                try {
+                    if (!noAutoUnsubscribe)
+                        assertEquals(0, U.<Map>field(proc, "rmtInfos").size());
+                }
+                finally {
+                    U.<Map>field(proc, "rmtInfos").clear();
+                }
 
-            assertEquals(0, U.<Map>field(proc, "rmtInfos").size());
-            assertEquals(0, U.<Map>field(proc, "startFuts").size());
-            assertEquals(0, U.<Map>field(proc, "stopFuts").size());
+                assertEquals(0, U.<Map>field(proc, "rmtInfos").size());
+                assertEquals(0, U.<Map>field(proc, "startFuts").size());
+                assertEquals(0, U.<Map>field(proc, "stopFuts").size());
+            }
+        }
+        finally {
+            stopAllGrids();
         }
     }
 
@@ -641,7 +652,7 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest implements
         final CountDownLatch latch = new CountDownLatch(GRID_CNT + 1);
 
         UUID consumeId = grid(0).events().remoteListen(
-            new P2<UUID, Event>() {
+            notSerializableProxy(new P2<UUID, Event>() {
                 @Override public boolean apply(UUID nodeId, Event evt) {
                     info("Event from " + nodeId + " [" + evt.shortDisplay() + ']');
 
@@ -653,12 +664,12 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest
implements
 
                     return true;
                 }
-            },
-            new P1<Event>() {
+            }),
+            notSerializableProxy(new P1<Event>() {
                 @Override public boolean apply(Event evt) {
                     return evt.type() == EVT_JOB_STARTED;
                 }
-            },
+            }),
             EVT_JOB_STARTED, EVT_JOB_FINISHED
         );
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5a983ffc/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index f3a9051..37a5dc5 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -1389,6 +1389,22 @@ public abstract class GridAbstractTest extends TestCase {
 
     /**
      * @param obj Object that should be wrap proxy
+     * @return Created proxy.
+     */
+    protected <T> T notSerializableProxy(final T obj) {
+        Class<T> cls = (Class<T>)obj.getClass();
+
+        Class<T>[] interfaces = (Class<T>[])cls.getInterfaces();
+
+        assert interfaces.length > 0;
+
+        Class<T> lastItf = interfaces[interfaces.length - 1];
+
+        return notSerializableProxy(obj, lastItf, Arrays.copyOf(interfaces, interfaces.length
- 1));
+    }
+
+    /**
+     * @param obj Object that should be wrap proxy
      * @param itfCls Interface that should be implemented by proxy
      * @param itfClses Interfaces that should be implemented by proxy (vararg parameter)
      * @return Created proxy.


Mime
View raw message