ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [11/50] ignite git commit: Refactor tests
Date Wed, 13 Apr 2016 14:53:10 GMT
Refactor tests


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

Branch: refs/heads/ignite-2977
Commit: 2940141d2b8c2c939a4eed7aa9ed29c5999b41fc
Parents: d8ced1c
Author: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Authored: Tue Apr 12 18:17:05 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Committed: Tue Apr 12 18:17:05 2016 +0300

----------------------------------------------------------------------
 .../Continuous/ContinuousQueryJavaFilterTest.cs | 75 +++++++++++---------
 1 file changed, 43 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2940141d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
index 3106b39..7d9033d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryJavaFilterTest.cs
@@ -43,46 +43,59 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         /** */
         private const string StopTask = "org.apache.ignite.platform.PlatformStopIgniteTask";
 
+        /** */
+        private IIgnite _ignite;
+        
+        /** */
+        private string _javaNodeName;
+
+        /** */
+        private static volatile ICacheEntryEvent<int, string> _lastEvent;
+
         /// <summary>
-        /// Test.
+        /// Fixture set up.
         /// </summary>
-        [Test]
-        public void Test()
+        [TestFixtureSetUp]
+        public void FixtureSetUp()
         {
-            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) {SpringConfigUrl
= SpringConfig};
+            // Main .NET nodes
+            _ignite =
+                Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
+                {
+                    SpringConfigUrl = SpringConfig
+                });
 
-            var cfg2 = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            // Second .NET node
+            Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
             {
                 SpringConfigUrl = SpringConfig2,
                 GridName = "dotNet2"
-            };
+            });
 
-            // 3 nodes: check local, remote, Java remote filters.
-            using (var ignite = Ignition.Start(cfg))
-            using (Ignition.Start(cfg2))
-            {
-                var javaNodeName = ignite.GetCompute().ExecuteJavaTask<string>(StartTask,
SpringConfig2);
 
-                try
-                {
-                    Assert.IsTrue(ignite.WaitTopology(3));
+            // Java-only node
+            _javaNodeName = _ignite.GetCompute().ExecuteJavaTask<string>(StartTask,
SpringConfig2);
 
-                    TestJavaObjects(ignite);
-                }
-                finally
-                {
-                    ignite.GetCompute().ExecuteJavaTask<object>(StopTask, javaNodeName);
-                }
-            }
+            Assert.IsTrue(_ignite.WaitTopology(3));
+        }
+
+        /// <summary>
+        /// Fixture tear down.
+        /// </summary>
+        [TestFixtureTearDown]
+        public void FixtureTearDown()
+        {
+            _ignite.GetCompute().ExecuteJavaTask<object>(StopTask, _javaNodeName);
+            Ignition.StopAll(true);
         }
 
         /// <summary>
         /// Tests the java objects.
         /// </summary>
-        [SuppressMessage("ReSharper", "PossibleNullReferenceException")]
-        private static void TestJavaObjects(IIgnite ignite)
+        [Test]
+        public void TestFilter()
         {
-            var cache = ignite.GetOrCreateCache<int, string>("qry");
+            var cache = _ignite.GetOrCreateCache<int, string>("qry");
 
             var pred = JavaObjectFactory.CreateCacheEntryEventFilter<int, string>(
                 "org.apache.ignite.platform.PlatformCacheEntryEventFilter",
@@ -95,13 +108,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
                 // Run on many keys to test all nodes
                 for (var i = 0; i < 200; i++)
                 {
-                    QueryListener.Event = null;
+                    _lastEvent = null;
                     cache[i] = "validValue";
-                    Assert.AreEqual(cache[i], QueryListener.Event.Value);
+                    // ReSharper disable once PossibleNullReferenceException
+                    Assert.AreEqual(cache[i], _lastEvent.Value);
 
-                    QueryListener.Event = null;
+                    _lastEvent = null;
                     cache[i] = "invalidValue";
-                    Assert.IsNull(QueryListener.Event);
+                    Assert.IsNull(_lastEvent);
                 }
             }
         }
@@ -111,13 +125,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
         /// </summary>
         private class QueryListener : ICacheEntryEventListener<int, string>
         {
-            /** */
-            public static volatile ICacheEntryEvent<int, string> Event;
-
             /** <inheritdoc /> */
             public void OnEvent(IEnumerable<ICacheEntryEvent<int, string>> evts)
             {
-                Event = evts.FirstOrDefault();
+                _lastEvent = evts.FirstOrDefault();
             }
         }
     }


Mime
View raw message