.NET: Clean up PluginTest (related to investigation)
@@ -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()
@@ -206,11 +205,17 @@ namespace Apache.Ignite.Core.Tests.Plugin
Assert.AreEqual(string.Format("Duplicate plugin name 'TestPlugin1' is used by plugin providers " +
"'{0}' and '{0}'", typeof(TestIgnitePluginProvider)),
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
