ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject [3/3] ignite git commit: .NET: Fix error messages when IgniteConfigurationSection content is missing
Date Wed, 09 Nov 2016 16:54:14 GMT
.NET: Fix error messages when IgniteConfigurationSection content is missing


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

Branch: refs/heads/master
Commit: 058ad505547c4d35afd16cc3f962ecfb04dd924c
Parents: d775ad1
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Tue Nov 8 19:38:28 2016 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Wed Nov 9 19:53:52 2016 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.AspNet/Impl/ConfigUtil.cs     |  2 +-
 .../IgniteConfigurationSectionTest.cs           | 20 ++++++++++++++++++++
 .../dotnet/Apache.Ignite.Core.Tests/app.config  |  1 +
 .../Apache.Ignite.Core.Tests/custom_app.config  |  1 +
 .../dotnet/Apache.Ignite.Core/Ignition.cs       | 12 ++++++++++++
 5 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/058ad505/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/ConfigUtil.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/ConfigUtil.cs b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/ConfigUtil.cs
index fc93c7e..b967518 100644
--- a/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/ConfigUtil.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.AspNet/Impl/ConfigUtil.cs
@@ -89,7 +89,7 @@ namespace Apache.Ignite.AspNet.Impl
 
                 if (config == null)
                     throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture,
-                        "{0} with name '{1}' is defined in <configSections>, but not
present in configuration", 
+                        "{0} with name '{1}' is defined in <configSections>, but not
present in configuration.", 
                         typeof(IgniteConfigurationSection).Name, sectionName));
             }
             else

http://git-wip-us.apache.org/repos/asf/ignite/blob/058ad505/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
index 4e10a2b..13bd9a2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
@@ -78,6 +78,7 @@ namespace Apache.Ignite.Core.Tests
         [Test]
         public void TestIgniteStartError()
         {
+            // Missing section in default file.
             var ex = Assert.Throws<ConfigurationErrorsException>(() =>
                 Ignition.StartFromApplicationConfiguration("igniteConfiguration111"));
 
@@ -85,17 +86,36 @@ namespace Apache.Ignite.Core.Tests
                 ex.Message);
 
 
+            // Missing section body.
+            ex = Assert.Throws<ConfigurationErrorsException>(() =>
+                Ignition.StartFromApplicationConfiguration("igniteConfigurationMissing"));
+
+            Assert.AreEqual("IgniteConfigurationSection with name 'igniteConfigurationMissing'
" +
+                            "is defined in <configSections>, but not present in configuration.",
ex.Message);
+
+
+            // Missing custom file.
             ex = Assert.Throws<ConfigurationErrorsException>(() =>
                 Ignition.StartFromApplicationConfiguration("igniteConfiguration", "somefile"));
 
             Assert.AreEqual("Specified config file does not exist: somefile", ex.Message);
 
 
+            // Missing section in custom file.
             ex = Assert.Throws<ConfigurationErrorsException>(() =>
                 Ignition.StartFromApplicationConfiguration("igniteConfiguration", "custom_app.config"));
 
             Assert.AreEqual("Could not find IgniteConfigurationSection with name 'igniteConfiguration'
" +
                             "in file 'custom_app.config'", ex.Message);
+            
+            
+            // Missing section body in custom file.
+            ex = Assert.Throws<ConfigurationErrorsException>(() =>
+                Ignition.StartFromApplicationConfiguration("igniteConfigurationMissing",
"custom_app.config"));
+
+            Assert.AreEqual("IgniteConfigurationSection with name 'igniteConfigurationMissing'
in file " +
+                            "'custom_app.config' is defined in <configSections>, but
not present in configuration.",
+                ex.Message);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/058ad505/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
index d22bea4..f928ed4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
@@ -21,6 +21,7 @@
     <configSections>
         <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection,
Apache.Ignite.Core" />
         <section name="igniteConfiguration2" type="Apache.Ignite.Core.IgniteConfigurationSection,
Apache.Ignite.Core" />
+        <section name="igniteConfigurationMissing" type="Apache.Ignite.Core.IgniteConfigurationSection,
Apache.Ignite.Core" />
     </configSections>
 
     <runtime>

http://git-wip-us.apache.org/repos/asf/ignite/blob/058ad505/modules/platforms/dotnet/Apache.Ignite.Core.Tests/custom_app.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/custom_app.config b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/custom_app.config
index 41ea39e..aec91dc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/custom_app.config
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/custom_app.config
@@ -20,6 +20,7 @@
 <configuration>
     <configSections>
         <section name="igniteConfiguration3" type="Apache.Ignite.Core.IgniteConfigurationSection,
Apache.Ignite.Core" />
+        <section name="igniteConfigurationMissing" type="Apache.Ignite.Core.IgniteConfigurationSection,
Apache.Ignite.Core" />
     </configSections>
 
     <igniteConfiguration3 gridName="myGrid3" localhost="127.0.0.1">

http://git-wip-us.apache.org/repos/asf/ignite/blob/058ad505/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 7b023f3..515902f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -152,6 +152,12 @@ namespace Apache.Ignite.Core
                 throw new ConfigurationErrorsException(string.Format("Could not find {0}
with name '{1}'",
                     typeof(IgniteConfigurationSection).Name, sectionName));
 
+            if (section.IgniteConfiguration == null)
+                throw new ConfigurationErrorsException(
+                    string.Format("{0} with name '{1}' is defined in <configSections>,
" +
+                                  "but not present in configuration.",
+                        typeof(IgniteConfigurationSection).Name, sectionName));
+
             return Start(section.IgniteConfiguration);
         }
 
@@ -177,6 +183,12 @@ namespace Apache.Ignite.Core
                     string.Format("Could not find {0} with name '{1}' in file '{2}'",
                         typeof(IgniteConfigurationSection).Name, sectionName, configPath));
 
+            if (section.IgniteConfiguration == null)
+                throw new ConfigurationErrorsException(
+                    string.Format("{0} with name '{1}' in file '{2}' is defined in <configSections>,
" +
+                                  "but not present in configuration.",
+                        typeof(IgniteConfigurationSection).Name, sectionName, configPath));
+
             return Start(section.IgniteConfiguration);
         }
 


Mime
View raw message