You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2019/06/21 18:26:26 UTC

[ignite] branch master updated: .NET: Clean up PluginTest (related to IGNITE-11930 investigation)

This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b9b043  .NET: Clean up PluginTest (related to IGNITE-11930 investigation)
0b9b043 is described below

commit 0b9b04340cca59a71b43f79387ad3b0d5f179b5b
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Fri Jun 21 21:26:02 2019 +0300

    .NET: Clean up PluginTest (related to IGNITE-11930 investigation)
---
 .../Apache.Ignite.Core.Tests/Plugin/PluginTest.cs  | 56 +++++++++++++++-------
 1 file changed, 39 insertions(+), 17 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
index f36d60d..0fc5efb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Plugin/PluginTest.cs
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Tests.Plugin
         /// Tests the plugin life cycle.
         /// </summary>
         [Test]
-        public void TestIgniteStartStop()
+        public void IgnitionStart_ValidPluginConfiguration_StartsAndReturnsWorkingPlugin()
         {
             var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
             {
@@ -175,29 +175,28 @@ namespace Apache.Ignite.Core.Tests.Plugin
                 "at org.apache.ignite.platform.plugin.PlatformTestPluginTarget.processInLongOutLong"));
         }
 
-        /// <summary>
-        /// Tests invalid plugins.
-        /// </summary>
         [Test]
-        public void TestInvalidPlugins()
+        public void IgnitionStart_MissingPluginConfigurationAttribute_ThrowsException()
         {
-            Action<ICollection<IPluginConfiguration>> check = x => Ignition.Start(
-                new IgniteConfiguration(TestUtils.GetTestConfiguration()) {PluginConfigurations = x});
-
-            // Missing attribute.
-            var ex = Assert.Throws<IgniteException>(() => check(new[] { new NoAttributeConfig(),  }));
+            var ex = Assert.Throws<IgniteException>(() => TryStart(new[] { new NoAttributeConfig() }));
             Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual(string.Format("{0} of type {1} has no {2}", typeof(IPluginConfiguration),
                 typeof(NoAttributeConfig), typeof(PluginProviderTypeAttribute)), ex.InnerException.Message);
+        }
 
-            // Empty plugin name.
-            ex = Assert.Throws<IgniteException>(() => check(new[] {new EmptyNameConfig()}));
+        [Test]
+        public void IgnitionStart_EmptyPluginName_ThrowsException()
+        {
+            var ex = Assert.Throws<IgniteException>(() => TryStart(new[] {new EmptyNameConfig()}));
             Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual(string.Format("{0}.Name should not be null or empty: {1}", typeof(IPluginProvider<>),
                 typeof(EmptyNamePluginProvider)), ex.InnerException.Message);
+        }
 
-            // Duplicate plugin name.
-            ex = Assert.Throws<IgniteException>(() => check(new[]
+        [Test]
+        public void IgnitionStart_DuplicatePluginName_ThrowsException()
+        {
+            var ex = Assert.Throws<IgniteException>(() => TryStart(new[]
             {
                 new TestIgnitePluginConfiguration(),
                 new TestIgnitePluginConfiguration()
@@ -205,12 +204,18 @@ namespace Apache.Ignite.Core.Tests.Plugin
             Assert.IsNotNull(ex.InnerException);
             Assert.AreEqual(string.Format("Duplicate plugin name 'TestPlugin1' is used by plugin providers " +
                                           "'{0}' and '{0}'", typeof(TestIgnitePluginProvider)),
-                                          ex.InnerException.Message);
+                ex.InnerException.Message);
+        }
 
-            // Provider throws an exception.
+        /// <summary>
+        /// Tests invalid plugins.
+        /// </summary>
+        [Test]
+        public void IgnitionStart_PluginProviderThrowsException_StopsAndRethrowsException()
+        {
             PluginLog.Clear();
 
-            ex = Assert.Throws<IgniteException>(() => check(new IPluginConfiguration[]
+            var ex = Assert.Throws<IgniteException>(() => TryStart(new IPluginConfiguration[]
             {
                 new NormalConfig(), new ExceptionConfig()
             }));
@@ -227,6 +232,23 @@ namespace Apache.Ignite.Core.Tests.Plugin
                 }, PluginLog);
         }
 
+        private static void TryStart(ICollection<IPluginConfiguration> x)
+        {
+            try
+            {
+                var igniteConfiguration = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+                {
+                    PluginConfigurations = x
+                };
+
+                Ignition.Start(igniteConfiguration);
+            }
+            finally
+            {
+                Ignition.StopAll(true);
+            }
+        }
+
         private class NoAttributeConfig : IPluginConfiguration
         {
             public int? PluginConfigurationClosureFactoryId