http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs index 17a2b3f..0660a20 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/ScanQueryTest.cs @@ -26,7 +26,6 @@ namespace Apache.Ignite.Core.Tests.Client.Cache using Apache.Ignite.Core.Cache.Query; using Apache.Ignite.Core.Client; using Apache.Ignite.Core.Configuration; - using Apache.Ignite.Core.Impl.Client; using NUnit.Framework; /// <summary> @@ -121,9 +120,10 @@ namespace Apache.Ignite.Core.Tests.Client.Cache var clientCache = client.GetCache<int, Person>(CacheName); // One result. - var single = clientCache.Query(new ScanQuery<int, Person>(new PersonFilter(x => x.Id == 3))).Single(); + var single = clientCache.Query(new ScanQuery<int, Person>(new PersonKeyFilter(3))).Single(); Assert.AreEqual(3, single.Key); +#if !NETCOREAPP2_0 // Serializing delegates is not supported on this platform. // Multiple results. var res = clientCache.Query(new ScanQuery<int, Person>(new PersonFilter(x => x.Name.Length == 1))) .ToList(); @@ -132,9 +132,11 @@ namespace Apache.Ignite.Core.Tests.Client.Cache // No results. res = clientCache.Query(new ScanQuery<int, Person>(new PersonFilter(x => x == null))).ToList(); Assert.AreEqual(0, res.Count); +#endif } } +#if !NETCOREAPP2_0 // Serializing delegates and exceptions is not supported on this platform. /// <summary> /// Tests the exception in filter. /// </summary> @@ -156,6 +158,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache Assert.AreEqual("foo", ex.Message); } } +#endif /// <summary> /// Tests multiple cursors with the same client. @@ -179,7 +182,9 @@ namespace Apache.Ignite.Core.Tests.Client.Cache // MaxCursors = 3 var ex = Assert.Throws<IgniteClientException>(() => clientCache.Query(qry)); Assert.AreEqual("Too many open cursors", ex.Message.Substring(0, 21)); - Assert.AreEqual((int) ClientStatus.TooManyCursors, ex.ErrorCode); +#if !NETCOREAPP2_0 + Assert.AreEqual((int) Impl.Client.ClientStatus.TooManyCursors, ex.ErrorCode); +#endif var count = 0; @@ -261,5 +266,28 @@ namespace Apache.Ignite.Core.Tests.Client.Cache return _filter(entry.Value); } } + + /// <summary> + /// Person filter. + /// </summary> + private class PersonKeyFilter : ICacheEntryFilter<int, Person> + { + /** Key. */ + private readonly int _key; + + /// <summary> + /// Initializes a new instance of the <see cref="PersonFilter"/> class. + /// </summary> + public PersonKeyFilter(int key) + { + _key = key; + } + + /** <inheritdoc /> */ + public bool Invoke(ICacheEntry<int, Person> entry) + { + return entry.Key == _key; + } + } } }
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs index 66aa844..d965b72 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs @@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Client using System.Net.Sockets; using Apache.Ignite.Core.Client; using Apache.Ignite.Core.Configuration; - using Apache.Ignite.Core.Impl.Client; using NUnit.Framework; /// <summary> @@ -108,6 +107,7 @@ namespace Apache.Ignite.Core.Tests.Client Assert.Throws<ArgumentNullException>(() => Ignition.StartClient(new IgniteClientConfiguration())); } +#if !NETCOREAPP2_0 /// <summary> /// Tests the incorrect protocol version error. /// </summary> @@ -118,15 +118,17 @@ namespace Apache.Ignite.Core.Tests.Client using (Ignition.Start(TestUtils.GetTestConfiguration())) { // ReSharper disable once ObjectCreationAsStatement - var ex = Assert.Throws<IgniteClientException>(() => new ClientSocket(GetClientConfiguration(), - new ClientProtocolVersion(-1, -1, -1))); + var ex = Assert.Throws<IgniteClientException>(() => + new Impl.Client.ClientSocket(GetClientConfiguration(), + new Impl.Client.ClientProtocolVersion(-1, -1, -1))); - Assert.AreEqual((int) ClientStatus.Fail, ex.ErrorCode); + Assert.AreEqual((int) Impl.Client.ClientStatus.Fail, ex.ErrorCode); Assert.AreEqual("Client handhsake failed: 'Unsupported version.'. " + "Client version: -1.-1.-1. Server version: 1.0.0", ex.Message); } } +#endif /// <summary> /// Tests that connector can be disabled. @@ -148,7 +150,7 @@ namespace Apache.Ignite.Core.Tests.Client { var ex = Assert.Throws<AggregateException>(() => Ignition.StartClient(clientCfg)); Assert.AreEqual("Failed to establish Ignite thin client connection, " + - "examine inner exceptions for details.", ex.Message); + "examine inner exceptions for details.", ex.Message.Substring(0, 88)); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.JavaTask.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.JavaTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.JavaTask.cs new file mode 100644 index 0000000..1f5c3a3 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.JavaTask.cs @@ -0,0 +1,582 @@ +/* + * 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. + */ + +// ReSharper disable SpecifyACultureInStringConversionExplicitly +namespace Apache.Ignite.Core.Tests.Compute +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using Apache.Ignite.Core.Binary; + using Apache.Ignite.Core.Common; + using Apache.Ignite.Core.Compute; + using Apache.Ignite.Core.Impl.Binary; + using NUnit.Framework; + + /// <summary> + /// Compute tests with Java tasks. + /// </summary> + public partial class ComputeApiTest + { + /** Echo task name. */ + public const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask"; + + /** Binary argument task name. */ + public const string BinaryArgTask = "org.apache.ignite.platform.PlatformComputeBinarizableArgTask"; + + /** Broadcast task name. */ + public const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask"; + + /** Broadcast task name. */ + private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask"; + + /** Echo type: null. */ + private const int EchoTypeNull = 0; + + /** Echo type: byte. */ + private const int EchoTypeByte = 1; + + /** Echo type: bool. */ + private const int EchoTypeBool = 2; + + /** Echo type: short. */ + private const int EchoTypeShort = 3; + + /** Echo type: char. */ + private const int EchoTypeChar = 4; + + /** Echo type: int. */ + private const int EchoTypeInt = 5; + + /** Echo type: long. */ + private const int EchoTypeLong = 6; + + /** Echo type: float. */ + private const int EchoTypeFloat = 7; + + /** Echo type: double. */ + private const int EchoTypeDouble = 8; + + /** Echo type: array. */ + private const int EchoTypeArray = 9; + + /** Echo type: collection. */ + private const int EchoTypeCollection = 10; + + /** Echo type: map. */ + private const int EchoTypeMap = 11; + + /** Echo type: binarizable. */ + public const int EchoTypeBinarizable = 12; + + /** Echo type: binary (Java only). */ + private const int EchoTypeBinarizableJava = 13; + + /** Type: object array. */ + private const int EchoTypeObjArray = 14; + + /** Type: binary object array. */ + private const int EchoTypeBinarizableArray = 15; + + /** Type: enum. */ + private const int EchoTypeEnum = 16; + + /** Type: enum array. */ + private const int EchoTypeEnumArray = 17; + + /** Type: enum field. */ + private const int EchoTypeEnumField = 18; + + /** Type: affinity key. */ + public const int EchoTypeAffinityKey = 19; + + /** Type: enum from cache. */ + private const int EchoTypeEnumFromCache = 20; + + /** Type: enum array from cache. */ + private const int EchoTypeEnumArrayFromCache = 21; + + /** Echo type: IgniteUuid. */ + private const int EchoTypeIgniteUuid = 22; + + /** Echo type: binary enum (created with builder). */ + private const int EchoTypeBinaryEnum = 23; + + /// <summary> + /// Test echo with decimals. + /// </summary> + [Test] + public void TestEchoDecimal() + { + decimal val; + + Assert.AreEqual(val = decimal.Zero, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = new decimal(0, 0, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = new decimal(0, 1, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 1, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = new decimal(1, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = new decimal(1, 1, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 1, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.Parse("65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.Parse("4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.Parse("281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.Parse("18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.Parse("1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.MaxValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.MinValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.MaxValue - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.MinValue + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + Assert.AreEqual(val = decimal.Parse("11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + Assert.AreEqual(val = decimal.Parse("-11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); + + // Test echo with overflow. + var ex = Assert.Throws<BinaryObjectException>(() => _grid1.GetCompute() + .ExecuteJavaTask<object>(DecimalTask, new object[] { null, decimal.MaxValue.ToString() + 1 })); + + Assert.AreEqual("Decimal magnitude overflow (must be less than 96 bits): 104", ex.Message); + + // Negative scale. 1E+1 parses to "1 scale -1" on Java side. + ex = Assert.Throws<BinaryObjectException>(() => _grid1.GetCompute() + .ExecuteJavaTask<object>(DecimalTask, new object[] { null, "1E+1" })); + + Assert.AreEqual("Decimal value scale overflow (must be between 0 and 28): -1", ex.Message); + } + + /// <summary> + /// Test echo task returning null. + /// </summary> + [Test] + public void TestEchoTaskNull() + { + Assert.IsNull(_grid1.GetCompute().ExecuteJavaTask<object>(EchoTask, EchoTypeNull)); + } + + /// <summary> + /// Test echo task returning various primitives. + /// </summary> + [Test] + public void TestEchoTaskPrimitives() + { + Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<byte>(EchoTask, EchoTypeByte)); + Assert.AreEqual(true, _grid1.GetCompute().ExecuteJavaTask<bool>(EchoTask, EchoTypeBool)); + Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<short>(EchoTask, EchoTypeShort)); + Assert.AreEqual((char)1, _grid1.GetCompute().ExecuteJavaTask<char>(EchoTask, EchoTypeChar)); + Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<int>(EchoTask, EchoTypeInt)); + Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<long>(EchoTask, EchoTypeLong)); + Assert.AreEqual((float)1, _grid1.GetCompute().ExecuteJavaTask<float>(EchoTask, EchoTypeFloat)); + Assert.AreEqual((double)1, _grid1.GetCompute().ExecuteJavaTask<double>(EchoTask, EchoTypeDouble)); + } + + /// <summary> + /// Test echo task returning compound types. + /// </summary> + [Test] + public void TestEchoTaskCompound() + { + int[] res1 = _grid1.GetCompute().ExecuteJavaTask<int[]>(EchoTask, EchoTypeArray); + + Assert.AreEqual(1, res1.Length); + Assert.AreEqual(1, res1[0]); + + var res2 = _grid1.GetCompute().ExecuteJavaTask<IList>(EchoTask, EchoTypeCollection); + + Assert.AreEqual(1, res2.Count); + Assert.AreEqual(1, res2[0]); + + var res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary>(EchoTask, EchoTypeMap); + + Assert.AreEqual(1, res3.Count); + Assert.AreEqual(1, res3[1]); + } + + /// <summary> + /// Test echo task returning binary object. + /// </summary> + [Test] + public void TestEchoTaskBinarizable() + { + var values = new[] { int.MinValue, int.MaxValue, 0, 1, -1, byte.MaxValue, byte.MinValue }; + var cache = _grid1.GetCache<int, int>(DefaultCacheName); + var compute = _grid1.GetCompute(); + + foreach (var val in values) + { + cache[EchoTypeBinarizable] = val; + + var res = compute.ExecuteJavaTask<PlatformComputeBinarizable>(EchoTask, EchoTypeBinarizable); + Assert.AreEqual(val, res.Field); + + // Binary mode. + var binRes = compute.WithKeepBinary().ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizable); + + Assert.AreEqual(val, binRes.GetField<long>("Field")); + +#if !NETCOREAPP2_0 + var dotNetBin = _grid1.GetBinary().ToBinary<BinaryObject>(res); + + Assert.AreEqual(dotNetBin.Header.HashCode, ((BinaryObject)binRes).Header.HashCode); + + Func<BinaryObject, byte[]> getData = bo => bo.Data.Skip(bo.Offset).Take(bo.Header.Length).ToArray(); + Assert.AreEqual(getData(dotNetBin), getData((BinaryObject)binRes)); +#endif + } + } + + /// <summary> + /// Test echo task returning binary object with no corresponding class definition. + /// </summary> + [Test] + public void TestEchoTaskBinarizableNoClass() + { + ICompute compute = _grid1.GetCompute(); + + compute.WithKeepBinary(); + + IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava); + + Assert.AreEqual(1, res.GetField<int>("field")); + + // This call must fail because "keepBinary" flag is reset. + var ex = Assert.Throws<BinaryObjectException>(() => + { + compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava); + }); + + Assert.AreEqual("Unknown pair [platformId=1, typeId=2009791293]", ex.Message); + } + + /// <summary> + /// Tests the echo task returning object array. + /// </summary> + [Test] + public void TestEchoTaskObjectArray() + { + var res = _grid1.GetCompute().ExecuteJavaTask<string[]>(EchoTask, EchoTypeObjArray); + + Assert.AreEqual(new[] { "foo", "bar", "baz" }, res); + } + + /// <summary> + /// Tests the echo task returning binary array. + /// </summary> + [Test] + public void TestEchoTaskBinarizableArray() + { + var res = _grid1.GetCompute().ExecuteJavaTask<object[]>(EchoTask, EchoTypeBinarizableArray); + + Assert.AreEqual(3, res.Length); + + for (var i = 0; i < res.Length; i++) + Assert.AreEqual(i + 1, ((PlatformComputeBinarizable)res[i]).Field); + } + + /// <summary> + /// Tests the echo task returning enum. + /// </summary> + [Test] + public void TestEchoTaskEnum() + { + var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum>(EchoTask, EchoTypeEnum); + + Assert.AreEqual(PlatformComputeEnum.Bar, res); + } + + /// <summary> + /// Tests the echo task returning enum. + /// </summary> + [Test] + public void TestEchoTaskBinaryEnum() + { + var res = _grid1.GetCompute().WithKeepBinary() + .ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinaryEnum); + + Assert.AreEqual("JavaFoo", res.EnumName); + Assert.AreEqual(1, res.EnumValue); + + var binType = res.GetBinaryType(); + + Assert.IsTrue(binType.IsEnum); + Assert.AreEqual("JavaDynEnum", binType.TypeName); + + var vals = binType.GetEnumValues().OrderBy(x => x.EnumValue).ToArray(); + Assert.AreEqual(new[] { 1, 2 }, vals.Select(x => x.EnumValue)); + Assert.AreEqual(new[] { "JavaFoo", "JavaBar" }, vals.Select(x => x.EnumName)); + } + + /// <summary> + /// Tests the echo task returning enum. + /// </summary> + [Test] + public void TestEchoTaskEnumFromCache() + { + var cache = _grid1.GetCache<int, PlatformComputeEnum>(DefaultCacheName); + + foreach (PlatformComputeEnum val in Enum.GetValues(typeof(PlatformComputeEnum))) + { + cache[EchoTypeEnumFromCache] = val; + + var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum>(EchoTask, EchoTypeEnumFromCache); + + Assert.AreEqual(val, res); + } + } + + /// <summary> + /// Tests the echo task returning enum. + /// </summary> + [Test] + public void TestEchoTaskEnumArray() + { + var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum[]>(EchoTask, EchoTypeEnumArray); + + Assert.AreEqual(new[] + { + PlatformComputeEnum.Bar, + PlatformComputeEnum.Baz, + PlatformComputeEnum.Foo + }, res); + } + + /// <summary> + /// Tests the echo task returning enum. + /// </summary> + [Test] + public void TestEchoTaskEnumArrayFromCache() + { + var cache = _grid1.GetCache<int, PlatformComputeEnum[]>(DefaultCacheName); + + foreach (var val in new[] + { + new[] {PlatformComputeEnum.Bar, PlatformComputeEnum.Baz, PlatformComputeEnum.Foo }, + new[] {PlatformComputeEnum.Foo, PlatformComputeEnum.Baz}, + new[] {PlatformComputeEnum.Bar} + }) + { + cache[EchoTypeEnumArrayFromCache] = val; + + var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum[]>( + EchoTask, EchoTypeEnumArrayFromCache); + + Assert.AreEqual(val, res); + } + } + + /// <summary> + /// Tests the echo task reading enum from a binary object field. + /// Ensures that Java can understand enums written by .NET. + /// </summary> + [Test] + public void TestEchoTaskEnumField() + { + var enumVal = PlatformComputeEnum.Baz; + + _grid1.GetCache<int, InteropComputeEnumFieldTest>(DefaultCacheName) + .Put(EchoTypeEnumField, new InteropComputeEnumFieldTest { InteropEnum = enumVal }); + + var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum>(EchoTask, EchoTypeEnumField); + + var enumMeta = _grid1.GetBinary().GetBinaryType(typeof(PlatformComputeEnum)); + + Assert.IsTrue(enumMeta.IsEnum); + Assert.AreEqual(enumMeta.TypeName, typeof(PlatformComputeEnum).Name); + Assert.AreEqual(0, enumMeta.Fields.Count); + + Assert.AreEqual(enumVal, res); + } + + /// <summary> + /// Tests that IgniteGuid in .NET maps to IgniteUuid in Java. + /// </summary> + [Test] + public void TestEchoTaskIgniteUuid() + { + var guid = Guid.NewGuid(); + + _grid1.GetCache<int, object>(DefaultCacheName)[EchoTypeIgniteUuid] = new IgniteGuid(guid, 25); + + var res = _grid1.GetCompute().ExecuteJavaTask<IgniteGuid>(EchoTask, EchoTypeIgniteUuid); + + Assert.AreEqual(guid, res.GlobalId); + Assert.AreEqual(25, res.LocalId); + } + + /// <summary> + /// Test for binary argument in Java. + /// </summary> + [Test] + public void TestBinarizableArgTask() + { + ICompute compute = _grid1.GetCompute(); + + compute.WithKeepBinary(); + + PlatformComputeNetBinarizable arg = new PlatformComputeNetBinarizable { Field = 100 }; + + int res = compute.ExecuteJavaTask<int>(BinaryArgTask, arg); + + Assert.AreEqual(arg.Field, res); + } + + /// <summary> + /// Test running broadcast task. + /// </summary> + [Test] + public void TestBroadcastTask([Values(false, true)] bool isAsync) + { + var execTask = + isAsync + ? (Func<ICompute, List<Guid>>)( + c => c.ExecuteJavaTaskAsync<ICollection>(BroadcastTask, null).Result.OfType<Guid>().ToList()) + : c => c.ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList(); + + var res = execTask(_grid1.GetCompute()); + + Assert.AreEqual(2, res.Count); + Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count); + Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count); + + var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id)); + + Assert.AreEqual(2, prj.GetNodes().Count); + + var filteredRes = execTask(prj.GetCompute()); + + Assert.AreEqual(2, filteredRes.Count); + Assert.IsTrue(filteredRes.Contains(res.ElementAt(0))); + Assert.IsTrue(filteredRes.Contains(res.ElementAt(1))); + } + + /// <summary> + /// Test "withNoFailover" feature. + /// </summary> + [Test] + public void TestWithNoFailover() + { + var res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection>(BroadcastTask, null) + .OfType<Guid>().ToList(); + + Assert.AreEqual(2, res.Count); + Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count); + Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count); + } + + /// <summary> + /// Test "withTimeout" feature. + /// </summary> + [Test] + public void TestWithTimeout() + { + var res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection>(BroadcastTask, null) + .OfType<Guid>().ToList(); + + Assert.AreEqual(2, res.Count); + Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count); + Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/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 80d8716..6c4c00a 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs @@ -15,118 +15,29 @@ * limitations under the License. */ -// ReSharper disable SpecifyACultureInStringConversionExplicitly // ReSharper disable UnusedAutoPropertyAccessor.Global namespace Apache.Ignite.Core.Tests.Compute { using System; - using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Cluster; - using Apache.Ignite.Core.Common; using Apache.Ignite.Core.Compute; using Apache.Ignite.Core.Events; - using Apache.Ignite.Core.Impl; - using Apache.Ignite.Core.Impl.Binary; using Apache.Ignite.Core.Resource; using NUnit.Framework; /// <summary> /// Tests for compute. /// </summary> - public class ComputeApiTest + public partial class ComputeApiTest { - /** Echo task name. */ - public const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask"; - - /** Binary argument task name. */ - public const string BinaryArgTask = "org.apache.ignite.platform.PlatformComputeBinarizableArgTask"; - - /** Broadcast task name. */ - public const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask"; - - /** Broadcast task name. */ - private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask"; - /** Java binary class name. */ private const string JavaBinaryCls = "PlatformComputeJavaBinarizable"; - /** Echo type: null. */ - private const int EchoTypeNull = 0; - - /** Echo type: byte. */ - private const int EchoTypeByte = 1; - - /** Echo type: bool. */ - private const int EchoTypeBool = 2; - - /** Echo type: short. */ - private const int EchoTypeShort = 3; - - /** Echo type: char. */ - private const int EchoTypeChar = 4; - - /** Echo type: int. */ - private const int EchoTypeInt = 5; - - /** Echo type: long. */ - private const int EchoTypeLong = 6; - - /** Echo type: float. */ - private const int EchoTypeFloat = 7; - - /** Echo type: double. */ - private const int EchoTypeDouble = 8; - - /** Echo type: array. */ - private const int EchoTypeArray = 9; - - /** Echo type: collection. */ - private const int EchoTypeCollection = 10; - - /** Echo type: map. */ - private const int EchoTypeMap = 11; - - /** Echo type: binarizable. */ - public const int EchoTypeBinarizable = 12; - - /** Echo type: binary (Java only). */ - private const int EchoTypeBinarizableJava = 13; - - /** Type: object array. */ - private const int EchoTypeObjArray = 14; - - /** Type: binary object array. */ - private const int EchoTypeBinarizableArray = 15; - - /** Type: enum. */ - private const int EchoTypeEnum = 16; - - /** Type: enum array. */ - private const int EchoTypeEnumArray = 17; - - /** Type: enum field. */ - private const int EchoTypeEnumField = 18; - - /** Type: affinity key. */ - public const int EchoTypeAffinityKey = 19; - - /** Type: enum from cache. */ - private const int EchoTypeEnumFromCache = 20; - - /** Type: enum array from cache. */ - private const int EchoTypeEnumArrayFromCache = 21; - - /** Echo type: IgniteUuid. */ - private const int EchoTypeIgniteUuid = 22; - - /** Echo type: binary enum (created with builder). */ - private const int EchoTypeBinaryEnum = 23; - /** */ private const string DefaultCacheName = "default"; @@ -145,8 +56,6 @@ namespace Apache.Ignite.Core.Tests.Compute [TestFixtureSetUp] public void InitClient() { - TestUtils.KillProcesses(); - var configs = GetConfigs(); _grid1 = Ignition.Start(Configuration(configs.Item1)); @@ -165,9 +74,9 @@ namespace Apache.Ignite.Core.Tests.Compute protected virtual Tuple<string, string, string> GetConfigs() { return Tuple.Create( - "config\\compute\\compute-grid1.xml", - "config\\compute\\compute-grid2.xml", - "config\\compute\\compute-grid3.xml"); + "Config\\Compute\\compute-grid1.xml", + "Config\\Compute\\compute-grid2.xml", + "Config\\Compute\\compute-grid3.xml"); } /// <summary> @@ -699,437 +608,7 @@ namespace Apache.Ignite.Core.Tests.Compute } } - /// <summary> - /// Test echo with decimals. - /// </summary> - [Test] - public void TestEchoDecimal() - { - decimal val; - - Assert.AreEqual(val = decimal.Zero, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = new decimal(0, 0, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MinValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MinValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 0, int.MaxValue, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = new decimal(0, 1, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 1, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 1, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, 1, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MinValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MinValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(0, int.MaxValue, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = new decimal(1, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MinValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(int.MaxValue, 0, 0, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = new decimal(1, 1, 1, false, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 1, 1, true, 0), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 1, 1, false, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = new decimal(1, 1, 1, true, 0) + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.Parse("65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-65536"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-65536") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-65536") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.Parse("4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-4294967296"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-4294967296") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-4294967296") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.Parse("281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-281474976710656"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-281474976710656") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-281474976710656") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.Parse("18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-18446744073709551616"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-18446744073709551616") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-18446744073709551616") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.Parse("1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-1208925819614629174706176") + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.MaxValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.MinValue, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.MaxValue - 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.MinValue + 1, _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - Assert.AreEqual(val = decimal.Parse("11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - Assert.AreEqual(val = decimal.Parse("-11,12"), _grid1.GetCompute().ExecuteJavaTask<object>(DecimalTask, new object[] { val, val.ToString() })); - - // Test echo with overflow. - var ex = Assert.Throws<BinaryObjectException>(() => _grid1.GetCompute() - .ExecuteJavaTask<object>(DecimalTask, new object[] {null, decimal.MaxValue.ToString() + 1})); - - Assert.AreEqual("Decimal magnitude overflow (must be less than 96 bits): 104", ex.Message); - - // Negative scale. 1E+1 parses to "1 scale -1" on Java side. - ex = Assert.Throws<BinaryObjectException>(() => _grid1.GetCompute() - .ExecuteJavaTask<object>(DecimalTask, new object[] {null, "1E+1"})); - - Assert.AreEqual("Decimal value scale overflow (must be between 0 and 28): -1", ex.Message); - } - - /// <summary> - /// Test echo task returning null. - /// </summary> - [Test] - public void TestEchoTaskNull() - { - Assert.IsNull(_grid1.GetCompute().ExecuteJavaTask<object>(EchoTask, EchoTypeNull)); - } - - /// <summary> - /// Test echo task returning various primitives. - /// </summary> - [Test] - public void TestEchoTaskPrimitives() - { - Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<byte>(EchoTask, EchoTypeByte)); - Assert.AreEqual(true, _grid1.GetCompute().ExecuteJavaTask<bool>(EchoTask, EchoTypeBool)); - Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<short>(EchoTask, EchoTypeShort)); - Assert.AreEqual((char)1, _grid1.GetCompute().ExecuteJavaTask<char>(EchoTask, EchoTypeChar)); - Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<int>(EchoTask, EchoTypeInt)); - Assert.AreEqual(1, _grid1.GetCompute().ExecuteJavaTask<long>(EchoTask, EchoTypeLong)); - Assert.AreEqual((float)1, _grid1.GetCompute().ExecuteJavaTask<float>(EchoTask, EchoTypeFloat)); - Assert.AreEqual((double)1, _grid1.GetCompute().ExecuteJavaTask<double>(EchoTask, EchoTypeDouble)); - } - - /// <summary> - /// Test echo task returning compound types. - /// </summary> - [Test] - public void TestEchoTaskCompound() - { - int[] res1 = _grid1.GetCompute().ExecuteJavaTask<int[]>(EchoTask, EchoTypeArray); - - Assert.AreEqual(1, res1.Length); - Assert.AreEqual(1, res1[0]); - - var res2 = _grid1.GetCompute().ExecuteJavaTask<IList>(EchoTask, EchoTypeCollection); - - Assert.AreEqual(1, res2.Count); - Assert.AreEqual(1, res2[0]); - - var res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary>(EchoTask, EchoTypeMap); - - Assert.AreEqual(1, res3.Count); - Assert.AreEqual(1, res3[1]); - } - - /// <summary> - /// Test echo task returning binary object. - /// </summary> - [Test] - public void TestEchoTaskBinarizable() - { - var values = new[] {int.MinValue, int.MaxValue, 0, 1, -1, byte.MaxValue, byte.MinValue}; - var cache = _grid1.GetCache<int, int>(DefaultCacheName); - var compute = _grid1.GetCompute(); - - foreach (var val in values) - { - cache[EchoTypeBinarizable] = val; - - var res = compute.ExecuteJavaTask<PlatformComputeBinarizable>(EchoTask, EchoTypeBinarizable); - Assert.AreEqual(val, res.Field); - - // Binary mode. - var binRes = compute.WithKeepBinary().ExecuteJavaTask<BinaryObject>(EchoTask, EchoTypeBinarizable); - - Assert.AreEqual(val, binRes.GetField<long>("Field")); - - var dotNetBin = _grid1.GetBinary().ToBinary<BinaryObject>(res); - - Assert.AreEqual(dotNetBin.Header.HashCode, binRes.Header.HashCode); - - Func<BinaryObject, byte[]> getData = bo => bo.Data.Skip(bo.Offset).Take(bo.Header.Length).ToArray(); - Assert.AreEqual(getData(dotNetBin), getData(binRes)); - } - } - - /// <summary> - /// Test echo task returning binary object with no corresponding class definition. - /// </summary> - [Test] - public void TestEchoTaskBinarizableNoClass() - { - ICompute compute = _grid1.GetCompute(); - - compute.WithKeepBinary(); - - IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava); - - Assert.AreEqual(1, res.GetField<int>("field")); - - // This call must fail because "keepBinary" flag is reset. - var ex = Assert.Throws<BinaryObjectException>(() => - { - compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava); - }); - - Assert.AreEqual("Unknown pair [platformId=1, typeId=2009791293]", ex.Message); - } - - /// <summary> - /// Tests the echo task returning object array. - /// </summary> - [Test] - public void TestEchoTaskObjectArray() - { - var res = _grid1.GetCompute().ExecuteJavaTask<string[]>(EchoTask, EchoTypeObjArray); - - Assert.AreEqual(new[] {"foo", "bar", "baz"}, res); - } - - /// <summary> - /// Tests the echo task returning binary array. - /// </summary> - [Test] - public void TestEchoTaskBinarizableArray() - { - var res = _grid1.GetCompute().ExecuteJavaTask<object[]>(EchoTask, EchoTypeBinarizableArray); - - Assert.AreEqual(3, res.Length); - - for (var i = 0; i < res.Length; i++) - Assert.AreEqual(i + 1, ((PlatformComputeBinarizable) res[i]).Field); - } - - /// <summary> - /// Tests the echo task returning enum. - /// </summary> - [Test] - public void TestEchoTaskEnum() - { - var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum>(EchoTask, EchoTypeEnum); - - Assert.AreEqual(PlatformComputeEnum.Bar, res); - } - - /// <summary> - /// Tests the echo task returning enum. - /// </summary> - [Test] - public void TestEchoTaskBinaryEnum() - { - var res = _grid1.GetCompute().WithKeepBinary() - .ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinaryEnum); - - Assert.AreEqual("JavaFoo", res.EnumName); - Assert.AreEqual(1, res.EnumValue); - - var binType = res.GetBinaryType(); - - Assert.IsTrue(binType.IsEnum); - Assert.AreEqual("JavaDynEnum", binType.TypeName); - - var vals = binType.GetEnumValues().OrderBy(x => x.EnumValue).ToArray(); - Assert.AreEqual(new[] {1, 2}, vals.Select(x => x.EnumValue)); - Assert.AreEqual(new[] {"JavaFoo", "JavaBar"}, vals.Select(x => x.EnumName)); - } - - /// <summary> - /// Tests the echo task returning enum. - /// </summary> - [Test] - public void TestEchoTaskEnumFromCache() - { - var cache = _grid1.GetCache<int, PlatformComputeEnum>(DefaultCacheName); - - foreach (PlatformComputeEnum val in Enum.GetValues(typeof(PlatformComputeEnum))) - { - cache[EchoTypeEnumFromCache] = val; - - var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum>(EchoTask, EchoTypeEnumFromCache); - - Assert.AreEqual(val, res); - } - } - - /// <summary> - /// Tests the echo task returning enum. - /// </summary> - [Test] - public void TestEchoTaskEnumArray() - { - var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum[]>(EchoTask, EchoTypeEnumArray); - - Assert.AreEqual(new[] - { - PlatformComputeEnum.Bar, - PlatformComputeEnum.Baz, - PlatformComputeEnum.Foo - }, res); - } - - /// <summary> - /// Tests the echo task returning enum. - /// </summary> - [Test] - public void TestEchoTaskEnumArrayFromCache() - { - var cache = _grid1.GetCache<int, PlatformComputeEnum[]>(DefaultCacheName); - - foreach (var val in new[] - { - new[] {PlatformComputeEnum.Bar, PlatformComputeEnum.Baz, PlatformComputeEnum.Foo }, - new[] {PlatformComputeEnum.Foo, PlatformComputeEnum.Baz}, - new[] {PlatformComputeEnum.Bar} - }) - { - cache[EchoTypeEnumArrayFromCache] = val; - - var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum[]>( - EchoTask, EchoTypeEnumArrayFromCache); - - Assert.AreEqual(val, res); - } - } - - /// <summary> - /// Tests the echo task reading enum from a binary object field. - /// Ensures that Java can understand enums written by .NET. - /// </summary> - [Test] - public void TestEchoTaskEnumField() - { - var enumVal = PlatformComputeEnum.Baz; - - _grid1.GetCache<int, InteropComputeEnumFieldTest>(DefaultCacheName) - .Put(EchoTypeEnumField, new InteropComputeEnumFieldTest {InteropEnum = enumVal}); - - var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeEnum>(EchoTask, EchoTypeEnumField); - - var enumMeta = _grid1.GetBinary().GetBinaryType(typeof (PlatformComputeEnum)); - - Assert.IsTrue(enumMeta.IsEnum); - Assert.AreEqual(enumMeta.TypeName, typeof(PlatformComputeEnum).Name); - Assert.AreEqual(0, enumMeta.Fields.Count); - - Assert.AreEqual(enumVal, res); - } - - /// <summary> - /// Tests that IgniteGuid in .NET maps to IgniteUuid in Java. - /// </summary> - [Test] - public void TestEchoTaskIgniteUuid() - { - var guid = Guid.NewGuid(); - - _grid1.GetCache<int, object>(DefaultCacheName)[EchoTypeIgniteUuid] = new IgniteGuid(guid, 25); - - var res = _grid1.GetCompute().ExecuteJavaTask<IgniteGuid>(EchoTask, EchoTypeIgniteUuid); - - Assert.AreEqual(guid, res.GlobalId); - Assert.AreEqual(25, res.LocalId); - } - - /// <summary> - /// Test for binary argument in Java. - /// </summary> - [Test] - public void TestBinarizableArgTask() - { - ICompute compute = _grid1.GetCompute(); - - compute.WithKeepBinary(); - PlatformComputeNetBinarizable arg = new PlatformComputeNetBinarizable {Field = 100}; - - int res = compute.ExecuteJavaTask<int>(BinaryArgTask, arg); - - Assert.AreEqual(arg.Field, res); - } - - /// <summary> - /// Test running broadcast task. - /// </summary> - [Test] - public void TestBroadcastTask([Values(false, true)] bool isAsync) - { - var execTask = - isAsync - ? (Func<ICompute, List<Guid>>) ( - c => c.ExecuteJavaTaskAsync<ICollection>(BroadcastTask, null).Result.OfType<Guid>().ToList()) - : c => c.ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList(); - - var res = execTask(_grid1.GetCompute()); - - Assert.AreEqual(2, res.Count); - Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count); - Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count); - - var prj = _grid1.GetCluster().ForPredicate(node => res.Take(2).Contains(node.Id)); - - Assert.AreEqual(2, prj.GetNodes().Count); - - var filteredRes = execTask(prj.GetCompute()); - - Assert.AreEqual(2, filteredRes.Count); - Assert.IsTrue(filteredRes.Contains(res.ElementAt(0))); - Assert.IsTrue(filteredRes.Contains(res.ElementAt(1))); - } /// <summary> /// Tests the action broadcast. @@ -1259,34 +738,6 @@ namespace Apache.Ignite.Core.Tests.Compute } /// <summary> - /// Test "withNoFailover" feature. - /// </summary> - [Test] - public void TestWithNoFailover() - { - var res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection>(BroadcastTask, null) - .OfType<Guid>().ToList(); - - Assert.AreEqual(2, res.Count); - Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count); - Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count); - } - - /// <summary> - /// Test "withTimeout" feature. - /// </summary> - [Test] - public void TestWithTimeout() - { - var res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection>(BroadcastTask, null) - .OfType<Guid>().ToList(); - - Assert.AreEqual(2, res.Count); - Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count); - Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(1)).GetNodes().Count); - } - - /// <summary> /// Test simple dotNet task execution. /// </summary> [Test] @@ -1333,23 +784,31 @@ namespace Apache.Ignite.Core.Tests.Compute _grid1.GetCluster().ForRemotes().GetCompute().Broadcast(new ExceptionalComputeAction())); Assert.IsNotNull(ex.InnerException); +#if NETCOREAPP2_0 + // Exceptions can't be serialized on .NET Core + Assert.AreEqual("Operation is not supported on this platform.", + ex.InnerException.Message); +#else Assert.AreEqual("Compute job has failed on remote node, examine InnerException for details.", ex.InnerException.Message); Assert.IsNotNull(ex.InnerException.InnerException); Assert.AreEqual(ExceptionalComputeAction.ErrorText, ex.InnerException.InnerException.Message); +#endif } +#if !NETCOREAPP2_0 /// <summary> /// Tests the footer setting. /// </summary> [Test] public void TestFooterSetting() { - Assert.AreEqual(CompactFooter, ((Ignite)_grid1).Marshaller.CompactFooter); + Assert.AreEqual(CompactFooter, ((Impl.Ignite) _grid1).Marshaller.CompactFooter); foreach (var g in new[] {_grid1, _grid2, _grid3}) Assert.AreEqual(CompactFooter, g.GetConfiguration().BinaryConfiguration.CompactFooter); } +#endif /// <summary> /// Create configuration. @@ -1369,7 +828,7 @@ namespace Apache.Ignite.Core.Tests.Compute new BinaryTypeConfiguration(typeof(PlatformComputeEnum)), new BinaryTypeConfiguration(typeof(InteropComputeEnumFieldTest)) }, - NameMapper = BinaryBasicNameMapper.SimpleNameInstance + NameMapper = new BinaryBasicNameMapper { IsSimpleName = true } }, SpringConfigUrl = path }; @@ -1492,7 +951,7 @@ namespace Apache.Ignite.Core.Tests.Compute class ComputeAction : IComputeAction { [InstanceResource] - #pragma warning disable 649 +#pragma warning disable 649 private IIgnite _grid; public static ConcurrentBag<Guid> Invokes = new ConcurrentBag<Guid>(); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicLongTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicLongTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicLongTest.cs index fd9849c..4550a18 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicLongTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicLongTest.cs @@ -31,7 +31,7 @@ namespace Apache.Ignite.Core.Tests.DataStructures /// <summary> /// Initializes a new instance of the <see cref="AtomicLongTest"/> class. /// </summary> - public AtomicLongTest() : base("config\\compute\\compute-grid1.xml") + public AtomicLongTest() : base("Config\\Compute\\compute-grid1.xml") { // No-op. } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs index 751b291..0b16785 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs @@ -33,7 +33,7 @@ namespace Apache.Ignite.Core.Tests.DataStructures /// <summary> /// Initializes a new instance of the <see cref="AtomicReferenceTest"/> class. /// </summary> - public AtomicReferenceTest() : base("config\\compute\\compute-grid1.xml") + public AtomicReferenceTest() : base("Config\\Compute\\compute-grid1.xml") { // No-op. } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs index 472dee2..7633021 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs @@ -31,7 +31,7 @@ namespace Apache.Ignite.Core.Tests.DataStructures /// <summary> /// Initializes a new instance of the <see cref="AtomicSequenceTest"/> class. /// </summary> - public AtomicSequenceTest() : base("config\\compute\\compute-grid1.xml") + public AtomicSequenceTest() : base("Config\\Compute\\compute-grid1.xml") { // No-op. } http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs index 27e55f3..1376d64 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs @@ -515,15 +515,15 @@ namespace Apache.Ignite.Core.Tests { // Empty section. var cfg = IgniteConfiguration.FromXml("<x />"); - TestUtils.AssertReflectionEqual(new IgniteConfiguration(), cfg); + AssertExtensions.ReflectionEqual(new IgniteConfiguration(), cfg); // Empty section with XML header. cfg = IgniteConfiguration.FromXml("<?xml version=\"1.0\" encoding=\"utf-16\"?><x />"); - TestUtils.AssertReflectionEqual(new IgniteConfiguration(), cfg); + AssertExtensions.ReflectionEqual(new IgniteConfiguration(), cfg); // Simple test. cfg = IgniteConfiguration.FromXml(@"<igCfg igniteInstanceName=""myGrid"" clientMode=""true"" />"); - TestUtils.AssertReflectionEqual(new IgniteConfiguration {IgniteInstanceName = "myGrid", ClientMode = true}, cfg); + AssertExtensions.ReflectionEqual(new IgniteConfiguration {IgniteInstanceName = "myGrid", ClientMode = true}, cfg); // Invalid xml. var ex = Assert.Throws<ConfigurationErrorsException>(() => @@ -538,7 +538,7 @@ namespace Apache.Ignite.Core.Tests { cfg = IgniteConfiguration.FromXml(xmlReader); } - TestUtils.AssertReflectionEqual(new IgniteConfiguration { IgniteInstanceName = "myGrid", ClientMode = true }, cfg); + AssertExtensions.ReflectionEqual(new IgniteConfiguration { IgniteInstanceName = "myGrid", ClientMode = true }, cfg); } /// <summary> @@ -590,7 +590,7 @@ namespace Apache.Ignite.Core.Tests { var resCfg = SerializeDeserialize(cfg); - TestUtils.AssertReflectionEqual(cfg, resCfg); + AssertExtensions.ReflectionEqual(cfg, resCfg); } /// <summary> http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs index 98c3f11..1d51c27 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs @@ -151,7 +151,7 @@ namespace Apache.Ignite.Core.Tests Assert.AreEqual(cfg.WorkDirectory.Trim('\\'), resCfg.WorkDirectory.Trim('\\')); Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath); Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions); - Assert.IsTrue(File.Exists(resCfg.JvmDllPath)); + Assert.AreEqual(cfg.JvmDllPath, resCfg.JvmDllPath); Assert.AreEqual(cfg.Localhost, resCfg.Localhost); Assert.AreEqual(cfg.IsDaemon, resCfg.IsDaemon); Assert.AreEqual(IgniteConfiguration.DefaultIsLateAffinityAssignment, resCfg.IsLateAffinityAssignment); @@ -238,7 +238,7 @@ namespace Apache.Ignite.Core.Tests Assert.AreEqual(sql.TcpNoDelay, resSql.TcpNoDelay); Assert.AreEqual(sql.ThreadPoolSize, resSql.ThreadPoolSize); - TestUtils.AssertReflectionEqual(cfg.DataStorageConfiguration, resCfg.DataStorageConfiguration); + AssertExtensions.ReflectionEqual(cfg.DataStorageConfiguration, resCfg.DataStorageConfiguration); } } @@ -496,6 +496,7 @@ namespace Apache.Ignite.Core.Tests Assert.AreEqual(IgniteConfiguration.DefaultIsActiveOnStart, cfg.IsActiveOnStart); Assert.AreEqual(IgniteConfiguration.DefaultClientConnectorConfigurationEnabled, cfg.ClientConnectorConfigurationEnabled); + Assert.AreEqual(IgniteConfiguration.DefaultRedirectJavaConsoleOutput, cfg.RedirectJavaConsoleOutput); // Thread pools. Assert.AreEqual(IgniteConfiguration.DefaultManagementThreadPoolSize, cfg.ManagementThreadPoolSize); http://git-wip-us.apache.org/repos/asf/ignite/blob/ed1ff82a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs index cb70f1e..4542eaa 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Log/CustomLoggerTest.cs @@ -118,6 +118,7 @@ namespace Apache.Ignite.Core.Tests.Log Assert.IsInstanceOf<ArithmeticException>(err.Exception); } +#if !NETCOREAPP2_0 // Exception serialization is not supported in .NET Core /// <summary> /// Tests that .NET exception propagates through Java to the log. /// </summary> @@ -139,9 +140,11 @@ namespace Apache.Ignite.Core.Tests.Log var errFromJava = TestLogger.Entries.Single(x => x.Exception != null); Assert.IsNotNull(errFromJava.Exception.InnerException); - Assert.AreEqual("Error in func.", ((ArithmeticException) errFromJava.Exception.InnerException).Message); + Assert.AreEqual("Error in func.", + ((ArithmeticException) errFromJava.Exception.InnerException).Message); } } +#endif /// <summary> /// Tests the <see cref="QueryEntity"/> validation.