IGNITE-6675 .NET: Fix ignored IgniteConfiguration.IgniteHome
authorPavel Tupitsyn <ptupitsyn@apache.org>
Thu, 19 Oct 2017 15:42:12 +0000 (18:42 +0300)
committerPavel Tupitsyn <ptupitsyn@apache.org>
Thu, 19 Oct 2017 15:42:12 +0000 (18:42 +0300)
This closes #2886

modules/platforms/dotnet/Apache.Ignite.Core.Tests/DeploymentTest.cs
modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs

index cb97076..1d80c60 100644 (file)
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Tests
     using System.IO;
     using System.Linq;
     using Apache.Ignite.Core.Compute;
+    using Apache.Ignite.Core.Impl;
     using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Resource;
     using Apache.Ignite.Core.Tests.Process;
@@ -38,7 +39,7 @@ namespace Apache.Ignite.Core.Tests
         public void TestCustomDeployment()
         {
             // Create temp folder
-            var folder = GetTempFolder();
+            var folder = IgniteUtils.GetTempDirectoryName();
 
             // Copy jars
             var home = IgniteHome.Resolve(null);
@@ -139,36 +140,6 @@ namespace Apache.Ignite.Core.Tests
             }
         }
 
-        /// <summary>
-        /// Gets the temporary folder.
-        /// </summary>
-        private static string GetTempFolder()
-        {
-            const string prefix = "ig-test-";
-            var temp = Path.GetTempPath();
-
-            for (int i = 0; i < int.MaxValue; i++)
-            {
-                {
-                    try
-                    {
-                        var path = Path.Combine(temp, prefix + i);
-
-                        if (Directory.Exists(path))
-                            Directory.Delete(path, true);
-
-                        return Directory.CreateDirectory(path).FullName;
-                    }
-                    catch (Exception)
-                    {
-                        // Ignore
-                    }
-                }
-            }
-
-            throw new InvalidOperationException();
-        }
-
         #pragma warning disable 649
         /// <summary>
         /// Function that returns process path.
index 3fd4772..cde216b 100644 (file)
@@ -36,6 +36,7 @@ namespace Apache.Ignite.Core.Tests
     using Apache.Ignite.Core.Discovery.Tcp.Static;
     using Apache.Ignite.Core.Events;
     using Apache.Ignite.Core.Impl;
+    using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.PersistentStore;
     using Apache.Ignite.Core.Tests.Plugin;
     using Apache.Ignite.Core.Transactions;
@@ -131,6 +132,7 @@ namespace Apache.Ignite.Core.Tests
                 Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray());
 
                 Assert.AreEqual(cfg.IgniteInstanceName, resCfg.IgniteInstanceName);
+                Assert.AreEqual(cfg.IgniteHome, resCfg.IgniteHome);
                 Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes);
                 Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime);
                 Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize);
@@ -682,6 +684,7 @@ namespace Apache.Ignite.Core.Tests
                     TopologyHistorySize = 1234567
                 },
                 IgniteInstanceName = "gridName1",
+                IgniteHome = IgniteHome.Resolve(null),
                 IncludedEventTypes = EventType.DiscoveryAll,
                 MetricsExpireTime = TimeSpan.FromMinutes(7),
                 MetricsHistorySize = 125,
index 2b73da9..c019f0c 100644 (file)
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Tests
 {
     using System;
     using System.IO;
+    using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl.Common;
     using NUnit.Framework;
 
@@ -39,7 +40,14 @@ namespace Apache.Ignite.Core.Tests
 
             try
             {
-                Assert.IsTrue(Directory.Exists(IgniteHome.Resolve(null)));
+                var home = IgniteHome.Resolve(null);
+                Assert.IsTrue(Directory.Exists(home));
+
+                // Invalid home.
+                var cfg = new IgniteConfiguration {IgniteHome = @"c:\foo\bar"};
+                var ex = Assert.Throws<IgniteException>(() => IgniteHome.Resolve(new IgniteConfiguration(cfg)));
+                Assert.AreEqual(string.Format(
+                    "IgniteConfiguration.IgniteHome is not valid: '{0}'", cfg.IgniteHome), ex.Message);
             }
             finally
             {
index a7a5ff4..b0fe0df 100644 (file)
@@ -734,6 +734,7 @@ namespace Apache.Ignite.Core
             }
 
             SpringConfigUrl = cfg.SpringConfigUrl;
+            IgniteHome = cfg.IgniteHome;
             JvmClasspath = cfg.JvmClasspath;
             JvmOptions = cfg.JvmOptions;
             Assemblies = cfg.Assemblies;