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 2016/08/16 15:11:56 UTC
[1/2] ignite git commit: IGNITE-3368 .NET: Improve test coverage
Repository: ignite
Updated Branches:
refs/heads/master ecc734c20 -> e4eda7cf3
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
index 0c983fd..912102c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
@@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(1, JobErrs.Count);
+ Assert.AreEqual(4, JobErrs.Count);
Assert.IsNotNull(JobErrs.First() as GoodException);
Assert.AreEqual(ErrorMode.LocJobErr, ((GoodException) JobErrs.First()).Mode);
}
@@ -122,7 +122,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(1, JobErrs.Count);
+ Assert.AreEqual(4, JobErrs.Count);
Assert.IsNotNull(JobErrs.First() as BadException); // Local job exception is not marshalled.
}
@@ -153,7 +153,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(1, JobErrs.Count);
+ Assert.AreEqual(4, JobErrs.Count);
Assert.IsNotNull(JobErrs.ElementAt(0) as GoodException);
@@ -172,7 +172,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(1, JobErrs.Count);
+ Assert.AreEqual(4, JobErrs.Count);
Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
}
@@ -189,7 +189,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res);
- Assert.AreEqual(1, JobErrs.Count);
+ Assert.AreEqual(4, JobErrs.Count);
Assert.IsNotNull(JobErrs.ElementAt(0) as IgniteException);
}
@@ -305,9 +305,19 @@ namespace Apache.Ignite.Core.Tests.Compute
{
JobErrs.Clear();
- object res = Grid1.GetCompute().Execute(new Task());
+ Func<object, int> getRes = r => r is GoodTaskResult ? ((GoodTaskResult) r).Res : ((BadTaskResult) r).Res;
- return res is GoodTaskResult ? ((GoodTaskResult)res).Res : ((BadTaskResult)res).Res;
+ var res1 = getRes(Grid1.GetCompute().Execute(new Task()));
+ var res2 = getRes(Grid1.GetCompute().Execute<object, object>(typeof(Task)));
+
+ var resAsync1 = getRes(Grid1.GetCompute().ExecuteAsync(new Task()).Result);
+ var resAsync2 = getRes(Grid1.GetCompute().ExecuteAsync<object, object>(typeof(Task)).Result);
+
+ Assert.AreEqual(res1, res2);
+ Assert.AreEqual(res2, resAsync1);
+ Assert.AreEqual(resAsync1, resAsync2);
+
+ return res1;
}
/// <summary>
@@ -318,20 +328,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
JobErrs.Clear();
- Exception err = null;
-
- try
- {
- Grid1.GetCompute().Execute(new Task());
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- err = e;
- }
-
- return err;
+ return Assert.Catch(() => Grid1.GetCompute().Execute(new Task()));
}
/// <summary>
@@ -391,11 +388,11 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
/// Task.
/// </summary>
- public class Task : IComputeTask<object, object>
+ private class Task : IComputeTask<object, object>
{
/** Grid. */
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** Result. */
private int _res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
index 522341a..433b635 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
@@ -54,6 +54,17 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
+ /// Test Ignite injection into the task.
+ /// </summary>
+ [Test]
+ public void TestTaskInjectionBinarizable()
+ {
+ int res = Grid1.GetCompute().Execute(new InjectionTaskBinarizable(), 0);
+
+ Assert.AreEqual(GetServerCount(), res);
+ }
+
+ /// <summary>
/// Test Ignite injection into the closure.
/// </summary>
[Test]
@@ -86,6 +97,12 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(GetServerCount(), res);
}
+ /** <inheritdoc /> */
+ protected override ICollection<Type> GetBinaryTypes()
+ {
+ return new[] {typeof(InjectionJobBinarizable)};
+ }
+
/// <summary>
/// Injection task.
/// </summary>
@@ -113,6 +130,40 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
+ /// Injection task.
+ /// </summary>
+ private class InjectionTaskBinarizable : Injectee, IComputeTask<object, int, int>
+ {
+ /** <inheritDoc /> */
+ public IDictionary<IComputeJob<int>, IClusterNode> Map(IList<IClusterNode> subgrid, object arg)
+ {
+ CheckInjection();
+
+ return subgrid.ToDictionary(x => (IComputeJob<int>) new InjectionJobBinarizable(), x => x);
+ }
+
+ /** <inheritDoc /> */
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ {
+ return ComputeJobResultPolicy.Wait;
+ }
+
+ /** <inheritDoc /> */
+ public int Reduce(IList<IComputeJobResult<int>> results)
+ {
+ return results.Sum(res => res.Data);
+ }
+ }
+
+ /// <summary>
+ /// Binarizable job.
+ /// </summary>
+ public class InjectionJobBinarizable : InjectionJob
+ {
+ // No-op.
+ }
+
+ /// <summary>
/// Injection job.
/// </summary>
[Serializable]
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
index ded56ed..8db4876 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/SerializableClosureTaskTest.cs
@@ -66,6 +66,11 @@ namespace Apache.Ignite.Core.Tests.Compute
{
Assert.IsTrue(err != null);
+ var aggregate = err as AggregateException;
+
+ if (aggregate != null)
+ err = aggregate.InnerException;
+
SerializableException err0 = err as SerializableException;
Assert.IsTrue(err0 != null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
index 7789ac4..32a28a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -22,7 +22,6 @@ namespace Apache.Ignite.Core.Tests.Compute
using System;
using System.Collections.Generic;
using System.Linq;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Resource;
using NUnit.Framework;
@@ -102,9 +101,9 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ protected override ICollection<Type> GetBinaryTypes()
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJob)));
+ return new[] { typeof(BinarizableJob) };
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
index 26286de..289b68b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Tests.Compute
{
using System;
using System.Collections.Generic;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Resource;
@@ -156,12 +155,15 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ protected override ICollection<Type> GetBinaryTypes()
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestBinarizableJob)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableOutFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFunc)));
+ return new[]
+ {
+ typeof(BinarizableResult),
+ typeof(TestBinarizableJob),
+ typeof(BinarizableOutFunc),
+ typeof(BinarizableFunc)
+ };
}
[Test]
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
index af5f499..3990e3b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
@@ -68,6 +68,7 @@
<value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableFunc</value>
<value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableResult</value>
<value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableException</value>
+ <value>Apache.Ignite.Core.Tests.Compute.ResourceTaskTest+InjectionJobBinarizable</value>
</list>
</property>
<property name="typesConfiguration">
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index c2ccd1a..cc21490 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#pragma warning disable 618
namespace Apache.Ignite.Core.Tests
{
using System;
@@ -25,6 +26,7 @@ namespace Apache.Ignite.Core.Tests
using System.Threading.Tasks;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache.Query;
+ using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Events;
using Apache.Ignite.Core.Impl;
@@ -141,7 +143,7 @@ namespace Apache.Ignite.Core.Tests
CheckSend(2);
// Unsubscribe from all events
- events.StopLocalListen(listener);
+ events.StopLocalListen(listener, Enumerable.Empty<int>());
CheckNoEvent();
@@ -299,10 +301,19 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
+ /// Tests the record local.
+ /// </summary>
+ [Test]
+ public void TestRecordLocal()
+ {
+ Assert.Throws<NotImplementedException>(() => _grid1.GetEvents().RecordLocal(new MyEvent()));
+ }
+
+ /// <summary>
/// Tests the WaitForLocal.
/// </summary>
[Test]
- public void TestWaitForLocal([Values(true, false)] bool async)
+ public void TestWaitForLocal()
{
var events = _grid1.GetEvents();
@@ -312,50 +323,80 @@ namespace Apache.Ignite.Core.Tests
events.EnableLocal(eventType);
- Func<IEventFilter<IEvent>, int[], Task<IEvent>> getWaitTask;
+ var taskFuncs = GetWaitTasks(events).Select(
+ func => (Func<IEventFilter<IEvent>, int[], Task<IEvent>>) (
+ (filter, types) =>
+ {
+ var task = func(filter, types);
- if (async)
- getWaitTask = (filter, types) =>
- {
- var task = events.WaitForLocalAsync(filter, types);
- GenerateTaskEvent();
- return task;
- };
- else
- getWaitTask = (filter, types) =>
+ Thread.Sleep(100); // allow task to start and begin waiting for events
+
+ GenerateTaskEvent();
+
+ return task;
+ })).ToArray();
+
+ for (int i = 0; i < taskFuncs.Length; i++)
+ {
+ var getWaitTask = taskFuncs[i];
+
+ // No params
+ var waitTask = getWaitTask(null, new int[0]);
+
+ waitTask.Wait(timeout);
+
+ // Event types
+ waitTask = getWaitTask(null, new[] {EventType.TaskReduced});
+
+ Assert.IsTrue(waitTask.Wait(timeout));
+ Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
+ Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
+
+ if (i > 3)
{
- var task = Task.Factory.StartNew(() => events.WaitForLocal(filter, types));
- Thread.Sleep(500); // allow task to start and begin waiting for events
- GenerateTaskEvent();
- return task;
- };
+ // Filter
+ waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced), new int[0]);
- // No params
- var waitTask = getWaitTask(null, new int[0]);
+ Assert.IsTrue(waitTask.Wait(timeout));
+ Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
+ Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
- waitTask.Wait(timeout);
+ // Filter & types
+ waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced),
+ new[] {EventType.TaskReduced});
- // Event types
- waitTask = getWaitTask(null, new[] {EventType.TaskReduced});
+ Assert.IsTrue(waitTask.Wait(timeout));
+ Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
+ Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
+ }
+ }
+ }
- Assert.IsTrue(waitTask.Wait(timeout));
- Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
+ /// <summary>
+ /// Gets the wait tasks for different overloads of WaitForLocal.
+ /// </summary>
+ private static IEnumerable<Func<IEventFilter<IEvent>, int[], Task<IEvent>>> GetWaitTasks(IEvents events)
+ {
+ yield return (filter, types) => Task.Factory.StartNew(() => events.WaitForLocal(types));
+ yield return (filter, types) => Task.Factory.StartNew(() => events.WaitForLocal(types.ToList()));
- // Filter
- waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced), new int[0]);
+ yield return (filter, types) => events.WaitForLocalAsync(types);
+ yield return (filter, types) => events.WaitForLocalAsync(types.ToList());
- Assert.IsTrue(waitTask.Wait(timeout));
- Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
+ yield return (filter, types) => Task.Factory.StartNew(() => events.WaitForLocal(filter, types));
+ yield return (filter, types) => Task.Factory.StartNew(() => events.WaitForLocal(filter, types.ToList()));
- // Filter & types
- waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced),
- new[] {EventType.TaskReduced});
+ yield return (filter, types) => events.WaitForLocalAsync(filter, types);
+ yield return (filter, types) => events.WaitForLocalAsync(filter, types.ToList());
+ }
- Assert.IsTrue(waitTask.Wait(timeout));
- Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
- Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
+ /// <summary>
+ /// Tests the wait for local overloads.
+ /// </summary>
+ [Test]
+ public void TestWaitForLocalOverloads()
+ {
+
}
/*
@@ -492,6 +533,7 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(expectedGuid, cacheEvent.SubjectId);
Assert.AreEqual("cloClsName", cacheEvent.ClosureClassName);
Assert.AreEqual("taskName", cacheEvent.TaskName);
+ Assert.IsTrue(cacheEvent.ToShortString().StartsWith("SWAP_SPACE_CLEARED: IsNear="));
var qryExecEvent = EventReader.Read<CacheQueryExecutedEvent>(reader);
CheckEventBase(qryExecEvent);
@@ -501,6 +543,9 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual("clause", qryExecEvent.Clause);
Assert.AreEqual(expectedGuid, qryExecEvent.SubjectId);
Assert.AreEqual("taskName", qryExecEvent.TaskName);
+ Assert.AreEqual(
+ "SWAP_SPACE_CLEARED: QueryType=qryType, CacheName=cacheName, ClassName=clsName, Clause=clause, " +
+ "SubjectId=00000000-0000-0001-0000-000000000002, TaskName=taskName", qryExecEvent.ToShortString());
var qryReadEvent = EventReader.Read<CacheQueryReadEvent>(reader);
CheckEventBase(qryReadEvent);
@@ -514,6 +559,10 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(2, qryReadEvent.Value);
Assert.AreEqual(3, qryReadEvent.OldValue);
Assert.AreEqual(4, qryReadEvent.Row);
+ Assert.AreEqual(
+ "SWAP_SPACE_CLEARED: QueryType=qryType, CacheName=cacheName, ClassName=clsName, Clause=clause, " +
+ "SubjectId=00000000-0000-0001-0000-000000000002, TaskName=taskName, Key=1, Value=2, " +
+ "OldValue=3, Row=4", qryReadEvent.ToShortString());
var cacheRebalancingEvent = EventReader.Read<CacheRebalancingEvent>(reader);
CheckEventBase(cacheRebalancingEvent);
@@ -522,15 +571,19 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(locNode, cacheRebalancingEvent.DiscoveryNode);
Assert.AreEqual(2, cacheRebalancingEvent.DiscoveryEventType);
Assert.AreEqual(3, cacheRebalancingEvent.DiscoveryTimestamp);
-
+ Assert.IsTrue(cacheRebalancingEvent.ToShortString().StartsWith(
+ "SWAP_SPACE_CLEARED: CacheName=cacheName, Partition=1, DiscoveryNode=GridNode"));
+
var checkpointEvent = EventReader.Read<CheckpointEvent>(reader);
CheckEventBase(checkpointEvent);
Assert.AreEqual("cpKey", checkpointEvent.Key);
-
+ Assert.AreEqual("SWAP_SPACE_CLEARED: Key=cpKey", checkpointEvent.ToShortString());
+
var discoEvent = EventReader.Read<DiscoveryEvent>(reader);
CheckEventBase(discoEvent);
Assert.AreEqual(grid.TopologyVersion, discoEvent.TopologyVersion);
Assert.AreEqual(grid.GetNodes(), discoEvent.TopologyNodes);
+ Assert.IsTrue(discoEvent.ToShortString().StartsWith("SWAP_SPACE_CLEARED: EventNode=GridNode"));
var jobEvent = EventReader.Read<JobEvent>(reader);
CheckEventBase(jobEvent);
@@ -540,10 +593,12 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual(locNode, jobEvent.TaskNode);
Assert.AreEqual(expectedGridGuid, jobEvent.TaskSessionId);
Assert.AreEqual(expectedGuid, jobEvent.TaskSubjectId);
+ Assert.IsTrue(jobEvent.ToShortString().StartsWith("SWAP_SPACE_CLEARED: TaskName=taskName"));
var spaceEvent = EventReader.Read<SwapSpaceEvent>(reader);
CheckEventBase(spaceEvent);
Assert.AreEqual("space", spaceEvent.Space);
+ Assert.IsTrue(spaceEvent.ToShortString().StartsWith("SWAP_SPACE_CLEARED: Space=space"));
var taskEvent = EventReader.Read<TaskEvent>(reader);
CheckEventBase(taskEvent);
@@ -552,6 +607,7 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual("taskClsName", taskEvent.TaskClassName);
Assert.AreEqual("taskName", taskEvent.TaskName);
Assert.AreEqual(expectedGridGuid, taskEvent.TaskSessionId);
+ Assert.IsTrue(taskEvent.ToShortString().StartsWith("SWAP_SPACE_CLEARED: TaskName=taskName"));
}
}
@@ -570,6 +626,11 @@ namespace Apache.Ignite.Core.Tests
Assert.AreNotEqual(Guid.Empty, evt.Id.GlobalId);
Assert.IsTrue(Math.Abs((evt.Timestamp - DateTime.UtcNow).TotalSeconds) < 20,
"Invalid event timestamp: '{0}', current time: '{1}'", evt.Timestamp, DateTime.Now);
+
+ Assert.Greater(evt.LocalOrder, 0);
+
+ Assert.IsTrue(evt.ToString().Contains("[Name=SWAP_SPACE_CLEARED"));
+ Assert.IsTrue(evt.ToShortString().StartsWith("SWAP_SPACE_CLEARED"));
}
/// <summary>
@@ -855,6 +916,7 @@ namespace Apache.Ignite.Core.Tests
}
/** <inheritdoc /> */
+ // ReSharper disable once UnusedMember.Global
public bool Invoke(T evt)
{
throw new Exception("Invalid method");
@@ -954,4 +1016,58 @@ namespace Apache.Ignite.Core.Tests
return EventObjectType.ToString();
}
}
+
+ /// <summary>
+ /// Custom event.
+ /// </summary>
+ public class MyEvent : IEvent
+ {
+ /** <inheritdoc /> */
+ public IgniteGuid Id
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public long LocalOrder
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public IClusterNode Node
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public string Message
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public int Type
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public string Name
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public DateTime Timestamp
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /** <inheritdoc /> */
+ public string ToShortString()
+ {
+ throw new NotImplementedException();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
index 02a5d0b..f6730d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/ExamplesTest.cs
@@ -27,7 +27,7 @@ namespace Apache.Ignite.Core.Tests.Examples
/// <summary>
/// Tests all examples in various modes.
/// </summary>
- [Category(TestUtils.CategoryIntensive)]
+ [Category(TestUtils.CategoryExamples)]
public class ExamplesTest
{
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index a324191..e766f5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -122,6 +122,52 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
+ /// Tests that all exceptions have mandatory constructors and are serializable.
+ /// </summary>
+ [Test]
+ public void TestAllExceptionsConstructors()
+ {
+ var types = typeof(IIgnite).Assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(Exception)));
+
+ foreach (var type in types)
+ {
+ Assert.IsTrue(type.IsSerializable, "Exception is not serializable: " + type);
+
+ // Default ctor.
+ var defCtor = type.GetConstructor(new Type[0]);
+ Assert.IsNotNull(defCtor);
+
+ var ex = (Exception) defCtor.Invoke(new object[0]);
+ Assert.AreEqual(string.Format("Exception of type '{0}' was thrown.", type.FullName), ex.Message);
+
+ // Message ctor.
+ var msgCtor = type.GetConstructor(new[] {typeof(string)});
+ Assert.IsNotNull(msgCtor);
+
+ ex = (Exception) msgCtor.Invoke(new object[] {"myMessage"});
+ Assert.AreEqual("myMessage", ex.Message);
+
+ // Serialization.
+ var stream = new MemoryStream();
+ var formatter = new BinaryFormatter();
+
+ formatter.Serialize(stream, ex);
+ stream.Seek(0, SeekOrigin.Begin);
+
+ ex = (Exception) formatter.Deserialize(stream);
+ Assert.AreEqual("myMessage", ex.Message);
+
+ // Message+cause ctor.
+ var msgCauseCtor = type.GetConstructor(new[] { typeof(string), typeof(Exception) });
+ Assert.IsNotNull(msgCauseCtor);
+
+ ex = (Exception) msgCauseCtor.Invoke(new object[] {"myMessage", new Exception("innerEx")});
+ Assert.AreEqual("myMessage", ex.Message);
+ Assert.AreEqual("innerEx", ex.InnerException.Message);
+ }
+ }
+
+ /// <summary>
/// Tests CachePartialUpdateException serialization.
/// </summary>
private static void TestPartialUpdateExceptionSerialization(Exception ex)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
index d3851db..88a2b52 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestUtils.cs
@@ -39,6 +39,9 @@ namespace Apache.Ignite.Core.Tests
/** Indicates long running and/or memory/cpu intensive test. */
public const string CategoryIntensive = "LONG_TEST";
+ /** Indicates examples tests. */
+ public const string CategoryExamples = "EXAMPLES_TEST";
+
/** */
public const int DfltBusywaitSleepInterval = 200;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index db2a96b..953b72f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -308,7 +308,6 @@
<Compile Include="Impl\Common\IgniteConfigurationXmlSerializer.cs" />
<Compile Include="Impl\Common\IgniteHome.cs" />
<Compile Include="Impl\Common\LoadedAssembliesResolver.cs" />
- <Compile Include="Impl\Common\ResizeableArray.cs" />
<Compile Include="Impl\Common\TypeCaster.cs" />
<Compile Include="Impl\Common\TypeStringConverter.cs" />
<Compile Include="Impl\Compute\Closure\ComputeAbstractClosureTask.cs" />
@@ -349,7 +348,6 @@
<Compile Include="Impl\Handle\HandleRegistry.cs" />
<Compile Include="Impl\Handle\IHandle.cs" />
<Compile Include="Impl\IInteropCallback.cs" />
- <Compile Include="Impl\InteropExceptionHolder.cs" />
<Compile Include="Impl\LifecycleBeanHolder.cs" />
<Compile Include="Impl\Memory\InteropExternalMemory.cs" />
<Compile Include="Impl\Memory\InteropMemoryUtils.cs" />
@@ -384,7 +382,6 @@
<Compile Include="Impl\Binary\BinarizableSerializer.cs" />
<Compile Include="Impl\Binary\Marshaller.cs" />
<Compile Include="Impl\Binary\BinaryMode.cs" />
- <Compile Include="Impl\Binary\BinaryObjectHandle.cs" />
<Compile Include="Impl\Binary\BinaryObjectHeader.cs" />
<Compile Include="Impl\Binary\BinaryObjectSchema.cs" />
<Compile Include="Impl\Binary\BinaryObjectSchemaField.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityKey.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityKey.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityKey.cs
index 1d27d65..1b7fcb0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityKey.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Affinity/AffinityKey.cs
@@ -158,5 +158,16 @@ namespace Apache.Ignite.Core.Cache.Affinity
{
return !left.Equals(right);
}
+
+ /// <summary>
+ /// Returns a <see cref="string" /> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="string" /> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return string.Format("AffinityKey [Key={0}, Affinity={1}]", _key, _affinity);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
index 907af14..484fceb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
@@ -71,7 +71,8 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="msg">Exception message.</param>
/// <param name="failedKeysException">Exception occurred during failed keys read/write.</param>
- public CachePartialUpdateException(string msg, Exception failedKeysException) : this(msg, null, failedKeysException)
+ public CachePartialUpdateException(string msg, Exception failedKeysException)
+ : this(msg, null, failedKeysException)
{
// No-op.
}
@@ -92,7 +93,8 @@ namespace Apache.Ignite.Core.Cache
/// <param name="msg">Exception message.</param>
/// <param name="failedKeys">Failed keys.</param>
/// <param name="failedKeysException">Exception occurred during failed keys read/write.</param>
- private CachePartialUpdateException(string msg, IList<object> failedKeys, Exception failedKeysException) : base(msg)
+ private CachePartialUpdateException(string msg, IList<object> failedKeys, Exception failedKeysException)
+ : base(msg, failedKeysException)
{
_failedKeys = failedKeys;
_failedKeysException = failedKeysException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
index 147f1bd..c506838 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheParallelLoadStoreAdapter.cs
@@ -110,6 +110,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// The value for the entry that is to be stored in the cache
/// or <c>null</c> if the object can't be loaded
/// </returns>
+ [ExcludeFromCodeCoverage]
public virtual object Load(object key)
{
return null;
@@ -124,6 +125,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// <returns>
/// A map of key, values to be stored in the cache.
/// </returns>
+ [ExcludeFromCodeCoverage]
public virtual IDictionary LoadAll(ICollection keys)
{
return null;
@@ -136,6 +138,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// </summary>
/// <param name="key">Key to write.</param>
/// <param name="val">Value to write.</param>
+ [ExcludeFromCodeCoverage]
public virtual void Write(object key, object val)
{
// No-op.
@@ -154,6 +157,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// <param name="entries">a mutable collection to write. Upon invocation, it contains the entries
/// to write for write-through. Upon return the collection must only contain entries
/// that were not successfully written. (see partial success above).</param>
+ [ExcludeFromCodeCoverage]
public virtual void WriteAll(IDictionary entries)
{
// No-op.
@@ -167,6 +171,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// This method is invoked even if no mapping for the key exists.
/// </summary>
/// <param name="key">The key that is used for the delete operation.</param>
+ [ExcludeFromCodeCoverage]
public virtual void Delete(object key)
{
// No-op.
@@ -189,6 +194,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// <param name="keys">a mutable collection of keys for entries to delete. Upon invocation,
/// it contains the keys to delete for write-through. Upon return the collection must only contain
/// the keys that were not successfully deleted.</param>
+ [ExcludeFromCodeCoverage]
public virtual void DeleteAll(ICollection keys)
{
// No-op.
@@ -199,6 +205,7 @@ namespace Apache.Ignite.Core.Cache.Store
/// <c>commit</c> parameter.
/// </summary>
/// <param name="commit"><c>True</c> if transaction should commit, <c>false</c> for rollback.</param>
+ [ExcludeFromCodeCoverage]
public virtual void SessionEnd(bool commit)
{
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Common/JavaException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/JavaException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/JavaException.cs
index a634010..5f7ba66 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/JavaException.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/JavaException.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Common
/// <summary>
/// Indicates an error on Java side and contains full Java stack trace.
/// </summary>
+ [Serializable]
public class JavaException : IgniteException
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
index 13d3133..39a2f8b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Impl.Binary
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
@@ -125,6 +126,7 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/** <inheritdoc /> */
+ [ExcludeFromCodeCoverage]
public int EnumValue
{
get
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
index 646d563..1626a2d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -1027,7 +1027,7 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Mutation ocntext.
+ /// Mutation context.
/// </summary>
private class Context
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs
deleted file mode 100644
index 35735fe..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHandle.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Binary
-{
- /// <summary>
- /// Object handle. Wraps a single value.
- /// </summary>
- internal class BinaryObjectHandle
- {
- /** Value. */
- private readonly object _val;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BinaryObjectHandle"/> class.
- /// </summary>
- /// <param name="val">The value.</param>
- public BinaryObjectHandle(object val)
- {
- _val = val;
- }
-
- /// <summary>
- /// Gets the value.
- /// </summary>
- public object Value
- {
- get { return _val; }
- }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- var that = obj as BinaryObjectHandle;
-
- return that != null && _val == that._val;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return _val != null ? _val.GetHashCode() : 0;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
index 2624d52..bb5c207 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Binary
{
using System;
using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
using Apache.Ignite.Core.Impl.Binary.IO;
@@ -100,6 +101,7 @@ namespace Apache.Ignite.Core.Impl.Binary
/// Initializes a new instance of the <see cref="BinaryObjectHeader"/> struct from specified stream.
/// </summary>
/// <param name="stream">The stream.</param>
+ [ExcludeFromCodeCoverage] // big-endian only
private BinaryObjectHeader(IBinaryStream stream)
{
Header = stream.ReadByte();
@@ -116,6 +118,7 @@ namespace Apache.Ignite.Core.Impl.Binary
/// Writes this instance to the specified stream.
/// </summary>
/// <param name="stream">The stream.</param>
+ [ExcludeFromCodeCoverage] // big-endian only
private void Write(IBinaryStream stream)
{
stream.WriteByte(Header);
@@ -292,7 +295,7 @@ namespace Apache.Ignite.Core.Impl.Binary
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
-
+
return obj is BinaryObjectHeader && Equals((BinaryObjectHeader) obj);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
index 16e3032..b572e7c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Constrcutor.
+ /// Constructor.
/// </summary>
/// <param name="cfg">Configuration.</param>
/// <param name="name">Type name.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 063aa9d..9f4c8c8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1442,26 +1442,6 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Check whether the given object is binarizeble, i.e. it can be serialized with binary marshaller.
- /// </summary>
- /// <param name="obj">Object.</param>
- /// <returns>True if binarizable.</returns>
- internal bool IsBinarizable(object obj)
- {
- if (obj != null)
- {
- Type type = obj.GetType();
-
- // We assume object as binarizable only in case it has descriptor.
- // Collections, Enums and non-primitive arrays do not have descriptors
- // and this is fine here because we cannot know whether their members are binarizable.
- return _marsh.GetDescriptor(type) != null || BinarySystemHandlers.GetWriteHandler(type) != null;
- }
-
- return true;
- }
-
- /// <summary>
/// Write field ID.
/// </summary>
/// <param name="fieldName">Field name.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
index dcbff81..b062689 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamAdapter.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Binary.IO
{
using System;
+ using System.Diagnostics.CodeAnalysis;
using System.IO;
/// <summary>
@@ -78,12 +79,14 @@ namespace Apache.Ignite.Core.Impl.Binary.IO
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException("Stream is not seekable.");
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public override long Position
{
get
@@ -97,6 +100,7 @@ namespace Apache.Ignite.Core.Impl.Binary.IO
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public override long Length
{
get
@@ -106,6 +110,7 @@ namespace Apache.Ignite.Core.Impl.Binary.IO
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public override void SetLength(long value)
{
throw new NotSupportedException("Stream is not seekable.");
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
index a5e140d..6286602 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/BinaryStreamBase.cs
@@ -25,7 +25,7 @@ namespace Apache.Ignite.Core.Impl.Binary.IO
/// <summary>
/// Base class for managed and unmanaged data streams.
/// </summary>
- internal unsafe abstract class BinaryStreamBase : IBinaryStream
+ internal abstract unsafe class BinaryStreamBase : IBinaryStream
{
/** Byte: zero. */
private const byte ByteZero = 0;
@@ -1070,13 +1070,10 @@ namespace Apache.Ignite.Core.Impl.Binary.IO
/// <returns>
/// <c>True</c> if they are same.
/// </returns>
- public virtual bool IsSameArray(byte[] arr)
- {
- return false;
- }
-
+ public abstract bool IsSameArray(byte[] arr);
+
/// <summary>
- /// Seek to the given positoin.
+ /// Seek to the given position.
/// </summary>
/// <param name="offset">Offset.</param>
/// <param name="origin">Seek origin.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
index d530713..cd509c6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Io/IBinaryStream.cs
@@ -312,7 +312,7 @@ namespace Apache.Ignite.Core.Impl.Binary.IO
bool IsSameArray(byte[] arr);
/// <summary>
- /// Seek to the given positoin.
+ /// Seek to the given position.
/// </summary>
/// <param name="offset">Offset.</param>
/// <param name="origin">Seek origin.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
index a8d94f2..109d55f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
@@ -62,9 +62,6 @@ namespace Apache.Ignite.Core.Impl.Binary
private static readonly Dictionary<string, Type> JavaToNet =
NetToJava.GroupBy(x => x.Value).ToDictionary(g => g.Key, g => g.First().Key);
- /** */
- private static readonly string MappedTypes = string.Join(", ", NetToJava.Keys.Select(x => x.Name));
-
/// <summary>
/// Gets the corresponding Java type name.
/// </summary>
@@ -110,13 +107,5 @@ namespace Apache.Ignite.Core.Impl.Binary
return JavaToNet.TryGetValue(javaTypeName, out res) ? res : null;
}
-
- /// <summary>
- /// Gets the supported types as a comma-separated string.
- /// </summary>
- public static string SupportedTypesString
- {
- get { return MappedTypes; }
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
index b5c2ece..a56e12a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Event/JavaCacheEntryEventFilter.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Event
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Cache.Event;
using Apache.Ignite.Core.Impl.Common;
@@ -30,6 +31,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Event
internal class JavaCacheEntryEventFilter<TK, TV> : PlatformJavaObjectFactoryProxy, ICacheEntryEventFilter<TK, TV>
{
/** <inheritdoc /> */
+ [ExcludeFromCodeCoverage]
public bool Evaluate(ICacheEntryEvent<TK, TV> evt)
{
throw new InvalidOperationException(GetType() + " cannot be invoked directly.");
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
index 2adb021..a4e9c93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/MultiValueDictionary.cs
@@ -52,32 +52,6 @@ namespace Apache.Ignite.Core.Impl.Collections
}
/// <summary>
- /// Tries the get a value. In case of multiple values for a key, returns the last one.
- /// </summary>
- /// <param name="key">The key.</param>
- /// <param name="val">The value.</param>
- /// <returns>True if value has been found for specified key; otherwise false.</returns>
- public bool TryGetValue(TKey key, out TValue val)
- {
- object val0;
-
- if (!_dict.TryGetValue(key, out val0))
- {
- val = default(TValue);
- return false;
- }
-
- var list = val0 as List<TValue>;
-
- if (list != null)
- val = list[list.Count - 1];
- else
- val = (TValue) val0;
-
- return true;
- }
-
- /// <summary>
/// Removes the specified value for the specified key.
/// </summary>
/// <param name="key">The key.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
index 60ec9d0..a51a149 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Collections/ReadOnlyDictionary.cs
@@ -110,7 +110,7 @@ namespace Apache.Ignite.Core.Impl.Collections
/** <inheritdoc /> */
public bool Remove(TKey key)
{
- return _dict.Remove(key);
+ throw GetReadonlyException();
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ResizeableArray.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ResizeableArray.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ResizeableArray.cs
deleted file mode 100644
index 82a8eee..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/ResizeableArray.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Common
-{
- using System.Collections.Generic;
-
- /// <summary>
- /// Simple append-only <see cref="List{T}"/> alternative which exposes internal array.
- /// </summary>
- internal class ResizeableArray<T>
- {
- /** Array. */
- private T[] _arr;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="capacity">Capacity.</param>
- public ResizeableArray(int capacity)
- {
- _arr = new T[capacity];
- }
-
- /// <summary>
- /// Array.
- /// </summary>
- public T[] Array
- {
- get { return _arr; }
- }
-
- /// <summary>
- /// Count.
- /// </summary>
- public int Count { get; private set; }
-
- /// <summary>
- /// Add element.
- /// </summary>
- /// <param name="element">Element.</param>
- public void Add(T element)
- {
- if (Count == _arr.Length)
- System.Array.Resize(ref _arr, _arr.Length*2);
-
- _arr[Count++] = element;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
index 6b8f935..f0d1564 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Impl.Events
using System;
using System.Collections.Generic;
using System.ComponentModel;
+ using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using Apache.Ignite.Core.Events;
@@ -57,6 +58,7 @@ namespace Apache.Ignite.Core.Impl.Events
/// <returns>
/// true if this converter can perform the conversion; otherwise, false.
/// </returns>
+ [ExcludeFromCodeCoverage] // not called
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string);
@@ -72,6 +74,7 @@ namespace Apache.Ignite.Core.Impl.Events
/// <returns>
/// true if this converter can perform the conversion; otherwise, false.
/// </returns>
+ [ExcludeFromCodeCoverage] // not called
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 783ba94..1d06072 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -154,6 +154,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
where T : IEvent
@@ -187,6 +188,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, IEnumerable<int> types = null)
where T : IEvent
@@ -195,6 +197,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
+ [ExcludeFromCodeCoverage]
public void StopRemoteListen(Guid opId)
{
DoOutOp((int) Op.StopRemoteListen, writer =>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
index 22881c6..a8c1471 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/ExceptionUtils.cs
@@ -201,6 +201,7 @@ namespace Apache.Ignite.Core.Impl
/// <param name="msg">Message.</param>
/// <param name="stackTrace">Stack trace.</param>
/// <returns>Exception.</returns>
+ [ExcludeFromCodeCoverage] // Covered by a test in a separate process.
public static Exception GetJvmInitializeException(string clsName, string msg, string stackTrace)
{
if (clsName != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
index fb56891..7791c91 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
@@ -39,7 +39,7 @@ namespace Apache.Ignite.Core.Impl.Handle
/// </summary>
/// <param name="target">Target.</param>
/// <param name="releaseAction">Release action.</param>
- public Handle(T target, Action<T> releaseAction)
+ protected Handle(T target, Action<T> releaseAction)
{
_target = target;
_releaseAction = releaseAction;
@@ -48,7 +48,7 @@ namespace Apache.Ignite.Core.Impl.Handle
/// <summary>
/// Target.
/// </summary>
- public T Target
+ protected T Target
{
get { return _target; }
}
@@ -61,13 +61,5 @@ namespace Apache.Ignite.Core.Impl.Handle
if (Interlocked.CompareExchange(ref _released, 1, 0) == 0)
_releaseAction(_target);
}
-
- /// <summary>
- /// Resource released flag.
- /// </summary>
- public bool Released
- {
- get { return Thread.VolatileRead(ref _released) == 1; }
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
index e18970f..4e1135a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/HandleRegistry.cs
@@ -102,16 +102,6 @@ namespace Apache.Ignite.Core.Impl.Handle
}
/// <summary>
- /// Allocate a handle for critical resource in safe mode.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <returns>Pointer.</returns>
- public long AllocateCriticalSafe(object target)
- {
- return Allocate0(target, true, true);
- }
-
- /// <summary>
/// Internal allocation routine.
/// </summary>
/// <param name="target">Target.</param>
@@ -121,7 +111,7 @@ namespace Apache.Ignite.Core.Impl.Handle
private long Allocate0(object target, bool critical, bool safe)
{
if (Closed)
- throw ClosedException();
+ throw GetClosedException();
// Try allocating on critical path.
if (critical)
@@ -140,7 +130,7 @@ namespace Apache.Ignite.Core.Impl.Handle
Release0(target, true);
- throw ClosedException();
+ throw GetClosedException();
}
return fastIdx;
@@ -159,7 +149,7 @@ namespace Apache.Ignite.Core.Impl.Handle
Release0(target, true);
- throw ClosedException();
+ throw GetClosedException();
}
return slowIdx;
@@ -320,6 +310,7 @@ namespace Apache.Ignite.Core.Impl.Handle
/// Gets a snapshot of currently referenced objects list.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
+ [ExcludeFromCodeCoverage]
public IList<KeyValuePair<long, object>> GetItems()
{
Thread.MemoryBarrier();
@@ -335,7 +326,8 @@ namespace Apache.Ignite.Core.Impl.Handle
/// Create new exception for closed state.
/// </summary>
/// <returns>Exception.</returns>
- private static Exception ClosedException()
+ [ExcludeFromCodeCoverage]
+ private static Exception GetClosedException()
{
return new InvalidOperationException("Cannot allocate a resource handle because Ignite is stopping.");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
index d147f8b..700ab5f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/IHandle.cs
@@ -26,10 +26,5 @@ namespace Apache.Ignite.Core.Impl.Handle
/// Release the resource.
/// </summary>
void Release();
-
- /// <summary>
- /// Resource released flag.
- /// </summary>
- bool Released { get; }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index ef811f5..ff63d55 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -41,6 +41,7 @@ namespace Apache.Ignite.Core.Impl
/// Grid proxy with fake serialization.
/// </summary>
[Serializable]
+ [ExcludeFromCodeCoverage]
internal class IgniteProxy : IIgnite, IClusterGroupEx, IBinaryWriteAware, ICluster
{
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 70d483d..04296c7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -20,7 +20,6 @@ namespace Apache.Ignite.Core.Impl
using System;
using System.Collections.Generic;
using System.ComponentModel;
- using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
@@ -238,6 +237,7 @@ namespace Apache.Ignite.Core.Impl
/// <summary>
/// Formats the Win32 error.
/// </summary>
+ [ExcludeFromCodeCoverage]
private static string FormatWin32Error(int errorCode)
{
if (errorCode == NativeMethods.ERROR_BAD_EXE_FORMAT)
@@ -493,25 +493,5 @@ namespace Apache.Ignite.Core.Impl
return res;
}
-
- /// <summary>
- /// Writes the node collection to a stream.
- /// </summary>
- /// <param name="writer">The writer.</param>
- /// <param name="nodes">The nodes.</param>
- public static void WriteNodes(IBinaryRawWriter writer, ICollection<IClusterNode> nodes)
- {
- Debug.Assert(writer != null);
-
- if (nodes != null)
- {
- writer.WriteInt(nodes.Count);
-
- foreach (var node in nodes)
- writer.WriteGuid(node.Id);
- }
- else
- writer.WriteInt(-1);
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
deleted file mode 100644
index 9edcb03..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/InteropExceptionHolder.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Runtime.Serialization.Formatters.Binary;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Binary.IO;
-
- /// <summary>
- /// Holder of exception which must be serialized to Java and then backwards to the native platform.
- /// </summary>
- internal class InteropExceptionHolder : IBinarizable
- {
- /** Initial exception. */
- private readonly Exception _err;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- public InteropExceptionHolder()
- {
- // No-op.
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="err">Error.</param>
- public InteropExceptionHolder(Exception err)
- {
- _err = err;
- }
-
- /// <summary>
- /// Underlying exception.
- /// </summary>
- public Exception Error
- {
- get { return _err; }
- }
-
- /** <inheritDoc /> */
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods")]
- public void WriteBinary(IBinaryWriter writer)
- {
- var writer0 = (BinaryWriter) writer.GetRawWriter();
-
- if (writer0.IsBinarizable(_err))
- {
- writer0.WriteBoolean(true);
- writer0.WriteObject(_err);
- }
- else
- {
- writer0.WriteBoolean(false);
-
- using (var streamAdapter = new BinaryStreamAdapter(writer0.Stream))
- {
- new BinaryFormatter().Serialize(streamAdapter, _err);
- }
- }
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- throw new NotImplementedException();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
index a991b3d..3aa5490 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryUtils.cs
@@ -88,16 +88,6 @@ namespace Apache.Ignite.Core.Impl.Memory
}
/// <summary>
- /// Sets capacity for the given memory chunk.
- /// </summary>
- /// <param name="memPtr">Memory pointer.</param>
- /// <param name="cap">CalculateCapacity.</param>
- public static void SetCapacity(long memPtr, int cap)
- {
- *((int*)(memPtr + MemHdrOffCap)) = cap;
- }
-
- /// <summary>
/// Gets length for the given memory chunk.
/// </summary>
/// <param name="memPtr">Memory pointer.</param>
@@ -138,16 +128,6 @@ namespace Apache.Ignite.Core.Impl.Memory
}
/// <summary>
- /// Check whether this memory chunk is external.
- /// </summary>
- /// <param name="memPtr">Memory pointer.</param>
- /// <returns><c>True</c> if owned by Java.</returns>
- public static bool IsExternal(long memPtr)
- {
- return IsExternal(GetFlags(memPtr));
- }
-
- /// <summary>
/// Check whether flags denote that this memory chunk is external.
/// </summary>
/// <param name="flags">Flags.</param>
@@ -158,16 +138,6 @@ namespace Apache.Ignite.Core.Impl.Memory
}
/// <summary>
- /// Check whether this memory chunk is pooled.
- /// </summary>
- /// <param name="memPtr">Memory pointer.</param>
- /// <returns><c>True</c> if pooled.</returns>
- public static bool IsPooled(long memPtr)
- {
- return IsPooled(GetFlags(memPtr));
- }
-
- /// <summary>
/// Check whether flags denote pooled memory chunk.
/// </summary>
/// <param name="flags">Flags.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
index 8e54261..f252ef3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
@@ -52,6 +52,7 @@ namespace Apache.Ignite.Core.Impl.Memory
}
/** <inheritdoc /> */
+ [ExcludeFromCodeCoverage]
public long Pointer
{
get { throw new NotSupportedException(); }
@@ -73,10 +74,13 @@ namespace Apache.Ignite.Core.Impl.Memory
public int Length
{
get { return _size; }
+
+ [ExcludeFromCodeCoverage]
set { throw new NotSupportedException(); }
}
/** <inheritdoc /> */
+ [ExcludeFromCodeCoverage]
public void Reallocate(int cap)
{
throw new NotSupportedException();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index 26b6033..f757cbc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -798,13 +798,5 @@ namespace Apache.Ignite.Core.Impl
if (_disposed)
throw new ObjectDisposedException(GetType().Name, "Object has been disposed.");
}
-
- /// <summary>
- /// Gets a value indicating whether this instance is disposed.
- /// </summary>
- protected bool IsDisposed
- {
- get { return _disposed; }
- }
}
}
[2/2] ignite git commit: IGNITE-3368 .NET: Improve test coverage
Posted by pt...@apache.org.
IGNITE-3368 .NET: Improve test coverage
This closes #953
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4eda7cf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4eda7cf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4eda7cf
Branch: refs/heads/master
Commit: e4eda7cf3a0de5ed3c6e4aaff4180ca80b1a981a
Parents: ecc734c
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Tue Aug 16 18:11:34 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Tue Aug 16 18:11:34 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.csproj | 10 +
.../Binary/BinaryBuilderSelfTest.cs | 24 ++-
.../Binary/BinaryReaderWriterTest.cs | 171 +++++++++++++++++
.../Binary/IO/BinaryStreamsTest.cs | 151 +++++++++++++++
.../Cache/Affinity/AffinityKeyTest.cs | 66 +++++++
.../Affinity/AffinityTopologyVersionTest.cs | 59 ++++++
.../Cache/CacheAbstractTest.cs | 62 +++++-
.../Cache/CacheResultTest.cs | 75 ++++++++
.../Continuous/ContinuousQueryAbstractTest.cs | 42 ++--
.../Cache/Store/CacheParallelLoadStoreTest.cs | 2 +-
.../Cache/Store/CacheStoreAdapterTest.cs | 90 +++++++++
.../Cache/Store/CacheTestParallelLoadStore.cs | 9 +
.../Collections/MultiValueDictionaryTest.cs | 58 ++++++
.../Collections/ReadOnlyCollectionTest.cs | 59 ++++++
.../Collections/ReadOnlyDictionaryTest.cs | 70 +++++++
.../Common/IgniteGuidTest.cs | 62 ++++++
.../Compute/AbstractTaskTest.cs | 40 ++--
.../Compute/BinarizableClosureTaskTest.cs | 18 +-
.../Compute/BinarizableTaskTest.cs | 18 +-
.../Compute/CancellationTest.cs | 10 +
.../Compute/ClosureTaskTest.cs | 192 +++++--------------
.../Compute/ComputeApiTest.cs | 53 +++--
.../Compute/FailoverTaskSelfTest.cs | 5 +-
.../Compute/IgniteExceptionTaskSelfTest.cs | 43 ++---
.../Compute/ResourceTaskTest.cs | 51 +++++
.../Compute/SerializableClosureTaskTest.cs | 5 +
.../Compute/TaskAdapterTest.cs | 5 +-
.../Compute/TaskResultTest.cs | 14 +-
.../Config/Compute/compute-standalone.xml | 1 +
.../Apache.Ignite.Core.Tests/EventsTest.cs | 192 +++++++++++++++----
.../Examples/ExamplesTest.cs | 2 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 46 +++++
.../Apache.Ignite.Core.Tests/TestUtils.cs | 3 +
.../Apache.Ignite.Core.csproj | 3 -
.../Cache/Affinity/AffinityKey.cs | 11 ++
.../Cache/CachePartialUpdateException.cs | 6 +-
.../Store/CacheParallelLoadStoreAdapter.cs | 7 +
.../Apache.Ignite.Core/Common/JavaException.cs | 1 +
.../Impl/Binary/BinaryObject.cs | 2 +
.../Impl/Binary/BinaryObjectBuilder.cs | 2 +-
.../Impl/Binary/BinaryObjectHandle.cs | 59 ------
.../Impl/Binary/BinaryObjectHeader.cs | 5 +-
.../Binary/BinarySurrogateTypeDescriptor.cs | 2 +-
.../Impl/Binary/BinaryWriter.cs | 20 --
.../Impl/Binary/Io/BinaryStreamAdapter.cs | 5 +
.../Impl/Binary/Io/BinaryStreamBase.cs | 11 +-
.../Impl/Binary/Io/IBinaryStream.cs | 2 +-
.../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs | 11 --
.../Cache/Event/JavaCacheEntryEventFilter.cs | 2 +
.../Impl/Collections/MultiValueDictionary.cs | 26 ---
.../Impl/Collections/ReadOnlyDictionary.cs | 2 +-
.../Impl/Common/ResizeableArray.cs | 64 -------
.../Impl/Events/EventTypeConverter.cs | 3 +
.../Apache.Ignite.Core/Impl/Events/Events.cs | 3 +
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 1 +
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 12 +-
.../Impl/Handle/HandleRegistry.cs | 20 +-
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 5 -
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 1 +
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 22 +--
.../Impl/InteropExceptionHolder.cs | 88 ---------
.../Impl/Memory/PlatformMemoryUtils.cs | 30 ---
.../Impl/Memory/PlatformRawMemory.cs | 4 +
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 8 -
64 files changed, 1464 insertions(+), 682 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 29dc81b..c4dcbae 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -56,6 +56,16 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Binary\BinaryReaderWriterTest.cs" />
+ <Compile Include="Binary\IO\BinaryStreamsTest.cs" />
+ <Compile Include="Cache\Affinity\AffinityKeyTest.cs" />
+ <Compile Include="Cache\Affinity\AffinityTopologyVersionTest.cs" />
+ <Compile Include="Cache\CacheResultTest.cs" />
+ <Compile Include="Cache\Store\CacheStoreAdapterTest.cs" />
+ <Compile Include="Collections\MultiValueDictionaryTest.cs" />
+ <Compile Include="Collections\ReadOnlyCollectionTest.cs" />
+ <Compile Include="Collections\ReadOnlyDictionaryTest.cs" />
+ <Compile Include="Common\IgniteGuidTest.cs" />
<Compile Include="Log\DefaultLoggerTest.cs" />
<Compile Include="TestAppConfig.cs" />
<Compile Include="AspNet\IgniteOutputCacheProviderTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index 80788a6..c280255 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Tests.Binary
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+ using System.Text.RegularExpressions;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Binary;
@@ -590,6 +591,23 @@ namespace Apache.Ignite.Core.Tests.Binary
}
/// <summary>
+ /// Tests equality and formatting members.
+ /// </summary>
+ [Test]
+ public void TestEquality()
+ {
+ var bin = _grid.GetBinary();
+
+ var obj1 = bin.GetBuilder("myType").SetStringField("str", "foo").SetIntField("int", 1).Build();
+ var obj2 = bin.GetBuilder("myType").SetStringField("str", "foo").SetIntField("int", 1).Build();
+
+ Assert.AreEqual(obj1, obj2);
+ Assert.AreEqual(obj1.GetHashCode(), obj2.GetHashCode());
+
+ Assert.IsTrue(Regex.IsMatch(obj1.ToString(), @"myType \[idHash=[0-9]+, str=foo, int=1\]"));
+ }
+
+ /// <summary>
/// Test primitive fields setting.
/// </summary>
[Test]
@@ -1617,9 +1635,13 @@ namespace Apache.Ignite.Core.Tests.Binary
foreach (var binEnum in binEnums)
{
Assert.IsTrue(binEnum.GetBinaryType().IsEnum);
+
Assert.AreEqual(val, binEnum.EnumValue);
- Assert.AreEqual((TestEnumRegistered)val, binEnum.Deserialize<TestEnumRegistered>());
+
+ Assert.AreEqual((TestEnumRegistered) val, binEnum.Deserialize<TestEnumRegistered>());
}
+
+ Assert.AreEqual(binEnums[0], binEnums[1]);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
new file mode 100644
index 0000000..e4cff1b
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryReaderWriterTest.cs
@@ -0,0 +1,171 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Binary
+{
+ using System;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests the <see cref="Impl.Binary.BinaryReader"/> and <see cref="Impl.Binary.BinaryWriter"/> classes.
+ /// </summary>
+ public class BinaryReaderWriterTest
+ {
+ /// <summary>
+ /// Tests all read/write methods.
+ /// </summary>
+ [Test]
+ public void TestWriteRead()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration(typeof(ReadWriteAll)));
+
+ marsh.Unmarshal<ReadWriteAll>(marsh.Marshal(new ReadWriteAll()));
+ }
+
+ private class ReadWriteAll : IBinarizable
+ {
+ private static readonly DateTime Date = DateTime.UtcNow;
+
+ private static readonly Guid Guid = Guid.NewGuid();
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteByte("Byte", 1);
+ writer.WriteByteArray("ByteArray", new byte[] {1});
+ writer.WriteChar("Char", '1');
+ writer.WriteCharArray("CharArray", new[] {'1'});
+ writer.WriteShort("Short", 1);
+ writer.WriteShortArray("ShortArray", new short[] {1});
+ writer.WriteInt("Int", 1);
+ writer.WriteIntArray("IntArray", new[] {1});
+ writer.WriteLong("Long", 1);
+ writer.WriteLongArray("LongArray", new long[] {1});
+ writer.WriteBoolean("Boolean", true);
+ writer.WriteBooleanArray("BooleanArray", new[] {true});
+ writer.WriteFloat("Float", 1);
+ writer.WriteFloatArray("FloatArray", new float[] {1});
+ writer.WriteDouble("Double", 1);
+ writer.WriteDoubleArray("DoubleArray", new double[] {1});
+ writer.WriteDecimal("Decimal", 1);
+ writer.WriteDecimalArray("DecimalArray", new decimal?[] {1});
+ writer.WriteTimestamp("Timestamp", Date);
+ writer.WriteTimestampArray("TimestampArray", new DateTime?[] {Date});
+ writer.WriteString("String", "1");
+ writer.WriteStringArray("StringArray", new[] {"1"});
+ writer.WriteGuid("Guid", Guid);
+ writer.WriteGuidArray("GuidArray", new Guid?[] {Guid});
+ writer.WriteEnum("Enum", MyEnum.Bar);
+ writer.WriteEnumArray("EnumArray", new[] {MyEnum.Bar});
+
+ var raw = writer.GetRawWriter();
+
+ raw.WriteByte(1);
+ raw.WriteByteArray(new byte[] {1});
+ raw.WriteChar('1');
+ raw.WriteCharArray(new[] {'1'});
+ raw.WriteShort(1);
+ raw.WriteShortArray(new short[] {1});
+ raw.WriteInt(1);
+ raw.WriteIntArray(new[] {1});
+ raw.WriteLong(1);
+ raw.WriteLongArray(new long[] {1});
+ raw.WriteBoolean(true);
+ raw.WriteBooleanArray(new[] {true});
+ raw.WriteFloat(1);
+ raw.WriteFloatArray(new float[] {1});
+ raw.WriteDouble(1);
+ raw.WriteDoubleArray(new double[] {1});
+ raw.WriteDecimal(1);
+ raw.WriteDecimalArray(new decimal?[] {1});
+ raw.WriteTimestamp(Date);
+ raw.WriteTimestampArray(new DateTime?[] {Date});
+ raw.WriteString("1");
+ raw.WriteStringArray(new[] {"1"});
+ raw.WriteGuid(Guid);
+ raw.WriteGuidArray(new Guid?[] {Guid});
+ raw.WriteEnum(MyEnum.Bar);
+ raw.WriteEnumArray(new[] {MyEnum.Bar});
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Assert.AreEqual(1, reader.ReadByte("Byte"));
+ Assert.AreEqual(new byte[] {1}, reader.ReadByteArray("ByteArray"));
+ Assert.AreEqual('1', reader.ReadChar("Char"));
+ Assert.AreEqual(new[] {'1'}, reader.ReadCharArray("CharArray"));
+ Assert.AreEqual(1, reader.ReadShort("Short"));
+ Assert.AreEqual(new short[] {1}, reader.ReadShortArray("ShortArray"));
+ Assert.AreEqual(1, reader.ReadInt("Int"));
+ Assert.AreEqual(new[] {1}, reader.ReadIntArray("IntArray"));
+ Assert.AreEqual(1, reader.ReadLong("Long"));
+ Assert.AreEqual(new long[] {1}, reader.ReadLongArray("LongArray"));
+ Assert.AreEqual(true, reader.ReadBoolean("Boolean"));
+ Assert.AreEqual(new[] {true}, reader.ReadBooleanArray("BooleanArray"));
+ Assert.AreEqual(1, reader.ReadFloat("Float"));
+ Assert.AreEqual(new float[] {1}, reader.ReadFloatArray("FloatArray"));
+ Assert.AreEqual(1, reader.ReadDouble("Double"));
+ Assert.AreEqual(new double[] {1}, reader.ReadDoubleArray("DoubleArray"));
+ Assert.AreEqual(1, reader.ReadDecimal("Decimal"));
+ Assert.AreEqual(new decimal?[] {1}, reader.ReadDecimalArray("DecimalArray"));
+ Assert.AreEqual(Date, reader.ReadTimestamp("Timestamp"));
+ Assert.AreEqual(new DateTime?[] {Date}, reader.ReadTimestampArray("TimestampArray"));
+ Assert.AreEqual("1", reader.ReadString("String"));
+ Assert.AreEqual(new[] {"1"}, reader.ReadStringArray("StringArray"));
+ Assert.AreEqual(Guid, reader.ReadGuid("Guid"));
+ Assert.AreEqual(new Guid?[] {Guid}, reader.ReadGuidArray("GuidArray"));
+ Assert.AreEqual(MyEnum.Bar, reader.ReadEnum<MyEnum>("Enum"));
+ Assert.AreEqual(new[] {MyEnum.Bar}, reader.ReadEnumArray<MyEnum>("EnumArray"));
+
+ var raw = reader.GetRawReader();
+
+ Assert.AreEqual(1, raw.ReadByte());
+ Assert.AreEqual(new byte[] { 1 }, raw.ReadByteArray());
+ Assert.AreEqual('1', raw.ReadChar());
+ Assert.AreEqual(new[] { '1' }, raw.ReadCharArray());
+ Assert.AreEqual(1, raw.ReadShort());
+ Assert.AreEqual(new short[] { 1 }, raw.ReadShortArray());
+ Assert.AreEqual(1, raw.ReadInt());
+ Assert.AreEqual(new[] { 1 }, raw.ReadIntArray());
+ Assert.AreEqual(1, raw.ReadLong());
+ Assert.AreEqual(new long[] { 1 }, raw.ReadLongArray());
+ Assert.AreEqual(true, raw.ReadBoolean());
+ Assert.AreEqual(new[] { true }, raw.ReadBooleanArray());
+ Assert.AreEqual(1, raw.ReadFloat());
+ Assert.AreEqual(new float[] { 1 }, raw.ReadFloatArray());
+ Assert.AreEqual(1, raw.ReadDouble());
+ Assert.AreEqual(new double[] { 1 }, raw.ReadDoubleArray());
+ Assert.AreEqual(1, raw.ReadDecimal());
+ Assert.AreEqual(new decimal?[] { 1 }, raw.ReadDecimalArray());
+ Assert.AreEqual(Date, raw.ReadTimestamp());
+ Assert.AreEqual(new DateTime?[] { Date }, raw.ReadTimestampArray());
+ Assert.AreEqual("1", raw.ReadString());
+ Assert.AreEqual(new[] { "1" }, raw.ReadStringArray());
+ Assert.AreEqual(Guid, raw.ReadGuid());
+ Assert.AreEqual(new Guid?[] { Guid }, raw.ReadGuidArray());
+ Assert.AreEqual(MyEnum.Bar, raw.ReadEnum<MyEnum>());
+ Assert.AreEqual(new[] { MyEnum.Bar }, raw.ReadEnumArray<MyEnum>());
+ }
+ }
+
+ private enum MyEnum
+ {
+ Bar
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/IO/BinaryStreamsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/IO/BinaryStreamsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/IO/BinaryStreamsTest.cs
new file mode 100644
index 0000000..ad5358d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/IO/BinaryStreamsTest.cs
@@ -0,0 +1,151 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Binary.IO
+{
+ using System;
+ using System.IO;
+ using System.Text;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+ using Apache.Ignite.Core.Impl.Memory;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests binary streams.
+ /// </summary>
+ public class BinaryStreamsTest
+ {
+ /// <summary>
+ /// Tests the platform memory stream.
+ /// </summary>
+ [Test]
+ public void TestPlatformMemoryStream()
+ {
+ var stream = new PlatformMemoryStream(GetMemory());
+ TestStream(stream, false, () => stream.SynchronizeOutput());
+ }
+
+ /// <summary>
+ /// Tests the platform big endian memory stream.
+ /// </summary>
+ [Test]
+ public void TestPlatformBigEndianMemoryStream()
+ {
+ var stream = new PlatformBigEndianMemoryStream(GetMemory());
+ TestStream(stream, false, () => stream.SynchronizeOutput());
+ }
+
+ /// <summary>
+ /// Tests the binary heap stream.
+ /// </summary>
+ [Test]
+ public void TestBinaryHeapStream()
+ {
+ TestStream(new BinaryHeapStream(1), true, () => { });
+ }
+
+ /// <summary>
+ /// Gets the memory.
+ /// </summary>
+ private static PlatformMemory GetMemory()
+ {
+ return new PlatformMemoryPool().Allocate(10);
+ }
+
+ /// <summary>
+ /// Tests the stream.
+ /// </summary>
+ private static unsafe void TestStream(IBinaryStream stream, bool sameArr, Action flush)
+ {
+ Action seek = () => Assert.AreEqual(0, stream.Seek(0, SeekOrigin.Begin));
+
+ Action<Action, Func<object>, object> check = (write, read, expectedResult) =>
+ {
+ seek();
+ write();
+ flush();
+ seek();
+ Assert.AreEqual(expectedResult, read());
+ };
+
+ // Arrays.
+ Assert.AreEqual(sameArr, stream.IsSameArray(stream.GetArray()));
+ Assert.IsFalse(stream.IsSameArray(new byte[1]));
+ Assert.IsFalse(stream.IsSameArray(stream.GetArrayCopy()));
+
+ // byte*
+ byte* bytes = stackalloc byte[10];
+ *bytes = 1;
+ *(bytes + 1) = 2;
+
+ stream.Write(bytes, 2);
+ Assert.AreEqual(2, stream.Position);
+ flush();
+
+ seek();
+ Assert.AreEqual(sameArr ? 256 : 2, stream.Remaining);
+ byte* bytes2 = stackalloc byte[2];
+ stream.Read(bytes2, 2);
+ Assert.AreEqual(1, *bytes2);
+ Assert.AreEqual(2, *(bytes2 + 1));
+
+ // char*
+ seek();
+ char* chars = stackalloc char[10];
+ *chars = 'a';
+ *(chars + 1) = 'b';
+
+ Assert.AreEqual(2, stream.WriteString(chars, 2, 2, Encoding.ASCII));
+ flush();
+
+ seek();
+ stream.Read(bytes2, 2);
+ Assert.AreEqual('a', *bytes2);
+ Assert.AreEqual('b', *(bytes2 + 1));
+
+ // Others.
+ check(() => stream.Write(new byte[] {3, 4, 5}, 1, 2), () => stream.ReadByteArray(2), new byte[] {4, 5});
+
+ check(() => stream.WriteBool(true), () => stream.ReadBool(), true);
+ check(() => stream.WriteBoolArray(new[] {true, false}), () => stream.ReadBoolArray(2),
+ new[] {true, false});
+
+ check(() => stream.WriteByte(4), () => stream.ReadByte(), 4);
+ check(() => stream.WriteByteArray(new byte[] {4, 5, 6}), () => stream.ReadByteArray(3),
+ new byte[] {4, 5, 6});
+
+ check(() => stream.WriteChar('x'), () => stream.ReadChar(), 'x');
+ check(() => stream.WriteCharArray(new[] {'a', 'b'}), () => stream.ReadCharArray(2), new[] {'a', 'b'});
+
+ check(() => stream.WriteDouble(4), () => stream.ReadDouble(), 4d);
+ check(() => stream.WriteDoubleArray(new[] {4d}), () => stream.ReadDoubleArray(1), new[] {4d});
+
+ check(() => stream.WriteFloat(4), () => stream.ReadFloat(), 4f);
+ check(() => stream.WriteFloatArray(new[] {4f}), () => stream.ReadFloatArray(1), new[] {4f});
+
+ check(() => stream.WriteInt(4), () => stream.ReadInt(), 4);
+ check(() => stream.WriteInt(0, 4), () => stream.ReadInt(), 4);
+ check(() => stream.WriteIntArray(new[] {4}), () => stream.ReadIntArray(1), new[] {4});
+
+ check(() => stream.WriteLong(4), () => stream.ReadLong(), 4L);
+ check(() => stream.WriteLongArray(new[] {4L}), () => stream.ReadLongArray(1), new[] {4L});
+
+ check(() => stream.WriteShort(4), () => stream.ReadShort(), (short)4);
+ check(() => stream.WriteShortArray(new short[] {4}), () => stream.ReadShortArray(1), new short[] {4});
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityKeyTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityKeyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityKeyTest.cs
new file mode 100644
index 0000000..cf86273
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityKeyTest.cs
@@ -0,0 +1,66 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Affinity
+{
+ using Apache.Ignite.Core.Cache.Affinity;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="AffinityKey"/>
+ /// </summary>
+ public class AffinityKeyTest
+ {
+ /// <summary>
+ /// Tests the equality.
+ /// </summary>
+ [Test]
+ public void TestEquality()
+ {
+ // Default.
+ var key = new AffinityKey();
+
+ Assert.IsNull(key.Key);
+ Assert.IsNull(key.Affinity);
+ Assert.AreEqual(0, key.GetHashCode());
+ Assert.AreEqual(new AffinityKey(), key);
+
+ // Ctor 1.
+ const string myKey = "myKey";
+ key = new AffinityKey(myKey);
+
+ Assert.AreEqual(myKey, key.Key);
+ Assert.AreEqual(myKey, key.Affinity);
+ Assert.AreNotEqual(0, key.GetHashCode());
+
+ // Ctor 2.
+ var ver1 = new AffinityKey(long.MaxValue, int.MaxValue);
+ var ver2 = new AffinityKey(long.MaxValue, int.MaxValue);
+
+ Assert.AreEqual(ver1, ver2);
+ Assert.IsTrue(ver1 == ver2);
+ Assert.IsFalse(ver1 != ver2);
+
+ Assert.AreNotEqual(key, ver1);
+ Assert.IsTrue(key != ver1);
+ Assert.IsFalse(key == ver1);
+
+ // ToString.
+ Assert.AreEqual("AffinityKey [Key=1, Affinity=2]", new AffinityKey(1, 2).ToString());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTopologyVersionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTopologyVersionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTopologyVersionTest.cs
new file mode 100644
index 0000000..de25ea4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTopologyVersionTest.cs
@@ -0,0 +1,59 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Affinity
+{
+ using Apache.Ignite.Core.Cache.Affinity;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="AffinityTopologyVersion"/>
+ /// </summary>
+ public class AffinityTopologyVersionTest
+ {
+ /// <summary>
+ /// Tests the equality.
+ /// </summary>
+ [Test]
+ public void TestEquality()
+ {
+ // Default.
+ var ver = new AffinityTopologyVersion();
+
+ Assert.AreEqual(0, ver.Version);
+ Assert.AreEqual(0, ver.MinorVersion);
+ Assert.AreEqual(0, ver.GetHashCode());
+ Assert.AreEqual(new AffinityTopologyVersion(), ver);
+
+ // Custom.
+ var ver1 = new AffinityTopologyVersion(long.MaxValue, int.MaxValue);
+ var ver2 = new AffinityTopologyVersion(long.MaxValue, int.MaxValue);
+
+ Assert.AreEqual(ver1, ver2);
+ Assert.IsTrue(ver1 == ver2);
+ Assert.IsFalse(ver1 != ver2);
+
+ Assert.AreNotEqual(ver, ver1);
+ Assert.IsTrue(ver != ver1);
+ Assert.IsFalse(ver == ver1);
+
+ // ToString.
+ Assert.AreEqual("AffinityTopologyVersion [Version=1, MinorVersion=2]",
+ new AffinityTopologyVersion(1, 2).ToString());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 62dc2df..5fb2cdd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -29,7 +29,6 @@ namespace Apache.Ignite.Core.Tests.Cache
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Cache;
using Apache.Ignite.Core.Tests.Query;
using Apache.Ignite.Core.Transactions;
@@ -991,10 +990,8 @@ namespace Apache.Ignite.Core.Tests.Cache
key1 = PrimaryKeyForCache(Cache(1));
}
- var cache = cache0.WithExpiryPolicy(new ExpiryPolicy(null, null, null));
-
// Test zero expiration.
- cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero));
+ var cache = cache0.WithExpiryPolicy(new ExpiryPolicy(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero));
cache.Put(key0, key0);
cache.Put(key1, key1);
@@ -1889,6 +1886,50 @@ namespace Apache.Ignite.Core.Tests.Cache
}, threads);
}
+ /// <summary>
+ /// Simple cache lock test (while <see cref="TestLock"/> is ignored).
+ /// </summary>
+ [Test]
+ public void TestLockSimple()
+ {
+ if (!LockingEnabled())
+ return;
+
+ var cache = Cache();
+
+ const int key = 7;
+
+ Action<ICacheLock> checkLock = lck =>
+ {
+ using (lck)
+ {
+ Assert.Throws<InvalidOperationException>(lck.Exit); // can't exit if not entered
+
+ lck.Enter();
+
+ Assert.IsTrue(cache.IsLocalLocked(key, true));
+ Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+ lck.Exit();
+
+ Assert.IsFalse(cache.IsLocalLocked(key, true));
+ Assert.IsFalse(cache.IsLocalLocked(key, false));
+
+ Assert.IsTrue(lck.TryEnter());
+
+ Assert.IsTrue(cache.IsLocalLocked(key, true));
+ Assert.IsTrue(cache.IsLocalLocked(key, false));
+
+ lck.Exit();
+ }
+
+ Assert.Throws<ObjectDisposedException>(lck.Enter); // Can't enter disposed lock
+ };
+
+ checkLock(cache.Lock(key));
+ checkLock(cache.LockAll(new[] {key, 1, 2, 3}));
+ }
+
[Test]
[Ignore("IGNITE-835")]
public void TestLock()
@@ -1994,7 +2035,7 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// ENsure taht lock cannot be obtained by other threads.
+ /// Ensure that lock cannot be obtained by other threads.
/// </summary>
/// <param name="getLock">Get lock function.</param>
/// <param name="sharedLock">Shared lock.</param>
@@ -2375,10 +2416,15 @@ namespace Apache.Ignite.Core.Tests.Cache
return;
var tx = Transactions.TxStart();
-
+
Assert.AreEqual(TransactionState.Active, tx.State);
+ Assert.AreEqual(Thread.CurrentThread.ManagedThreadId, tx.ThreadId);
- tx.Rollback();
+ tx.AddMeta("myMeta", 42);
+ Assert.AreEqual(42, tx.Meta<int>("myMeta"));
+ Assert.AreEqual(42, tx.RemoveMeta<int>("myMeta"));
+
+ tx.RollbackAsync().Wait();
Assert.AreEqual(TransactionState.RolledBack, tx.State);
@@ -3302,7 +3348,7 @@ namespace Apache.Ignite.Core.Tests.Cache
return true;
}
- protected virtual bool LockingEnabled()
+ protected bool LockingEnabled()
{
return TxEnabled();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheResultTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheResultTest.cs
new file mode 100644
index 0000000..6be26bf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheResultTest.cs
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Cache;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// <see cref="CacheResult{T}"/> tests.
+ /// </summary>
+ public class CacheResultTest
+ {
+ /// <summary>
+ /// Tests equality members.
+ /// </summary>
+ [Test]
+ public void TestEquality()
+ {
+ var entry1 = new CacheResult<int>(2);
+ var entry2 = new CacheResult<int>(2);
+ var entry3 = new CacheResult<int>(3);
+
+ Assert.AreEqual(entry1, entry2);
+ Assert.AreNotEqual(entry1, entry3);
+
+ Assert.IsTrue(entry1 == entry2);
+ Assert.IsFalse(entry1 != entry2);
+
+ Assert.IsTrue(entry1 != entry3);
+ Assert.IsFalse(entry1 == entry3);
+
+ var boxedEntry1 = (object) entry1;
+ var boxedEntry2 = (object) entry2;
+ var boxedEntry3 = (object) entry3;
+
+ Assert.IsFalse(ReferenceEquals(boxedEntry1, boxedEntry2));
+
+ Assert.AreEqual(boxedEntry1, boxedEntry2);
+ Assert.AreNotEqual(boxedEntry1, boxedEntry3);
+ }
+
+ /// <summary>
+ /// Tests with hash data structures.
+ /// </summary>
+ [Test]
+ public void TestHashCode()
+ {
+ var entry1 = new CacheResult<int>(2);
+ var entry2 = new CacheResult<int>(2);
+ var entry3 = new CacheResult<int>(3);
+
+ var set = new HashSet<object> {entry1};
+
+ Assert.IsTrue(set.Contains(entry1));
+ Assert.IsTrue(set.Contains(entry2));
+ Assert.IsFalse(set.Contains(entry3));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index 4b285f9..270c3fc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -181,11 +181,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
{
// Put from local node.
cache1.GetAndPut(key1, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1), CacheEntryEventType.Created);
// Put from remote node.
cache2.GetAndPut(key2, Entry(key2));
- CheckCallbackSingle(key2, null, Entry(key2));
+ CheckCallbackSingle(key2, null, Entry(key2), CacheEntryEventType.Created);
}
qryHnd.Dispose();
@@ -217,13 +217,13 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
{
// Put from local node.
cache1.GetAndPut(key1, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1), CacheEntryEventType.Created);
cache1.GetAndPut(key1, Entry(key1 + 1));
- CheckCallbackSingle(key1, Entry(key1), Entry(key1 + 1));
+ CheckCallbackSingle(key1, Entry(key1), Entry(key1 + 1), CacheEntryEventType.Updated);
cache1.Remove(key1);
- CheckCallbackSingle(key1, Entry(key1 + 1), null);
+ CheckCallbackSingle(key1, Entry(key1 + 1), null, CacheEntryEventType.Removed);
// Put from remote node.
cache2.GetAndPut(key2, Entry(key2));
@@ -231,21 +231,21 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
if (loc)
CheckNoCallback(100);
else
- CheckCallbackSingle(key2, null, Entry(key2));
+ CheckCallbackSingle(key2, null, Entry(key2), CacheEntryEventType.Created);
cache1.GetAndPut(key2, Entry(key2 + 1));
if (loc)
CheckNoCallback(100);
else
- CheckCallbackSingle(key2, Entry(key2), Entry(key2 + 1));
+ CheckCallbackSingle(key2, Entry(key2), Entry(key2 + 1), CacheEntryEventType.Updated);
cache1.Remove(key2);
if (loc)
CheckNoCallback(100);
else
- CheckCallbackSingle(key2, Entry(key2 + 1), null);
+ CheckCallbackSingle(key2, Entry(key2 + 1), null, CacheEntryEventType.Removed);
}
cache1.Put(key1, Entry(key1));
@@ -310,7 +310,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
cache1.GetAndPut(key1, Entry(key1));
CheckFilterSingle(key1, null, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1), CacheEntryEventType.Created);
// Put from remote node.
int key2 = PrimaryKey(cache2);
@@ -324,7 +324,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
else
{
CheckFilterSingle(key2, null, Entry(key2));
- CheckCallbackSingle(key2, null, Entry(key2));
+ CheckCallbackSingle(key2, null, Entry(key2), CacheEntryEventType.Created);
}
AbstractFilter<BinarizableEntry>.res = false;
@@ -755,12 +755,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
{
// Put from local node.
cache1.GetAndPut(key1, Entry(key1));
- CheckCallbackSingle(key1, null, Entry(key1));
+ CheckCallbackSingle(key1, null, Entry(key1), CacheEntryEventType.Created);
// Put from remote node.
cache1.GetAndPut(key2, Entry(key2));
CheckNoCallback(100);
- CheckCallbackSingle(key2, null, Entry(key2), 1000);
+ CheckCallbackSingle(key2, null, Entry(key2), CacheEntryEventType.Created);
}
}
@@ -851,7 +851,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
// Check continuous query
cache1.Put(44, Entry(44));
- CheckCallbackSingle(44, null, Entry(44));
+ CheckCallbackSingle(44, null, Entry(44), CacheEntryEventType.Created);
}
Assert.Throws<ObjectDisposedException>(() => contQry.GetInitialQueryCursor());
@@ -922,19 +922,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expKey">Expected key.</param>
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected new value.</param>
- private static void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal)
- {
- CheckCallbackSingle(expKey, expOldVal, expVal, 1000);
- }
-
- /// <summary>
- /// Check single callback event.
- /// </summary>
- /// <param name="expKey">Expected key.</param>
- /// <param name="expOldVal">Expected old value.</param>
- /// <param name="expVal">Expected new value.</param>
+ /// <param name="expType">Expected type.</param>
/// <param name="timeout">Timeout.</param>
- private static void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal, int timeout)
+ private static void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal,
+ CacheEntryEventType expType, int timeout = 1000)
{
CallbackEvent evt;
@@ -946,6 +937,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
Assert.AreEqual(expKey, e.Key);
Assert.AreEqual(expOldVal, e.OldValue);
Assert.AreEqual(expVal, e.Value);
+ Assert.AreEqual(expType, e.EventType);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
index 4aa910c..105dea2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheParallelLoadStoreTest.cs
@@ -96,7 +96,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
}
// check that items were processed in parallel
- Assert.GreaterOrEqual(CacheTestParallelLoadStore.UniqueThreadCount, Environment.ProcessorCount);
+ Assert.GreaterOrEqual(CacheTestParallelLoadStore.UniqueThreadCount, Environment.ProcessorCount - 1);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreAdapterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreAdapterTest.cs
new file mode 100644
index 0000000..6690584
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreAdapterTest.cs
@@ -0,0 +1,90 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache.Store
+{
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Cache.Store;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="CacheStoreAdapter"/>.
+ /// </summary>
+ public class CacheStoreAdapterTest
+ {
+ /// <summary>
+ /// Tests the load write delete.
+ /// </summary>
+ [Test]
+ public void TestLoadWriteDelete()
+ {
+ var store = new Store();
+
+ store.LoadCache(null);
+ Assert.IsEmpty(store.Map);
+
+ var data = Enumerable.Range(1, 5).ToDictionary(x => x, x => x.ToString());
+
+ // Write.
+ store.WriteAll(data);
+ Assert.AreEqual(data, store.Map);
+
+ // Load.
+ CollectionAssert.AreEqual(data, store.LoadAll(data.Keys));
+ CollectionAssert.AreEqual(data.Where(x => x.Key < 3).ToDictionary(x => x.Key, x => x.Value),
+ store.LoadAll(data.Keys.Where(x => x < 3).ToList()));
+
+ // Delete.
+ var removed = new[] {3, 5};
+
+ foreach (var key in removed)
+ data.Remove(key);
+
+ store.DeleteAll(removed);
+ CollectionAssert.AreEqual(data, store.LoadAll(data.Keys));
+ }
+
+ /// <summary>
+ /// Test store.
+ /// </summary>
+ private class Store : CacheStoreAdapter
+ {
+ /** */
+ public readonly Dictionary<object, object> Map = new Dictionary<object, object>();
+
+ /** <inheritdoc /> */
+ public override object Load(object key)
+ {
+ object res;
+ return Map.TryGetValue(key, out res) ? res : null;
+ }
+
+ /** <inheritdoc /> */
+ public override void Write(object key, object val)
+ {
+ Map[key] = val;
+ }
+
+ /** <inheritdoc /> */
+ public override void Delete(object key)
+ {
+ Map.Remove(key);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
index 770ca83..81b4697 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheTestParallelLoadStore.cs
@@ -17,6 +17,7 @@
namespace Apache.Ignite.Core.Tests.Cache.Store
{
+ using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -36,6 +37,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
private static readonly ConcurrentDictionary<int, int> ThreadIds = new ConcurrentDictionary<int, int>();
/// <summary>
+ /// Initializes a new instance of the <see cref="CacheTestParallelLoadStore"/> class.
+ /// </summary>
+ public CacheTestParallelLoadStore()
+ {
+ MaxDegreeOfParallelism -= 1;
+ }
+
+ /// <summary>
/// Gets the count of unique threads that entered Parse method.
/// </summary>
public static int UniqueThreadCount
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/MultiValueDictionaryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/MultiValueDictionaryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/MultiValueDictionaryTest.cs
new file mode 100644
index 0000000..aa3e2aa
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/MultiValueDictionaryTest.cs
@@ -0,0 +1,58 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Collections
+{
+ using Apache.Ignite.Core.Impl.Collections;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests the <see cref="MultiValueDictionary{TKey,TValue}"/>.
+ /// </summary>
+ public class MultiValueDictionaryTest
+ {
+ /// <summary>
+ /// Tests the dictionary.
+ /// </summary>
+ [Test]
+ public void TestMultiValueDictionary()
+ {
+ var dict = new MultiValueDictionary<int, int>();
+
+ dict.Add(1, 1);
+ dict.Add(1, 2);
+
+ int val;
+
+ Assert.IsTrue(dict.TryRemove(1, out val));
+ Assert.AreEqual(2, val);
+
+ Assert.IsTrue(dict.TryRemove(1, out val));
+ Assert.AreEqual(1, val);
+
+ Assert.IsFalse(dict.TryRemove(1, out val));
+
+ dict.Add(2, 1);
+ dict.Add(2, 2);
+ dict.Remove(2, 3);
+ dict.Remove(2, 2);
+
+ Assert.IsTrue(dict.TryRemove(2, out val));
+ Assert.AreEqual(1, val);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyCollectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyCollectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyCollectionTest.cs
new file mode 100644
index 0000000..27991a3
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyCollectionTest.cs
@@ -0,0 +1,59 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Collections
+{
+ using System;
+ using System.Collections;
+ using System.Linq;
+ using Apache.Ignite.Core.Impl.Collections;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="ReadOnlyCollection{T}"/>
+ /// </summary>
+ public class ReadOnlyCollectionTest
+ {
+ /// <summary>
+ /// Tests the disctionary.
+ /// </summary>
+ [Test]
+ public void TestCollection()
+ {
+ // Default ctor.
+ var data = Enumerable.Range(1, 5).ToArray();
+ var col = new ReadOnlyCollection<int>(data);
+
+ Assert.AreEqual(5, col.Count);
+ Assert.IsTrue(col.IsReadOnly);
+ CollectionAssert.AreEqual(data, col);
+
+ Assert.IsTrue(col.GetEnumerator().MoveNext());
+ Assert.IsTrue(((IEnumerable) col).GetEnumerator().MoveNext());
+
+ Assert.IsTrue(col.Contains(4));
+
+ var arr = new int[5];
+ col.CopyTo(arr, 0);
+ CollectionAssert.AreEqual(data, arr);
+
+ Assert.Throws<NotSupportedException>(() => col.Add(1));
+ Assert.Throws<NotSupportedException>(() => col.Clear());
+ Assert.Throws<NotSupportedException>(() => col.Remove(1));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyDictionaryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyDictionaryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyDictionaryTest.cs
new file mode 100644
index 0000000..294251a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Collections/ReadOnlyDictionaryTest.cs
@@ -0,0 +1,70 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Collections
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Impl.Collections;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests for <see cref="ReadOnlyDictionary{TKey,TValue}"/>
+ /// </summary>
+ public class ReadOnlyDictionaryTest
+ {
+ /// <summary>
+ /// Tests the disctionary.
+ /// </summary>
+ [Test]
+ public void TestDictionary()
+ {
+ // Default ctor.
+ var data = Enumerable.Range(1, 5).ToDictionary(x => x, x => x.ToString());
+ var dict = new ReadOnlyDictionary<int, string>(data);
+
+ Assert.AreEqual(5, dict.Count);
+ Assert.IsTrue(dict.IsReadOnly);
+ CollectionAssert.AreEqual(data, dict);
+ CollectionAssert.AreEqual(data.Keys, dict.Keys);
+ CollectionAssert.AreEqual(data.Values, dict.Values);
+
+ Assert.IsTrue(dict.GetEnumerator().MoveNext());
+ Assert.IsTrue(((IEnumerable) dict).GetEnumerator().MoveNext());
+
+ Assert.IsTrue(dict.ContainsKey(1));
+ Assert.IsTrue(dict.Contains(new KeyValuePair<int, string>(4, "4")));
+ Assert.AreEqual("3", dict[3]);
+
+ string val;
+ Assert.IsTrue(dict.TryGetValue(2, out val));
+ Assert.AreEqual("2", val);
+
+ var arr = new KeyValuePair<int, string>[5];
+ dict.CopyTo(arr, 0);
+ CollectionAssert.AreEqual(data, arr);
+
+ Assert.Throws<NotSupportedException>(() => dict.Add(1, "2"));
+ Assert.Throws<NotSupportedException>(() => dict.Add(new KeyValuePair<int, string>(1, "2")));
+ Assert.Throws<NotSupportedException>(() => dict.Clear());
+ Assert.Throws<NotSupportedException>(() => dict.Remove(1));
+ Assert.Throws<NotSupportedException>(() => dict.Remove(new KeyValuePair<int, string>(1, "2")));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Common/IgniteGuidTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Common/IgniteGuidTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Common/IgniteGuidTest.cs
new file mode 100644
index 0000000..705faf4
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Common/IgniteGuidTest.cs
@@ -0,0 +1,62 @@
+\ufeff/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Common
+{
+ using System;
+ using Apache.Ignite.Core.Common;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests the <see cref="IgniteGuid"/>.
+ /// </summary>
+ public class IgniteGuidTest
+ {
+ /// <summary>
+ /// Tests the <see cref="IgniteGuid"/>.
+ /// </summary>
+ [Test]
+ public void TestIgniteGuid()
+ {
+ var guid = Guid.NewGuid();
+
+ var id1 = new IgniteGuid(guid, 1);
+ var id2 = new IgniteGuid(guid, 1);
+ var id3 = new IgniteGuid(guid, 2);
+ var id4 = new IgniteGuid(Guid.NewGuid(), 2);
+
+ // Properties.
+ Assert.AreEqual(guid, id1.GlobalId);
+ Assert.AreEqual(1, id1.LocalId);
+ Assert.AreEqual(id1.GetHashCode(), id2.GetHashCode());
+
+ // Equality.
+ Assert.AreEqual(id1, id2);
+ Assert.IsTrue(id1 == id2);
+ Assert.IsFalse(id1 != id2);
+
+ // Inequality.
+ Assert.AreNotEqual(id1, id3);
+ Assert.IsFalse(id1 == id3);
+ Assert.IsTrue(id1 != id3);
+
+ Assert.AreNotEqual(id4, id3);
+ Assert.IsFalse(id4 == id3);
+ Assert.IsTrue(id4 != id3);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
index d31ad43..6bcd010 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -162,30 +162,21 @@ namespace Apache.Ignite.Core.Tests.Compute
/// </summary>
/// <param name="path">Path to Java XML configuration.</param>
/// <returns>Node configuration.</returns>
- protected IgniteConfiguration Configuration(string path)
+ private IgniteConfiguration Configuration(string path)
{
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- if (!_fork)
+ return new IgniteConfiguration
{
- BinaryConfiguration portCfg = new BinaryConfiguration();
-
- ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
-
- GetBinaryTypeConfigurations(portTypeCfgs);
-
- portCfg.TypeConfigurations = portTypeCfgs;
-
- cfg.BinaryConfiguration = portCfg;
- }
-
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
-
- cfg.JvmOptions = TestUtils.TestJavaOptions();
-
- cfg.SpringConfigUrl = path;
-
- return cfg;
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = path,
+ BinaryConfiguration = _fork
+ ? null
+ : new BinaryConfiguration
+ {
+ TypeConfigurations =
+ (GetBinaryTypes() ?? new Type[0]).Select(t => new BinaryTypeConfiguration(t)).ToList()
+ }
+ };
}
/// <summary>
@@ -209,10 +200,9 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
/// Define binary types.
/// </summary>
- /// <param name="portTypeCfgs">Binary type configurations.</param>
- protected virtual void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ protected virtual ICollection<Type> GetBinaryTypes()
{
- // No-op.
+ return null;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
index b881582..c169f1e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
@@ -40,12 +40,15 @@ namespace Apache.Ignite.Core.Tests.Compute
protected BinarizableClosureTaskTest(bool fork) : base(fork) { }
/** <inheritDoc /> */
- protected override void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ protected override ICollection<Type> GetBinaryTypes()
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableOutFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableException)));
+ return new []
+ {
+ typeof(BinarizableOutFunc),
+ typeof(BinarizableFunc),
+ typeof(BinarizableResult),
+ typeof(BinarizableException)
+ };
}
/** <inheritDoc /> */
@@ -76,6 +79,11 @@ namespace Apache.Ignite.Core.Tests.Compute
{
Assert.IsTrue(err != null);
+ var aggregate = err as AggregateException;
+
+ if (aggregate != null)
+ err = aggregate.InnerException;
+
BinarizableException err0 = err as BinarizableException;
Assert.IsTrue(err0 != null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
index 8aa28de..6bdfd9c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
@@ -17,6 +17,7 @@
namespace Apache.Ignite.Core.Tests.Compute
{
+ using System;
using System.Collections.Generic;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cluster;
@@ -71,14 +72,17 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ protected override ICollection<Type> GetBinaryTypes()
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJobArgument)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJobResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableTaskArgument)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableTaskResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJob)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableWrapper)));
+ return new[]
+ {
+ typeof(BinarizableJobResult),
+ typeof(BinarizableTaskArgument),
+ typeof(BinarizableTaskResult),
+ typeof(BinarizableJobArgument),
+ typeof(BinarizableJob),
+ typeof(BinarizableWrapper)
+ };
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/CancellationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/CancellationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/CancellationTest.cs
index bbd1169..19bb40d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/CancellationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/CancellationTest.cs
@@ -68,11 +68,21 @@ namespace Apache.Ignite.Core.Tests.Compute
public void TestClosures()
{
TestClosure((c, t) => c.BroadcastAsync(new ComputeAction(), t));
+ TestClosure((c, t) => c.BroadcastAsync(new ComputeFunc(), t));
+ TestClosure((c, t) => c.BroadcastAsync(new ComputeBiFunc(), 10, t));
+
TestClosure((c, t) => c.AffinityRunAsync(null, 0, new ComputeAction(), t));
+
TestClosure((c, t) => c.RunAsync(new ComputeAction(), t));
TestClosure((c, t) => c.RunAsync(Enumerable.Range(1, 10).Select(x => new ComputeAction()), t));
+
TestClosure((c, t) => c.CallAsync(new ComputeFunc(), t));
+ TestClosure((c, t) => c.CallAsync(Enumerable.Range(1, 10).Select(x => new ComputeFunc()), t));
+ TestClosure((c, t) => c.CallAsync(Enumerable.Range(1, 10).Select(x => new ComputeFunc()),
+ new ComputeReducer(), t));
+
TestClosure((c, t) => c.AffinityCallAsync(null, 0, new ComputeFunc(), t));
+
TestClosure((c, t) => c.ApplyAsync(new ComputeBiFunc(), 10, t));
TestClosure((c, t) => c.ApplyAsync(new ComputeBiFunc(), Enumerable.Range(1, 100), t));
TestClosure((c, t) => c.ApplyAsync(new ComputeBiFunc(), Enumerable.Range(1, 100), new ComputeReducer(), t));
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
index 8664413..ffb2844 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ClosureTaskTest.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
using System;
using System.Collections.Generic;
+ using System.Linq;
using Apache.Ignite.Core.Compute;
using NUnit.Framework;
@@ -27,7 +28,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// </summary>
public abstract class ClosureTaskTest : AbstractTaskTest
{
- /** Amount of multiple clousres. */
+ /** Amount of multiple closures. */
private const int MultiCloCnt = 5;
/** */
@@ -45,9 +46,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestExecuteSingle()
{
- var res = Grid1.GetCompute().Call(OutFunc(false));
-
- CheckResult(res);
+ CheckResult(Grid1.GetCompute().Call(OutFunc(false)));
+ CheckResult(Grid1.GetCompute().CallAsync(OutFunc(false)).Result);
}
/// <summary>
@@ -56,16 +56,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestExecuteSingleException()
{
- try
- {
- Grid1.GetCompute().Call(OutFunc(true));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Call(OutFunc(true))));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().CallAsync(OutFunc(true)).Wait()));
}
/// <summary>
@@ -74,15 +66,10 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestExecuteMultiple()
{
- var clos = new List<IComputeFunc<object>>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- clos.Add(OutFunc(false));
-
- ICollection<object> ress = Grid1.GetCompute().Call(clos);
+ var clos = Enumerable.Range(0, MultiCloCnt).Select(x => OutFunc(false)).ToArray();
- foreach (object res in ress)
- CheckResult(res);
+ Grid1.GetCompute().Call(clos).ToList().ForEach(CheckResult);
+ Grid1.GetCompute().CallAsync(clos).Result.ToList().ForEach(CheckResult);
}
/// <summary>
@@ -91,15 +78,10 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestExecuteMultipleReduced()
{
- var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+ var clos = Enumerable.Range(0, MultiCloCnt).Select(x => OutFunc(false)).ToArray();
- for (int i = 0; i < MultiCloCnt; i++)
- clos.Add(OutFunc(false));
-
- ICollection<object> ress = Grid1.GetCompute().Call(clos, new Reducer(false));
-
- foreach (object res in ress)
- CheckResult(res);
+ Grid1.GetCompute().Call(clos, new Reducer(false)).ToList().ForEach(CheckResult);
+ Grid1.GetCompute().CallAsync(clos, new Reducer(false)).Result.ToList().ForEach(CheckResult);
}
/// <summary>
@@ -108,21 +90,11 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestExecuteMultipleException()
{
- var clos = new List<IComputeFunc<object>>(MultiCloCnt);
+ // Some closures will be faulty.
+ var clos = Enumerable.Range(0, MultiCloCnt).Select(x => OutFunc(x % 2 == 0)).ToArray();
- for (int i = 0; i < MultiCloCnt; i++)
- clos.Add(OutFunc(i % 2 == 0)); // Some closures will be faulty.
-
- try
- {
- Grid1.GetCompute().Call(clos);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Call(clos)));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().CallAsync(clos).Wait()));
}
/// <summary>
@@ -131,10 +103,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestBroadcastOut()
{
- ICollection<object> ress = Grid1.GetCompute().Broadcast(OutFunc(false));
-
- foreach (object res in ress)
- CheckResult(res);
+ Grid1.GetCompute().Broadcast(OutFunc(false)).ToList().ForEach(CheckResult);
+ Grid1.GetCompute().BroadcastAsync(OutFunc(false)).Result.ToList().ForEach(CheckResult);
}
/// <summary>
@@ -143,16 +113,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestBroadcastOutException()
{
- try
- {
- Grid1.GetCompute().Broadcast(OutFunc(true));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Broadcast(OutFunc(true))));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().BroadcastAsync(OutFunc(true)).Wait()));
}
/// <summary>
@@ -161,10 +123,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestBroadcastInOut()
{
- ICollection<object> ress = Grid1.GetCompute().Broadcast(Func(false), 1);
-
- foreach (object res in ress)
- CheckResult(res);
+ Grid1.GetCompute().Broadcast(Func(false), 1).ToList().ForEach(CheckResult);
+ Grid1.GetCompute().BroadcastAsync(Func(false), 1).Result.ToList().ForEach(CheckResult);
}
/// <summary>
@@ -173,16 +133,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestBroadcastInOutException()
{
- try
- {
- Grid1.GetCompute().Broadcast(Func(true), 1);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Broadcast(Func(true), 1)));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().BroadcastAsync(Func(true), 1).Wait()));
}
/// <summary>
@@ -191,9 +143,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestApply()
{
- object res = Grid1.GetCompute().Apply(Func(false), 1);
-
- CheckResult(res);
+ CheckResult(Grid1.GetCompute().Apply(Func(false), 1));
+ CheckResult(Grid1.GetCompute().ApplyAsync(Func(false), 1).Result);
}
/// <summary>
@@ -202,16 +153,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestApplyException()
{
- try
- {
- Grid1.GetCompute().Apply(Func(true), 1);
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Apply(Func(true), 1)));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().ApplyAsync(Func(true), 1).Wait()));
}
/// <summary>
@@ -220,19 +163,10 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestApplyMultiple()
{
- var args = new List<object>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- Console.WriteLine("START TASK");
-
- var ress = Grid1.GetCompute().Apply(Func(false), args);
+ var args = Enumerable.Repeat(1, MultiCloCnt).Cast<object>().ToArray();
- Console.WriteLine("END TASK.");
-
- foreach (object res in ress)
- CheckResult(res);
+ Grid1.GetCompute().Apply(Func(false), args).ToList().ForEach(CheckResult);
+ Grid1.GetCompute().ApplyAsync(Func(false), args).Result.ToList().ForEach(CheckResult);
}
/// <summary>
@@ -241,21 +175,10 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestApplyMultipleException()
{
- ICollection<int> args = new List<int>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- try
- {
- Grid1.GetCompute().Apply(Func(true), args);
+ var args = Enumerable.Repeat(1, MultiCloCnt).Cast<object>().ToArray();
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Apply(Func(true), args)));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().ApplyAsync(Func(true), args).Wait()));
}
/// <summary>
@@ -264,16 +187,10 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestApplyMultipleReducer()
{
- var args = new List<object>(MultiCloCnt);
+ var args = Enumerable.Repeat(1, MultiCloCnt).Cast<object>().ToArray();
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- ICollection<object> ress =
- Grid1.GetCompute().Apply(Func(false), args, new Reducer(false));
-
- foreach (object res in ress)
- CheckResult(res);
+ Grid1.GetCompute().Apply(Func(false), args, new Reducer(false)).ToList().ForEach(CheckResult);
+ Grid1.GetCompute().ApplyAsync(Func(false), args, new Reducer(false)).Result.ToList().ForEach(CheckResult);
}
/// <summary>
@@ -282,21 +199,10 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestAppylMultipleReducerJobException()
{
- List<object> args = new List<object>(MultiCloCnt);
+ var args = Enumerable.Repeat(1, MultiCloCnt).Cast<object>().ToArray();
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
-
- try
- {
- Grid1.GetCompute().Apply(Func(true), args, new Reducer(false));
-
- Assert.Fail();
- }
- catch (Exception e)
- {
- CheckError(e);
- }
+ CheckError(Assert.Catch(() => Grid1.GetCompute().Apply(Func(true), args, new Reducer(false))));
+ CheckError(Assert.Catch(() => Grid1.GetCompute().ApplyAsync(Func(true), args, new Reducer(false)).Wait()));
}
/// <summary>
@@ -305,23 +211,11 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestAppylMultipleReducerReduceException()
{
- var args = new List<object>(MultiCloCnt);
-
- for (int i = 0; i < MultiCloCnt; i++)
- args.Add(1);
+ var args = Enumerable.Repeat(1, MultiCloCnt).Cast<object>().ToArray();
- try
- {
- Grid1.GetCompute().Apply(Func(false), args, new Reducer(true));
+ var e = Assert.Throws<Exception>(() => Grid1.GetCompute().Apply(Func(false), args, new Reducer(true)));
- Assert.Fail();
- }
- catch (Exception e)
- {
- Assert.AreEqual(typeof(Exception), e.GetType());
-
- Assert.AreEqual(ErrMsg, e.Message);
- }
+ Assert.AreEqual(ErrMsg, e.Message);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index bc26e4c..5a29167 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -187,7 +187,10 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.NotNull(prj);
- Assert.IsTrue(prj == prj.Ignite);
+ Assert.AreEqual(prj, prj.Ignite);
+
+ // Check that default Compute projection excludes client nodes.
+ CollectionAssert.AreEquivalent(prj.ForServers().GetNodes(), prj.GetCompute().ClusterGroup.GetNodes());
}
/// <summary>
@@ -965,9 +968,7 @@ namespace Apache.Ignite.Core.Tests.Compute
compute.WithKeepBinary();
- PlatformComputeNetBinarizable arg = new PlatformComputeNetBinarizable();
-
- arg.Field = 100;
+ PlatformComputeNetBinarizable arg = new PlatformComputeNetBinarizable {Field = 100};
int res = compute.ExecuteJavaTask<int>(BinaryArgTask, arg);
@@ -1010,9 +1011,11 @@ namespace Apache.Ignite.Core.Tests.Compute
public void TestBroadcastAction()
{
var id = Guid.NewGuid();
-
_grid1.GetCompute().Broadcast(new ComputeAction(id));
+ Assert.AreEqual(2, ComputeAction.InvokeCount(id));
+ id = Guid.NewGuid();
+ _grid1.GetCompute().BroadcastAsync(new ComputeAction(id)).Wait();
Assert.AreEqual(2, ComputeAction.InvokeCount(id));
}
@@ -1023,9 +1026,11 @@ namespace Apache.Ignite.Core.Tests.Compute
public void TestRunAction()
{
var id = Guid.NewGuid();
-
_grid1.GetCompute().Run(new ComputeAction(id));
+ Assert.AreEqual(1, ComputeAction.InvokeCount(id));
+ id = Guid.NewGuid();
+ _grid1.GetCompute().RunAsync(new ComputeAction(id)).Wait();
Assert.AreEqual(1, ComputeAction.InvokeCount(id));
}
@@ -1055,12 +1060,12 @@ namespace Apache.Ignite.Core.Tests.Compute
public void TestRunActions()
{
var id = Guid.NewGuid();
-
- var actions = Enumerable.Range(0, 10).Select(x => new ComputeAction(id));
-
- _grid1.GetCompute().Run(actions);
-
+ _grid1.GetCompute().Run(Enumerable.Range(0, 10).Select(x => new ComputeAction(id)));
Assert.AreEqual(10, ComputeAction.InvokeCount(id));
+
+ var id2 = Guid.NewGuid();
+ _grid1.GetCompute().RunAsync(Enumerable.Range(0, 10).Select(x => new ComputeAction(id2))).Wait();
+ Assert.AreEqual(10, ComputeAction.InvokeCount(id2));
}
/// <summary>
@@ -1083,7 +1088,9 @@ namespace Apache.Ignite.Core.Tests.Compute
var affinityKey = _grid1.GetAffinity(cacheName).GetAffinityKey<int, int>(primaryKey);
_grid1.GetCompute().AffinityRun(cacheName, affinityKey, new ComputeAction());
+ Assert.AreEqual(node.Id, ComputeAction.LastNodeId);
+ _grid1.GetCompute().AffinityRunAsync(cacheName, affinityKey, new ComputeAction()).Wait();
Assert.AreEqual(node.Id, ComputeAction.LastNodeId);
}
}
@@ -1112,6 +1119,15 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(result, ComputeFunc.InvokeCount);
Assert.AreEqual(node.Id, ComputeFunc.LastNodeId);
+
+ // Async.
+ ComputeFunc.InvokeCount = 0;
+
+ result = _grid1.GetCompute().AffinityCallAsync(cacheName, affinityKey, new ComputeFunc()).Result;
+
+ Assert.AreEqual(result, ComputeFunc.InvokeCount);
+
+ Assert.AreEqual(node.Id, ComputeFunc.LastNodeId);
}
}
@@ -1149,10 +1165,18 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestNetTaskSimple()
{
- int res = _grid1.GetCompute().Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
- typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Res;
+ Assert.AreEqual(2, _grid1.GetCompute()
+ .Execute<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
+ typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Res);
+
+ Assert.AreEqual(2, _grid1.GetCompute()
+ .ExecuteAsync<NetSimpleJobArgument, NetSimpleJobResult, NetSimpleTaskResult>(
+ typeof(NetSimpleTask), new NetSimpleJobArgument(1)).Result.Res);
- Assert.AreEqual(2, res);
+ Assert.AreEqual(4, _grid1.GetCompute().Execute(new NetSimpleTask(), new NetSimpleJobArgument(2)).Res);
+
+ Assert.AreEqual(6, _grid1.GetCompute().ExecuteAsync(new NetSimpleTask(), new NetSimpleJobArgument(3))
+ .Result.Res);
}
/// <summary>
@@ -1381,6 +1405,7 @@ namespace Apache.Ignite.Core.Tests.Compute
int IComputeFunc<int>.Invoke()
{
+ Thread.Sleep(10);
InvokeCount++;
LastNodeId = _grid.GetCluster().GetLocalNode().Id;
return InvokeCount;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4eda7cf/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
index 45af888..1987245 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Tests.Compute
{
using System;
using System.Collections.Generic;
- using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Resource;
@@ -111,9 +110,9 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ protected override ICollection<Type> GetBinaryTypes()
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestBinarizableJob)));
+ return new[] {typeof(TestBinarizableJob)};
}
/// <summary>