You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/17 14:58:22 UTC
[1/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Repository: ignite
Updated Branches:
refs/heads/ignite-1282 fff85cb22 -> d69362f86
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
deleted file mode 100644
index 16c68e1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
+++ /dev/null
@@ -1,173 +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.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Cache;
- using NUnit.Framework;
-
- /// <summary>
- /// Portable configuration tests.
- /// </summary>
- public class PortableConfigurationTest
- {
- /** Cache. */
- private ICache<int, TestGenericPortableBase> _cache;
-
- /** Random generator. */
- private static readonly Random Rnd = new Random();
-
- /** Test types for code config */
- private static readonly Type[] TestTypes = {
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
- };
-
- /** Test types for xml config */
- private static readonly Type[] TestTypesXml = {
- typeof (TestGenericPortable<long>),
- typeof (TestGenericPortable<Type>),
- typeof (TestGenericPortable<TestGenericPortable<long>>),
- typeof (TestGenericPortable<List<Tuple<long, string>>>),
- typeof (TestGenericPortable<long, string>),
- typeof (TestGenericPortable<long, TestGenericPortable<string>>),
- typeof (TestGenericPortable<long, string, Type>),
- typeof (TestGenericPortable<long, string, TestGenericPortable<long, string, Type>>)
- };
-
- /// <summary>
- /// Starts the grid with provided config.
- /// </summary>
- /// <param name="binaryConfiguration">The portable configuration.</param>
- private void StartGrid(BinaryConfiguration binaryConfiguration)
- {
- Ignition.StopAll(true);
-
- var grid = Ignition.Start(new IgniteConfiguration
- {
- SpringConfigUrl = "config\\cache-portables.xml",
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- BinaryConfiguration = binaryConfiguration
- });
-
- _cache = grid.GetCache<int, TestGenericPortableBase>(null);
- }
-
- /// <summary>
- /// Test fixture tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TestFixtureTearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Tests the configuration set in code.
- /// </summary>
- [Test]
- public void TestCodeConfiguration()
- {
- StartGrid(new BinaryConfiguration
- {
- TypeConfigurations = TestTypes.Select(x => new BinaryTypeConfiguration(x)).ToList()
- });
-
- CheckPortableTypes(TestTypes);
- }
-
- /// <summary>
- /// Tests the configuration set in xml.
- /// </summary>
- [Test]
- public void TestXmlConfiguration()
- {
- StartGrid(null);
-
- CheckPortableTypes(TestTypesXml);
- }
-
- /// <summary>
- /// Checks that specified types are portable and can be successfully used in cache.
- /// </summary>
- private void CheckPortableTypes(IEnumerable<Type> testTypes)
- {
- int key = 0;
-
- foreach (var typ in testTypes)
- {
- key += 1;
-
- var inst = CreateInstance(typ);
-
- _cache.Put(key, inst);
-
- var result = _cache.Get(key);
-
- Assert.AreEqual(inst.Prop, result.Prop);
-
- Assert.AreEqual(typ, result.GetType());
- }
- }
-
- /// <summary>
- /// Creates the instance of specified test portable type and sets a value on it.
- /// </summary>
- private static TestGenericPortableBase CreateInstance(Type type)
- {
- var inst = (TestGenericPortableBase)Activator.CreateInstance(type);
-
- inst.Prop = Rnd.Next(int.MaxValue);
-
- return inst;
- }
- }
-
- public abstract class TestGenericPortableBase
- {
- public object Prop { get; set; }
- }
-
- public class TestGenericPortable<T> : TestGenericPortableBase
- {
- public T Prop1 { get; set; }
- }
-
- public class TestGenericPortable<T1, T2> : TestGenericPortableBase
- {
- public T1 Prop1 { get; set; }
- public T2 Prop2 { get; set; }
- }
-
- public class TestGenericPortable<T1, T2, T3> : TestGenericPortableBase
- {
- public T1 Prop1 { get; set; }
- public T2 Prop2 { get; set; }
- public T3 Prop3 { get; set; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs
new file mode 100644
index 0000000..c2e38bb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs
@@ -0,0 +1,69 @@
+/*
+ * 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.Query
+{
+ using Apache.Ignite.Core.Binary;
+
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class BinarizablePerson : IBinarizable
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarizablePerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public BinarizablePerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address.
+ /// </summary>
+ public string Address { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+
+ /** <ineritdoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteString("name", Name);
+ writer.WriteString("address", Address);
+ writer.WriteInt("age", Age);
+ }
+
+ /** <ineritdoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Name = reader.ReadString("name");
+ Address = reader.ReadString("address");
+ Age = reader.ReadInt("age");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs
new file mode 100644
index 0000000..b7e9524
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs
@@ -0,0 +1,46 @@
+/*
+ * 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.Query
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class ImplicitBinarizablePerson
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ImplicitBinarizablePerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public ImplicitBinarizablePerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
deleted file mode 100644
index f80c4eb..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
+++ /dev/null
@@ -1,46 +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.Tests.Query
-{
- /// <summary>
- /// Test person.
- /// </summary>
- internal class ImplicitPortablePerson
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ImplicitPortablePerson"/> class.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="age">The age.</param>
- public ImplicitPortablePerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs
new file mode 100644
index 0000000..5ae4159
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.Query
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class NoDefBinarizablePerson
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
deleted file mode 100644
index 16bd07d..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
+++ /dev/null
@@ -1,35 +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.Tests.Query
-{
- /// <summary>
- /// Test person.
- /// </summary>
- internal class NoDefPortablePerson
- {
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
deleted file mode 100644
index 08134fd..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
+++ /dev/null
@@ -1,69 +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.Tests.Query
-{
- using Apache.Ignite.Core.Binary;
-
- /// <summary>
- /// Test person.
- /// </summary>
- internal class PortablePerson : IBinarizable
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="PortablePerson"/> class.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="age">The age.</param>
- public PortablePerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the address.
- /// </summary>
- public string Address { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
-
- /** <ineritdoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteString("name", Name);
- writer.WriteString("address", Address);
- writer.WriteInt("age", Age);
- }
-
- /** <ineritdoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Name = reader.ReadString("name");
- Address = reader.ReadString("address");
- Age = reader.ReadInt("age");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
index 1fe6a21..1797337 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -42,8 +42,8 @@ namespace Apache.Ignite.Core.Tests.Services
{
TypeConfigurations = new[]
{
- new BinaryTypeConfiguration(typeof (TestPortableClass)),
- new BinaryTypeConfiguration(typeof (CustomExceptionPortable))
+ new BinaryTypeConfiguration(typeof (TestBinarizableClass)),
+ new BinaryTypeConfiguration(typeof (CustomExceptionBinarizable))
}
});
@@ -54,10 +54,10 @@ namespace Apache.Ignite.Core.Tests.Services
private readonly PlatformMemoryManager _memory = new PlatformMemoryManager(1024);
/** */
- protected bool KeepPortable;
+ protected bool KeepBinary;
/** */
- protected bool SrvKeepPortable;
+ protected bool SrvKeepBinary;
/// <summary>
/// Initializes a new instance of the <see cref="ServiceProxyTest"/> class.
@@ -196,13 +196,13 @@ namespace Apache.Ignite.Core.Tests.Services
}
[Test]
- public void TestPortableMarshallingException()
+ public void TestBinarizableMarshallingException()
{
var prx = GetProxy();
- var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(false, false));
+ var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(false, false));
- if (KeepPortable)
+ if (KeepBinary)
{
Assert.AreEqual("Proxy method invocation failed with a binary error. " +
"Examine BinaryCause for details.", ex.Message);
@@ -219,15 +219,15 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.IsNotNull(ex.InnerException);
}
- ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, false));
+ ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(true, false));
Assert.IsTrue(ex.ToString().Contains(
- "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
- "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
+ "Call completed with error, but error serialization failed [errType=CustomExceptionBinarizable, " +
+ "serializationErrMsg=Expected exception in CustomExceptionBinarizable.WriteBinary]"));
- ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, true));
+ ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(true, true));
Assert.IsTrue(ex.ToString().Contains(
- "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
- "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
+ "Call completed with error, but error serialization failed [errType=CustomExceptionBinarizable, " +
+ "serializationErrMsg=Expected exception in CustomExceptionBinarizable.WriteBinary]"));
}
/// <summary>
@@ -266,7 +266,7 @@ namespace Apache.Ignite.Core.Tests.Services
using (var outStream = new PlatformMemoryStream(_memory.Allocate()))
{
// 1) Write to a stream
- inStream.WriteBool(SrvKeepPortable); // WriteProxyMethod does not do this, but Java does
+ inStream.WriteBool(SrvKeepBinary); // WriteProxyMethod does not do this, but Java does
ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method, args);
@@ -290,7 +290,7 @@ namespace Apache.Ignite.Core.Tests.Services
outStream.Seek(0, SeekOrigin.Begin);
- return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepPortable);
+ return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepBinary);
}
}
@@ -354,16 +354,16 @@ namespace Apache.Ignite.Core.Tests.Services
void CustomExceptionMethod();
/** */
- void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
+ void CustomExceptionBinarizableMethod(bool throwOnWrite, bool throwOnRead);
/** */
- TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2);
+ TestBinarizableClass BinarizableArgMethod(int arg1, IBinaryObject arg2);
/** */
- IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2);
+ IBinaryObject BinarizableResultMethod(int arg1, TestBinarizableClass arg2);
/** */
- IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2);
+ IBinaryObject BinarizableArgAndResultMethod(int arg1, IBinaryObject arg2);
/** */
int AmbiguousMethod(int arg);
@@ -414,16 +414,16 @@ namespace Apache.Ignite.Core.Tests.Services
void CustomExceptionMethod();
/** */
- void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
+ void CustomExceptionBinarizableMethod(bool throwOnWrite, bool throwOnRead);
/** */
- TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2);
+ TestBinarizableClass BinarizableArgMethod(int arg1, IBinaryObject arg2);
/** */
- IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2);
+ IBinaryObject BinarizableResultMethod(int arg1, TestBinarizableClass arg2);
/** */
- IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2);
+ IBinaryObject BinarizableArgAndResultMethod(int arg1, IBinaryObject arg2);
/** */
void MissingMethod();
@@ -444,7 +444,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// <summary>
/// Initializes a new instance of the <see cref="TestIgniteService"/> class.
/// </summary>
- /// <param name="igniteBinary">The portables.</param>
+ /// <param name="igniteBinary">Binary.</param>
public TestIgniteService(IIgniteBinary igniteBinary)
{
_igniteBinary = igniteBinary;
@@ -520,27 +520,27 @@ namespace Apache.Ignite.Core.Tests.Services
}
/** <inheritdoc /> */
- public void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead)
+ public void CustomExceptionBinarizableMethod(bool throwOnWrite, bool throwOnRead)
{
- throw new CustomExceptionPortable {ThrowOnRead = throwOnRead, ThrowOnWrite = throwOnWrite};
+ throw new CustomExceptionBinarizable {ThrowOnRead = throwOnRead, ThrowOnWrite = throwOnWrite};
}
/** <inheritdoc /> */
- public TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2)
+ public TestBinarizableClass BinarizableArgMethod(int arg1, IBinaryObject arg2)
{
- return arg2.Deserialize<TestPortableClass>();
+ return arg2.Deserialize<TestBinarizableClass>();
}
/** <inheritdoc /> */
- public IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2)
+ public IBinaryObject BinarizableResultMethod(int arg1, TestBinarizableClass arg2)
{
return _igniteBinary.ToBinary<IBinaryObject>(arg2);
}
/** <inheritdoc /> */
- public IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2)
+ public IBinaryObject BinarizableArgAndResultMethod(int arg1, IBinaryObject arg2)
{
- return _igniteBinary.ToBinary<IBinaryObject>(arg2.Deserialize<TestPortableClass>());
+ return _igniteBinary.ToBinary<IBinaryObject>(arg2.Deserialize<TestBinarizableClass>());
}
/** <inheritdoc /> */
@@ -595,7 +595,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// <summary>
/// Custom non-serializable exception.
/// </summary>
- private class CustomExceptionPortable : Exception, IBinarizable
+ private class CustomExceptionBinarizable : Exception, IBinarizable
{
/** */
public bool ThrowOnWrite { get; set; }
@@ -609,7 +609,7 @@ namespace Apache.Ignite.Core.Tests.Services
writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
if (ThrowOnWrite)
- throw new Exception("Expected exception in CustomExceptionPortable.WritePortable");
+ throw new Exception("Expected exception in CustomExceptionBinarizable.WriteBinary");
}
/** <inheritdoc /> */
@@ -618,14 +618,14 @@ namespace Apache.Ignite.Core.Tests.Services
ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
if (ThrowOnRead)
- throw new Exception("Expected exception in CustomExceptionPortable.ReadPortable");
+ throw new Exception("Expected exception in CustomExceptionBinarizable.ReadBinary");
}
}
/// <summary>
- /// Portable object for method argument/result.
+ /// Binarizable object for method argument/result.
/// </summary>
- protected class TestPortableClass : IBinarizable
+ protected class TestBinarizableClass : IBinarizable
{
/** */
public string Prop { get; set; }
@@ -643,7 +643,7 @@ namespace Apache.Ignite.Core.Tests.Services
writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
if (ThrowOnWrite)
- throw new Exception("Expected exception in TestPortableClass.WritePortable");
+ throw new Exception("Expected exception in TestBinarizableClass.WriteBinary");
}
/** <inheritdoc /> */
@@ -653,89 +653,89 @@ namespace Apache.Ignite.Core.Tests.Services
ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
if (ThrowOnRead)
- throw new Exception("Expected exception in TestPortableClass.ReadPortable");
+ throw new Exception("Expected exception in TestBinarizableClass.ReadBinary");
}
}
}
/// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client.
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepBinary mode enabled on client.
/// </summary>
- public class ServiceProxyTestKeepPortableClient : ServiceProxyTest
+ public class ServiceProxyTestKeepBinaryClient : ServiceProxyTest
{
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClient"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepBinaryClient"/> class.
/// </summary>
- public ServiceProxyTestKeepPortableClient()
+ public ServiceProxyTestKeepBinaryClient()
{
- KeepPortable = true;
+ KeepBinary = true;
}
[Test]
- public void TestPortableMethods()
+ public void TestBinarizableMethods()
{
var prx = GetProxy();
- var obj = new TestPortableClass { Prop = "PropValue" };
+ var obj = new TestBinarizableClass { Prop = "PropValue" };
- var result = prx.PortableResultMethod(1, obj);
+ var result = prx.BinarizableResultMethod(1, obj);
- Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
+ Assert.AreEqual(obj.Prop, result.Deserialize<TestBinarizableClass>().Prop);
}
}
/// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on server.
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepBinary mode enabled on server.
/// </summary>
- public class ServiceProxyTestKeepPortableServer : ServiceProxyTest
+ public class ServiceProxyTestKeepBinaryServer : ServiceProxyTest
{
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableServer"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepBinaryServer"/> class.
/// </summary>
- public ServiceProxyTestKeepPortableServer()
+ public ServiceProxyTestKeepBinaryServer()
{
- SrvKeepPortable = true;
+ SrvKeepBinary = true;
}
[Test]
- public void TestPortableMethods()
+ public void TestBinarizableMethods()
{
var prx = GetProxy();
- var obj = new TestPortableClass { Prop = "PropValue" };
+ var obj = new TestBinarizableClass { Prop = "PropValue" };
var portObj = IgniteBinary.ToBinary<IBinaryObject>(obj);
- var result = prx.PortableArgMethod(1, portObj);
+ var result = prx.BinarizableArgMethod(1, portObj);
Assert.AreEqual(obj.Prop, result.Prop);
}
}
/// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client and on server.
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepBinary mode enabled on client and on server.
/// </summary>
- public class ServiceProxyTestKeepPortableClientServer : ServiceProxyTest
+ public class ServiceProxyTestKeepBinaryClientServer : ServiceProxyTest
{
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClientServer"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepBinaryClientServer"/> class.
/// </summary>
- public ServiceProxyTestKeepPortableClientServer()
+ public ServiceProxyTestKeepBinaryClientServer()
{
- KeepPortable = true;
- SrvKeepPortable = true;
+ KeepBinary = true;
+ SrvKeepBinary = true;
}
[Test]
- public void TestPortableMethods()
+ public void TestBinarizableMethods()
{
var prx = GetProxy();
- var obj = new TestPortableClass { Prop = "PropValue" };
+ var obj = new TestBinarizableClass { Prop = "PropValue" };
var portObj = IgniteBinary.ToBinary<IBinaryObject>(obj);
- var result = prx.PortableArgAndResultMethod(1, portObj);
+ var result = prx.BinarizableArgAndResultMethod(1, portObj);
- Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
+ Assert.AreEqual(obj.Prop, result.Deserialize<TestBinarizableClass>().Prop);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index c4b5776..33f255e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -102,7 +102,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// Tests deployment.
/// </summary>
[Test]
- public void TestDeploy([Values(true, false)] bool portable)
+ public void TestDeploy([Values(true, false)] bool binarizable)
{
var cfg = new ServiceConfiguration
{
@@ -110,7 +110,7 @@ namespace Apache.Ignite.Core.Tests.Services
MaxPerNodeCount = 3,
TotalCount = 3,
NodeFilter = new NodeFilter {NodeId = Grid1.GetCluster().GetLocalNode().Id},
- Service = portable ? new TestIgniteServicePortable() : new TestIgniteServiceSerializable()
+ Service = binarizable ? new TestIgniteServiceBinarizable() : new TestIgniteServiceSerializable()
};
Services.Deploy(cfg);
@@ -161,7 +161,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestDeployKeyAffinitySingleton()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey);
@@ -176,13 +176,13 @@ namespace Apache.Ignite.Core.Tests.Services
/// Tests key affinity singleton deployment.
/// </summary>
[Test]
- public void TestDeployKeyAffinitySingletonPortable()
+ public void TestDeployKeyAffinitySingletonBinarizable()
{
var services = Services.WithKeepBinary();
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
- var affKey = new PortableObject {Val = AffKey};
+ var affKey = new BinarizableObject {Val = AffKey};
services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey);
@@ -213,7 +213,7 @@ namespace Apache.Ignite.Core.Tests.Services
{
for (var i = 0; i < 10; i++)
{
- Services.DeployNodeSingleton(SvcName + i, new TestIgniteServicePortable());
+ Services.DeployNodeSingleton(SvcName + i, new TestIgniteServiceBinarizable());
Assert.IsNotNull(Services.GetService<ITestIgniteService>(SvcName + i));
}
@@ -236,7 +236,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// Tests service proxy.
/// </summary>
[Test]
- public void TestGetServiceProxy([Values(true, false)] bool portable)
+ public void TestGetServiceProxy([Values(true, false)] bool binarizable)
{
// Test proxy without a service
var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
@@ -247,8 +247,8 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.AreEqual("Failed to find deployed service: " + SvcName, ex.Message);
// Deploy to grid2 & grid3
- var svc = portable
- ? new TestIgniteServicePortable {TestProperty = 17}
+ var svc = binarizable
+ ? new TestIgniteServiceBinarizable {TestProperty = 17}
: new TestIgniteServiceSerializable {TestProperty = 17};
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid3.GetCluster().GetLocalNode().Id).GetServices()
@@ -300,7 +300,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestDuckTyping([Values(true, false)] bool local)
{
- var svc = new TestIgniteServicePortable {TestProperty = 33};
+ var svc = new TestIgniteServiceBinarizable {TestProperty = 33};
// Deploy locally or to the remote node
var nodeId = (local ? Grid1 : Grid2).GetCluster().GetLocalNode().Id;
@@ -358,12 +358,12 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Tests the client portable flag.
+ /// Tests the client binary flag.
/// </summary>
[Test]
- public void TestWithKeepPortableClient()
+ public void TestWithKeepBinaryClient()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
// Deploy to grid2
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary()
@@ -372,22 +372,22 @@ namespace Apache.Ignite.Core.Tests.Services
// Get proxy
var prx = Services.WithKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
- var obj = new PortableObject {Val = 11};
+ var obj = new BinarizableObject {Val = 11};
var res = (IBinaryObject) prx.Method(obj);
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
res = (IBinaryObject) prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
}
/// <summary>
- /// Tests the server portable flag.
+ /// Tests the server binary flag.
/// </summary>
[Test]
- public void TestWithKeepPortableServer()
+ public void TestWithKeepBinaryServer()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
// Deploy to grid2
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithServerKeepBinary()
@@ -396,22 +396,22 @@ namespace Apache.Ignite.Core.Tests.Services
// Get proxy
var prx = Services.WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
- var obj = new PortableObject { Val = 11 };
+ var obj = new BinarizableObject { Val = 11 };
- var res = (PortableObject) prx.Method(obj);
+ var res = (BinarizableObject) prx.Method(obj);
Assert.AreEqual(11, res.Val);
- res = (PortableObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
+ res = (BinarizableObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
Assert.AreEqual(11, res.Val);
}
/// <summary>
- /// Tests server and client portable flag.
+ /// Tests server and client binary flag.
/// </summary>
[Test]
- public void TestWithKeepPortableBoth()
+ public void TestWithKeepBinaryBoth()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
// Deploy to grid2
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary().WithServerKeepBinary()
@@ -420,13 +420,13 @@ namespace Apache.Ignite.Core.Tests.Services
// Get proxy
var prx = Services.WithKeepBinary().WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
- var obj = new PortableObject { Val = 11 };
+ var obj = new BinarizableObject { Val = 11 };
var res = (IBinaryObject)prx.Method(obj);
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
res = (IBinaryObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
}
/// <summary>
@@ -484,7 +484,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestMarshalExceptionOnRead()
{
- var svc = new TestIgniteServicePortableErr();
+ var svc = new TestIgniteServiceBinarizableErr();
var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
Assert.AreEqual("Expected exception", ex.Message);
@@ -497,7 +497,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestMarshalExceptionOnWrite()
{
- var svc = new TestIgniteServicePortableErr {ThrowOnWrite = true};
+ var svc = new TestIgniteServiceBinarizableErr {ThrowOnWrite = true};
var ex = Assert.Throws<Exception>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
Assert.AreEqual("Expected exception", ex.Message);
@@ -570,9 +570,9 @@ namespace Apache.Ignite.Core.Tests.Services
{
TypeConfigurations = new List<BinaryTypeConfiguration>
{
- new BinaryTypeConfiguration(typeof(TestIgniteServicePortable)),
- new BinaryTypeConfiguration(typeof(TestIgniteServicePortableErr)),
- new BinaryTypeConfiguration(typeof(PortableObject))
+ new BinaryTypeConfiguration(typeof(TestIgniteServiceBinarizable)),
+ new BinaryTypeConfiguration(typeof(TestIgniteServiceBinarizableErr)),
+ new BinaryTypeConfiguration(typeof(BinarizableObject))
}
}
};
@@ -734,11 +734,11 @@ namespace Apache.Ignite.Core.Tests.Services
if (context.AffinityKey != null && !(context.AffinityKey is int))
{
- var portableObject = context.AffinityKey as IBinaryObject;
+ var binaryObj = context.AffinityKey as IBinaryObject;
- var key = portableObject != null
- ? portableObject.Deserialize<PortableObject>()
- : (PortableObject) context.AffinityKey;
+ var key = binaryObj != null
+ ? binaryObj.Deserialize<BinarizableObject>()
+ : (BinarizableObject) context.AffinityKey;
Assert.AreEqual(AffKey, key.Val);
}
@@ -751,9 +751,9 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Test portable service.
+ /// Test binary service.
/// </summary>
- private class TestIgniteServicePortable : TestIgniteServiceSerializable, IBinarizable
+ private class TestIgniteServiceBinarizable : TestIgniteServiceSerializable, IBinarizable
{
/** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
@@ -769,9 +769,9 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Test portable service with exceptions in marshalling.
+ /// Test binary service with exceptions in marshalling.
/// </summary>
- private class TestIgniteServicePortableErr : TestIgniteServiceSerializable, IBinarizable
+ private class TestIgniteServiceBinarizableErr : TestIgniteServiceSerializable, IBinarizable
{
/** */
public bool ThrowOnWrite { get; set; }
@@ -813,9 +813,9 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Portable object.
+ /// Binary object.
/// </summary>
- private class PortableObject
+ private class BinarizableObject
{
public int Val { get; set; }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
index c75f003..a95ecd7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
@@ -38,16 +38,16 @@ namespace Apache.Ignite.Core.Tests
{
var testTypes = new[]
{
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>),
- typeof (List<TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
+ typeof (TestGenericBinarizable<int>),
+ typeof (TestGenericBinarizable<string>),
+ typeof (TestGenericBinarizable<TestGenericBinarizable<int>>),
+ typeof (TestGenericBinarizable<List<Tuple<int, string>>>),
+ typeof (TestGenericBinarizable<List<TestGenericBinarizable<List<Tuple<int, string>>>>>),
+ typeof (List<TestGenericBinarizable<List<TestGenericBinarizable<List<Tuple<int, string>>>>>>),
+ typeof (TestGenericBinarizable<int, string>),
+ typeof (TestGenericBinarizable<int, TestGenericBinarizable<string>>),
+ typeof (TestGenericBinarizable<int, string, Type>),
+ typeof (TestGenericBinarizable<int, string, TestGenericBinarizable<int, string, Type>>)
};
foreach (var type in testTypes)
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 12abefb..98ea106 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -604,7 +604,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
private void DataStreamerStreamReceiverInvoke(void* target, long rcvPtr, void* cache, long memPtr,
- byte keepPortable)
+ byte keepBinary)
{
SafeCall(() =>
{
@@ -612,14 +612,14 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream, BinaryMode.ForceBinary);
- var portableReceiver = reader.ReadObject<BinaryObject>();
+ var binaryReceiver = reader.ReadObject<BinaryObject>();
var receiver = _handleRegistry.Get<StreamReceiverHolder>(rcvPtr) ??
- portableReceiver.Deserialize<StreamReceiverHolder>();
+ binaryReceiver.Deserialize<StreamReceiverHolder>();
if (receiver != null)
receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx, cache), stream,
- keepPortable != 0);
+ keepBinary != 0);
}
});
}
@@ -893,12 +893,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- bool srvKeepPortable = reader.ReadBoolean();
+ bool srvKeepBinary = reader.ReadBoolean();
var svc = reader.ReadObject<IService>();
ResourceProcessor.Inject(svc, _ignite);
- svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+ svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary)));
return _handleRegistry.Allocate(svc);
}
@@ -915,10 +915,10 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- bool srvKeepPortable = reader.ReadBoolean();
+ bool srvKeepBinary = reader.ReadBoolean();
svc.Execute(new ServiceContext(
- _ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+ _ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary)));
}
});
}
@@ -935,9 +935,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- bool srvKeepPortable = reader.ReadBoolean();
+ bool srvKeepBinary = reader.ReadBoolean();
- svc.Cancel(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+ svc.Cancel(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary)));
}
}
finally
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Config/example-cache-query.xml b/modules/platforms/dotnet/examples/Config/example-cache-query.xml
index 7755645..a3b854b 100644
--- a/modules/platforms/dotnet/examples/Config/example-cache-query.xml
+++ b/modules/platforms/dotnet/examples/Config/example-cache-query.xml
@@ -33,12 +33,12 @@
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
<property name="types">
<list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Account</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Address</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Employee</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.EmployeeKey</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Organization</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.OrganizationType</value>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Config/example-cache.xml b/modules/platforms/dotnet/examples/Config/example-cache.xml
index d31938a..21a6a76 100644
--- a/modules/platforms/dotnet/examples/Config/example-cache.xml
+++ b/modules/platforms/dotnet/examples/Config/example-cache.xml
@@ -32,12 +32,12 @@
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
<property name="types">
<list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Account</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Address</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Employee</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.EmployeeKey</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Organization</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.OrganizationType</value>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 07c1847..d52ae4c 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -763,6 +763,7 @@
<exclude>**/*.fxcop</exclude>
<exclude>**/*.metaproj</exclude>
<exclude>**/*.metaproj.tmp</exclude>
+ <exclude>**/*.nunit</exclude>
<exclude>**/teamcity_boost.cpp</exclude>
<exclude>**/teamcity_messages.h</exclude>
<exclude>**/teamcity_messages.cpp</exclude>
[5/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs
new file mode 100644
index 0000000..74ae244
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs
@@ -0,0 +1,173 @@
+/*
+ * 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
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Binary configuration tests.
+ /// </summary>
+ public class BinaryConfigurationTest
+ {
+ /** Cache. */
+ private ICache<int, TestGenericBinarizableBase> _cache;
+
+ /** Random generator. */
+ private static readonly Random Rnd = new Random();
+
+ /** Test types for code config */
+ private static readonly Type[] TestTypes = {
+ typeof (TestGenericBinarizable<int>),
+ typeof (TestGenericBinarizable<string>),
+ typeof (TestGenericBinarizable<TestGenericBinarizable<int>>),
+ typeof (TestGenericBinarizable<List<Tuple<int, string>>>),
+ typeof (TestGenericBinarizable<int, string>),
+ typeof (TestGenericBinarizable<int, TestGenericBinarizable<string>>),
+ typeof (TestGenericBinarizable<int, string, Type>),
+ typeof (TestGenericBinarizable<int, string, TestGenericBinarizable<int, string, Type>>)
+ };
+
+ /** Test types for xml config */
+ private static readonly Type[] TestTypesXml = {
+ typeof (TestGenericBinarizable<long>),
+ typeof (TestGenericBinarizable<Type>),
+ typeof (TestGenericBinarizable<TestGenericBinarizable<long>>),
+ typeof (TestGenericBinarizable<List<Tuple<long, string>>>),
+ typeof (TestGenericBinarizable<long, string>),
+ typeof (TestGenericBinarizable<long, TestGenericBinarizable<string>>),
+ typeof (TestGenericBinarizable<long, string, Type>),
+ typeof (TestGenericBinarizable<long, string, TestGenericBinarizable<long, string, Type>>)
+ };
+
+ /// <summary>
+ /// Starts the grid with provided config.
+ /// </summary>
+ /// <param name="binaryConfiguration">The binary configuration.</param>
+ private void StartGrid(BinaryConfiguration binaryConfiguration)
+ {
+ Ignition.StopAll(true);
+
+ var grid = Ignition.Start(new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\cache-binarizables.xml",
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ BinaryConfiguration = binaryConfiguration
+ });
+
+ _cache = grid.GetCache<int, TestGenericBinarizableBase>(null);
+ }
+
+ /// <summary>
+ /// Test fixture tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the configuration set in code.
+ /// </summary>
+ [Test]
+ public void TestCodeConfiguration()
+ {
+ StartGrid(new BinaryConfiguration
+ {
+ TypeConfigurations = TestTypes.Select(x => new BinaryTypeConfiguration(x)).ToList()
+ });
+
+ CheckBinarizableTypes(TestTypes);
+ }
+
+ /// <summary>
+ /// Tests the configuration set in xml.
+ /// </summary>
+ [Test]
+ public void TestXmlConfiguration()
+ {
+ StartGrid(null);
+
+ CheckBinarizableTypes(TestTypesXml);
+ }
+
+ /// <summary>
+ /// Checks that specified types are binarizable and can be successfully used in cache.
+ /// </summary>
+ private void CheckBinarizableTypes(IEnumerable<Type> testTypes)
+ {
+ int key = 0;
+
+ foreach (var typ in testTypes)
+ {
+ key += 1;
+
+ var inst = CreateInstance(typ);
+
+ _cache.Put(key, inst);
+
+ var result = _cache.Get(key);
+
+ Assert.AreEqual(inst.Prop, result.Prop);
+
+ Assert.AreEqual(typ, result.GetType());
+ }
+ }
+
+ /// <summary>
+ /// Creates the instance of specified test binarizable type and sets a value on it.
+ /// </summary>
+ private static TestGenericBinarizableBase CreateInstance(Type type)
+ {
+ var inst = (TestGenericBinarizableBase)Activator.CreateInstance(type);
+
+ inst.Prop = Rnd.Next(int.MaxValue);
+
+ return inst;
+ }
+ }
+
+ public abstract class TestGenericBinarizableBase
+ {
+ public object Prop { get; set; }
+ }
+
+ public class TestGenericBinarizable<T> : TestGenericBinarizableBase
+ {
+ public T Prop1 { get; set; }
+ }
+
+ public class TestGenericBinarizable<T1, T2> : TestGenericBinarizableBase
+ {
+ public T1 Prop1 { get; set; }
+ public T2 Prop2 { get; set; }
+ }
+
+ public class TestGenericBinarizable<T1, T2, T3> : TestGenericBinarizableBase
+ {
+ public T1 Prop1 { get; set; }
+ public T2 Prop2 { get; set; }
+ public T3 Prop3 { get; set; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 7df0e5a..64124d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -148,7 +148,7 @@ namespace Apache.Ignite.Core.Tests.Cache
public bool ThrowErr { get; set; }
// Error flag
- public bool ThrowErrPortable { get; set; }
+ public bool ThrowErrBinarizable { get; set; }
// Error flag
public bool ThrowErrNonSerializable { get; set; }
@@ -179,8 +179,8 @@ namespace Apache.Ignite.Core.Tests.Cache
if (ThrowErr)
throw new Exception(ExceptionText);
- if (ThrowErrPortable)
- throw new PortableTestException {Info = ExceptionText};
+ if (ThrowErrBinarizable)
+ throw new BinarizableTestException {Info = ExceptionText};
if (ThrowErrNonSerializable)
throw new NonSerializableException();
@@ -204,9 +204,9 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Portable add processor.
+ /// Binary add processor.
/// </summary>
- public class PortableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IBinarizable
+ public class BinarizableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IBinarizable
{
/** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
@@ -214,7 +214,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var w = writer.GetRawWriter();
w.WriteBoolean(ThrowErr);
- w.WriteBoolean(ThrowErrPortable);
+ w.WriteBoolean(ThrowErrBinarizable);
w.WriteBoolean(ThrowErrNonSerializable);
w.WriteInt(ThrowOnKey);
w.WriteBoolean(Remove);
@@ -227,7 +227,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var r = reader.GetRawReader();
ThrowErr = r.ReadBoolean();
- ThrowErrPortable = r.ReadBoolean();
+ ThrowErrBinarizable = r.ReadBoolean();
ThrowErrNonSerializable = r.ReadBoolean();
ThrowOnKey = r.ReadInt();
Remove = r.ReadBoolean();
@@ -244,9 +244,9 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Portable exception.
+ /// Binary exception.
/// </summary>
- public class PortableTestException : Exception, IBinarizable
+ public class BinarizableTestException : Exception, IBinarizable
{
/// <summary>
/// Gets or sets exception info.
@@ -298,11 +298,11 @@ namespace Apache.Ignite.Core.Tests.Cache
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortablePerson)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizablePerson)));
portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(CacheTestKey)));
portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestReferenceObject)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableAddArgCacheEntryProcessor)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTestException)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableAddArgCacheEntryProcessor)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableTestException)));
portCfg.TypeConfigurations = portTypeCfgs;
@@ -1558,11 +1558,11 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestPutGetPortable()
+ public void TestPutGetBinary()
{
- var cache = Cache<int, PortablePerson>();
+ var cache = Cache<int, BinarizablePerson>();
- PortablePerson obj1 = new PortablePerson("obj1", 1);
+ BinarizablePerson obj1 = new BinarizablePerson("obj1", 1);
cache.Put(1, obj1);
@@ -1573,11 +1573,11 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestPutGetPortableAsync()
+ public void TestPutGetBinaryAsync()
{
- var cache = Cache<int, PortablePerson>().WrapAsync();
+ var cache = Cache<int, BinarizablePerson>().WrapAsync();
- PortablePerson obj1 = new PortablePerson("obj1", 1);
+ BinarizablePerson obj1 = new BinarizablePerson("obj1", 1);
cache.Put(1, obj1);
@@ -1588,7 +1588,7 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestPutGetPortableKey()
+ public void TestPutGetBinaryKey()
{
var cache = Cache<CacheTestKey, string>();
@@ -1674,7 +1674,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Category(TestUtils.CategoryIntensive)]
public void TestPutGetAsyncMultithreaded()
{
- var cache = Cache<CacheTestKey, PortablePerson>();
+ var cache = Cache<CacheTestKey, BinarizablePerson>();
const int threads = 10;
const int objPerThread = 1000;
@@ -1692,7 +1692,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- futs.Add(cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key)));
+ futs.Add(cache.PutAsync(new CacheTestKey(key), new BinarizablePerson("Person-" + key, key)));
}
foreach (var fut in futs)
@@ -1729,7 +1729,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key)).Wait();
+ cache.PutAsync(new CacheTestKey(key), new BinarizablePerson("Person-" + key, key)).Wait();
}
}, threads);
@@ -1739,7 +1739,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<Task<PortablePerson>>();
+ var futs = new List<Task<BinarizablePerson>>();
for (int i = 0; i < objPerThread; i++)
{
@@ -1765,9 +1765,9 @@ namespace Apache.Ignite.Core.Tests.Cache
//[Test]
//[Category(TestUtils.CATEGORY_INTENSIVE)]
- public void TestAsyncMultithreadedKeepPortable()
+ public void TestAsyncMultithreadedKeepBinary()
{
- var cache = Cache().WithKeepBinary<CacheTestKey, PortablePerson>();
+ var cache = Cache().WithKeepBinary<CacheTestKey, BinarizablePerson>();
var portCache = Cache().WithKeepBinary<CacheTestKey, IBinaryObject>();
const int threads = 10;
@@ -1786,7 +1786,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- var task = cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
+ var task = cache.PutAsync(new CacheTestKey(key), new BinarizablePerson("Person-" + key, key));
futs.Add(task);
}
@@ -2742,15 +2742,15 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestKeepPortableFlag()
+ public void TestKeepBinaryFlag()
{
- TestKeepPortableFlag(false);
+ TestKeepBinaryFlag(false);
}
[Test]
- public void TestKeepPortableFlagAsync()
+ public void TestKeepBinaryFlagAsync()
{
- TestKeepPortableFlag(true);
+ TestKeepBinaryFlag(true);
}
[Test]
@@ -2793,7 +2793,7 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestSerializableKeepPortable()
+ public void TestSerializableKeepBinary()
{
var cache = Cache<int, TestSerializableObject>();
@@ -2801,9 +2801,9 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.Put(1, obj);
- var portableResult = cache.WithKeepBinary<int, IBinaryObject>().Get(1);
+ var binaryRes = cache.WithKeepBinary<int, IBinaryObject>().Get(1);
- var resultObj = portableResult.Deserialize<TestSerializableObject>();
+ var resultObj = binaryRes.Deserialize<TestSerializableObject>();
Assert.AreEqual(obj, resultObj);
}
@@ -2823,7 +2823,7 @@ namespace Apache.Ignite.Core.Tests.Cache
private void TestInvoke(bool async)
{
TestInvoke<AddArgCacheEntryProcessor>(async);
- TestInvoke<PortableAddArgCacheEntryProcessor>(async);
+ TestInvoke<BinarizableAddArgCacheEntryProcessor>(async);
try
{
@@ -2863,7 +2863,7 @@ namespace Apache.Ignite.Core.Tests.Cache
// Test exceptions
AssertThrowsCacheEntryProcessorException(() => cache.Invoke(key, new T {ThrowErr = true}, arg));
AssertThrowsCacheEntryProcessorException(
- () => cache.Invoke(key, new T {ThrowErrPortable = true}, arg));
+ () => cache.Invoke(key, new T {ThrowErrBinarizable = true}, arg));
AssertThrowsCacheEntryProcessorException(
() => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "BinaryObjectException");
}
@@ -2904,7 +2904,7 @@ namespace Apache.Ignite.Core.Tests.Cache
for (var i = 1; i < 10; i++)
{
TestInvokeAll<AddArgCacheEntryProcessor>(async, i);
- TestInvokeAll<PortableAddArgCacheEntryProcessor>(async, i);
+ TestInvokeAll<BinarizableAddArgCacheEntryProcessor>(async, i);
try
{
@@ -2956,7 +2956,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var errKey = entries.Keys.Reverse().Take(5).Last();
TestInvokeAllException(cache, entries, new T { ThrowErr = true, ThrowOnKey = errKey }, arg, errKey);
- TestInvokeAllException(cache, entries, new T { ThrowErrPortable = true, ThrowOnKey = errKey },
+ TestInvokeAllException(cache, entries, new T { ThrowErrBinarizable = true, ThrowOnKey = errKey },
arg, errKey);
TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey },
arg, errKey, "BinaryObjectException");
@@ -3088,20 +3088,20 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(5, cache[1]);
}
- private void TestKeepPortableFlag(bool async)
+ private void TestKeepBinaryFlag(bool async)
{
var cache0 = async ? Cache().WrapAsync() : Cache();
- var cache = cache0.WithKeepBinary<int, PortablePerson>();
+ var cache = cache0.WithKeepBinary<int, BinarizablePerson>();
- var portCache = cache0.WithKeepBinary<int, IBinaryObject>();
+ var binCache = cache0.WithKeepBinary<int, IBinaryObject>();
int cnt = 10;
IList<int> keys = new List<int>();
for (int i = 0; i < cnt; i++ ) {
- cache.Put(i, new PortablePerson("person-" + i, i));
+ cache.Put(i, new BinarizablePerson("person-" + i, i));
keys.Add(i);
}
@@ -3110,7 +3110,7 @@ namespace Apache.Ignite.Core.Tests.Cache
for (int i = 0; i < cnt; i++)
{
- var obj = portCache.Get(i);
+ var obj = binCache.Get(i);
CheckPersonData(obj, "person-" + i, i);
@@ -3125,10 +3125,10 @@ namespace Apache.Ignite.Core.Tests.Cache
CheckPersonData(obj, "person-" + i, i);
}
- // Check keepPortable for GetAll operation.
- var allObjs1 = portCache.GetAll(keys);
+ // Check keepBinary for GetAll operation.
+ var allObjs1 = binCache.GetAll(keys);
- var allObjs2 = portCache.GetAll(keys);
+ var allObjs2 = binCache.GetAll(keys);
for (int i = 0; i < cnt; i++)
{
@@ -3137,7 +3137,7 @@ namespace Apache.Ignite.Core.Tests.Cache
CheckPersonData(allObjs2[i], "person-" + i, i);
}
- // Check keepPortable for Remove operation.
+ // Check keepBinary for Remove operation.
var success0 = cache.Remove(0);
var success1 = cache.Remove(1);
@@ -3150,7 +3150,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(expName, obj.GetField<string>("name"));
Assert.AreEqual(expAge, obj.GetField<int>("age"));
- PortablePerson person = obj.Deserialize<PortablePerson>();
+ BinarizablePerson person = obj.Deserialize<BinarizablePerson>();
Assert.AreEqual(expName, person.Name);
Assert.AreEqual(expAge, person.Age);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
index abb9e02..5a1af03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -77,10 +77,10 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Test affinity with portable flag.
+ /// Test affinity with binary flag.
/// </summary>
[Test]
- public void TestAffinityPortable()
+ public void TestAffinityBinary()
{
IIgnite g = Ignition.GetIgnite("grid-0");
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
index 693a664..63443b7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -109,17 +109,17 @@ namespace Apache.Ignite.Core.Tests.Cache
{
Assert.Throws<ArgumentException>(() =>
{
- Ignition.GetIgnite(GridData).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ Ignition.GetIgnite(GridData).GetCache<CacheTestKey, BinarizablePerson>(CacheDummy);
});
Assert.Throws<ArgumentException>(() =>
{
- Ignition.GetIgnite(GridDataNoCfg).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ Ignition.GetIgnite(GridDataNoCfg).GetCache<CacheTestKey, BinarizablePerson>(CacheDummy);
});
Assert.Throws<ArgumentException>(() =>
{
- Ignition.GetIgnite(GridClient).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ Ignition.GetIgnite(GridClient).GetCache<CacheTestKey, BinarizablePerson>(CacheDummy);
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 74c4801..411ef05 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -64,8 +64,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
TypeConfigurations = new[]
{
new BinaryTypeConfiguration(typeof (QueryPerson)),
- new BinaryTypeConfiguration(typeof (PortableScanQueryFilter<QueryPerson>)),
- new BinaryTypeConfiguration(typeof (PortableScanQueryFilter<BinaryObject>))
+ new BinaryTypeConfiguration(typeof (BinarizableScanQueryFilter<QueryPerson>)),
+ new BinaryTypeConfiguration(typeof (BinarizableScanQueryFilter<BinaryObject>))
}
},
JvmClasspath = TestUtils.CreateTestClasspath(),
@@ -359,10 +359,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check SQL query in portable mode.
+ /// Check SQL query in binary mode.
/// </summary>
[Test]
- public void TestSqlQueryPortable()
+ public void TestSqlQueryBinary()
{
CheckSqlQuery(MaxItemCnt, false, true);
}
@@ -377,10 +377,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check local SQL query in portable mode.
+ /// Check local SQL query in binary mode.
/// </summary>
[Test]
- public void TestSqlQueryLocalPortable()
+ public void TestSqlQueryLocalBinary()
{
CheckSqlQuery(MaxItemCnt, true, true);
}
@@ -390,8 +390,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckSqlQuery(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckSqlQuery(int cnt, bool loc, bool keepBinary)
{
var cache = Cache();
@@ -402,7 +402,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
SqlQuery qry = loc ? new SqlQuery(typeof(QueryPerson), "age < 50", true) :
new SqlQuery(typeof(QueryPerson), "age < 50");
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
}
/// <summary>
@@ -479,10 +479,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check SQL query in portable mode.
+ /// Check SQL query in binary mode.
/// </summary>
[Test]
- public void TestTextQueryPortable()
+ public void TestTextQueryBinary()
{
CheckTextQuery(MaxItemCnt, false, true);
}
@@ -497,10 +497,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check local SQL query in portable mode.
+ /// Check local SQL query in binary mode.
/// </summary>
[Test]
- public void TestTextQueryLocalPortable()
+ public void TestTextQueryLocalBinary()
{
CheckTextQuery(MaxItemCnt, true, true);
}
@@ -510,8 +510,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckTextQuery(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckTextQuery(int cnt, bool loc, bool keepBinary)
{
var cache = Cache();
@@ -522,7 +522,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
TextQuery qry = loc ? new TextQuery(typeof(QueryPerson), "1*", true) :
new TextQuery(typeof(QueryPerson), "1*");
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
}
/// <summary>
@@ -535,10 +535,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check scan query in portable mode.
+ /// Check scan query in binary mode.
/// </summary>
[Test]
- public void TestScanQueryPortable()
+ public void TestScanQueryBinary()
{
CheckScanQuery<BinaryObject>(MaxItemCnt, false, true);
}
@@ -553,10 +553,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check local scan query in portable mode.
+ /// Check local scan query in binary mode.
/// </summary>
[Test]
- public void TestScanQueryLocalPortable()
+ public void TestScanQueryLocalBinary()
{
CheckScanQuery<BinaryObject>(MaxItemCnt, true, true);
}
@@ -572,11 +572,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check scan query with partitions in portable mode.
+ /// Check scan query with partitions in binary mode.
/// </summary>
[Test]
[Ignore("IGNITE-1012")]
- public void TestScanQueryPartitionsPortable([Values(true, false)] bool loc)
+ public void TestScanQueryPartitionsBinary([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);
}
@@ -609,36 +609,36 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckScanQuery<TV>(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckScanQuery<TV>(int cnt, bool loc, bool keepBinary)
{
var cache = Cache();
// No predicate
var exp = PopulateCache(cache, loc, cnt, x => true);
var qry = new ScanQuery<int, TV>();
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
// Serializable
exp = PopulateCache(cache, loc, cnt, x => x < 50);
qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>());
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
- // Portable
+ // Binarizable
exp = PopulateCache(cache, loc, cnt, x => x < 50);
- qry = new ScanQuery<int, TV>(new PortableScanQueryFilter<TV>());
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ qry = new ScanQuery<int, TV>(new BinarizableScanQueryFilter<TV>());
+ ValidateQueryResults(cache, qry, exp, keepBinary);
// Invalid
exp = PopulateCache(cache, loc, cnt, x => x < 50);
qry = new ScanQuery<int, TV>(new InvalidScanQueryFilter<TV>());
- Assert.Throws<BinaryObjectException>(() => ValidateQueryResults(cache, qry, exp, keepPortable));
+ Assert.Throws<BinaryObjectException>(() => ValidateQueryResults(cache, qry, exp, keepBinary));
// Exception
exp = PopulateCache(cache, loc, cnt, x => x < 50);
qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV> {ThrowErr = true});
- var ex = Assert.Throws<IgniteException>(() => ValidateQueryResults(cache, qry, exp, keepPortable));
+ var ex = Assert.Throws<IgniteException>(() => ValidateQueryResults(cache, qry, exp, keepBinary));
Assert.AreEqual(ScanQueryFilter<TV>.ErrMessage, ex.Message);
}
@@ -647,8 +647,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepBinary)
{
StopGrids();
StartGrids();
@@ -669,7 +669,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
var qry = new ScanQuery<int, TV> { Partition = part };
Console.WriteLine("Checking query on partition " + part);
- ValidateQueryResults(cache, qry, exp0, keepPortable);
+ ValidateQueryResults(cache, qry, exp0, keepBinary);
}
// Partitions with predicate
@@ -686,7 +686,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
var qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>()) { Partition = part };
Console.WriteLine("Checking predicate query on partition " + part);
- ValidateQueryResults(cache, qry, exp0, keepPortable);
+ ValidateQueryResults(cache, qry, exp0, keepBinary);
}
}
@@ -697,11 +697,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// <param name="cache">Cache.</param>
/// <param name="qry">Query.</param>
/// <param name="exp">Expected keys.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
+ /// <param name="keepBinary">Keep binary flag.</param>
private static void ValidateQueryResults(ICache<int, QueryPerson> cache, QueryBase qry, HashSet<int> exp,
- bool keepPortable)
+ bool keepBinary)
{
- if (keepPortable)
+ if (keepBinary)
{
var cache0 = cache.WithKeepBinary<int, IBinaryObject>();
@@ -906,9 +906,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Portable query filter.
+ /// binary query filter.
/// </summary>
- public class PortableScanQueryFilter<TV> : ScanQueryFilter<TV>, IBinarizable
+ public class BinarizableScanQueryFilter<TV> : ScanQueryFilter<TV>, IBinarizable
{
/** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 b81405b..cb9542f 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
@@ -69,10 +69,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
private IIgnite grid2;
/** Cache on the first node. */
- private ICache<int, PortableEntry> cache1;
+ private ICache<int, BinarizableEntry> cache1;
/** Cache on the second node. */
- private ICache<int, PortableEntry> cache2;
+ private ICache<int, BinarizableEntry> cache2;
/** Cache name. */
private readonly string cacheName;
@@ -101,9 +101,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableEntry)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFilter)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepPortableFilter)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableEntry)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFilter)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepBinaryFilter)));
portCfg.TypeConfigurations = portTypeCfgs;
@@ -114,11 +114,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
cfg.GridName = "grid-1";
grid1 = Ignition.Start(cfg);
- cache1 = grid1.GetCache<int, PortableEntry>(cacheName);
+ cache1 = grid1.GetCache<int, BinarizableEntry>(cacheName);
cfg.GridName = "grid-2";
grid2 = Ignition.Start(cfg);
- cache2 = grid2.GetCache<int, PortableEntry>(cacheName);
+ cache2 = grid2.GetCache<int, BinarizableEntry>(cacheName);
}
/// <summary>
@@ -139,10 +139,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
CB_EVTS = new BlockingCollection<CallbackEvent>();
FILTER_EVTS = new BlockingCollection<FilterEvent>();
- AbstractFilter<PortableEntry>.res = true;
- AbstractFilter<PortableEntry>.err = false;
- AbstractFilter<PortableEntry>.marshErr = false;
- AbstractFilter<PortableEntry>.unmarshErr = false;
+ AbstractFilter<BinarizableEntry>.res = true;
+ AbstractFilter<BinarizableEntry>.err = false;
+ AbstractFilter<BinarizableEntry>.marshErr = false;
+ AbstractFilter<BinarizableEntry>.unmarshErr = false;
cache1.Remove(PrimaryKey(cache1));
cache1.Remove(PrimaryKey(cache2));
@@ -159,7 +159,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
[Test]
public void TestValidation()
{
- Assert.Throws<ArgumentException>(() => { cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(null)); });
+ Assert.Throws<ArgumentException>(() => { cache1.QueryContinuous(new ContinuousQuery<int, BinarizableEntry>(null)); });
}
/// <summary>
@@ -171,8 +171,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
int key2 = PrimaryKey(cache2);
- ContinuousQuery<int, PortableEntry> qry =
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry =
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
IDisposable qryHnd;
@@ -208,9 +208,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
int key2 = PrimaryKey(cache2);
- ContinuousQuery<int, PortableEntry> qry = loc ?
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>(), true) :
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry = loc ?
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>(), true) :
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
using (cache1.QueryContinuous(qry))
{
@@ -260,21 +260,21 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
[Test]
public void TestCallbackInjection()
{
- Listener<PortableEntry> cb = new Listener<PortableEntry>();
+ Listener<BinarizableEntry> cb = new Listener<BinarizableEntry>();
Assert.IsNull(cb.ignite);
- using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb)))
+ using (cache1.QueryContinuous(new ContinuousQuery<int, BinarizableEntry>(cb)))
{
Assert.IsNotNull(cb.ignite);
}
}
/// <summary>
- /// Test portable filter logic.
+ /// Test binarizable filter logic.
/// </summary>
[Test]
- public void TestFilterPortable()
+ public void TestFilterBinarizable()
{
CheckFilter(true, false);
}
@@ -291,17 +291,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter.
/// </summary>
- /// <param name="portable">Portable.</param>
+ /// <param name="binarizable">Binarizable.</param>
/// <param name="loc">Local cache flag.</param>
- protected void CheckFilter(bool portable, bool loc)
+ protected void CheckFilter(bool binarizable, bool loc)
{
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>) new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = loc ?
- new ContinuousQuery<int, PortableEntry>(lsnr, filter, true) :
- new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = loc ?
+ new ContinuousQuery<int, BinarizableEntry>(lsnr, filter, true) :
+ new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
using (cache1.QueryContinuous(qry))
{
@@ -326,7 +326,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
CheckCallbackSingle(key2, null, Entry(key2));
}
- AbstractFilter<PortableEntry>.res = false;
+ AbstractFilter<BinarizableEntry>.res = false;
// Ignored put from local node.
cache1.GetAndPut(key1, Entry(key1 + 1));
@@ -346,11 +346,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter error during invoke.
+ /// Test binarizable filter error during invoke.
/// </summary>
[Ignore("IGNITE-521")]
[Test]
- public void TestFilterInvokeErrorPortable()
+ public void TestFilterInvokeErrorBinarizable()
{
CheckFilterInvokeError(true);
}
@@ -368,15 +368,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter error handling logic during invoke.
/// </summary>
- private void CheckFilterInvokeError(bool portable)
+ private void CheckFilterInvokeError(bool binarizable)
{
- AbstractFilter<PortableEntry>.err = true;
+ AbstractFilter<BinarizableEntry>.err = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>) new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>) new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
using (cache1.QueryContinuous(qry))
{
@@ -415,10 +415,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter marshalling error.
+ /// Test binarizable filter marshalling error.
/// </summary>
[Test]
- public void TestFilterMarshalErrorPortable()
+ public void TestFilterMarshalErrorBinarizable()
{
CheckFilterMarshalError(true);
}
@@ -435,16 +435,16 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter marshal error handling.
/// </summary>
- /// <param name="portable">Portable flag.</param>
- private void CheckFilterMarshalError(bool portable)
+ /// <param name="binarizable">Binarizable flag.</param>
+ private void CheckFilterMarshalError(bool binarizable)
{
- AbstractFilter<PortableEntry>.marshErr = true;
+ AbstractFilter<BinarizableEntry>.marshErr = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>)new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
Assert.Throws<Exception>(() =>
{
@@ -470,14 +470,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="loc"></param>
protected void CheckFilterNonSerializable(bool loc)
{
- AbstractFilter<PortableEntry>.unmarshErr = true;
+ AbstractFilter<BinarizableEntry>.unmarshErr = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter = new LocalFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter = new LocalFilter();
- ContinuousQuery<int, PortableEntry> qry = loc
- ? new ContinuousQuery<int, PortableEntry>(lsnr, filter, true)
- : new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = loc
+ ? new ContinuousQuery<int, BinarizableEntry>(lsnr, filter, true)
+ : new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
if (loc)
{
@@ -502,11 +502,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter unmarshalling error.
+ /// Test binarizable filter unmarshalling error.
/// </summary>
[Ignore("IGNITE-521")]
[Test]
- public void TestFilterUnmarshalErrorPortable()
+ public void TestFilterUnmarshalErrorBinarizable()
{
CheckFilterUnmarshalError(true);
}
@@ -524,16 +524,16 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter unmarshal error handling.
/// </summary>
- /// <param name="portable">Portable flag.</param>
- private void CheckFilterUnmarshalError(bool portable)
+ /// <param name="binarizable">Binarizable flag.</param>
+ private void CheckFilterUnmarshalError(bool binarizable)
{
- AbstractFilter<PortableEntry>.unmarshErr = true;
+ AbstractFilter<BinarizableEntry>.unmarshErr = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>) new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
using (cache1.QueryContinuous(qry))
{
@@ -566,12 +566,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
[Test]
public void TestFilterInjection()
{
- Listener<PortableEntry> cb = new Listener<PortableEntry>();
- PortableFilter filter = new PortableFilter();
+ Listener<BinarizableEntry> cb = new Listener<BinarizableEntry>();
+ BinarizableFilter filter = new BinarizableFilter();
Assert.IsNull(filter.ignite);
- using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb, filter)))
+ using (cache1.QueryContinuous(new ContinuousQuery<int, BinarizableEntry>(cb, filter)))
{
// Local injection.
Assert.IsNotNull(filter.ignite);
@@ -589,15 +589,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
- /// Test "keep-portable" scenario.
+ /// Test "keep-binary" scenario.
/// </summary>
[Test]
- public void TestKeepPortable()
+ public void TestKeepBinary()
{
var cache = cache1.WithKeepBinary<int, IBinaryObject>();
ContinuousQuery<int, IBinaryObject> qry = new ContinuousQuery<int, IBinaryObject>(
- new Listener<IBinaryObject>(), new KeepPortableFilter());
+ new Listener<IBinaryObject>(), new KeepBinaryFilter());
using (cache.QueryContinuous(qry))
{
@@ -611,14 +611,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
Assert.AreEqual(PrimaryKey(cache1), filterEvt.entry.Key);
Assert.AreEqual(null, filterEvt.entry.OldValue);
Assert.AreEqual(Entry(1), (filterEvt.entry.Value as IBinaryObject)
- .Deserialize<PortableEntry>());
+ .Deserialize<BinarizableEntry>());
Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
Assert.AreEqual(1, cbEvt.entries.Count);
Assert.AreEqual(PrimaryKey(cache1), cbEvt.entries.First().Key);
Assert.AreEqual(null, cbEvt.entries.First().OldValue);
Assert.AreEqual(Entry(1), (cbEvt.entries.First().Value as IBinaryObject)
- .Deserialize<PortableEntry>());
+ .Deserialize<BinarizableEntry>());
// 2. Remote put.
cache1.GetAndPut(PrimaryKey(cache2), Entry(2));
@@ -627,14 +627,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
Assert.AreEqual(PrimaryKey(cache2), filterEvt.entry.Key);
Assert.AreEqual(null, filterEvt.entry.OldValue);
Assert.AreEqual(Entry(2), (filterEvt.entry.Value as IBinaryObject)
- .Deserialize<PortableEntry>());
+ .Deserialize<BinarizableEntry>());
Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
Assert.AreEqual(1, cbEvt.entries.Count);
Assert.AreEqual(PrimaryKey(cache2), cbEvt.entries.First().Key);
Assert.AreEqual(null, cbEvt.entries.First().OldValue);
Assert.AreEqual(Entry(2),
- (cbEvt.entries.First().Value as IBinaryObject).Deserialize<PortableEntry>());
+ (cbEvt.entries.First().Value as IBinaryObject).Deserialize<BinarizableEntry>());
}
}
/// <summary>
@@ -697,7 +697,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
// Put two remote keys in advance.
List<int> rmtKeys = PrimaryKeys(cache2, 2);
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
qry.BufferSize = 2;
qry.TimeInterval = TimeSpan.FromMilliseconds(1000000);
@@ -743,8 +743,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
int key2 = PrimaryKey(cache2);
- ContinuousQuery<int, PortableEntry> qry =
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry =
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
qry.BufferSize = 2;
qry.TimeInterval = TimeSpan.FromMilliseconds(500);
@@ -791,26 +791,26 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
public void TestInitialQuery()
{
// Scan query, GetAll
- TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.GetAll());
+ TestInitialQuery(new ScanQuery<int, BinarizableEntry>(new InitialQueryScanFilter()), cur => cur.GetAll());
// Scan query, iterator
- TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.ToList());
+ TestInitialQuery(new ScanQuery<int, BinarizableEntry>(new InitialQueryScanFilter()), cur => cur.ToList());
// Sql query, GetAll
- TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.GetAll());
+ TestInitialQuery(new SqlQuery(typeof(BinarizableEntry), "val < 33"), cur => cur.GetAll());
// Sql query, iterator
- TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.ToList());
+ TestInitialQuery(new SqlQuery(typeof(BinarizableEntry), "val < 33"), cur => cur.ToList());
// Text query, GetAll
- TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.GetAll());
+ TestInitialQuery(new TextQuery(typeof(BinarizableEntry), "1*"), cur => cur.GetAll());
// Text query, iterator
- TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.ToList());
+ TestInitialQuery(new TextQuery(typeof(BinarizableEntry), "1*"), cur => cur.ToList());
// Test exception: invalid initial query
var ex = Assert.Throws<IgniteException>(
- () => TestInitialQuery(new TextQuery(typeof (PortableEntry), "*"), cur => cur.GetAll()));
+ () => TestInitialQuery(new TextQuery(typeof (BinarizableEntry), "*"), cur => cur.GetAll()));
Assert.AreEqual("Cannot parse '*': '*' or '?' not allowed as first character in WildcardQuery", ex.Message);
}
@@ -818,10 +818,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Tests the initial query.
/// </summary>
- private void TestInitialQuery(QueryBase initialQry, Func<IQueryCursor<ICacheEntry<int, PortableEntry>>,
- IEnumerable<ICacheEntry<int, PortableEntry>>> getAllFunc)
+ private void TestInitialQuery(QueryBase initialQry, Func<IQueryCursor<ICacheEntry<int, BinarizableEntry>>,
+ IEnumerable<ICacheEntry<int, BinarizableEntry>>> getAllFunc)
{
- var qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ var qry = new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
cache1.Put(11, Entry(11));
cache1.Put(12, Entry(12));
@@ -829,7 +829,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
try
{
- IContinuousQueryHandle<ICacheEntry<int, PortableEntry>> contQry;
+ IContinuousQueryHandle<ICacheEntry<int, BinarizableEntry>> contQry;
using (contQry = cache1.QueryContinuous(qry, initialQry))
{
@@ -868,7 +868,7 @@ 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 value.</param>
- private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
+ private void CheckFilterSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal)
{
CheckFilterSingle(expKey, expOldVal, expVal, 1000);
}
@@ -880,7 +880,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected value.</param>
/// <param name="timeout">Timeout.</param>
- private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
+ private void CheckFilterSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal, int timeout)
{
FilterEvent evt;
@@ -908,7 +908,7 @@ 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 void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
+ private void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal)
{
CheckCallbackSingle(expKey, expOldVal, expVal, 1000);
}
@@ -920,7 +920,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected new value.</param>
/// <param name="timeout">Timeout.</param>
- private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
+ private void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal, int timeout)
{
CallbackEvent evt;
@@ -949,9 +949,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// </summary>
/// <param name="val">Value.</param>
/// <returns>Entry.</returns>
- private static PortableEntry Entry(int val)
+ private static BinarizableEntry Entry(int val)
{
- return new PortableEntry(val);
+ return new BinarizableEntry(val);
}
/// <summary>
@@ -1010,9 +1010,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Portable entry.
+ /// Binarizable entry.
/// </summary>
- public class PortableEntry
+ public class BinarizableEntry
{
/** Value. */
public readonly int val;
@@ -1027,7 +1027,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// Constructor.
/// </summary>
/// <param name="val">Value.</param>
- public PortableEntry(int val)
+ public BinarizableEntry(int val)
{
this.val = val;
}
@@ -1035,7 +1035,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/** <inheritDoc /> */
public override bool Equals(object obj)
{
- return obj != null && obj is PortableEntry && ((PortableEntry)obj).val == val;
+ return obj != null && obj is BinarizableEntry && ((BinarizableEntry)obj).val == val;
}
}
@@ -1076,15 +1076,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Filter which cannot be serialized.
/// </summary>
- public class LocalFilter : AbstractFilter<PortableEntry>
+ public class LocalFilter : AbstractFilter<BinarizableEntry>
{
// No-op.
}
/// <summary>
- /// Portable filter.
+ /// Binarizable filter.
/// </summary>
- public class PortableFilter : AbstractFilter<PortableEntry>, IBinarizable
+ public class BinarizableFilter : AbstractFilter<BinarizableEntry>, IBinarizable
{
/** <inheritDoc /> */
public void WriteBinary(IBinaryWriter writer)
@@ -1105,7 +1105,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// Serializable filter.
/// </summary>
[Serializable]
- public class SerializableFilter : AbstractFilter<PortableEntry>, ISerializable
+ public class SerializableFilter : AbstractFilter<BinarizableEntry>, ISerializable
{
/// <summary>
/// Constructor.
@@ -1135,9 +1135,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Filter for "keep-portable" scenario.
+ /// Filter for "keep-binary" scenario.
/// </summary>
- public class KeepPortableFilter : AbstractFilter<IBinaryObject>
+ public class KeepBinaryFilter : AbstractFilter<IBinaryObject>
{
// No-op.
}
@@ -1173,7 +1173,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
IBinaryType meta = val.GetBinaryType();
- Assert.AreEqual(typeof(PortableEntry).Name, meta.TypeName);
+ Assert.AreEqual(typeof(BinarizableEntry).Name, meta.TypeName);
}
countDown.Signal();
@@ -1225,10 +1225,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// ScanQuery filter for InitialQuery test.
/// </summary>
[Serializable]
- private class InitialQueryScanFilter : ICacheEntryFilter<int, PortableEntry>
+ private class InitialQueryScanFilter : ICacheEntryFilter<int, BinarizableEntry>
{
/** <inheritdoc /> */
- public bool Invoke(ICacheEntry<int, PortableEntry> entry)
+ public bool Invoke(ICacheEntry<int, BinarizableEntry> entry)
{
return entry.Key < 33;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
index aa7d627..1d2f1f2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
@@ -43,10 +43,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter logic.
+ /// Test binary filter logic.
/// </summary>
[Test]
- public void TestFilterPortableLocal()
+ public void TestFilterBinarizableLocal()
{
CheckFilter(true, true);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index eb148f0..1270138 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -117,7 +117,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
public class CacheStoreTest
{
/** */
- private const string PortableStoreCacheName = "portable_store";
+ private const string BinaryStoreCacheName = "binary_store";
/** */
private const string ObjectStoreCacheName = "object_store";
@@ -145,7 +145,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
IgniteConfigurationEx cfg = new IgniteConfigurationEx();
- cfg.GridName = GridName();
+ cfg.GridName = GridName;
cfg.JvmClasspath = TestUtils.CreateTestClasspath();
cfg.JvmOptions = TestUtils.TestJavaOptions();
cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
@@ -183,7 +183,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[TearDown]
public void AfterTest()
{
- var cache = Cache();
+ var cache = GetCache();
cache.Clear();
@@ -191,7 +191,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
CacheTestStore.Reset();
- TestUtils.AssertHandleRegistryHasItems(300, _storeCount, Ignition.GetIgnite(GridName()));
+ TestUtils.AssertHandleRegistryHasItems(300, _storeCount, Ignition.GetIgnite(GridName));
Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
}
@@ -199,7 +199,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLoadCache()
{
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -220,7 +220,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLocalLoadCache()
{
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
{
CacheTestStore.LoadObjects = true;
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -255,7 +255,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLoadCacheAsync()
{
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -272,7 +272,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestPutLoad()
{
- var cache = Cache();
+ var cache = GetCache();
cache.Put(1, "val");
@@ -290,9 +290,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
}
[Test]
- public void TestPutLoadPortables()
+ public void TestPutLoadBinarizable()
{
- var cache = PortableStoreCache<int, Value>();
+ var cache = GetBinaryStoreCache<int, Value>();
cache.Put(1, new Value(1));
@@ -316,7 +316,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestPutLoadObjects()
{
- var cache = ObjectStoreCache<int, Value>();
+ var cache = GetObjectStoreCache<int, Value>();
cache.Put(1, new Value(1));
@@ -345,7 +345,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
for (int i = 0; i < 10; i++)
putMap.Add(i, "val_" + i);
- var cache = Cache();
+ var cache = GetCache();
cache.PutAll(putMap);
@@ -378,7 +378,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestRemove()
{
- var cache = Cache();
+ var cache = GetCache();
for (int i = 0; i < 10; i++)
cache.Put(i, "val_" + i);
@@ -399,7 +399,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestRemoveAll()
{
- var cache = Cache();
+ var cache = GetCache();
for (int i = 0; i < 10; i++)
cache.Put(i, "val_" + i);
@@ -419,7 +419,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestTx()
{
- var cache = Cache();
+ var cache = GetCache();
using (var tx = cache.Ignite.GetTransactions().TxStart())
{
@@ -444,7 +444,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
{
CacheTestStore.LoadMultithreaded = true;
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -459,7 +459,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestCustomStoreProperties()
{
- var cache = CustomStoreCache();
+ var cache = GetCustomStoreCache();
Assert.IsNotNull(cache);
Assert.AreEqual(42, CacheTestStore.intProperty);
@@ -469,7 +469,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestDynamicStoreStart()
{
- var cache = TemplateStoreCache();
+ var cache = GetTemplateStoreCache();
Assert.IsNotNull(cache);
@@ -483,10 +483,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
/// <summary>
/// Get's grid name for this test.
/// </summary>
- /// <returns>Grid name.</returns>
- protected virtual string GridName()
+ /// <value>Grid name.</value>
+ protected virtual string GridName
{
- return null;
+ get { return null; }
}
private IDictionary StoreMap()
@@ -494,31 +494,31 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
return CacheTestStore.Map;
}
- private ICache<int, string> Cache()
+ private ICache<int, string> GetCache()
{
- return PortableStoreCache<int, string>();
+ return GetBinaryStoreCache<int, string>();
}
- private ICache<TK, TV> PortableStoreCache<TK, TV>()
+ private ICache<TK, TV> GetBinaryStoreCache<TK, TV>()
{
- return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(PortableStoreCacheName);
+ return Ignition.GetIgnite(GridName).GetCache<TK, TV>(BinaryStoreCacheName);
}
- private ICache<TK, TV> ObjectStoreCache<TK, TV>()
+ private ICache<TK, TV> GetObjectStoreCache<TK, TV>()
{
- return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(ObjectStoreCacheName);
+ return Ignition.GetIgnite(GridName).GetCache<TK, TV>(ObjectStoreCacheName);
}
- private ICache<int, string> CustomStoreCache()
+ private ICache<int, string> GetCustomStoreCache()
{
- return Ignition.GetIgnite(GridName()).GetCache<int, string>(CustomStoreCacheName);
+ return Ignition.GetIgnite(GridName).GetCache<int, string>(CustomStoreCacheName);
}
- private ICache<int, string> TemplateStoreCache()
+ private ICache<int, string> GetTemplateStoreCache()
{
var cacheName = TemplateStoreCacheName.Replace("*", Guid.NewGuid().ToString());
- return Ignition.GetIgnite(GridName()).GetOrCreateCache<int, string>(cacheName);
+ return Ignition.GetIgnite(GridName).GetOrCreateCache<int, string>(cacheName);
}
}
@@ -528,9 +528,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
public class NamedNodeCacheStoreTest : CacheStoreTest
{
/** <inheritDoc /> */
- protected override string GridName()
+ protected override string GridName
{
- return "name";
+ get { return "name"; }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 9e96ca2..e3d0d96 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -171,7 +171,7 @@ namespace Apache.Ignite.Core.Tests.Compute
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- PortableTypeConfigurations(portTypeCfgs);
+ GetBinaryTypeConfigurations(portTypeCfgs);
portCfg.TypeConfigurations = portTypeCfgs;
@@ -206,10 +206,10 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Define portable types.
+ /// Define binary types.
/// </summary>
- /// <param name="portTypeCfgs">Portable type configurations.</param>
- protected virtual void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ /// <param name="portTypeCfgs">Binary type configurations.</param>
+ protected virtual void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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
new file mode 100644
index 0000000..b881582
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
@@ -0,0 +1,185 @@
+/*
+ * 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.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Closure execution tests for binary objects.
+ /// </summary>
+ public class BinarizableClosureTaskTest : ClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public BinarizableClosureTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected BinarizableClosureTaskTest(bool fork) : base(fork) { }
+
+ /** <inheritDoc /> */
+ protected override void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableOutFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableResult)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableException)));
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object> OutFunc(bool err)
+ {
+ return new BinarizableOutFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object, object> Func(bool err)
+ {
+ return new BinarizableFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckResult(object res)
+ {
+ Assert.IsTrue(res != null);
+
+ BinarizableResult res0 = res as BinarizableResult;
+
+ Assert.IsTrue(res0 != null);
+ Assert.AreEqual(1, res0.Res);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckError(Exception err)
+ {
+ Assert.IsTrue(err != null);
+
+ BinarizableException err0 = err as BinarizableException;
+
+ Assert.IsTrue(err0 != null);
+ Assert.AreEqual(ErrMsg, err0.Msg);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableOutFunc : IComputeFunc<object>
+ {
+ /** Error. */
+ private readonly bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public BinarizableOutFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke()
+ {
+ if (_err)
+ throw new BinarizableException(ErrMsg);
+ return new BinarizableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableFunc : IComputeFunc<object, object>
+ {
+ /** Error. */
+ private readonly bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public BinarizableFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke(object arg)
+ {
+ if (_err)
+ throw new BinarizableException(ErrMsg);
+ return new BinarizableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableException : Exception, IBinarizable
+ {
+ /** */
+ public string Msg;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="msg"></param>
+ public BinarizableException(string msg)
+ {
+ Msg = msg;
+ }
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.GetRawWriter().WriteString(Msg);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Msg = reader.GetRawReader().ReadString();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableResult
+ {
+ /** */
+ public readonly int Res;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="res"></param>
+ public BinarizableResult(int res)
+ {
+ Res = res;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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
new file mode 100644
index 0000000..5c1ee34
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
@@ -0,0 +1,269 @@
+/*
+ * 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.Compute
+{
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Task test result.
+ /// </summary>
+ public class BinarizableTaskTest : AbstractTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public BinarizableTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected BinarizableTaskTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestBinarizableObjectInTask()
+ {
+ var taskArg = new BinarizableWrapper {Item = ToBinary(Grid1, new BinarizableTaskArgument(100))};
+
+ TestTask task = new TestTask(Grid1, taskArg);
+
+ var res = Grid1.GetCompute().Execute(task, taskArg).Item;
+
+ Assert.NotNull(res);
+
+ Assert.AreEqual(400, res.GetField<int>("val"));
+
+ BinarizableTaskResult resObj = res.Deserialize<BinarizableTaskResult>();
+
+ Assert.AreEqual(400, resObj.Val);
+ }
+
+ private static IBinaryObject ToBinary(IIgnite grid, object obj)
+ {
+ var cache = grid.GetCache<object, object>(Cache1Name).WithKeepBinary<object, object>();
+
+ cache.Put(1, obj);
+
+ return (IBinaryObject) cache.Get(1);
+ }
+
+ /** <inheritDoc /> */
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ {
+ 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)));
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ class TestTask : ComputeTaskAdapter<BinarizableWrapper, BinarizableWrapper, BinarizableWrapper>
+ {
+ /** */
+ private readonly IIgnite _grid;
+
+ private readonly BinarizableWrapper _taskArgField;
+
+ public TestTask(IIgnite grid, BinarizableWrapper taskArgField)
+ {
+ _grid = grid;
+ _taskArgField = taskArgField;
+ }
+
+ /** <inheritDoc /> */
+ override public IDictionary<IComputeJob<BinarizableWrapper>, IClusterNode> Map(IList<IClusterNode> subgrid, BinarizableWrapper arg)
+ {
+ Assert.AreEqual(3, subgrid.Count);
+ Assert.NotNull(_grid);
+
+ var taskArg = arg;
+
+ CheckTaskArgument(taskArg);
+
+ CheckTaskArgument(_taskArgField);
+
+ var jobs = new Dictionary<IComputeJob<BinarizableWrapper>, IClusterNode>();
+
+
+ foreach (IClusterNode node in subgrid)
+ {
+ if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
+ {
+ var job = new BinarizableJob
+ {
+ Arg = new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableJobArgument(200))}
+ };
+
+ jobs.Add(job, node);
+ }
+ }
+
+ Assert.AreEqual(2, jobs.Count);
+
+ return jobs;
+ }
+
+ private void CheckTaskArgument(BinarizableWrapper arg)
+ {
+ Assert.IsNotNull(arg);
+
+ var taskArg = arg.Item;
+
+ Assert.IsNotNull(taskArg);
+
+ Assert.AreEqual(100, taskArg.GetField<int>("val"));
+
+ BinarizableTaskArgument taskArgObj = taskArg.Deserialize<BinarizableTaskArgument>();
+
+ Assert.AreEqual(100, taskArgObj.Val);
+ }
+
+ /** <inheritDoc /> */
+ override public BinarizableWrapper Reduce(IList<IComputeJobResult<BinarizableWrapper>> results)
+ {
+ Assert.NotNull(_grid);
+
+ Assert.AreEqual(2, results.Count);
+
+ foreach (var res in results)
+ {
+ var jobRes = res.Data.Item;
+
+ Assert.NotNull(jobRes);
+
+ Assert.AreEqual(300, jobRes.GetField<int>("val"));
+
+ BinarizableJobResult jobResObj = jobRes.Deserialize<BinarizableJobResult>();
+
+ Assert.AreEqual(300, jobResObj.Val);
+ }
+
+ return new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableTaskResult(400))};
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableJobArgument
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableJobArgument(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableJobResult
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableJobResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableTaskArgument
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableTaskArgument(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableTaskResult
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableTaskResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableJob : IComputeJob<BinarizableWrapper>
+ {
+ [InstanceResource]
+ private readonly IIgnite _grid = null;
+
+ /** */
+ public BinarizableWrapper Arg;
+
+ /** <inheritDoc /> */
+
+ public BinarizableWrapper Execute()
+ {
+ Assert.IsNotNull(Arg);
+
+ var arg = Arg.Item;
+
+ Assert.IsNotNull(arg);
+
+ Assert.AreEqual(200, arg.GetField<int>("val"));
+
+ var argObj = arg.Deserialize<BinarizableJobArgument>();
+
+ Assert.AreEqual(200, argObj.Val);
+
+ return new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableJobResult(300))};
+ }
+
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ class BinarizableWrapper
+ {
+ public IBinaryObject Item { get; set; }
+ }
+ }
+}
[7/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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
new file mode 100644
index 0000000..ea472eb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -0,0 +1,1721 @@
+/*
+ * 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 UnassignedField.Global
+// ReSharper disable CollectionNeverUpdated.Global
+namespace Apache.Ignite.Core.Tests.Binary
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Binary builder self test.
+ /// </summary>
+ public class BinaryBuilderSelfTest
+ {
+ /** Undefined type: Empty. */
+ private const string TypeEmpty = "EmptyUndefined";
+
+ /** Grid. */
+ private Ignite _grid;
+
+ /** Marshaller. */
+ private Marshaller _marsh;
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+
+ var cfg = new IgniteConfiguration
+ {
+ BinaryConfiguration = new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (Empty)),
+ new BinaryTypeConfiguration(typeof (Primitives)),
+ new BinaryTypeConfiguration(typeof (PrimitiveArrays)),
+ new BinaryTypeConfiguration(typeof (StringDateGuidEnum)),
+ new BinaryTypeConfiguration(typeof (WithRaw)),
+ new BinaryTypeConfiguration(typeof (MetaOverwrite)),
+ new BinaryTypeConfiguration(typeof (NestedOuter)),
+ new BinaryTypeConfiguration(typeof (NestedInner)),
+ new BinaryTypeConfiguration(typeof (MigrationOuter)),
+ new BinaryTypeConfiguration(typeof (MigrationInner)),
+ new BinaryTypeConfiguration(typeof (InversionOuter)),
+ new BinaryTypeConfiguration(typeof (InversionInner)),
+ new BinaryTypeConfiguration(typeof (CompositeOuter)),
+ new BinaryTypeConfiguration(typeof (CompositeInner)),
+ new BinaryTypeConfiguration(typeof (CompositeArray)),
+ new BinaryTypeConfiguration(typeof (CompositeContainer)),
+ new BinaryTypeConfiguration(typeof (ToBinary)),
+ new BinaryTypeConfiguration(typeof (Remove)),
+ new BinaryTypeConfiguration(typeof (RemoveInner)),
+ new BinaryTypeConfiguration(typeof (BuilderInBuilderOuter)),
+ new BinaryTypeConfiguration(typeof (BuilderInBuilderInner)),
+ new BinaryTypeConfiguration(typeof (BuilderCollection)),
+ new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
+ new BinaryTypeConfiguration(typeof (DecimalHolder)),
+ new BinaryTypeConfiguration(TypeEmpty)
+ },
+ DefaultIdMapper = new IdMapper()
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = new List<string>
+ {
+ "-ea",
+ "-Xcheck:jni",
+ "-Xms4g",
+ "-Xmx4g",
+ "-DIGNITE_QUIET=false",
+ "-Xnoagent",
+ "-Djava.compiler=NONE",
+ "-Xdebug",
+ "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
+ "-XX:+HeapDumpOnOutOfMemoryError"
+ },
+ SpringConfigUrl = "config\\binary.xml"
+ };
+
+ _grid = (Ignite) Ignition.Start(cfg);
+
+ _marsh = _grid.Marshaller;
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void TearDown()
+ {
+ if (_grid != null)
+ Ignition.Stop(_grid.Name, true);
+
+ _grid = null;
+ }
+
+ /// <summary>
+ /// Ensure that binary engine is able to work with type names, which are not configured.
+ /// </summary>
+ [Test]
+ public void TestNonConfigured()
+ {
+ string typeName1 = "Type1";
+ string typeName2 = "Type2";
+ string field1 = "field1";
+ string field2 = "field2";
+
+ // 1. Ensure that builder works fine.
+ IBinaryObject binObj1 = _grid.GetBinary().GetBuilder(typeName1).SetField(field1, 1).Build();
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+
+ // 2. Ensure that object can be unmarshalled without deserialization.
+ byte[] data = ((BinaryObject) binObj1).Data;
+
+ binObj1 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+
+ // 3. Ensure that we can nest one anonymous object inside another
+ IBinaryObject binObj2 =
+ _grid.GetBinary().GetBuilder(typeName2).SetField(field2, binObj1).Build();
+
+ Assert.AreEqual(typeName2, binObj2.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj2.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field2, binObj2.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, binObj2.GetBinaryType().GetFieldTypeName(field2));
+
+ binObj1 = binObj2.GetField<IBinaryObject>(field2);
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+
+ // 4. Ensure that we can unmarshal object with other nested object.
+ data = ((BinaryObject) binObj2).Data;
+
+ binObj2 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(typeName2, binObj2.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj2.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field2, binObj2.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, binObj2.GetBinaryType().GetFieldTypeName(field2));
+
+ binObj1 = binObj2.GetField<IBinaryObject>(field2);
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+ }
+
+ /// <summary>
+ /// Test "ToBinary()" method.
+ /// </summary>
+ [Test]
+ public void TestToBinary()
+ {
+ DateTime date = DateTime.Now.ToUniversalTime();
+ Guid guid = Guid.NewGuid();
+
+ IIgniteBinary api = _grid.GetBinary();
+
+ // 1. Primitives.
+ Assert.AreEqual(1, api.ToBinary<byte>((byte)1));
+ Assert.AreEqual(1, api.ToBinary<short>((short)1));
+ Assert.AreEqual(1, api.ToBinary<int>(1));
+ Assert.AreEqual(1, api.ToBinary<long>((long)1));
+
+ Assert.AreEqual((float)1, api.ToBinary<float>((float)1));
+ Assert.AreEqual((double)1, api.ToBinary<double>((double)1));
+
+ Assert.AreEqual(true, api.ToBinary<bool>(true));
+ Assert.AreEqual('a', api.ToBinary<char>('a'));
+
+ // 2. Special types.
+ Assert.AreEqual("a", api.ToBinary<string>("a"));
+ Assert.AreEqual(date, api.ToBinary<DateTime>(date));
+ Assert.AreEqual(guid, api.ToBinary<Guid>(guid));
+ Assert.AreEqual(TestEnum.One, api.ToBinary<TestEnum>(TestEnum.One));
+
+ // 3. Arrays.
+ Assert.AreEqual(new byte[] { 1 }, api.ToBinary<byte[]>(new byte[] { 1 }));
+ Assert.AreEqual(new short[] { 1 }, api.ToBinary<short[]>(new short[] { 1 }));
+ Assert.AreEqual(new[] { 1 }, api.ToBinary<int[]>(new[] { 1 }));
+ Assert.AreEqual(new long[] { 1 }, api.ToBinary<long[]>(new long[] { 1 }));
+
+ Assert.AreEqual(new float[] { 1 }, api.ToBinary<float[]>(new float[] { 1 }));
+ Assert.AreEqual(new double[] { 1 }, api.ToBinary<double[]>(new double[] { 1 }));
+
+ Assert.AreEqual(new[] { true }, api.ToBinary<bool[]>(new[] { true }));
+ Assert.AreEqual(new[] { 'a' }, api.ToBinary<char[]>(new[] { 'a' }));
+
+ Assert.AreEqual(new[] { "a" }, api.ToBinary<string[]>(new[] { "a" }));
+ Assert.AreEqual(new[] { date }, api.ToBinary<DateTime[]>(new[] { date }));
+ Assert.AreEqual(new[] { guid }, api.ToBinary<Guid[]>(new[] { guid }));
+ Assert.AreEqual(new[] { TestEnum.One }, api.ToBinary<TestEnum[]>(new[] { TestEnum.One }));
+
+ // 4. Objects.
+ IBinaryObject binObj = api.ToBinary<IBinaryObject>(new ToBinary(1));
+
+ Assert.AreEqual(typeof(ToBinary).Name, binObj.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj.GetBinaryType().Fields.Count);
+ Assert.AreEqual("Val", binObj.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj.GetBinaryType().GetFieldTypeName("Val"));
+
+ Assert.AreEqual(1, binObj.GetField<int>("val"));
+ Assert.AreEqual(1, binObj.Deserialize<ToBinary>().Val);
+
+ // 5. Object array.
+ var binObjArr = api.ToBinary<object[]>(new object[] {new ToBinary(1)})
+ .OfType<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(1, binObjArr.Length);
+ Assert.AreEqual(1, binObjArr[0].GetField<int>("Val"));
+ Assert.AreEqual(1, binObjArr[0].Deserialize<ToBinary>().Val);
+ }
+
+ /// <summary>
+ /// Test builder field remove logic.
+ /// </summary>
+ [Test]
+ public void TestRemove()
+ {
+ // Create empty object.
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Remove)).Build();
+
+ Assert.IsNull(binObj.GetField<object>("val"));
+ Assert.IsNull(binObj.Deserialize<Remove>().Val);
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+
+ // Populate it with field.
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(binObj);
+
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ object val = 1;
+
+ builder.SetField("val", val);
+
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ binObj = builder.Build();
+
+ Assert.AreEqual(val, binObj.GetField<object>("val"));
+ Assert.AreEqual(val, binObj.Deserialize<Remove>().Val);
+
+ meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("val", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
+
+ // Perform field remove.
+ builder = _grid.GetBinary().GetBuilder(binObj);
+
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ builder.RemoveField("val");
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ builder.SetField("val", val);
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ builder.RemoveField("val");
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ binObj = builder.Build();
+
+ Assert.IsNull(binObj.GetField<object>("val"));
+ Assert.IsNull(binObj.Deserialize<Remove>().Val);
+
+ // Test correct removal of field being referenced by handle somewhere else.
+ RemoveInner inner = new RemoveInner(2);
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(Remove))
+ .SetField("val", inner)
+ .SetField("val2", inner)
+ .Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).RemoveField("val").Build();
+
+ Remove obj = binObj.Deserialize<Remove>();
+
+ Assert.IsNull(obj.Val);
+ Assert.AreEqual(2, obj.Val2.Val);
+ }
+
+ /// <summary>
+ /// Test builder-in-builder scenario.
+ /// </summary>
+ [Test]
+ public void TestBuilderInBuilder()
+ {
+ // Test different builders assembly.
+ IBinaryObjectBuilder builderOuter = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter));
+ IBinaryObjectBuilder builderInner = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner));
+
+ builderOuter.SetField<object>("inner", builderInner);
+ builderInner.SetField<object>("outer", builderOuter);
+
+ IBinaryObject outerbinObj = builderOuter.Build();
+
+ IBinaryType meta = outerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("inner", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+
+ IBinaryObject innerbinObj = outerbinObj.GetField<IBinaryObject>("inner");
+
+ meta = innerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("outer", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
+
+ BuilderInBuilderOuter outer = outerbinObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer, outer.Inner.Outer);
+
+ // Test same builders assembly.
+ innerbinObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner)).Build();
+
+ outerbinObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter))
+ .SetField("inner", innerbinObj)
+ .SetField("inner2", innerbinObj)
+ .Build();
+
+ meta = outerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.IsTrue(meta.Fields.Contains("inner"));
+ Assert.IsTrue(meta.Fields.Contains("inner2"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
+
+ outer = outerbinObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer.Inner, outer.Inner2);
+
+ builderOuter = _grid.GetBinary().GetBuilder(outerbinObj);
+ IBinaryObjectBuilder builderInner2 = builderOuter.GetField<IBinaryObjectBuilder>("inner2");
+
+ builderInner2.SetField("outer", builderOuter);
+
+ outerbinObj = builderOuter.Build();
+
+ outer = outerbinObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer, outer.Inner.Outer);
+ Assert.AreSame(outer.Inner, outer.Inner2);
+ }
+
+ /// <summary>
+ /// Test for decimals building.
+ /// </summary>
+ [Test]
+ public void TestDecimals()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(DecimalHolder))
+ .SetField("val", decimal.One)
+ .SetField("valArr", new decimal?[] { decimal.MinusOne })
+ .Build();
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.IsTrue(meta.Fields.Contains("val"));
+ Assert.IsTrue(meta.Fields.Contains("valArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
+
+ Assert.AreEqual(decimal.One, binObj.GetField<decimal>("val"));
+ Assert.AreEqual(new decimal?[] { decimal.MinusOne }, binObj.GetField<decimal?[]>("valArr"));
+
+ DecimalHolder obj = binObj.Deserialize<DecimalHolder>();
+
+ Assert.AreEqual(decimal.One, obj.Val);
+ Assert.AreEqual(new decimal?[] { decimal.MinusOne }, obj.ValArr);
+ }
+
+ /// <summary>
+ /// Test for an object returning collection of builders.
+ /// </summary>
+ [Test]
+ public void TestBuilderCollection()
+ {
+ // Test collection with single element.
+ IBinaryObjectBuilder builderCol = _grid.GetBinary().GetBuilder(typeof(BuilderCollection));
+ IBinaryObjectBuilder builderItem =
+ _grid.GetBinary().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
+
+ builderCol.SetCollectionField("col", new ArrayList { builderItem });
+
+ IBinaryObject binCol = builderCol.Build();
+
+ IBinaryType meta = binCol.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("col", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+
+ var binColItems = binCol.GetField<ArrayList>("col");
+
+ Assert.AreEqual(1, binColItems.Count);
+
+ var binItem = (IBinaryObject) binColItems[0];
+
+ meta = binItem.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("val", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
+
+ BuilderCollection col = binCol.Deserialize<BuilderCollection>();
+
+ Assert.IsNotNull(col.Col);
+ Assert.AreEqual(1, col.Col.Count);
+ Assert.AreEqual(1, ((BuilderCollectionItem) col.Col[0]).Val);
+
+ // Add more binary objects to collection.
+ builderCol = _grid.GetBinary().GetBuilder(binCol);
+
+ IList builderColItems = builderCol.GetField<IList>("col");
+
+ Assert.AreEqual(1, builderColItems.Count);
+
+ BinaryObjectBuilder builderColItem = (BinaryObjectBuilder) builderColItems[0];
+
+ builderColItem.SetField("val", 2); // Change nested value.
+
+ builderColItems.Add(builderColItem); // Add the same object to check handles.
+ builderColItems.Add(builderItem); // Add item from another builder.
+ builderColItems.Add(binItem); // Add item in binary form.
+
+ binCol = builderCol.Build();
+
+ col = binCol.Deserialize<BuilderCollection>();
+
+ Assert.AreEqual(4, col.Col.Count);
+
+ var item0 = (BuilderCollectionItem) col.Col[0];
+ var item1 = (BuilderCollectionItem) col.Col[1];
+ var item2 = (BuilderCollectionItem) col.Col[2];
+ var item3 = (BuilderCollectionItem) col.Col[3];
+
+ Assert.AreEqual(2, item0.Val);
+
+ Assert.AreSame(item0, item1);
+ Assert.AreNotSame(item0, item2);
+ Assert.AreNotSame(item0, item3);
+
+ Assert.AreEqual(1, item2.Val);
+ Assert.AreEqual(1, item3.Val);
+
+ Assert.AreNotSame(item2, item3);
+
+ // Test handle update inside collection.
+ builderCol = _grid.GetBinary().GetBuilder(binCol);
+
+ builderColItems = builderCol.GetField<IList>("col");
+
+ ((BinaryObjectBuilder) builderColItems[1]).SetField("val", 3);
+
+ binCol = builderCol.Build();
+
+ col = binCol.Deserialize<BuilderCollection>();
+
+ item0 = (BuilderCollectionItem) col.Col[0];
+ item1 = (BuilderCollectionItem) col.Col[1];
+
+ Assert.AreEqual(3, item0.Val);
+ Assert.AreSame(item0, item1);
+ }
+
+ /// <summary>
+ /// Test build of an empty object.
+ /// </summary>
+ [Test]
+ public void TestEmptyDefined()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
+
+ Assert.IsNotNull(binObj);
+ Assert.AreEqual(0, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.IsNotNull(meta);
+ Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+
+ Empty obj = binObj.Deserialize<Empty>();
+
+ Assert.IsNotNull(obj);
+ }
+
+ /// <summary>
+ /// Test build of an empty undefined object.
+ /// </summary>
+ [Test]
+ public void TestEmptyUndefined()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(TypeEmpty).Build();
+
+ Assert.IsNotNull(binObj);
+ Assert.AreEqual(0, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.IsNotNull(meta);
+ Assert.AreEqual(TypeEmpty, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+ }
+
+ /// <summary>
+ /// Test object rebuild with no changes.
+ /// </summary>
+ [Test]
+ public void TestEmptyRebuild()
+ {
+ var binObj = (BinaryObject) _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
+
+ BinaryObject newbinObj = (BinaryObject) _grid.GetBinary().GetBuilder(binObj).Build();
+
+ Assert.AreEqual(binObj.Data, newbinObj.Data);
+ }
+
+ /// <summary>
+ /// Test hash code alteration.
+ /// </summary>
+ [Test]
+ public void TestHashCodeChange()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Empty)).SetHashCode(100).Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+ }
+
+ /// <summary>
+ /// Test primitive fields setting.
+ /// </summary>
+ [Test]
+ public void TestPrimitiveFields()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
+ .SetField<byte>("fByte", 1)
+ .SetField("fBool", true)
+ .SetField<short>("fShort", 2)
+ .SetField("fChar", 'a')
+ .SetField("fInt", 3)
+ .SetField<long>("fLong", 4)
+ .SetField<float>("fFloat", 5)
+ .SetField<double>("fDouble", 6)
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
+
+ Assert.AreEqual(1, binObj.GetField<byte>("fByte"));
+ Assert.AreEqual(true, binObj.GetField<bool>("fBool"));
+ Assert.AreEqual(2, binObj.GetField<short>("fShort"));
+ Assert.AreEqual('a', binObj.GetField<char>("fChar"));
+ Assert.AreEqual(3, binObj.GetField<int>("fInt"));
+ Assert.AreEqual(4, binObj.GetField<long>("fLong"));
+ Assert.AreEqual(5, binObj.GetField<float>("fFloat"));
+ Assert.AreEqual(6, binObj.GetField<double>("fDouble"));
+
+ Primitives obj = binObj.Deserialize<Primitives>();
+
+ Assert.AreEqual(1, obj.FByte);
+ Assert.AreEqual(true, obj.FBool);
+ Assert.AreEqual(2, obj.FShort);
+ Assert.AreEqual('a', obj.FChar);
+ Assert.AreEqual(3, obj.FInt);
+ Assert.AreEqual(4, obj.FLong);
+ Assert.AreEqual(5, obj.FFloat);
+ Assert.AreEqual(6, obj.FDouble);
+
+ // Overwrite.
+ binObj = _grid.GetBinary().GetBuilder(binObj)
+ .SetField<byte>("fByte", 7)
+ .SetField("fBool", false)
+ .SetField<short>("fShort", 8)
+ .SetField("fChar", 'b')
+ .SetField("fInt", 9)
+ .SetField<long>("fLong", 10)
+ .SetField<float>("fFloat", 11)
+ .SetField<double>("fDouble", 12)
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ Assert.AreEqual(7, binObj.GetField<byte>("fByte"));
+ Assert.AreEqual(false, binObj.GetField<bool>("fBool"));
+ Assert.AreEqual(8, binObj.GetField<short>("fShort"));
+ Assert.AreEqual('b', binObj.GetField<char>("fChar"));
+ Assert.AreEqual(9, binObj.GetField<int>("fInt"));
+ Assert.AreEqual(10, binObj.GetField<long>("fLong"));
+ Assert.AreEqual(11, binObj.GetField<float>("fFloat"));
+ Assert.AreEqual(12, binObj.GetField<double>("fDouble"));
+
+ obj = binObj.Deserialize<Primitives>();
+
+ Assert.AreEqual(7, obj.FByte);
+ Assert.AreEqual(false, obj.FBool);
+ Assert.AreEqual(8, obj.FShort);
+ Assert.AreEqual('b', obj.FChar);
+ Assert.AreEqual(9, obj.FInt);
+ Assert.AreEqual(10, obj.FLong);
+ Assert.AreEqual(11, obj.FFloat);
+ Assert.AreEqual(12, obj.FDouble);
+ }
+
+ /// <summary>
+ /// Test primitive array fields setting.
+ /// </summary>
+ [Test]
+ public void TestPrimitiveArrayFields()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
+ .SetField("fByte", new byte[] { 1 })
+ .SetField("fBool", new[] { true })
+ .SetField("fShort", new short[] { 2 })
+ .SetField("fChar", new[] { 'a' })
+ .SetField("fInt", new[] { 3 })
+ .SetField("fLong", new long[] { 4 })
+ .SetField("fFloat", new float[] { 5 })
+ .SetField("fDouble", new double[] { 6 })
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
+
+ Assert.AreEqual(new byte[] { 1 }, binObj.GetField<byte[]>("fByte"));
+ Assert.AreEqual(new[] { true }, binObj.GetField<bool[]>("fBool"));
+ Assert.AreEqual(new short[] { 2 }, binObj.GetField<short[]>("fShort"));
+ Assert.AreEqual(new[] { 'a' }, binObj.GetField<char[]>("fChar"));
+ Assert.AreEqual(new[] { 3 }, binObj.GetField<int[]>("fInt"));
+ Assert.AreEqual(new long[] { 4 }, binObj.GetField<long[]>("fLong"));
+ Assert.AreEqual(new float[] { 5 }, binObj.GetField<float[]>("fFloat"));
+ Assert.AreEqual(new double[] { 6 }, binObj.GetField<double[]>("fDouble"));
+
+ PrimitiveArrays obj = binObj.Deserialize<PrimitiveArrays>();
+
+ Assert.AreEqual(new byte[] { 1 }, obj.FByte);
+ Assert.AreEqual(new[] { true }, obj.FBool);
+ Assert.AreEqual(new short[] { 2 }, obj.FShort);
+ Assert.AreEqual(new[] { 'a' }, obj.FChar);
+ Assert.AreEqual(new[] { 3 }, obj.FInt);
+ Assert.AreEqual(new long[] { 4 }, obj.FLong);
+ Assert.AreEqual(new float[] { 5 }, obj.FFloat);
+ Assert.AreEqual(new double[] { 6 }, obj.FDouble);
+
+ // Overwrite.
+ binObj = _grid.GetBinary().GetBuilder(binObj)
+ .SetField("fByte", new byte[] { 7 })
+ .SetField("fBool", new[] { false })
+ .SetField("fShort", new short[] { 8 })
+ .SetField("fChar", new[] { 'b' })
+ .SetField("fInt", new[] { 9 })
+ .SetField("fLong", new long[] { 10 })
+ .SetField("fFloat", new float[] { 11 })
+ .SetField("fDouble", new double[] { 12 })
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ Assert.AreEqual(new byte[] { 7 }, binObj.GetField<byte[]>("fByte"));
+ Assert.AreEqual(new[] { false }, binObj.GetField<bool[]>("fBool"));
+ Assert.AreEqual(new short[] { 8 }, binObj.GetField<short[]>("fShort"));
+ Assert.AreEqual(new[] { 'b' }, binObj.GetField<char[]>("fChar"));
+ Assert.AreEqual(new[] { 9 }, binObj.GetField<int[]>("fInt"));
+ Assert.AreEqual(new long[] { 10 }, binObj.GetField<long[]>("fLong"));
+ Assert.AreEqual(new float[] { 11 }, binObj.GetField<float[]>("fFloat"));
+ Assert.AreEqual(new double[] { 12 }, binObj.GetField<double[]>("fDouble"));
+
+ obj = binObj.Deserialize<PrimitiveArrays>();
+
+ Assert.AreEqual(new byte[] { 7 }, obj.FByte);
+ Assert.AreEqual(new[] { false }, obj.FBool);
+ Assert.AreEqual(new short[] { 8 }, obj.FShort);
+ Assert.AreEqual(new[] { 'b' }, obj.FChar);
+ Assert.AreEqual(new[] { 9 }, obj.FInt);
+ Assert.AreEqual(new long[] { 10 }, obj.FLong);
+ Assert.AreEqual(new float[] { 11 }, obj.FFloat);
+ Assert.AreEqual(new double[] { 12 }, obj.FDouble);
+ }
+
+ /// <summary>
+ /// Test non-primitive fields and their array counterparts.
+ /// </summary>
+ [Test]
+ public void TestStringDateGuidEnum()
+ {
+ DateTime? nDate = DateTime.Now;
+
+ Guid? nGuid = Guid.NewGuid();
+
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
+ .SetField("fStr", "str")
+ .SetField("fNDate", nDate)
+ .SetGuidField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.One)
+ .SetField("fStrArr", new[] { "str" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetGuidArrayField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.One })
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
+
+ Assert.AreEqual("str", binObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, binObj.GetField<TestEnum[]>("fEnumArr"));
+
+ StringDateGuidEnum obj = binObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.One, obj.FEnum);
+ Assert.AreEqual(new[] { "str" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+
+ // Check builder field caching.
+ var builder = _grid.GetBinary().GetBuilder(binObj);
+
+ Assert.AreEqual("str", builder.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, builder.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, builder.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, builder.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, builder.GetField<TestEnum[]>("fEnumArr"));
+
+ // Check reassemble.
+ binObj = builder.Build();
+
+ Assert.AreEqual("str", binObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, binObj.GetField<TestEnum[]>("fEnumArr"));
+
+ obj = binObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.One, obj.FEnum);
+ Assert.AreEqual(new[] { "str" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+
+ // Overwrite.
+ nDate = DateTime.Now.ToUniversalTime();
+ nGuid = Guid.NewGuid();
+
+ binObj = builder
+ .SetField("fStr", "str2")
+ .SetTimestampField("fNDate", nDate)
+ .SetField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.Two)
+ .SetField("fStrArr", new[] { "str2" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.Two })
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ Assert.AreEqual("str2", binObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.Two, binObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str2" }, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.Two }, binObj.GetField<TestEnum[]>("fEnumArr"));
+
+ obj = binObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str2", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.Two, obj.FEnum);
+ Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
+ }
+
+ /// <summary>
+ /// Test arrays.
+ /// </summary>
+ [Test]
+ public void TestCompositeArray()
+ {
+ // 1. Test simple array.
+ object[] inArr = { new CompositeInner(1) };
+
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("inArr", inArr).Build();
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ var binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(1, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+
+ CompositeArray arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(1, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
+
+ // 2. Test addition to array.
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+ .SetField("inArr", new object[] { binInArr[0], null }).Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+ Assert.IsNull(binInArr[1]);
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
+ Assert.IsNull(arr.InArr[1]);
+
+ binInArr[1] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(300)
+ .SetField("inArr", binInArr.OfType<object>().ToArray()).Build();
+
+ Assert.AreEqual(300, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+ Assert.AreEqual(2, binInArr[1].GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(2, ((CompositeInner)arr.InArr[1]).Val);
+
+ // 3. Test top-level handle inversion.
+ CompositeInner inner = new CompositeInner(1);
+
+ inArr = new object[] { inner, inner };
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("inArr", inArr).Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+ Assert.AreEqual(1, binInArr[1].GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
+
+ binInArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+ .SetField("inArr", binInArr.ToArray<object>()).Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(2, binInArr[0].GetField<int>("val"));
+ Assert.AreEqual(1, binInArr[1].GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(2, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
+
+ // 4. Test nested object handle inversion.
+ CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("outArr", outArr.ToArray<object>()).Build();
+
+ meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ var binOutArr = binObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binOutArr.Length);
+ Assert.AreEqual(1, binOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
+ Assert.AreEqual(1, binOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.InArr);
+ Assert.AreEqual(2, arr.OutArr.Length);
+ Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
+
+ binOutArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeOuter))
+ .SetField("inner", new CompositeInner(2)).Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+ .SetField("outArr", binOutArr.ToArray<object>()).Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(2, binOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
+ Assert.AreEqual(1, binOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.InArr);
+ Assert.AreEqual(2, arr.OutArr.Length);
+ Assert.AreEqual(2, ((CompositeOuter)arr.OutArr[0]).Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter)arr.OutArr[1]).Inner.Val);
+ }
+
+ /// <summary>
+ /// Test container types other than array.
+ /// </summary>
+ [Test]
+ public void TestCompositeContainer()
+ {
+ ArrayList col = new ArrayList();
+ IDictionary dict = new Hashtable();
+
+ col.Add(new CompositeInner(1));
+ dict[3] = new CompositeInner(3);
+
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
+ .SetCollectionField("col", col)
+ .SetDictionaryField("dict", dict).Build();
+
+ // 1. Check meta.
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
+
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
+
+ // 2. Check in binary form.
+ Assert.AreEqual(1, binObj.GetField<ICollection>("col").Count);
+ Assert.AreEqual(1, binObj.GetField<ICollection>("col").OfType<IBinaryObject>().First()
+ .GetField<int>("val"));
+
+ Assert.AreEqual(1, binObj.GetField<IDictionary>("dict").Count);
+ Assert.AreEqual(3, ((IBinaryObject) binObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
+
+ // 3. Check in deserialized form.
+ CompositeContainer obj = binObj.Deserialize<CompositeContainer>();
+
+ Assert.AreEqual(1, obj.Col.Count);
+ Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
+
+ Assert.AreEqual(1, obj.Dict.Count);
+ Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
+ }
+
+ /// <summary>
+ /// Ensure that raw data is not lost during build.
+ /// </summary>
+ [Test]
+ public void TestRawData()
+ {
+ var raw = new WithRaw
+ {
+ A = 1,
+ B = 2
+ };
+
+ var binObj = _marsh.Unmarshal<IBinaryObject>(_marsh.Marshal(raw), BinaryMode.ForceBinary);
+
+ raw = binObj.Deserialize<WithRaw>();
+
+ Assert.AreEqual(1, raw.A);
+ Assert.AreEqual(2, raw.B);
+
+ IBinaryObject newbinObj = _grid.GetBinary().GetBuilder(binObj).SetField("a", 3).Build();
+
+ raw = newbinObj.Deserialize<WithRaw>();
+
+ Assert.AreEqual(3, raw.A);
+ Assert.AreEqual(2, raw.B);
+ }
+
+ /// <summary>
+ /// Test nested objects.
+ /// </summary>
+ [Test]
+ public void TestNested()
+ {
+ // 1. Create from scratch.
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(NestedOuter));
+
+ NestedInner inner1 = new NestedInner {Val = 1};
+ builder.SetField("inner1", inner1);
+
+ IBinaryObject outerbinObj = builder.Build();
+
+ IBinaryType meta = outerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
+
+ IBinaryObject innerbinObj1 = outerbinObj.GetField<IBinaryObject>("inner1");
+
+ IBinaryType innerMeta = innerbinObj1.GetBinaryType();
+
+ Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
+ Assert.AreEqual(1, innerMeta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
+
+ inner1 = innerbinObj1.Deserialize<NestedInner>();
+
+ Assert.AreEqual(1, inner1.Val);
+
+ NestedOuter outer = outerbinObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(outer.Inner1.Val, 1);
+ Assert.IsNull(outer.Inner2);
+
+ // 2. Add another field over existing binary object.
+ builder = _grid.GetBinary().GetBuilder(outerbinObj);
+
+ NestedInner inner2 = new NestedInner {Val = 2};
+ builder.SetField("inner2", inner2);
+
+ outerbinObj = builder.Build();
+
+ outer = outerbinObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(1, outer.Inner1.Val);
+ Assert.AreEqual(2, outer.Inner2.Val);
+
+ // 3. Try setting inner object in binary form.
+ innerbinObj1 = _grid.GetBinary().GetBuilder(innerbinObj1).SetField("val", 3).Build();
+
+ inner1 = innerbinObj1.Deserialize<NestedInner>();
+
+ Assert.AreEqual(3, inner1.Val);
+
+ outerbinObj = _grid.GetBinary().GetBuilder(outerbinObj).SetField<object>("inner1", innerbinObj1).Build();
+
+ outer = outerbinObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(3, outer.Inner1.Val);
+ Assert.AreEqual(2, outer.Inner2.Val);
+ }
+
+ /// <summary>
+ /// Test handle migration.
+ /// </summary>
+ [Test]
+ public void TestHandleMigration()
+ {
+ // 1. Simple comparison of results.
+ MigrationInner inner = new MigrationInner {Val = 1};
+
+ MigrationOuter outer = new MigrationOuter
+ {
+ Inner1 = inner,
+ Inner2 = inner
+ };
+
+ byte[] outerBytes = _marsh.Marshal(outer);
+
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(MigrationOuter));
+
+ builder.SetHashCode(outer.GetHashCode());
+
+ builder.SetField<object>("inner1", inner);
+ builder.SetField<object>("inner2", inner);
+
+ BinaryObject portOuter = (BinaryObject) builder.Build();
+
+ byte[] portOuterBytes = new byte[outerBytes.Length];
+
+ Buffer.BlockCopy(portOuter.Data, 0, portOuterBytes, 0, portOuterBytes.Length);
+
+ Assert.AreEqual(outerBytes, portOuterBytes);
+
+ // 2. Change the first inner object so that the handle must migrate.
+ MigrationInner inner1 = new MigrationInner {Val = 2};
+
+ IBinaryObject portOuterMigrated =
+ _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
+
+ MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
+
+ Assert.AreEqual(2, outerMigrated.Inner1.Val);
+ Assert.AreEqual(1, outerMigrated.Inner2.Val);
+
+ // 3. Change the first value using serialized form.
+ IBinaryObject inner1Port =
+ _grid.GetBinary().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
+
+ portOuterMigrated =
+ _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
+
+ outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
+
+ Assert.AreEqual(2, outerMigrated.Inner1.Val);
+ Assert.AreEqual(1, outerMigrated.Inner2.Val);
+ }
+
+ /// <summary>
+ /// Test handle inversion.
+ /// </summary>
+ [Test]
+ public void TestHandleInversion()
+ {
+ InversionInner inner = new InversionInner();
+ InversionOuter outer = new InversionOuter();
+
+ inner.Outer = outer;
+ outer.Inner = inner;
+
+ byte[] rawOuter = _marsh.Marshal(outer);
+
+ IBinaryObject portOuter = _marsh.Unmarshal<IBinaryObject>(rawOuter, BinaryMode.ForceBinary);
+ IBinaryObject portInner = portOuter.GetField<IBinaryObject>("inner");
+
+ // 1. Ensure that inner object can be deserialized after build.
+ IBinaryObject portInnerNew = _grid.GetBinary().GetBuilder(portInner).Build();
+
+ InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
+
+ Assert.AreSame(innerNew, innerNew.Outer.Inner);
+
+ // 2. Ensure that binary object with external dependencies could be added to builder.
+ IBinaryObject portOuterNew =
+ _grid.GetBinary().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
+
+ InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
+
+ Assert.AreNotSame(outerNew, outerNew.Inner.Outer);
+ Assert.AreSame(outerNew.Inner, outerNew.Inner.Outer.Inner);
+ }
+
+ /// <summary>
+ /// Test build multiple objects.
+ /// </summary>
+ [Test]
+ public void TestBuildMultiple()
+ {
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(Primitives));
+
+ builder.SetField<byte>("fByte", 1).SetField("fBool", true);
+
+ IBinaryObject po1 = builder.Build();
+ IBinaryObject po2 = builder.Build();
+
+ Assert.AreEqual(1, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(1, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ builder.SetField<byte>("fByte", 2);
+
+ IBinaryObject po3 = builder.Build();
+
+ Assert.AreEqual(1, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(1, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ Assert.AreEqual(2, po3.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ builder = _grid.GetBinary().GetBuilder(po1);
+
+ builder.SetField<byte>("fByte", 10);
+
+ po1 = builder.Build();
+ po2 = builder.Build();
+
+ builder.SetField<byte>("fByte", 20);
+
+ po3 = builder.Build();
+
+ Assert.AreEqual(10, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(10, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ Assert.AreEqual(20, po3.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po3.GetField<bool>("fBool"));
+ }
+
+ /// <summary>
+ /// Tests type id method.
+ /// </summary>
+ [Test]
+ public void TestTypeId()
+ {
+ Assert.Throws<ArgumentException>(() => _grid.GetBinary().GetTypeId(null));
+
+ Assert.AreEqual(IdMapper.TestTypeId, _grid.GetBinary().GetTypeId(IdMapper.TestTypeName));
+
+ Assert.AreEqual(BinaryUtils.GetStringHashCode("someTypeName"), _grid.GetBinary().GetTypeId("someTypeName"));
+ }
+
+ /// <summary>
+ /// Tests metadata methods.
+ /// </summary>
+ [Test]
+ public void TestMetadata()
+ {
+ // Populate metadata
+ var binary = _grid.GetBinary();
+
+ binary.ToBinary<IBinaryObject>(new DecimalHolder());
+
+ // All meta
+ var allMetas = binary.GetBinaryTypes();
+
+ var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type
+ decimalMeta = binary.GetBinaryType(typeof (DecimalHolder));
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type id
+ decimalMeta = binary.GetBinaryType(binary.GetTypeId("DecimalHolder"));
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type name
+ decimalMeta = binary.GetBinaryType("DecimalHolder");
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+ }
+ }
+
+ /// <summary>
+ /// Empty binary class.
+ /// </summary>
+ public class Empty
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// binary with primitive fields.
+ /// </summary>
+ public class Primitives
+ {
+ public byte FByte;
+ public bool FBool;
+ public short FShort;
+ public char FChar;
+ public int FInt;
+ public long FLong;
+ public float FFloat;
+ public double FDouble;
+ }
+
+ /// <summary>
+ /// binary with primitive array fields.
+ /// </summary>
+ public class PrimitiveArrays
+ {
+ public byte[] FByte;
+ public bool[] FBool;
+ public short[] FShort;
+ public char[] FChar;
+ public int[] FInt;
+ public long[] FLong;
+ public float[] FFloat;
+ public double[] FDouble;
+ }
+
+ /// <summary>
+ /// binary having strings, dates, Guids and enums.
+ /// </summary>
+ public class StringDateGuidEnum
+ {
+ public string FStr;
+ public DateTime? FnDate;
+ public Guid? FnGuid;
+ public TestEnum FEnum;
+
+ public string[] FStrArr;
+ public DateTime?[] FDateArr;
+ public Guid?[] FGuidArr;
+ public TestEnum[] FEnumArr;
+ }
+
+ /// <summary>
+ /// Enumeration.
+ /// </summary>
+ public enum TestEnum
+ {
+ One, Two
+ }
+
+ /// <summary>
+ /// binary with raw data.
+ /// </summary>
+ public class WithRaw : IBinarizable
+ {
+ public int A;
+ public int B;
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("a", A);
+ writer.GetRawWriter().WriteInt(B);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ A = reader.ReadInt("a");
+ B = reader.GetRawReader().ReadInt();
+ }
+ }
+
+ /// <summary>
+ /// Empty class for metadata overwrite test.
+ /// </summary>
+ public class MetaOverwrite
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Nested outer object.
+ /// </summary>
+ public class NestedOuter
+ {
+ public NestedInner Inner1;
+ public NestedInner Inner2;
+ }
+
+ /// <summary>
+ /// Nested inner object.
+ /// </summary>
+ public class NestedInner
+ {
+ public int Val;
+ }
+
+ /// <summary>
+ /// Outer object for handle migration test.
+ /// </summary>
+ public class MigrationOuter
+ {
+ public MigrationInner Inner1;
+ public MigrationInner Inner2;
+ }
+
+ /// <summary>
+ /// Inner object for handle migration test.
+ /// </summary>
+ public class MigrationInner
+ {
+ public int Val;
+ }
+
+ /// <summary>
+ /// Outer object for handle inversion test.
+ /// </summary>
+ public class InversionOuter
+ {
+ public InversionInner Inner;
+ }
+
+ /// <summary>
+ /// Inner object for handle inversion test.
+ /// </summary>
+ public class InversionInner
+ {
+ public InversionOuter Outer;
+ }
+
+ /// <summary>
+ /// Object for composite array tests.
+ /// </summary>
+ public class CompositeArray
+ {
+ public object[] InArr;
+ public object[] OutArr;
+ }
+
+ /// <summary>
+ /// Object for composite collection/dictionary tests.
+ /// </summary>
+ public class CompositeContainer
+ {
+ public ICollection Col;
+ public IDictionary Dict;
+ }
+
+ /// <summary>
+ /// OUter object for composite structures test.
+ /// </summary>
+ public class CompositeOuter
+ {
+ public CompositeInner Inner;
+
+ public CompositeOuter()
+ {
+ // No-op.
+ }
+
+ public CompositeOuter(CompositeInner inner)
+ {
+ Inner = inner;
+ }
+ }
+
+ /// <summary>
+ /// Inner object for composite structures test.
+ /// </summary>
+ public class CompositeInner
+ {
+ public int Val;
+
+ public CompositeInner()
+ {
+ // No-op.
+ }
+
+ public CompositeInner(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test "ToBinary()" logic.
+ /// </summary>
+ public class ToBinary
+ {
+ public int Val;
+
+ public ToBinary(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test removal.
+ /// </summary>
+ public class Remove
+ {
+ public object Val;
+ public RemoveInner Val2;
+ }
+
+ /// <summary>
+ /// Inner type to test removal.
+ /// </summary>
+ public class RemoveInner
+ {
+ /** */
+ public int Val;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="val"></param>
+ public RemoveInner(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderInBuilderOuter
+ {
+ /** */
+ public BuilderInBuilderInner Inner;
+
+ /** */
+ public BuilderInBuilderInner Inner2;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderInBuilderInner
+ {
+ /** */
+ public BuilderInBuilderOuter Outer;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderCollection
+ {
+ /** */
+ public readonly ArrayList Col;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="col"></param>
+ public BuilderCollection(ArrayList col)
+ {
+ Col = col;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderCollectionItem
+ {
+ /** */
+ public int Val;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="val"></param>
+ public BuilderCollectionItem(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class DecimalHolder
+ {
+ /** */
+ public decimal Val;
+
+ /** */
+ public decimal?[] ValArr;
+ }
+
+ /// <summary>
+ /// Test id mapper.
+ /// </summary>
+ public class IdMapper : IBinaryIdMapper
+ {
+ /** */
+ public const string TestTypeName = "IdMapperTestType";
+
+ /** */
+ public const int TestTypeId = -65537;
+
+ /** <inheritdoc /> */
+ public int GetTypeId(string typeName)
+ {
+ return typeName == TestTypeName ? TestTypeId : 0;
+ }
+
+ /** <inheritdoc /> */
+ public int GetFieldId(int typeId, string fieldName)
+ {
+ return 0;
+ }
+ }
+}
[4/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 cb582b7..68616ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -39,8 +39,8 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Echo task name. */
private const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask";
- /** Portable argument task name. */
- private const string PortableArgTask = "org.apache.ignite.platform.PlatformComputePortableArgTask";
+ /** Binary argument task name. */
+ private const string BinaryArgTask = "org.apache.ignite.platform.PlatformComputeBinarizableArgTask";
/** Broadcast task name. */
private const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask";
@@ -48,8 +48,8 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Broadcast task name. */
private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask";
- /** Java portable class name. */
- private const string JavaPortableCls = "GridInteropComputeJavaPortable";
+ /** Java binary class name. */
+ private const string JavaBinaryCls = "PlatformComputeJavaBinarizable";
/** Echo type: null. */
private const int EchoTypeNull = 0;
@@ -87,17 +87,17 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Echo type: map. */
private const int EchoTypeMap = 11;
- /** Echo type: portable. */
- private const int EchoTypePortable = 12;
+ /** Echo type: binarizable. */
+ private const int EchoTypeBinarizable = 12;
- /** Echo type: portable (Java only). */
- private const int EchoTypePortableJava = 13;
+ /** Echo type: binary (Java only). */
+ private const int EchoTypeBinarizableJava = 13;
/** Type: object array. */
private const int EchoTypeObjArray = 14;
- /** Type: portable object array. */
- private const int EchoTypePortableArray = 15;
+ /** Type: binary object array. */
+ private const int EchoTypeBinarizableArray = 15;
/** Type: enum. */
private const int EchoTypeEnum = 16;
@@ -799,34 +799,34 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test echo task returning portable object.
+ /// Test echo task returning binary object.
/// </summary>
[Test]
- public void TestEchoTaskPortable()
+ public void TestEchoTaskBinarizable()
{
- PlatformComputePortable res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable>(EchoTask, EchoTypePortable);
+ var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeBinarizable>(EchoTask, EchoTypeBinarizable);
Assert.AreEqual(1, res.Field);
}
/// <summary>
- /// Test echo task returning portable object with no corresponding class definition.
+ /// Test echo task returning binary object with no corresponding class definition.
/// </summary>
[Test]
- public void TestEchoTaskPortableNoClass()
+ public void TestEchoTaskBinarizableNoClass()
{
ICompute compute = _grid1.GetCompute();
compute.WithKeepBinary();
- IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypePortableJava);
+ IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava);
Assert.AreEqual(1, res.GetField<int>("field"));
- // This call must fail because "keepPortable" flag is reset.
+ // This call must fail because "keepBinary" flag is reset.
Assert.Catch(typeof(BinaryObjectException), () =>
{
- compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypePortableJava);
+ compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava);
});
}
@@ -842,17 +842,17 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Tests the echo task returning portable array.
+ /// Tests the echo task returning binary array.
/// </summary>
[Test]
- public void TestEchoTaskPortableArray()
+ public void TestEchoTaskBinarizableArray()
{
- var res = _grid1.GetCompute().ExecuteJavaTask<object[]>(EchoTask, EchoTypePortableArray);
+ 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, ((PlatformComputePortable) res[i]).Field);
+ Assert.AreEqual(i + 1, ((PlatformComputeBinarizable) res[i]).Field);
}
/// <summary>
@@ -883,20 +883,20 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test for portable argument in Java.
+ /// Test for binary argument in Java.
/// </summary>
[Test]
- public void TestPortableArgTask()
+ public void TestBinarizableArgTask()
{
ICompute compute = _grid1.GetCompute();
compute.WithKeepBinary();
- PlatformComputeNetPortable arg = new PlatformComputeNetPortable();
+ PlatformComputeNetBinarizable arg = new PlatformComputeNetBinarizable();
arg.Field = 100;
- int res = compute.ExecuteJavaTask<int>(PortableArgTask, arg);
+ int res = compute.ExecuteJavaTask<int>(BinaryArgTask, arg);
Assert.AreEqual(arg.Field, res);
}
@@ -1109,9 +1109,9 @@ namespace Apache.Ignite.Core.Tests.Compute
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputePortable)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeNetPortable)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(JavaPortableCls));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeBinarizable)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeNetBinarizable)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(JavaBinaryCls));
portCfg.TypeConfigurations = portTypeCfgs;
@@ -1127,7 +1127,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
}
- class PlatformComputePortable
+ class PlatformComputeBinarizable
{
public int Field
{
@@ -1136,7 +1136,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
}
- class PlatformComputeNetPortable : PlatformComputePortable
+ class PlatformComputeNetBinarizable : PlatformComputeBinarizable
{
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 044b5a6..34a1573 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -73,10 +73,10 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test for GridComputeJobFailoverException with portable job.
+ /// Test for GridComputeJobFailoverException with binary job.
/// </summary>
[Test]
- public void TestTaskAdapterFailoverExceptionPortable()
+ public void TestTaskAdapterFailoverExceptionBinarizable()
{
TestTaskAdapterFailoverException(false);
}
@@ -111,9 +111,9 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestPortableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestBinarizableJob)));
}
/// <summary>
@@ -138,7 +138,7 @@ namespace Apache.Ignite.Core.Tests.Compute
if (serializable)
job = new TestSerializableJob();
else
- job = new TestPortableJob();
+ job = new TestBinarizableJob();
foreach (IClusterNode node in subgrid) {
bool add = local ? node.IsLocal : !node.IsLocal;
@@ -172,7 +172,7 @@ namespace Apache.Ignite.Core.Tests.Compute
class TestClosure : IComputeFunc<int>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
public int Invoke()
@@ -188,7 +188,7 @@ namespace Apache.Ignite.Core.Tests.Compute
class TestSerializableJob : IComputeJob<int>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
public int Execute()
@@ -206,10 +206,10 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class TestPortableJob : IComputeJob<int>
+ class TestBinarizableJob : IComputeJob<int>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
public int Execute()
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs
new file mode 100644
index 0000000..315bbbe
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs
@@ -0,0 +1,30 @@
+/*
+ * 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.Compute.Forked
+{
+ /// <summary>
+ /// Forked closure execution tests for binary objects.
+ /// </summary>
+ public class ForkedBinarizableClosureTaskTest : BinarizableClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ForkedBinarizableClosureTaskTest() : base(true) { }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
deleted file mode 100644
index 4ce917b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
+++ /dev/null
@@ -1,30 +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.Tests.Compute.Forked
-{
- /// <summary>
- /// Forked closure execution tests for portable objects.
- /// </summary>
- public class ForkedPortableClosureTaskTest : PortableClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ForkedPortableClosureTaskTest() : base(true) { }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
index 84c1ba2..a16db03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
@@ -17,12 +17,9 @@
namespace Apache.Ignite.Core.Tests.Compute.Forked
{
- using NUnit.Framework;
-
/// <summary>
/// Forked resource task test.
/// </summary>
- [Ignore("IGNITE-1381")]
public class ForkedResourceTaskTest : ResourceTaskTest
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
index 0324125..c6582ad 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
@@ -17,12 +17,9 @@
namespace Apache.Ignite.Core.Tests.Compute.Forked
{
- using NUnit.Framework;
-
/// <summary>
/// Forked closure execution tests for serializable objects.
/// </summary>
- [Ignore("IGNITE-1381")]
public class ForkedSerializableClosureTaskTest : SerializableClosureTaskTest
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
deleted file mode 100644
index bca5ab6..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
+++ /dev/null
@@ -1,217 +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.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Closure execution tests for portable objects.
- /// </summary>
- public class PortableClosureTaskTest : ClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public PortableClosureTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected PortableClosureTaskTest(bool fork) : base(fork) { }
-
- /** <inheritDoc /> */
- protected override void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableOutFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableException)));
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object> OutFunc(bool err)
- {
- return new PortableOutFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object, object> Func(bool err)
- {
- return new PortableFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override void CheckResult(object res)
- {
- Assert.IsTrue(res != null);
-
- PortableResult res0 = res as PortableResult;
-
- Assert.IsTrue(res0 != null);
- Assert.AreEqual(1, res0.Res);
- }
-
- /** <inheritDoc /> */
- protected override void CheckError(Exception err)
- {
- Assert.IsTrue(err != null);
-
- PortableException err0 = err as PortableException;
-
- Assert.IsTrue(err0 != null);
- Assert.AreEqual(ErrMsg, err0.Msg);
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableOutFunc : IComputeFunc<object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public PortableOutFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public PortableOutFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke()
- {
- if (_err)
- throw new PortableException(ErrMsg);
- return new PortableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableFunc : IComputeFunc<object, object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public PortableFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public PortableFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke(object arg)
- {
- if (_err)
- throw new PortableException(ErrMsg);
- return new PortableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableException : Exception, IBinarizable
- {
- /** */
- public string Msg;
-
- /// <summary>
- ///
- /// </summary>
- public PortableException()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="msg"></param>
- public PortableException(string msg) : this()
- {
- Msg = msg;
- }
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.GetRawWriter().WriteString(Msg);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Msg = reader.GetRawReader().ReadString();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableResult
- {
- /** */
- public int Res;
-
- /// <summary>
- ///
- /// </summary>
- public PortableResult()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="res"></param>
- public PortableResult(int res)
- {
- Res = res;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
deleted file mode 100644
index 40a0f72..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
+++ /dev/null
@@ -1,269 +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.Tests.Compute
-{
- using System.Collections.Generic;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Task test result.
- /// </summary>
- public class PortableTaskTest : AbstractTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public PortableTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected PortableTaskTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestPortableObjectInTask()
- {
- var taskArg = new PortableWrapper {Item = ToPortable(Grid1, new PortableTaskArgument(100))};
-
- TestTask task = new TestTask(Grid1, taskArg);
-
- var res = Grid1.GetCompute().Execute(task, taskArg).Item;
-
- Assert.NotNull(res);
-
- Assert.AreEqual(400, res.GetField<int>("val"));
-
- PortableTaskResult resObj = res.Deserialize<PortableTaskResult>();
-
- Assert.AreEqual(400, resObj.Val);
- }
-
- private static IBinaryObject ToPortable(IIgnite grid, object obj)
- {
- var cache = grid.GetCache<object, object>(Cache1Name).WithKeepBinary<object, object>();
-
- cache.Put(1, obj);
-
- return (IBinaryObject) cache.Get(1);
- }
-
- /** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJobArgument)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJobResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTaskArgument)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTaskResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJob)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableWrapper)));
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- class TestTask : ComputeTaskAdapter<PortableWrapper, PortableWrapper, PortableWrapper>
- {
- /** */
- private readonly IIgnite _grid;
-
- private readonly PortableWrapper _taskArgField;
-
- public TestTask(IIgnite grid, PortableWrapper taskArgField)
- {
- _grid = grid;
- _taskArgField = taskArgField;
- }
-
- /** <inheritDoc /> */
- override public IDictionary<IComputeJob<PortableWrapper>, IClusterNode> Map(IList<IClusterNode> subgrid, PortableWrapper arg)
- {
- Assert.AreEqual(3, subgrid.Count);
- Assert.NotNull(_grid);
-
- var taskArg = arg;
-
- CheckTaskArgument(taskArg);
-
- CheckTaskArgument(_taskArgField);
-
- var jobs = new Dictionary<IComputeJob<PortableWrapper>, IClusterNode>();
-
-
- foreach (IClusterNode node in subgrid)
- {
- if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
- {
- var job = new PortableJob
- {
- Arg = new PortableWrapper {Item = ToPortable(_grid, new PortableJobArgument(200))}
- };
-
- jobs.Add(job, node);
- }
- }
-
- Assert.AreEqual(2, jobs.Count);
-
- return jobs;
- }
-
- private void CheckTaskArgument(PortableWrapper arg)
- {
- Assert.IsNotNull(arg);
-
- var taskArg = arg.Item;
-
- Assert.IsNotNull(taskArg);
-
- Assert.AreEqual(100, taskArg.GetField<int>("val"));
-
- PortableTaskArgument taskArgObj = taskArg.Deserialize<PortableTaskArgument>();
-
- Assert.AreEqual(100, taskArgObj.Val);
- }
-
- /** <inheritDoc /> */
- override public PortableWrapper Reduce(IList<IComputeJobResult<PortableWrapper>> results)
- {
- Assert.NotNull(_grid);
-
- Assert.AreEqual(2, results.Count);
-
- foreach (var res in results)
- {
- var jobRes = res.Data.Item;
-
- Assert.NotNull(jobRes);
-
- Assert.AreEqual(300, jobRes.GetField<int>("val"));
-
- PortableJobResult jobResObj = jobRes.Deserialize<PortableJobResult>();
-
- Assert.AreEqual(300, jobResObj.Val);
- }
-
- return new PortableWrapper {Item = ToPortable(_grid, new PortableTaskResult(400))};
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJobArgument
- {
- /** */
- public int Val;
-
- public PortableJobArgument(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJobResult
- {
- /** */
- public int Val;
-
- public PortableJobResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableTaskArgument
- {
- /** */
- public int Val;
-
- public PortableTaskArgument(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableTaskResult
- {
- /** */
- public int Val;
-
- public PortableTaskResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJob : IComputeJob<PortableWrapper>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** */
- public PortableWrapper Arg;
-
- /** <inheritDoc /> */
-
- public PortableWrapper Execute()
- {
- Assert.IsNotNull(Arg);
-
- var arg = Arg.Item;
-
- Assert.IsNotNull(arg);
-
- Assert.AreEqual(200, arg.GetField<int>("val"));
-
- PortableJobArgument argObj = arg.Deserialize<PortableJobArgument>();
-
- Assert.AreEqual(200, argObj.Val);
-
- return new PortableWrapper {Item = ToPortable(_grid, new PortableJobResult(300))};
- }
-
- public void Cancel()
- {
- // No-op.
- }
- }
-
- class PortableWrapper
- {
- public IBinaryObject Item { get; set; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 57e23b8..8418306 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -88,7 +88,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// Test for job adapter.
/// </summary>
[Test]
- public void TestPortableJobAdapter()
+ public void TestBinarizableJobAdapter()
{
for (int i = 0; i < 10; i++)
{
@@ -99,9 +99,9 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJob)));
}
/// <summary>
@@ -158,7 +158,7 @@ namespace Apache.Ignite.Core.Tests.Compute
if (serializable)
jobs.Add(new SerializableJob(100, "str"));
else
- jobs.Add(new PortableJob(100, "str"));
+ jobs.Add(new BinarizableJob(100, "str"));
return jobs;
}
@@ -236,14 +236,14 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test portable job.
+ /// Test binary job.
/// </summary>
- public class PortableJob : ComputeJobAdapter<bool>
+ public class BinarizableJob : ComputeJobAdapter<bool>
{
[InstanceResource]
private IIgnite _grid = null;
- public PortableJob(params object[] args) : base(args)
+ public BinarizableJob(params object[] args) : base(args)
{
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 20b19a1..4bf1e21 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -99,19 +99,19 @@ namespace Apache.Ignite.Core.Tests.Compute
/// Test for task result.
/// </summary>
[Test]
- public void TestTaskResultPortable()
+ public void TestTaskResultBinarizable()
{
- TestTask<PortableResult> task = new TestTask<PortableResult>();
+ TestTask<BinarizableResult> task = new TestTask<BinarizableResult>();
- PortableResult val = new PortableResult(100);
+ BinarizableResult val = new BinarizableResult(100);
- PortableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(true, val));
+ BinarizableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, BinarizableResult>(true, val));
Assert.AreEqual(val.Val, res.Val);
val.Val = 101;
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(false, val));
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, BinarizableResult>(false, val));
Assert.AreEqual(val.Val, res.Val);
}
@@ -156,18 +156,18 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestPortableJob)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableOutFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableResult)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestBinarizableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableOutFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFunc)));
}
[Test]
public void TestOutFuncResultPrimitive1()
{
- ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableOutFunc());
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new BinarizableOutFunc());
Assert.AreEqual(3, res.Count);
@@ -189,7 +189,7 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestFuncResultPrimitive1()
{
- ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableFunc(), 10);
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new BinarizableFunc(), 10);
Assert.AreEqual(3, res.Count);
@@ -216,7 +216,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
/// Test function.
/// </summary>
- public class PortableFunc : IComputeFunc<int, int>, IUserInterface<int, int>
+ public class BinarizableFunc : IComputeFunc<int, int>, IUserInterface<int, int>
{
int IComputeFunc<int, int>.Invoke(int arg)
{
@@ -252,7 +252,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
/// Test function.
/// </summary>
- public class PortableOutFunc : IComputeFunc<int>
+ public class BinarizableOutFunc : IComputeFunc<int>
{
public int Invoke()
{
@@ -291,9 +291,9 @@ namespace Apache.Ignite.Core.Tests.Compute
IComputeJob<T> job;
- if (res is PortableResult)
+ if (res is BinarizableResult)
{
- TestPortableJob job0 = new TestPortableJob();
+ TestBinarizableJob job0 = new TestBinarizableJob();
job0.SetArguments(res);
@@ -365,12 +365,12 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class PortableResult
+ class BinarizableResult
{
/** */
public int Val;
- public PortableResult(int val)
+ public BinarizableResult(int val)
{
Val = val;
}
@@ -398,7 +398,7 @@ namespace Apache.Ignite.Core.Tests.Compute
class TestJob<T> : ComputeJobAdapter<T>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
override public T Execute()
@@ -416,19 +416,19 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class TestPortableJob : ComputeJobAdapter<PortableResult>
+ class TestBinarizableJob : ComputeJobAdapter<BinarizableResult>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
- override public PortableResult Execute()
+ override public BinarizableResult Execute()
{
Assert.IsNotNull(_grid);
_gridName = _grid.Name;
- PortableResult res = GetArgument<PortableResult>(0);
+ BinarizableResult res = GetArgument<BinarizableResult>(0);
return res;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
index 0ad0070..e373b89 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
@@ -67,16 +67,16 @@
</bean>
</property>
- <!-- Portable marshaller configuration -->
+ <!-- Binary marshaller configuration -->
<property name="marshaller">
<bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
<property name="typeConfigurations">
<list>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputePortable"/>
+ <property name="className" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
</bean>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
+ <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
</bean>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
<property name="className" value="org.apache.ignite.platform.PlatformComputeEnum"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 6447b4e..ddedf40 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
@@ -61,20 +61,20 @@
<list>
<value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration</value>
<value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfigurationClosure</value>
- <value>Apache.Ignite.Core.Tests.Compute.TaskAdapterTest+PortableJob</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableOutFunc</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableFunc</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableResult</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableException</value>
+ <value>Apache.Ignite.Core.Tests.Compute.TaskAdapterTest+BinarizableJob</value>
+ <value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableOutFunc</value>
+ <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>
</list>
</property>
<property name="typesConfiguration">
<list>
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
- <property name="typeName" value="org.apache.ignite.platform.PlatformComputePortable"/>
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
</bean>
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
- <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
</bean>
</list>
</property>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml
new file mode 100644
index 0000000..f013749
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid"/>
+
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml
new file mode 100644
index 0000000..a31a450
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Type]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,Apache.Ignite.Core.Tests.TestGenericBinarizable[System.String]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,System.Type]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,System.Type]]</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" />
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
deleted file mode 100644
index 26bf87b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="binaryConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Type]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,Apache.Ignite.Core.Tests.TestGenericPortable[System.String]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]]</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration" />
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
index 7f9ce40..86a46e4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
@@ -40,7 +40,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
@@ -70,7 +70,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
@@ -100,7 +100,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
@@ -130,7 +130,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
new file mode 100644
index 0000000..11b87bd
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller" />
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
deleted file mode 100644
index 753fad1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
index 6845a3c..c2bf78c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
@@ -36,7 +36,7 @@
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="portable_store"/>
+ <property name="name" value="binary_store"/>
<property name="cacheMode" value="LOCAL"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
index c48e867..d8d4553 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
@@ -139,56 +139,5 @@
<property name="swapEnabled" value="true"/>
<property name="backups" value="1"/>
<property name="eagerTtl" value="true"/>
-
- <!--
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>address</value>
- </list>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridImplicitPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridNoDefPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- </list>
- </property>
- -->
</bean>
</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
deleted file mode 100644
index f013749..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid"/>
-
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index 2f9f6c9..20ae629 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -383,7 +383,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
[Test]
public void TestStreamReceiver()
{
- TestStreamReceiver(new StreamReceiverPortable());
+ TestStreamReceiver(new StreamReceiverBinarizable());
TestStreamReceiver(new StreamReceiverSerializable());
}
@@ -403,7 +403,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
public void TestStreamTransformer()
{
TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorSerializable()));
- TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorPortable()));
+ TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorBinarizable()));
}
/// <summary>
@@ -415,7 +415,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
{
ldr.AllowOverwrite = true;
- ldr.Receiver = new StreamReceiverPortable();
+ ldr.Receiver = new StreamReceiverBinarizable();
ldr.Receiver = receiver; // check double assignment
@@ -432,23 +432,23 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Tests the stream receiver in keepPortable mode.
+ /// Tests the stream receiver in keepBinary mode.
/// </summary>
[Test]
- public void TestStreamReceiverKeepPortable()
+ public void TestStreamReceiverKeepBinary()
{
// ReSharper disable once LocalVariableHidesMember
- var cache = _grid.GetCache<int, PortableEntry>(CacheName);
+ var cache = _grid.GetCache<int, BinarizableEntry>(CacheName);
using (var ldr0 = _grid.GetDataStreamer<int, int>(CacheName))
using (var ldr = ldr0.WithKeepBinary<int, IBinaryObject>())
{
- ldr.Receiver = new StreamReceiverKeepPortable();
+ ldr.Receiver = new StreamReceiverKeepBinary();
ldr.AllowOverwrite = true;
for (var i = 0; i < 100; i++)
- ldr.AddData(i, _grid.GetBinary().ToBinary<IBinaryObject>(new PortableEntry {Val = i}));
+ ldr.AddData(i, _grid.GetBinary().ToBinary<IBinaryObject>(new BinarizableEntry {Val = i}));
ldr.Flush();
@@ -474,9 +474,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
{
new BinaryTypeConfiguration(typeof (CacheTestKey)),
new BinaryTypeConfiguration(typeof (TestReferenceObject)),
- new BinaryTypeConfiguration(typeof (StreamReceiverPortable)),
- new BinaryTypeConfiguration(typeof (EntryProcessorPortable)),
- new BinaryTypeConfiguration(typeof (PortableEntry))
+ new BinaryTypeConfiguration(typeof (StreamReceiverBinarizable)),
+ new BinaryTypeConfiguration(typeof (EntryProcessorBinarizable)),
+ new BinaryTypeConfiguration(typeof (BinarizableEntry))
}
},
JvmOptions = TestUtils.TestJavaOptions().Concat(new[]
@@ -497,9 +497,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Test portable receiver.
+ /// Test binarizable receiver.
/// </summary>
- private class StreamReceiverPortable : IStreamReceiver<int, int>
+ private class StreamReceiverBinarizable : IStreamReceiver<int, int>
{
/** <inheritdoc /> */
public void Receive(ICache<int, int> cache, ICollection<ICacheEntry<int, int>> entries)
@@ -509,20 +509,20 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Test portable receiver.
+ /// Test binary receiver.
/// </summary>
[Serializable]
- private class StreamReceiverKeepPortable : IStreamReceiver<int, IBinaryObject>
+ private class StreamReceiverKeepBinary : IStreamReceiver<int, IBinaryObject>
{
/** <inheritdoc /> */
public void Receive(ICache<int, IBinaryObject> cache, ICollection<ICacheEntry<int, IBinaryObject>> entries)
{
- var portables = cache.Ignite.GetBinary();
+ var binary = cache.Ignite.GetBinary();
cache.PutAll(entries.ToDictionary(x => x.Key, x =>
- portables.ToBinary<IBinaryObject>(new PortableEntry
+ binary.ToBinary<IBinaryObject>(new BinarizableEntry
{
- Val = x.Value.Deserialize<PortableEntry>().Val + 1
+ Val = x.Value.Deserialize<BinarizableEntry>().Val + 1
})));
}
}
@@ -558,7 +558,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
/// <summary>
/// Test entry processor.
/// </summary>
- private class EntryProcessorPortable : ICacheEntryProcessor<int, int, int, int>, IBinarizable
+ private class EntryProcessorBinarizable : ICacheEntryProcessor<int, int, int, int>, IBinarizable
{
/** <inheritdoc /> */
public int Process(IMutableCacheEntry<int, int> entry, int arg)
@@ -582,9 +582,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Portablecache entry.
+ /// Binarizable entry.
/// </summary>
- private class PortableEntry
+ private class BinarizableEntry
{
public int Val { get; set; }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 403f8a7..9f22355 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -365,7 +365,7 @@ namespace Apache.Ignite.Core.Tests
[Test]
public void TestRemoteListen(
[Values(true, false)] bool async,
- [Values(true, false)] bool portable,
+ [Values(true, false)] bool binarizable,
[Values(true, false)] bool autoUnsubscribe)
{
foreach (var g in _grids)
@@ -378,8 +378,8 @@ namespace Apache.Ignite.Core.Tests
var expectedType = EventType.JobStarted;
- var remoteFilter = portable
- ? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
+ var remoteFilter = binary
+ ? (IEventFilter<IEvent>) new RemoteEventBinarizableFilter(expectedType)
: new RemoteEventFilter(expectedType);
var localListener = EventsTestHelper.GetListener();
@@ -616,7 +616,7 @@ namespace Apache.Ignite.Core.Tests
{
TypeConfigurations = new List<BinaryTypeConfiguration>
{
- new BinaryTypeConfiguration(typeof (RemoteEventPortableFilter))
+ new BinaryTypeConfiguration(typeof (RemoteEventBinarizableFilter))
}
}
};
@@ -882,18 +882,18 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
- /// Portable remote event filter.
+ /// Binary remote event filter.
/// </summary>
- public class RemoteEventPortableFilter : IEventFilter<IEvent>, IBinarizable
+ public class RemoteEventBinarizableFilter : IEventFilter<IEvent>, IBinarizable
{
/** */
private int _type;
/// <summary>
- /// Initializes a new instance of the <see cref="RemoteEventPortableFilter"/> class.
+ /// Initializes a new instance of the <see cref="RemoteEventBinarizableFilter"/> class.
/// </summary>
/// <param name="type">The event type.</param>
- public RemoteEventPortableFilter(int type)
+ public RemoteEventBinarizableFilter(int type)
{
_type = type;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 196d8ae..79297da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -107,18 +107,18 @@ namespace Apache.Ignite.Core.Tests
TestPartialUpdateException(false, (x, g) => x);
// User type
- TestPartialUpdateException(false, (x, g) => new PortableEntry(x));
+ TestPartialUpdateException(false, (x, g) => new BinarizableEntry(x));
}
/// <summary>
- /// Tests CachePartialUpdateException keys propagation in portable mode.
+ /// Tests CachePartialUpdateException keys propagation in binary mode.
/// </summary>
[Test]
[Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionPortable()
+ public void TestPartialUpdateExceptionBinarizable()
{
// User type
- TestPartialUpdateException(false, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new PortableEntry(x)));
+ TestPartialUpdateException(false, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new BinarizableEntry(x)));
}
/// <summary>
@@ -195,17 +195,17 @@ namespace Apache.Ignite.Core.Tests
TestPartialUpdateException(true, (x, g) => x);
// User type
- TestPartialUpdateException(true, (x, g) => new PortableEntry(x));
+ TestPartialUpdateException(true, (x, g) => new BinarizableEntry(x));
}
/// <summary>
- /// Tests CachePartialUpdateException keys propagation in portable mode.
+ /// Tests CachePartialUpdateException keys propagation in binary mode.
/// </summary>
[Test]
[Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionAsyncPortable()
+ public void TestPartialUpdateExceptionAsyncBinarizable()
{
- TestPartialUpdateException(true, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new PortableEntry(x)));
+ TestPartialUpdateException(true, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new BinarizableEntry(x)));
}
/// <summary>
@@ -295,16 +295,16 @@ namespace Apache.Ignite.Core.Tests
{
TypeConfigurations = new[]
{
- new BinaryTypeConfiguration(typeof (PortableEntry))
+ new BinaryTypeConfiguration(typeof (BinarizableEntry))
}
}
});
}
/// <summary>
- /// Portable entry.
+ /// Binarizable entry.
/// </summary>
- private class PortableEntry
+ private class BinarizableEntry
{
/** Value. */
private readonly int _val;
@@ -319,7 +319,7 @@ namespace Apache.Ignite.Core.Tests
/// Constructor.
/// </summary>
/// <param name="val">Value.</param>
- public PortableEntry(int val)
+ public BinarizableEntry(int val)
{
_val = val;
}
@@ -327,12 +327,12 @@ namespace Apache.Ignite.Core.Tests
/** <inheritDoc /> */
public override bool Equals(object obj)
{
- return obj is PortableEntry && ((PortableEntry)obj)._val == _val;
+ return obj is BinarizableEntry && ((BinarizableEntry)obj)._val == _val;
}
}
/// <summary>
- /// Portable entry.
+ /// Serializable entry.
/// </summary>
[Serializable]
private class SerializableEntry
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
index e32f49a..f18be8c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Core.Tests
BinaryConfiguration = new BinaryConfiguration
{
TypeConfigurations =
- new List<BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(Portable)) }
+ new List<BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(Binarizable)) }
}
});
@@ -107,7 +107,7 @@ namespace Apache.Ignite.Core.Tests
TestType(18m); // decimal
- TestType(new Portable { A = 10, B = "foo" });
+ TestType(new Binarizable { A = 10, B = "foo" });
}
/// <summary>
@@ -123,9 +123,9 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
- /// Portable test class.
+ /// Binary test class.
/// </summary>
- private class Portable : IBinarizable
+ private class Binarizable : IBinarizable
{
public int A;
public string B;
@@ -156,7 +156,7 @@ namespace Apache.Ignite.Core.Tests
if (obj.GetType() != GetType())
return false;
- var other = (Portable)obj;
+ var other = (Binarizable)obj;
return A == other.A && string.Equals(B, other.B);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
index d3af288..541de0c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
@@ -27,7 +27,7 @@ namespace Apache.Ignite.Core.Tests
{
/// <summary>
/// Tests the default marhsaller.
- /// By default, portable marshaller is used.
+ /// By default, binary marshaller is used.
/// </summary>
[Test]
public void TestDefaultMarhsaller()
@@ -43,13 +43,13 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
- /// Tests the portable marhsaller.
- /// PortableMarshaller can be specified explicitly in config.
+ /// Tests the binary marhsaller.
+ /// Marshaller can be specified explicitly in config.
/// </summary>
[Test]
- public void TestPortableMarhsaller()
+ public void TestExplicitMarhsaller()
{
- using (var grid = Ignition.Start("config\\marshaller-portable.xml"))
+ using (var grid = Ignition.Start("config\\marshaller-explicit.xml"))
{
var cache = grid.GetOrCreateCache<int, int>(null);
[3/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
deleted file mode 100644
index 9529503..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ /dev/null
@@ -1,1777 +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.
- */
-
-// ReSharper disable UnassignedField.Global
-// ReSharper disable CollectionNeverUpdated.Global
-namespace Apache.Ignite.Core.Tests.Portable
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Binary;
- using NUnit.Framework;
-
- /// <summary>
- /// Portable builder self test.
- /// </summary>
- public class PortableApiSelfTest
- {
- /** Undefined type: Empty. */
- private const string TypeEmpty = "EmptyUndefined";
-
- /** Grid. */
- private Ignite _grid;
-
- /** Marshaller. */
- private Marshaller _marsh;
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
-
- var cfg = new IgniteConfiguration
- {
- BinaryConfiguration = new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (Empty)),
- new BinaryTypeConfiguration(typeof (Primitives)),
- new BinaryTypeConfiguration(typeof (PrimitiveArrays)),
- new BinaryTypeConfiguration(typeof (StringDateGuidEnum)),
- new BinaryTypeConfiguration(typeof (WithRaw)),
- new BinaryTypeConfiguration(typeof (MetaOverwrite)),
- new BinaryTypeConfiguration(typeof (NestedOuter)),
- new BinaryTypeConfiguration(typeof (NestedInner)),
- new BinaryTypeConfiguration(typeof (MigrationOuter)),
- new BinaryTypeConfiguration(typeof (MigrationInner)),
- new BinaryTypeConfiguration(typeof (InversionOuter)),
- new BinaryTypeConfiguration(typeof (InversionInner)),
- new BinaryTypeConfiguration(typeof (CompositeOuter)),
- new BinaryTypeConfiguration(typeof (CompositeInner)),
- new BinaryTypeConfiguration(typeof (CompositeArray)),
- new BinaryTypeConfiguration(typeof (CompositeContainer)),
- new BinaryTypeConfiguration(typeof (ToPortable)),
- new BinaryTypeConfiguration(typeof (Remove)),
- new BinaryTypeConfiguration(typeof (RemoveInner)),
- new BinaryTypeConfiguration(typeof (BuilderInBuilderOuter)),
- new BinaryTypeConfiguration(typeof (BuilderInBuilderInner)),
- new BinaryTypeConfiguration(typeof (BuilderCollection)),
- new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
- new BinaryTypeConfiguration(typeof (DecimalHolder)),
- new BinaryTypeConfiguration(TypeEmpty),
- TypeConfigurationNoMeta(typeof (EmptyNoMeta)),
- TypeConfigurationNoMeta(typeof (ToPortableNoMeta))
- },
- DefaultIdMapper = new IdMapper()
- },
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = new List<string>
- {
- "-ea",
- "-Xcheck:jni",
- "-Xms4g",
- "-Xmx4g",
- "-DIGNITE_QUIET=false",
- "-Xnoagent",
- "-Djava.compiler=NONE",
- "-Xdebug",
- "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
- "-XX:+HeapDumpOnOutOfMemoryError"
- },
- SpringConfigUrl = "config\\portable.xml"
- };
-
- _grid = (Ignite) Ignition.Start(cfg);
-
- _marsh = _grid.Marshaller;
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TestFixtureTearDown]
- public virtual void TearDown()
- {
- if (_grid != null)
- Ignition.Stop(_grid.Name, true);
-
- _grid = null;
- }
-
- /// <summary>
- /// Ensure that portable engine is able to work with type names, which are not configured.
- /// </summary>
- [Test]
- public void TestNonConfigured()
- {
- string typeName1 = "Type1";
- string typeName2 = "Type2";
- string field1 = "field1";
- string field2 = "field2";
-
- // 1. Ensure that builder works fine.
- IBinaryObject portObj1 = _grid.GetBinary().GetBuilder(typeName1).SetField(field1, 1).Build();
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 2. Ensure that object can be unmarshalled without deserialization.
- byte[] data = ((BinaryObject) portObj1).Data;
-
- portObj1 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 3. Ensure that we can nest one anonymous object inside another
- IBinaryObject portObj2 =
- _grid.GetBinary().GetBuilder(typeName2).SetField(field2, portObj1).Build();
-
- Assert.AreEqual(typeName2, portObj2.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj2.GetBinaryType().Fields.Count);
- Assert.AreEqual(field2, portObj2.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, portObj2.GetBinaryType().GetFieldTypeName(field2));
-
- portObj1 = portObj2.GetField<IBinaryObject>(field2);
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 4. Ensure that we can unmarshal object with other nested object.
- data = ((BinaryObject) portObj2).Data;
-
- portObj2 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- Assert.AreEqual(typeName2, portObj2.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj2.GetBinaryType().Fields.Count);
- Assert.AreEqual(field2, portObj2.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, portObj2.GetBinaryType().GetFieldTypeName(field2));
-
- portObj1 = portObj2.GetField<IBinaryObject>(field2);
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
- }
-
- /// <summary>
- /// Test "ToPortable()" method.
- /// </summary>
- [Test]
- public void TestToPortable()
- {
- DateTime date = DateTime.Now.ToUniversalTime();
- Guid guid = Guid.NewGuid();
-
- IIgniteBinary api = _grid.GetBinary();
-
- // 1. Primitives.
- Assert.AreEqual(1, api.ToBinary<byte>((byte)1));
- Assert.AreEqual(1, api.ToBinary<short>((short)1));
- Assert.AreEqual(1, api.ToBinary<int>(1));
- Assert.AreEqual(1, api.ToBinary<long>((long)1));
-
- Assert.AreEqual((float)1, api.ToBinary<float>((float)1));
- Assert.AreEqual((double)1, api.ToBinary<double>((double)1));
-
- Assert.AreEqual(true, api.ToBinary<bool>(true));
- Assert.AreEqual('a', api.ToBinary<char>('a'));
-
- // 2. Special types.
- Assert.AreEqual("a", api.ToBinary<string>("a"));
- Assert.AreEqual(date, api.ToBinary<DateTime>(date));
- Assert.AreEqual(guid, api.ToBinary<Guid>(guid));
- Assert.AreEqual(TestEnum.One, api.ToBinary<TestEnum>(TestEnum.One));
-
- // 3. Arrays.
- Assert.AreEqual(new byte[] { 1 }, api.ToBinary<byte[]>(new byte[] { 1 }));
- Assert.AreEqual(new short[] { 1 }, api.ToBinary<short[]>(new short[] { 1 }));
- Assert.AreEqual(new[] { 1 }, api.ToBinary<int[]>(new[] { 1 }));
- Assert.AreEqual(new long[] { 1 }, api.ToBinary<long[]>(new long[] { 1 }));
-
- Assert.AreEqual(new float[] { 1 }, api.ToBinary<float[]>(new float[] { 1 }));
- Assert.AreEqual(new double[] { 1 }, api.ToBinary<double[]>(new double[] { 1 }));
-
- Assert.AreEqual(new[] { true }, api.ToBinary<bool[]>(new[] { true }));
- Assert.AreEqual(new[] { 'a' }, api.ToBinary<char[]>(new[] { 'a' }));
-
- Assert.AreEqual(new[] { "a" }, api.ToBinary<string[]>(new[] { "a" }));
- Assert.AreEqual(new[] { date }, api.ToBinary<DateTime[]>(new[] { date }));
- Assert.AreEqual(new[] { guid }, api.ToBinary<Guid[]>(new[] { guid }));
- Assert.AreEqual(new[] { TestEnum.One }, api.ToBinary<TestEnum[]>(new[] { TestEnum.One }));
-
- // 4. Objects.
- IBinaryObject portObj = api.ToBinary<IBinaryObject>(new ToPortable(1));
-
- Assert.AreEqual(typeof(ToPortable).Name, portObj.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj.GetBinaryType().Fields.Count);
- Assert.AreEqual("Val", portObj.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj.GetBinaryType().GetFieldTypeName("Val"));
-
- Assert.AreEqual(1, portObj.GetField<int>("val"));
- Assert.AreEqual(1, portObj.Deserialize<ToPortable>().Val);
-
- portObj = api.ToBinary<IBinaryObject>(new ToPortableNoMeta(1));
-
- Assert.AreEqual(1, portObj.GetBinaryType().Fields.Count);
-
- Assert.AreEqual(1, portObj.GetField<int>("Val"));
- Assert.AreEqual(1, portObj.Deserialize<ToPortableNoMeta>().Val);
-
- // 5. Object array.
- var portObjArr = api.ToBinary<object[]>(new object[] {new ToPortable(1)})
- .OfType<IBinaryObject>().ToArray();
-
- Assert.AreEqual(1, portObjArr.Length);
- Assert.AreEqual(1, portObjArr[0].GetField<int>("Val"));
- Assert.AreEqual(1, portObjArr[0].Deserialize<ToPortable>().Val);
- }
-
- /// <summary>
- /// Test builder field remove logic.
- /// </summary>
- [Test]
- public void TestRemove()
- {
- // Create empty object.
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Remove)).Build();
-
- Assert.IsNull(portObj.GetField<object>("val"));
- Assert.IsNull(portObj.Deserialize<Remove>().Val);
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
-
- // Populate it with field.
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(portObj);
-
- Assert.IsNull(builder.GetField<object>("val"));
-
- object val = 1;
-
- builder.SetField("val", val);
-
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- portObj = builder.Build();
-
- Assert.AreEqual(val, portObj.GetField<object>("val"));
- Assert.AreEqual(val, portObj.Deserialize<Remove>().Val);
-
- meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("val", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
-
- // Perform field remove.
- builder = _grid.GetBinary().GetBuilder(portObj);
-
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- builder.RemoveField("val");
- Assert.IsNull(builder.GetField<object>("val"));
-
- builder.SetField("val", val);
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- builder.RemoveField("val");
- Assert.IsNull(builder.GetField<object>("val"));
-
- portObj = builder.Build();
-
- Assert.IsNull(portObj.GetField<object>("val"));
- Assert.IsNull(portObj.Deserialize<Remove>().Val);
-
- // Test correct removal of field being referenced by handle somewhere else.
- RemoveInner inner = new RemoveInner(2);
-
- portObj = _grid.GetBinary().GetBuilder(typeof(Remove))
- .SetField("val", inner)
- .SetField("val2", inner)
- .Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).RemoveField("val").Build();
-
- Remove obj = portObj.Deserialize<Remove>();
-
- Assert.IsNull(obj.Val);
- Assert.AreEqual(2, obj.Val2.Val);
- }
-
- /// <summary>
- /// Test builder-in-builder scenario.
- /// </summary>
- [Test]
- public void TestBuilderInBuilder()
- {
- // Test different builders assembly.
- IBinaryObjectBuilder builderOuter = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter));
- IBinaryObjectBuilder builderInner = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner));
-
- builderOuter.SetField<object>("inner", builderInner);
- builderInner.SetField<object>("outer", builderOuter);
-
- IBinaryObject outerPortObj = builderOuter.Build();
-
- IBinaryType meta = outerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("inner", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
-
- IBinaryObject innerPortObj = outerPortObj.GetField<IBinaryObject>("inner");
-
- meta = innerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("outer", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
-
- BuilderInBuilderOuter outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer, outer.Inner.Outer);
-
- // Test same builders assembly.
- innerPortObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner)).Build();
-
- outerPortObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter))
- .SetField("inner", innerPortObj)
- .SetField("inner2", innerPortObj)
- .Build();
-
- meta = outerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.IsTrue(meta.Fields.Contains("inner"));
- Assert.IsTrue(meta.Fields.Contains("inner2"));
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
-
- outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer.Inner, outer.Inner2);
-
- builderOuter = _grid.GetBinary().GetBuilder(outerPortObj);
- IBinaryObjectBuilder builderInner2 = builderOuter.GetField<IBinaryObjectBuilder>("inner2");
-
- builderInner2.SetField("outer", builderOuter);
-
- outerPortObj = builderOuter.Build();
-
- outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer, outer.Inner.Outer);
- Assert.AreSame(outer.Inner, outer.Inner2);
- }
-
- /// <summary>
- /// Test for decimals building.
- /// </summary>
- [Test]
- public void TestDecimals()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(DecimalHolder))
- .SetField("val", decimal.One)
- .SetField("valArr", new decimal?[] { decimal.MinusOne })
- .Build();
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.IsTrue(meta.Fields.Contains("val"));
- Assert.IsTrue(meta.Fields.Contains("valArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
-
- Assert.AreEqual(decimal.One, portObj.GetField<decimal>("val"));
- Assert.AreEqual(new decimal?[] { decimal.MinusOne }, portObj.GetField<decimal?[]>("valArr"));
-
- DecimalHolder obj = portObj.Deserialize<DecimalHolder>();
-
- Assert.AreEqual(decimal.One, obj.Val);
- Assert.AreEqual(new decimal?[] { decimal.MinusOne }, obj.ValArr);
- }
-
- /// <summary>
- /// Test for an object returning collection of builders.
- /// </summary>
- [Test]
- public void TestBuilderCollection()
- {
- // Test collection with single element.
- IBinaryObjectBuilder builderCol = _grid.GetBinary().GetBuilder(typeof(BuilderCollection));
- IBinaryObjectBuilder builderItem =
- _grid.GetBinary().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
-
- builderCol.SetCollectionField("col", new ArrayList { builderItem });
-
- IBinaryObject portCol = builderCol.Build();
-
- IBinaryType meta = portCol.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("col", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
-
- var portColItems = portCol.GetField<ArrayList>("col");
-
- Assert.AreEqual(1, portColItems.Count);
-
- var portItem = (IBinaryObject) portColItems[0];
-
- meta = portItem.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("val", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
-
- BuilderCollection col = portCol.Deserialize<BuilderCollection>();
-
- Assert.IsNotNull(col.Col);
- Assert.AreEqual(1, col.Col.Count);
- Assert.AreEqual(1, ((BuilderCollectionItem) col.Col[0]).Val);
-
- // Add more portable objects to collection.
- builderCol = _grid.GetBinary().GetBuilder(portCol);
-
- IList builderColItems = builderCol.GetField<IList>("col");
-
- Assert.AreEqual(1, builderColItems.Count);
-
- BinaryObjectBuilder builderColItem = (BinaryObjectBuilder) builderColItems[0];
-
- builderColItem.SetField("val", 2); // Change nested value.
-
- builderColItems.Add(builderColItem); // Add the same object to check handles.
- builderColItems.Add(builderItem); // Add item from another builder.
- builderColItems.Add(portItem); // Add item in portable form.
-
- portCol = builderCol.Build();
-
- col = portCol.Deserialize<BuilderCollection>();
-
- Assert.AreEqual(4, col.Col.Count);
-
- var item0 = (BuilderCollectionItem) col.Col[0];
- var item1 = (BuilderCollectionItem) col.Col[1];
- var item2 = (BuilderCollectionItem) col.Col[2];
- var item3 = (BuilderCollectionItem) col.Col[3];
-
- Assert.AreEqual(2, item0.Val);
-
- Assert.AreSame(item0, item1);
- Assert.AreNotSame(item0, item2);
- Assert.AreNotSame(item0, item3);
-
- Assert.AreEqual(1, item2.Val);
- Assert.AreEqual(1, item3.Val);
-
- Assert.AreNotSame(item2, item3);
-
- // Test handle update inside collection.
- builderCol = _grid.GetBinary().GetBuilder(portCol);
-
- builderColItems = builderCol.GetField<IList>("col");
-
- ((BinaryObjectBuilder) builderColItems[1]).SetField("val", 3);
-
- portCol = builderCol.Build();
-
- col = portCol.Deserialize<BuilderCollection>();
-
- item0 = (BuilderCollectionItem) col.Col[0];
- item1 = (BuilderCollectionItem) col.Col[1];
-
- Assert.AreEqual(3, item0.Val);
- Assert.AreSame(item0, item1);
- }
-
- /// <summary>
- /// Test build of an empty object.
- /// </summary>
- [Test]
- public void TestEmptyDefined()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.IsNotNull(meta);
- Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
-
- Empty obj = portObj.Deserialize<Empty>();
-
- Assert.IsNotNull(obj);
- }
-
- /// <summary>
- /// Test build of an empty object with disabled metadata.
- /// </summary>
- [Test]
- public void TestEmptyNoMeta()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- EmptyNoMeta obj = portObj.Deserialize<EmptyNoMeta>();
-
- Assert.IsNotNull(obj);
- }
-
- /// <summary>
- /// Test build of an empty undefined object.
- /// </summary>
- [Test]
- public void TestEmptyUndefined()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(TypeEmpty).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.IsNotNull(meta);
- Assert.AreEqual(TypeEmpty, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
- }
-
- /// <summary>
- /// Test object rebuild with no changes.
- /// </summary>
- [Test]
- public void TestEmptyRebuild()
- {
- var portObj = (BinaryObject) _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).Build();
-
- BinaryObject newPortObj = (BinaryObject) _grid.GetBinary().GetBuilder(portObj).Build();
-
- Assert.AreEqual(portObj.Data, newPortObj.Data);
- }
-
- /// <summary>
- /// Test hash code alteration.
- /// </summary>
- [Test]
- public void TestHashCodeChange()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).SetHashCode(100).Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
- }
-
- /// <summary>
- /// Test primitive fields setting.
- /// </summary>
- [Test]
- public void TestPrimitiveFields()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
- .SetField<byte>("fByte", 1)
- .SetField("fBool", true)
- .SetField<short>("fShort", 2)
- .SetField("fChar", 'a')
- .SetField("fInt", 3)
- .SetField<long>("fLong", 4)
- .SetField<float>("fFloat", 5)
- .SetField<double>("fDouble", 6)
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
- Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
- Assert.AreEqual(BinaryTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
- Assert.AreEqual(BinaryTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
- Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
- Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
- Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
-
- Assert.AreEqual(1, portObj.GetField<byte>("fByte"));
- Assert.AreEqual(true, portObj.GetField<bool>("fBool"));
- Assert.AreEqual(2, portObj.GetField<short>("fShort"));
- Assert.AreEqual('a', portObj.GetField<char>("fChar"));
- Assert.AreEqual(3, portObj.GetField<int>("fInt"));
- Assert.AreEqual(4, portObj.GetField<long>("fLong"));
- Assert.AreEqual(5, portObj.GetField<float>("fFloat"));
- Assert.AreEqual(6, portObj.GetField<double>("fDouble"));
-
- Primitives obj = portObj.Deserialize<Primitives>();
-
- Assert.AreEqual(1, obj.FByte);
- Assert.AreEqual(true, obj.FBool);
- Assert.AreEqual(2, obj.FShort);
- Assert.AreEqual('a', obj.FChar);
- Assert.AreEqual(3, obj.FInt);
- Assert.AreEqual(4, obj.FLong);
- Assert.AreEqual(5, obj.FFloat);
- Assert.AreEqual(6, obj.FDouble);
-
- // Overwrite.
- portObj = _grid.GetBinary().GetBuilder(portObj)
- .SetField<byte>("fByte", 7)
- .SetField("fBool", false)
- .SetField<short>("fShort", 8)
- .SetField("fChar", 'b')
- .SetField("fInt", 9)
- .SetField<long>("fLong", 10)
- .SetField<float>("fFloat", 11)
- .SetField<double>("fDouble", 12)
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual(7, portObj.GetField<byte>("fByte"));
- Assert.AreEqual(false, portObj.GetField<bool>("fBool"));
- Assert.AreEqual(8, portObj.GetField<short>("fShort"));
- Assert.AreEqual('b', portObj.GetField<char>("fChar"));
- Assert.AreEqual(9, portObj.GetField<int>("fInt"));
- Assert.AreEqual(10, portObj.GetField<long>("fLong"));
- Assert.AreEqual(11, portObj.GetField<float>("fFloat"));
- Assert.AreEqual(12, portObj.GetField<double>("fDouble"));
-
- obj = portObj.Deserialize<Primitives>();
-
- Assert.AreEqual(7, obj.FByte);
- Assert.AreEqual(false, obj.FBool);
- Assert.AreEqual(8, obj.FShort);
- Assert.AreEqual('b', obj.FChar);
- Assert.AreEqual(9, obj.FInt);
- Assert.AreEqual(10, obj.FLong);
- Assert.AreEqual(11, obj.FFloat);
- Assert.AreEqual(12, obj.FDouble);
- }
-
- /// <summary>
- /// Test primitive array fields setting.
- /// </summary>
- [Test]
- public void TestPrimitiveArrayFields()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
- .SetField("fByte", new byte[] { 1 })
- .SetField("fBool", new[] { true })
- .SetField("fShort", new short[] { 2 })
- .SetField("fChar", new[] { 'a' })
- .SetField("fInt", new[] { 3 })
- .SetField("fLong", new long[] { 4 })
- .SetField("fFloat", new float[] { 5 })
- .SetField("fDouble", new double[] { 6 })
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
-
- Assert.AreEqual(new byte[] { 1 }, portObj.GetField<byte[]>("fByte"));
- Assert.AreEqual(new[] { true }, portObj.GetField<bool[]>("fBool"));
- Assert.AreEqual(new short[] { 2 }, portObj.GetField<short[]>("fShort"));
- Assert.AreEqual(new[] { 'a' }, portObj.GetField<char[]>("fChar"));
- Assert.AreEqual(new[] { 3 }, portObj.GetField<int[]>("fInt"));
- Assert.AreEqual(new long[] { 4 }, portObj.GetField<long[]>("fLong"));
- Assert.AreEqual(new float[] { 5 }, portObj.GetField<float[]>("fFloat"));
- Assert.AreEqual(new double[] { 6 }, portObj.GetField<double[]>("fDouble"));
-
- PrimitiveArrays obj = portObj.Deserialize<PrimitiveArrays>();
-
- Assert.AreEqual(new byte[] { 1 }, obj.FByte);
- Assert.AreEqual(new[] { true }, obj.FBool);
- Assert.AreEqual(new short[] { 2 }, obj.FShort);
- Assert.AreEqual(new[] { 'a' }, obj.FChar);
- Assert.AreEqual(new[] { 3 }, obj.FInt);
- Assert.AreEqual(new long[] { 4 }, obj.FLong);
- Assert.AreEqual(new float[] { 5 }, obj.FFloat);
- Assert.AreEqual(new double[] { 6 }, obj.FDouble);
-
- // Overwrite.
- portObj = _grid.GetBinary().GetBuilder(portObj)
- .SetField("fByte", new byte[] { 7 })
- .SetField("fBool", new[] { false })
- .SetField("fShort", new short[] { 8 })
- .SetField("fChar", new[] { 'b' })
- .SetField("fInt", new[] { 9 })
- .SetField("fLong", new long[] { 10 })
- .SetField("fFloat", new float[] { 11 })
- .SetField("fDouble", new double[] { 12 })
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual(new byte[] { 7 }, portObj.GetField<byte[]>("fByte"));
- Assert.AreEqual(new[] { false }, portObj.GetField<bool[]>("fBool"));
- Assert.AreEqual(new short[] { 8 }, portObj.GetField<short[]>("fShort"));
- Assert.AreEqual(new[] { 'b' }, portObj.GetField<char[]>("fChar"));
- Assert.AreEqual(new[] { 9 }, portObj.GetField<int[]>("fInt"));
- Assert.AreEqual(new long[] { 10 }, portObj.GetField<long[]>("fLong"));
- Assert.AreEqual(new float[] { 11 }, portObj.GetField<float[]>("fFloat"));
- Assert.AreEqual(new double[] { 12 }, portObj.GetField<double[]>("fDouble"));
-
- obj = portObj.Deserialize<PrimitiveArrays>();
-
- Assert.AreEqual(new byte[] { 7 }, obj.FByte);
- Assert.AreEqual(new[] { false }, obj.FBool);
- Assert.AreEqual(new short[] { 8 }, obj.FShort);
- Assert.AreEqual(new[] { 'b' }, obj.FChar);
- Assert.AreEqual(new[] { 9 }, obj.FInt);
- Assert.AreEqual(new long[] { 10 }, obj.FLong);
- Assert.AreEqual(new float[] { 11 }, obj.FFloat);
- Assert.AreEqual(new double[] { 12 }, obj.FDouble);
- }
-
- /// <summary>
- /// Test non-primitive fields and their array counterparts.
- /// </summary>
- [Test]
- public void TestStringDateGuidEnum()
- {
- DateTime? nDate = DateTime.Now;
-
- Guid? nGuid = Guid.NewGuid();
-
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
- .SetField("fStr", "str")
- .SetField("fNDate", nDate)
- .SetGuidField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.One)
- .SetField("fStrArr", new[] { "str" })
- .SetArrayField("fDateArr", new[] { nDate })
- .SetGuidArrayField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.One })
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
- Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
- Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
-
- Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- StringDateGuidEnum obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
-
- // Check builder field caching.
- var builder = _grid.GetBinary().GetBuilder(portObj);
-
- Assert.AreEqual("str", builder.GetField<string>("fStr"));
- Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, builder.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, builder.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, builder.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, builder.GetField<TestEnum[]>("fEnumArr"));
-
- // Check reassemble.
- portObj = builder.Build();
-
- Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
-
- // Overwrite.
- nDate = DateTime.Now.ToUniversalTime();
- nGuid = Guid.NewGuid();
-
- portObj = builder
- .SetField("fStr", "str2")
- .SetTimestampField("fNDate", nDate)
- .SetField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.Two)
- .SetField("fStrArr", new[] { "str2" })
- .SetArrayField("fDateArr", new[] { nDate })
- .SetField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.Two })
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual("str2", portObj.GetField<string>("fStr"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.Two, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str2" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.Two }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str2", obj.FStr);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.Two, obj.FEnum);
- Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
- }
-
- /// <summary>
- /// Test arrays.
- /// </summary>
- [Test]
- public void TestCompositeArray()
- {
- // 1. Test simple array.
- object[] inArr = { new CompositeInner(1) };
-
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("inArr", inArr).Build();
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryObject[] portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(1, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
-
- CompositeArray arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(1, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
-
- // 2. Test addition to array.
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", new object[] { portInArr[0], null }).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.IsNull(portInArr[1]);
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
- Assert.IsNull(arr.InArr[1]);
-
- portInArr[1] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(300)
- .SetField("inArr", portInArr.OfType<object>().ToArray()).Build();
-
- Assert.AreEqual(300, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(2, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
- Assert.AreEqual(2, ((CompositeInner)arr.InArr[1]).Val);
-
- // 3. Test top-level handle inversion.
- CompositeInner inner = new CompositeInner(1);
-
- inArr = new object[] { inner, inner };
-
- portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("inArr", inArr).Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
-
- portInArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", portInArr.ToArray<object>()).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(2, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(2, ((CompositeInner)arr.InArr[0]).Val);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
-
- // 4. Test nested object handle inversion.
- CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
-
- portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("outArr", outArr.ToArray<object>()).Build();
-
- meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- var portOutArr = portObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portOutArr.Length);
- Assert.AreEqual(1, portOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
- Assert.AreEqual(1, portOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.InArr);
- Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
- Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
-
- portOutArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeOuter))
- .SetField("inner", new CompositeInner(2)).Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
- .SetField("outArr", portOutArr.ToArray<object>()).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(2, portOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
- Assert.AreEqual(1, portOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.InArr);
- Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(2, ((CompositeOuter)arr.OutArr[0]).Inner.Val);
- Assert.AreEqual(1, ((CompositeOuter)arr.OutArr[1]).Inner.Val);
- }
-
- /// <summary>
- /// Test container types other than array.
- /// </summary>
- [Test]
- public void TestCompositeContainer()
- {
- ArrayList col = new ArrayList();
- IDictionary dict = new Hashtable();
-
- col.Add(new CompositeInner(1));
- dict[3] = new CompositeInner(3);
-
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
- .SetCollectionField("col", col)
- .SetDictionaryField("dict", dict).Build();
-
- // 1. Check meta.
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
-
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
- Assert.AreEqual(BinaryTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
-
- // 2. Check in portable form.
- Assert.AreEqual(1, portObj.GetField<ICollection>("col").Count);
- Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IBinaryObject>().First()
- .GetField<int>("val"));
-
- Assert.AreEqual(1, portObj.GetField<IDictionary>("dict").Count);
- Assert.AreEqual(3, ((IBinaryObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
-
- // 3. Check in deserialized form.
- CompositeContainer obj = portObj.Deserialize<CompositeContainer>();
-
- Assert.AreEqual(1, obj.Col.Count);
- Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
-
- Assert.AreEqual(1, obj.Dict.Count);
- Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
- }
-
- /// <summary>
- /// Ensure that raw data is not lost during build.
- /// </summary>
- [Test]
- public void TestRawData()
- {
- var raw = new WithRaw
- {
- A = 1,
- B = 2
- };
-
- var portObj = _marsh.Unmarshal<IBinaryObject>(_marsh.Marshal(raw), BinaryMode.ForceBinary);
-
- raw = portObj.Deserialize<WithRaw>();
-
- Assert.AreEqual(1, raw.A);
- Assert.AreEqual(2, raw.B);
-
- IBinaryObject newPortObj = _grid.GetBinary().GetBuilder(portObj).SetField("a", 3).Build();
-
- raw = newPortObj.Deserialize<WithRaw>();
-
- Assert.AreEqual(3, raw.A);
- Assert.AreEqual(2, raw.B);
- }
-
- /// <summary>
- /// Test nested objects.
- /// </summary>
- [Test]
- public void TestNested()
- {
- // 1. Create from scratch.
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(NestedOuter));
-
- NestedInner inner1 = new NestedInner {Val = 1};
- builder.SetField("inner1", inner1);
-
- IBinaryObject outerPortObj = builder.Build();
-
- IBinaryType meta = outerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
-
- IBinaryObject innerPortObj1 = outerPortObj.GetField<IBinaryObject>("inner1");
-
- IBinaryType innerMeta = innerPortObj1.GetBinaryType();
-
- Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
- Assert.AreEqual(1, innerMeta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
-
- inner1 = innerPortObj1.Deserialize<NestedInner>();
-
- Assert.AreEqual(1, inner1.Val);
-
- NestedOuter outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(outer.Inner1.Val, 1);
- Assert.IsNull(outer.Inner2);
-
- // 2. Add another field over existing portable object.
- builder = _grid.GetBinary().GetBuilder(outerPortObj);
-
- NestedInner inner2 = new NestedInner {Val = 2};
- builder.SetField("inner2", inner2);
-
- outerPortObj = builder.Build();
-
- outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(1, outer.Inner1.Val);
- Assert.AreEqual(2, outer.Inner2.Val);
-
- // 3. Try setting inner object in portable form.
- innerPortObj1 = _grid.GetBinary().GetBuilder(innerPortObj1).SetField("val", 3).Build();
-
- inner1 = innerPortObj1.Deserialize<NestedInner>();
-
- Assert.AreEqual(3, inner1.Val);
-
- outerPortObj = _grid.GetBinary().GetBuilder(outerPortObj).SetField<object>("inner1", innerPortObj1).Build();
-
- outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(3, outer.Inner1.Val);
- Assert.AreEqual(2, outer.Inner2.Val);
- }
-
- /// <summary>
- /// Test handle migration.
- /// </summary>
- [Test]
- public void TestHandleMigration()
- {
- // 1. Simple comparison of results.
- MigrationInner inner = new MigrationInner {Val = 1};
-
- MigrationOuter outer = new MigrationOuter
- {
- Inner1 = inner,
- Inner2 = inner
- };
-
- byte[] outerBytes = _marsh.Marshal(outer);
-
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(MigrationOuter));
-
- builder.SetHashCode(outer.GetHashCode());
-
- builder.SetField<object>("inner1", inner);
- builder.SetField<object>("inner2", inner);
-
- BinaryObject portOuter = (BinaryObject) builder.Build();
-
- byte[] portOuterBytes = new byte[outerBytes.Length];
-
- Buffer.BlockCopy(portOuter.Data, 0, portOuterBytes, 0, portOuterBytes.Length);
-
- Assert.AreEqual(outerBytes, portOuterBytes);
-
- // 2. Change the first inner object so that the handle must migrate.
- MigrationInner inner1 = new MigrationInner {Val = 2};
-
- IBinaryObject portOuterMigrated =
- _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
-
- MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
-
- Assert.AreEqual(2, outerMigrated.Inner1.Val);
- Assert.AreEqual(1, outerMigrated.Inner2.Val);
-
- // 3. Change the first value using serialized form.
- IBinaryObject inner1Port =
- _grid.GetBinary().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
-
- portOuterMigrated =
- _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
-
- outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
-
- Assert.AreEqual(2, outerMigrated.Inner1.Val);
- Assert.AreEqual(1, outerMigrated.Inner2.Val);
- }
-
- /// <summary>
- /// Test handle inversion.
- /// </summary>
- [Test]
- public void TestHandleInversion()
- {
- InversionInner inner = new InversionInner();
- InversionOuter outer = new InversionOuter();
-
- inner.Outer = outer;
- outer.Inner = inner;
-
- byte[] rawOuter = _marsh.Marshal(outer);
-
- IBinaryObject portOuter = _marsh.Unmarshal<IBinaryObject>(rawOuter, BinaryMode.ForceBinary);
- IBinaryObject portInner = portOuter.GetField<IBinaryObject>("inner");
-
- // 1. Ensure that inner object can be deserialized after build.
- IBinaryObject portInnerNew = _grid.GetBinary().GetBuilder(portInner).Build();
-
- InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
-
- Assert.AreSame(innerNew, innerNew.Outer.Inner);
-
- // 2. Ensure that portable object with external dependencies could be added to builder.
- IBinaryObject portOuterNew =
- _grid.GetBinary().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
-
- InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
-
- Assert.AreNotSame(outerNew, outerNew.Inner.Outer);
- Assert.AreSame(outerNew.Inner, outerNew.Inner.Outer.Inner);
- }
-
- /// <summary>
- /// Test build multiple objects.
- /// </summary>
- [Test]
- public void TestBuildMultiple()
- {
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(Primitives));
-
- builder.SetField<byte>("fByte", 1).SetField("fBool", true);
-
- IBinaryObject po1 = builder.Build();
- IBinaryObject po2 = builder.Build();
-
- Assert.AreEqual(1, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(1, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- builder.SetField<byte>("fByte", 2);
-
- IBinaryObject po3 = builder.Build();
-
- Assert.AreEqual(1, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(1, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- Assert.AreEqual(2, po3.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- builder = _grid.GetBinary().GetBuilder(po1);
-
- builder.SetField<byte>("fByte", 10);
-
- po1 = builder.Build();
- po2 = builder.Build();
-
- builder.SetField<byte>("fByte", 20);
-
- po3 = builder.Build();
-
- Assert.AreEqual(10, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(10, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- Assert.AreEqual(20, po3.GetField<byte>("fByte"));
- Assert.AreEqual(true, po3.GetField<bool>("fBool"));
- }
-
- /// <summary>
- /// Tests type id method.
- /// </summary>
- [Test]
- public void TestTypeId()
- {
- Assert.Throws<ArgumentException>(() => _grid.GetBinary().GetTypeId(null));
-
- Assert.AreEqual(IdMapper.TestTypeId, _grid.GetBinary().GetTypeId(IdMapper.TestTypeName));
-
- Assert.AreEqual(BinaryUtils.GetStringHashCode("someTypeName"), _grid.GetBinary().GetTypeId("someTypeName"));
- }
-
- /// <summary>
- /// Tests metadata methods.
- /// </summary>
- [Test]
- public void TestMetadata()
- {
- // Populate metadata
- var portables = _grid.GetBinary();
-
- portables.ToBinary<IBinaryObject>(new DecimalHolder());
-
- // All meta
- var allMetas = portables.GetBinaryTypes();
-
- var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type
- decimalMeta = portables.GetBinaryType(typeof (DecimalHolder));
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type id
- decimalMeta = portables.GetBinaryType(portables.GetTypeId("DecimalHolder"));
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type name
- decimalMeta = portables.GetBinaryType("DecimalHolder");
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
- }
-
- /// <summary>
- /// Create portable type configuration with disabled metadata.
- /// </summary>
- /// <param name="typ">Type.</param>
- /// <returns>Configuration.</returns>
- private static BinaryTypeConfiguration TypeConfigurationNoMeta(Type typ)
- {
- return new BinaryTypeConfiguration(typ);
- }
- }
-
- /// <summary>
- /// Empty portable class.
- /// </summary>
- public class Empty
- {
- // No-op.
- }
-
- /// <summary>
- /// Empty portable class with no metadata.
- /// </summary>
- public class EmptyNoMeta
- {
- // No-op.
- }
-
- /// <summary>
- /// Portable with primitive fields.
- /// </summary>
- public class Primitives
- {
- public byte FByte;
- public bool FBool;
- public short FShort;
- public char FChar;
- public int FInt;
- public long FLong;
- public float FFloat;
- public double FDouble;
- }
-
- /// <summary>
- /// Portable with primitive array fields.
- /// </summary>
- public class PrimitiveArrays
- {
- public byte[] FByte;
- public bool[] FBool;
- public short[] FShort;
- public char[] FChar;
- public int[] FInt;
- public long[] FLong;
- public float[] FFloat;
- public double[] FDouble;
- }
-
- /// <summary>
- /// Portable having strings, dates, Guids and enums.
- /// </summary>
- public class StringDateGuidEnum
- {
- public string FStr;
- public DateTime? FnDate;
- public Guid? FnGuid;
- public TestEnum FEnum;
-
- public string[] FStrArr;
- public DateTime?[] FDateArr;
- public Guid?[] FGuidArr;
- public TestEnum[] FEnumArr;
- }
-
- /// <summary>
- /// Enumeration.
- /// </summary>
- public enum TestEnum
- {
- One, Two
- }
-
- /// <summary>
- /// Portable with raw data.
- /// </summary>
- public class WithRaw : IBinarizable
- {
- public int A;
- public int B;
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteInt("a", A);
- writer.GetRawWriter().WriteInt(B);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- A = reader.ReadInt("a");
- B = reader.GetRawReader().ReadInt();
- }
- }
-
- /// <summary>
- /// Empty class for metadata overwrite test.
- /// </summary>
- public class MetaOverwrite
- {
- // No-op.
- }
-
- /// <summary>
- /// Nested outer object.
- /// </summary>
- public class NestedOuter
- {
- public NestedInner Inner1;
- public NestedInner Inner2;
- }
-
- /// <summary>
- /// Nested inner object.
- /// </summary>
- public class NestedInner
- {
- public int Val;
- }
-
- /// <summary>
- /// Outer object for handle migration test.
- /// </summary>
- public class MigrationOuter
- {
- public MigrationInner Inner1;
- public MigrationInner Inner2;
- }
-
- /// <summary>
- /// Inner object for handle migration test.
- /// </summary>
- public class MigrationInner
- {
- public int Val;
- }
-
- /// <summary>
- /// Outer object for handle inversion test.
- /// </summary>
- public class InversionOuter
- {
- public InversionInner Inner;
- }
-
- /// <summary>
- /// Inner object for handle inversion test.
- /// </summary>
- public class InversionInner
- {
- public InversionOuter Outer;
- }
-
- /// <summary>
- /// Object for composite array tests.
- /// </summary>
- public class CompositeArray
- {
- public object[] InArr;
- public object[] OutArr;
- }
-
- /// <summary>
- /// Object for composite collection/dictionary tests.
- /// </summary>
- public class CompositeContainer
- {
- public ICollection Col;
- public IDictionary Dict;
- }
-
- /// <summary>
- /// OUter object for composite structures test.
- /// </summary>
- public class CompositeOuter
- {
- public CompositeInner Inner;
-
- public CompositeOuter()
- {
- // No-op.
- }
-
- public CompositeOuter(CompositeInner inner)
- {
- Inner = inner;
- }
- }
-
- /// <summary>
- /// Inner object for composite structures test.
- /// </summary>
- public class CompositeInner
- {
- public int Val;
-
- public CompositeInner()
- {
- // No-op.
- }
-
- public CompositeInner(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test "ToPortable()" logic.
- /// </summary>
- public class ToPortable
- {
- public int Val;
-
- public ToPortable(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test "ToPortable()" logic with metadata disabled.
- /// </summary>
- public class ToPortableNoMeta
- {
- public int Val;
-
- public ToPortableNoMeta(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test removal.
- /// </summary>
- public class Remove
- {
- public object Val;
- public RemoveInner Val2;
- }
-
- /// <summary>
- /// Inner type to test removal.
- /// </summary>
- public class RemoveInner
- {
- /** */
- public int Val;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="val"></param>
- public RemoveInner(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderInBuilderOuter
- {
- /** */
- public BuilderInBuilderInner Inner;
-
- /** */
- public BuilderInBuilderInner Inner2;
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderInBuilderInner
- {
- /** */
- public BuilderInBuilderOuter Outer;
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderCollection
- {
- /** */
- public readonly ArrayList Col;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="col"></param>
- public BuilderCollection(ArrayList col)
- {
- Col = col;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderCollectionItem
- {
- /** */
- public int Val;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="val"></param>
- public BuilderCollectionItem(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class DecimalHolder
- {
- /** */
- public decimal Val;
-
- /** */
- public decimal?[] ValArr;
- }
-
- /// <summary>
- /// Test id mapper.
- /// </summary>
- public class IdMapper : IBinaryIdMapper
- {
- /** */
- public const string TestTypeName = "IdMapperTestType";
-
- /** */
- public const int TestTypeId = -65537;
-
- /** <inheritdoc /> */
- public int GetTypeId(string typeName)
- {
- return typeName == TestTypeName ? TestTypeId : 0;
- }
-
- /** <inheritdoc /> */
- public int GetFieldId(int typeId, string fieldName)
- {
- return 0;
- }
- }
-}
[2/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
deleted file mode 100644
index 150110f..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ /dev/null
@@ -1,2157 +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.
- */
-
-// ReSharper disable NonReadonlyMemberInGetHashCode
-// ReSharper disable CompareOfFloatsByEqualityOperator
-// ReSharper disable PossibleInvalidOperationException
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-// ReSharper disable MemberCanBePrivate.Global
-namespace Apache.Ignite.Core.Tests.Portable
-{
- 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.Impl.Binary;
- using Apache.Ignite.Core.Impl.Binary.IO;
- using NUnit.Framework;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixture]
- public class PortableSelfTest {
- /** */
- private Marshaller _marsh;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public void BeforeTest()
- {
- _marsh = new Marshaller(null);
- }
-
- /**
- * <summary>Check write of primitive boolean.</summary>
- */
- [Test]
- public void TestWritePrimitiveBool()
- {
- Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
-
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive boolean array.</summary>
- */
- [Test]
- public void TestWritePrimitiveBoolArray()
- {
- bool[] vals = { true, false };
-
- Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
-
- bool?[] vals2 = { true, false };
-
- Assert.AreEqual(_marsh.Unmarshal<bool?[]>(_marsh.Marshal(vals2)), vals2);
- }
-
- /**
- * <summary>Check write of primitive sbyte.</summary>
- */
- [Test]
- public void TestWritePrimitiveSbyte()
- {
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal((sbyte)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MinValue)), sbyte.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive sbyte array.</summary>
- */
- [Test]
- public void TestWritePrimitiveSbyteArray()
- {
- sbyte[] vals = { sbyte.MinValue, 0, 1, sbyte.MaxValue };
- sbyte[] newVals = _marsh.Unmarshal<sbyte[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive byte.</summary>
- */
- [Test]
- public void TestWritePrimitiveByte()
- {
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal((byte)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MinValue)), byte.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive byte array.</summary>
- */
- [Test]
- public void TestWritePrimitiveByteArray()
- {
- byte[] vals = { byte.MinValue, 0, 1, byte.MaxValue };
- byte[] newVals = _marsh.Unmarshal<byte[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive short.</summary>
- */
- [Test]
- public void TestWritePrimitiveShort()
- {
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal((short)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MinValue)), short.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive short array.</summary>
- */
- [Test]
- public void TestWritePrimitiveShortArray()
- {
- short[] vals = { short.MinValue, 0, 1, short.MaxValue };
- short[] newVals = _marsh.Unmarshal<short[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive ushort.</summary>
- */
- [Test]
- public void TestWritePrimitiveUshort()
- {
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal((ushort)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MinValue)), ushort.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive short array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUshortArray()
- {
- ushort[] vals = { ushort.MinValue, 0, 1, ushort.MaxValue };
- ushort[] newVals = _marsh.Unmarshal<ushort[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive char.</summary>
- */
- [Test]
- public void TestWritePrimitiveChar()
- {
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal((char)1)), (char)1);
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MinValue)), char.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveCharArray()
- {
- char[] vals = { char.MinValue, (char)0, (char)1, char.MaxValue };
- char[] newVals = _marsh.Unmarshal<char[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive int.</summary>
- */
- [Test]
- public void TestWritePrimitiveInt()
- {
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MinValue)), int.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveIntArray()
- {
- int[] vals = { int.MinValue, 0, 1, int.MaxValue };
- int[] newVals = _marsh.Unmarshal<int[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive uint.</summary>
- */
- [Test]
- public void TestWritePrimitiveUint()
- {
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal((uint)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MinValue)), uint.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUintArray()
- {
- uint[] vals = { uint.MinValue, 0, 1, uint.MaxValue };
- uint[] newVals = _marsh.Unmarshal<uint[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive long.</summary>
- */
- [Test]
- public void TestWritePrimitiveLong()
- {
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal((long)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MinValue)), long.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive long array.</summary>
- */
- [Test]
- public void TestWritePrimitiveLongArray()
- {
- long[] vals = { long.MinValue, 0, 1, long.MaxValue };
- long[] newVals = _marsh.Unmarshal<long[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive ulong.</summary>
- */
- [Test]
- public void TestWritePrimitiveUlong()
- {
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal((ulong)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MinValue)), ulong.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive ulong array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUlongArray()
- {
- ulong[] vals = { ulong.MinValue, 0, 1, ulong.MaxValue };
- ulong[] newVals = _marsh.Unmarshal<ulong[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive float.</summary>
- */
- [Test]
- public void TestWritePrimitiveFloat()
- {
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal((float)1)), (float)1);
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MinValue)), float.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive float array.</summary>
- */
- [Test]
- public void TestWritePrimitiveFloatArray()
- {
- float[] vals = { float.MinValue, 0, 1, float.MaxValue };
- float[] newVals = _marsh.Unmarshal<float[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive double.</summary>
- */
- [Test]
- public void TestWritePrimitiveDouble()
- {
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal((double)1)), (double)1);
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MinValue)), double.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive double array.</summary>
- */
- [Test]
- public void TestWritePrimitiveDoubleArray()
- {
- double[] vals = { double.MinValue, 0, 1, double.MaxValue };
- double[] newVals = _marsh.Unmarshal<double[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of decimal.</summary>
- */
- [Test]
- public void TestWritePrimitiveDecimal()
- {
- decimal val;
-
- // Test positibe and negative.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Zero)), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, true, 0))), val);
-
- // Test 32, 64 and 96 bits + mixed.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, true, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, true, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, true, 0))), val);
-
- // Test extremes.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("65536"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-65536"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("4294967296"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-4294967296"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("281474976710656"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-281474976710656"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("18446744073709551616"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-18446744073709551616"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("1208925819614629174706176"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-1208925819614629174706176"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MaxValue)), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MinValue)), val);
-
- // Test scale.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("11,12"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
-
- // Test null.
- Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal((decimal?)null)), null);
- }
-
- /**
- * <summary>Check write of decimal array.</summary>
- */
- [Test]
- public void TestWritePrimitiveDecimalArray()
- {
- decimal?[] vals = { decimal.One, decimal.Parse("11,12") };
- var newVals = _marsh.Unmarshal<decimal?[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of string.</summary>
- */
- [Test]
- public void TestWriteString()
- {
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal((string) null)), null);
- }
-
- /**
- * <summary>Check write of string array.</summary>
- */
- [Test]
- public void TestWriteStringArray()
- {
- string[] vals = { "str1", null, "", "str2", null};
- string[] newVals = _marsh.Unmarshal<string[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of Guid.</summary>
- */
- [Test]
- public void TestWriteGuid()
- {
- Guid guid = Guid.NewGuid();
- Guid? nGuid = guid;
-
- Assert.AreEqual(_marsh.Unmarshal<Guid>(_marsh.Marshal(guid)), guid);
- Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), nGuid);
-
- nGuid = null;
-
- // ReSharper disable once ExpressionIsAlwaysNull
- Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), null);
- }
-
- /**
- * <summary>Check write of string array.</summary>
- */
- [Test]
- public void TestWriteGuidArray()
- {
- Guid?[] vals = { Guid.NewGuid(), null, Guid.Empty, Guid.NewGuid(), null };
- Guid?[] newVals = _marsh.Unmarshal<Guid?[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of enum.</summary>
- */
- [Test]
- public void TestWriteEnum()
- {
- TestEnum val = TestEnum.Val1;
-
- Assert.AreEqual(_marsh.Unmarshal<TestEnum>(_marsh.Marshal(val)), val);
- }
-
- /**
- * <summary>Check write of enum.</summary>
- */
- [Test]
- public void TestWriteEnumArray()
- {
- TestEnum[] vals = { TestEnum.Val2, TestEnum.Val3 };
- TestEnum[] newVals = _marsh.Unmarshal<TestEnum[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /// <summary>
- /// Test object with dates.
- /// </summary>
- [Test]
- public void TestDateObject()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(DateTimeType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- DateTime now = DateTime.Now;
-
- DateTimeType obj = new DateTimeType(now);
-
- DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
-
- Assert.AreEqual(obj.Utc, otherObj.Utc);
- Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
- Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
-
- Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
- Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
- Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
- }
-
- /// <summary>
- /// Tests the DateTime marshalling.
- /// </summary>
- [Test]
- public void TestDateTime()
- {
- var time = DateTime.Now;
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
-
- var timeUtc = DateTime.UtcNow;
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), timeUtc);
-
- // Check exception with non-UTC date
- var stream = new BinaryHeapStream(128);
- var writer = _marsh.StartMarshal(stream);
- Assert.Throws<InvalidOperationException>(() => writer.WriteTimestamp(DateTime.Now));
- }
-
- /**
- * <summary>Check generic collections.</summary>
- */
- [Test]
- public void TestGenericCollections()
- {
- var list = new List<string> {"1"};
-
- var data = _marsh.Marshal(list);
-
- var newObjList = _marsh.Unmarshal<IList<string>>(data);
-
- CollectionAssert.AreEquivalent(list, newObjList);
- }
-
- /// <summary>
- /// Tests marshal aware type with generic collections.
- /// </summary>
- [Test]
- public void TestGenericCollectionsType()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (PrimitiveFieldType)),
- new BinaryTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
- }
- });
-
- var obj = new GenericCollectionsType<PrimitiveFieldType, SerializableObject>
- {
- Keys = new[] {new PrimitiveFieldType(), new PrimitiveFieldType()},
- Values =
- new List<SerializableObject>
- {
- new SerializableObject {Foo = 1},
- new SerializableObject {Foo = 5}
- },
- Pairs = new Dictionary<PrimitiveFieldType, SerializableObject>
- {
- {new PrimitiveFieldType(), new SerializableObject {Foo = 10}},
- {new PrimitiveFieldType {PByte = 10}, new SerializableObject {Foo = 20}}
- },
- Objects = new object[] {1, 2, "3", 4.4}
- };
-
- var data = marsh.Marshal(obj);
-
- var result = marsh.Unmarshal<GenericCollectionsType<PrimitiveFieldType, SerializableObject>>(data);
-
- CollectionAssert.AreEquivalent(obj.Keys, result.Keys);
- CollectionAssert.AreEquivalent(obj.Values, result.Values);
- CollectionAssert.AreEquivalent(obj.Pairs, result.Pairs);
- CollectionAssert.AreEquivalent(obj.Objects, result.Objects);
- }
-
- /**
- * <summary>Check property read.</summary>
- */
- [Test]
- public void TestProperty()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PropertyType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- PropertyType obj = new PropertyType
- {
- Field1 = 1,
- Field2 = 2
- };
-
- byte[] data = marsh.Marshal(obj);
-
- PropertyType newObj = marsh.Unmarshal<PropertyType>(data);
-
- Assert.AreEqual(obj.Field1, newObj.Field1);
- Assert.AreEqual(obj.Field2, newObj.Field2);
-
- IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
- Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
- }
-
- /**
- * <summary>Check write of primitive fields through reflection.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsReflective()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsPortable()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldPortableType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldPortableType obj = new PrimitiveFieldPortableType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsRawPortable()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldRawPortableType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldRawPortableType obj = new PrimitiveFieldRawPortableType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsSerializer()
- {
- var typeCfgs = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (PrimitiveFieldType))
- {
- Serializer = new PrimitiveFieldsSerializer()
- }
- };
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check decimals.</summary>
- */
- [Test]
- public void TestDecimalFields()
- {
- BinaryConfiguration cfg = new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (DecimalReflective)),
- new BinaryTypeConfiguration(typeof (DecimalMarshalAware))
- }
- };
-
- Marshaller marsh = new Marshaller(cfg);
-
- // 1. Test reflective stuff.
- DecimalReflective obj1 = new DecimalReflective
- {
- Val = decimal.Zero,
- ValArr = new decimal?[] {decimal.One, decimal.MinusOne}
- };
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj1), BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal?[]>("valArr"));
-
- Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
- Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
-
- // 2. Test marshal aware stuff.
- DecimalMarshalAware obj2 = new DecimalMarshalAware();
-
- obj2.Val = decimal.Zero;
- obj2.ValArr = new decimal?[] { decimal.One, decimal.MinusOne };
- obj2.RawVal = decimal.MaxValue;
- obj2.RawValArr = new decimal?[] { decimal.MinusOne, decimal.One} ;
-
- portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj2), BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal?[]>("valArr"));
-
- Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
- Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
- Assert.AreEqual(obj2.RawVal, portObj.Deserialize<DecimalMarshalAware>().RawVal);
- Assert.AreEqual(obj2.RawValArr, portObj.Deserialize<DecimalMarshalAware>().RawValArr);
- }
-
- /**
- * <summary>Check write of primitive fields through raw serializer.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsRawSerializer()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- BinaryTypeConfiguration typeCfg =
- new BinaryTypeConfiguration(typeof(PrimitiveFieldType));
-
- typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
-
- typeCfgs.Add(typeCfg);
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- private void CheckPrimitiveFields(Marshaller marsh, PrimitiveFieldType obj)
- {
- obj.PBool = true;
- obj.PByte = 2;
- obj.PSbyte = 3;
- obj.PShort = 4;
- obj.PUshort = 5;
- obj.PInt = 6;
- obj.PUint = 7;
- obj.PLong = 8;
- obj.PUlong = 9;
- obj.PChar = 'a';
- obj.PFloat = 10;
- obj.PDouble = 11;
- obj.PString = "abc";
- obj.PGuid = Guid.NewGuid();
- obj.PnGuid = Guid.NewGuid();
- obj.IgniteGuid = new IgniteGuid(Guid.NewGuid(), 123);
-
- CheckPrimitiveFieldsSerialization(marsh, obj);
- }
-
- private void CheckPrimitiveFieldsSerialization(Marshaller marsh, PrimitiveFieldType obj)
- {
- byte[] bytes = marsh.Marshal(obj);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
-
- Assert.AreEqual(obj, newObj);
- }
-
- /**
- * <summary>Check write of object with enums.</summary>
- */
- [Test]
- public void TestEnumsReflective()
- {
- Marshaller marsh =
- new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations =
- new List<BinaryTypeConfiguration> {new BinaryTypeConfiguration(typeof (EnumType))}
- });
-
- EnumType obj = new EnumType
- {
- PEnum = TestEnum.Val1,
- PEnumArray = new[] {TestEnum.Val2, TestEnum.Val3}
- };
-
- byte[] bytes = marsh.Marshal(obj);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- EnumType newObj = portObj.Deserialize<EnumType>();
-
- Assert.AreEqual(obj.PEnum, newObj.PEnum);
- Assert.AreEqual(obj.PEnumArray, newObj.PEnumArray);
- }
-
- /**
- * <summary>Check write of object with collections.</summary>
- */
- [Test]
- public void TestCollectionsReflective()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (CollectionsType)),
- new BinaryTypeConfiguration(typeof (InnerObjectType))
- }
- });
-
- var obj = new CollectionsType
- {
- Hashtable = new Hashtable {{1, 2}, {3, 4}},
- LinkedList = new LinkedList<int>(new[] {1, 2, 3}),
- SortedDict = new SortedDictionary<string, int> {{"1", 2}},
- Dict = new Dictionary<int, string> {{1, "2"}},
- Arr = new[] {new InnerObjectType()}
- };
-
- var list = new ArrayList
- {
- true,
- (byte) 1,
- (short) 2,
- 'a',
- 3,
- (long) 4,
- (float) 5,
- (double) 6,
- "string",
- Guid.NewGuid(),
- new InnerObjectType
- {
- PInt1 = 1,
- PInt2 = 2
- }
- };
-
- obj.Col1 = list;
-
- byte[] bytes = marsh.Marshal(obj);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- CollectionsType newObj = portObj.Deserialize<CollectionsType>();
-
- Assert.AreEqual(obj, newObj);
-
- obj.Col1 = null;
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
-
- obj.Col1 = list;
- obj.Col2 = list;
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
-
- obj.Col2 = new TestList();
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
- }
-
- /**
- * <summary>Check write of object fields through reflective serializer.</summary>
- */
- [Test]
- public void TestObjectReflective()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(OuterObjectType)));
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(InnerObjectType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
- }
-
- /**
- * <summary>Test handles.</summary>
- */
- [Test]
- public void TestHandles()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleInner)));
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleOuter)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- HandleOuter outer = new HandleOuter();
-
- outer.Before = "outBefore";
- outer.After = "outAfter";
- outer.RawBefore = "outRawBefore";
- outer.RawAfter = "outRawAfter";
-
- HandleInner inner = new HandleInner();
-
- inner.Before = "inBefore";
- inner.After = "inAfter";
- inner.RawBefore = "inRawBefore";
- inner.RawAfter = "inRawAfter";
-
- outer.Inner = inner;
- outer.RawInner = inner;
-
- inner.Outer = outer;
- inner.RawOuter = outer;
-
- byte[] bytes = marsh.Marshal(outer);
-
- IBinaryObject outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
- HandleInner newInner = newOuter.Inner;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
-
- // Get inner object by field.
- IBinaryObject innerObj = outerObj.GetField<IBinaryObject>("inner");
-
- newInner = innerObj.Deserialize<HandleInner>();
- newOuter = newInner.Outer;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
-
- // Get outer object from inner object by handle.
- outerObj = innerObj.GetField<IBinaryObject>("outer");
-
- newOuter = outerObj.Deserialize<HandleOuter>();
- newInner = newOuter.Inner;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
- }
-
- /**
- * <summary>Test handles with exclusive writes.</summary>
- */
- [Test]
- public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asPortable)
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (HandleInner)),
- new BinaryTypeConfiguration(typeof (HandleOuterExclusive))
- }
- });
-
- var inner = new HandleInner
- {
- Before = "inBefore",
- After = "inAfter",
- RawBefore = "inRawBefore",
- RawAfter = "inRawAfter"
- };
-
- var outer = new HandleOuterExclusive
- {
- Before = "outBefore",
- After = "outAfter",
- RawBefore = "outRawBefore",
- RawAfter = "outRawAfter",
- Inner = inner,
- RawInner = inner
- };
-
- inner.Outer = outer;
- inner.RawOuter = outer;
-
- var bytes = asPortable
- ? marsh.Marshal(new IgniteBinary(marsh).ToBinary<IBinaryObject>(outer))
- : marsh.Marshal(outer);
-
- IBinaryObject outerObj;
-
- if (detached)
- {
- var reader = new BinaryReader(marsh, new Dictionary<long, IBinaryTypeDescriptor>(),
- new BinaryHeapStream(bytes), BinaryMode.ForceBinary, null);
-
- reader.DetachNext();
-
- outerObj = reader.Deserialize<IBinaryObject>();
- }
- else
- outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
-
- Assert.IsFalse(newOuter == newOuter.Inner.Outer);
- Assert.IsFalse(newOuter == newOuter.Inner.RawOuter);
- Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
- Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
-
- Assert.IsFalse(newOuter.Inner == newOuter.RawInner);
-
- Assert.IsTrue(newOuter.Inner.Outer == newOuter.Inner.RawOuter);
- Assert.IsTrue(newOuter.RawInner.Outer == newOuter.RawInner.RawOuter);
-
- Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.Inner);
- Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.RawInner);
- Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.Inner);
- Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.RawInner);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedDefault()
- {
- CheckKeepSerialized(new BinaryConfiguration(), true);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedDefaultFalse()
- {
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.DefaultKeepDeserialized = false;
-
- CheckKeepSerialized(cfg, false);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedTypeCfgFalse()
- {
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
-
- typeCfg.KeepDeserialized = false;
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
-
- CheckKeepSerialized(cfg, false);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedTypeCfgTrue()
- {
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
- typeCfg.KeepDeserialized = true;
-
- BinaryConfiguration cfg = new BinaryConfiguration();
- cfg.DefaultKeepDeserialized = false;
-
- cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
-
- CheckKeepSerialized(cfg, true);
- }
-
- /// <summary>
- /// Test correct serialization/deserialization of arrays of special types.
- /// </summary>
- [Test]
- public void TestSpecialArrays()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArray)));
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArrayMarshalAware)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- Guid[] guidArr = { Guid.NewGuid() };
- Guid?[] nGuidArr = { Guid.NewGuid() };
- DateTime[] dateArr = { DateTime.Now.ToUniversalTime() };
- DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
-
- // Use special object.
- SpecialArray obj1 = new SpecialArray
- {
- GuidArr = guidArr,
- NGuidArr = nGuidArr,
- DateArr = dateArr,
- NDateArr = nDateArr
- };
-
- byte[] bytes = marsh.Marshal(obj1);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.IsNotNull(portObj.Deserialize<SpecialArray>());
-
- Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
- Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
- Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
- Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("nDateArr"));
-
- obj1 = portObj.Deserialize<SpecialArray>();
-
- Assert.AreEqual(guidArr, obj1.GuidArr);
- Assert.AreEqual(nGuidArr, obj1.NGuidArr);
- Assert.AreEqual(dateArr, obj1.DateArr);
- Assert.AreEqual(nDateArr, obj1.NDateArr);
-
- // Use special with IGridPortableMarshalAware.
- SpecialArrayMarshalAware obj2 = new SpecialArrayMarshalAware();
-
- obj2.GuidArr = guidArr;
- obj2.NGuidArr = nGuidArr;
- obj2.DateArr = dateArr;
- obj2.NDateArr = nDateArr;
-
- bytes = marsh.Marshal(obj2);
-
- portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
- Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
- Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("c"));
- Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("d"));
-
- obj2 = portObj.Deserialize<SpecialArrayMarshalAware>();
-
- Assert.AreEqual(guidArr, obj2.GuidArr);
- Assert.AreEqual(nGuidArr, obj2.NGuidArr);
- Assert.AreEqual(dateArr, obj2.DateArr);
- Assert.AreEqual(nDateArr, obj2.NDateArr);
- }
-
- /// <summary>
- /// Writes objects of various sizes to test schema compaction
- /// (where field offsets can be stored as 1, 2 or 4 bytes).
- /// </summary>
- [Test]
- public void TestCompactSchema()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (SpecialArray)),
- new BinaryTypeConfiguration(typeof (SpecialArrayMarshalAware))
- }
- });
-
- var dt = new SpecialArrayMarshalAware();
-
- foreach (var i in new[] {1, 5, 10, 13, 14, 15, 100, 200, 1000, 5000, 15000, 30000})
- {
- dt.NGuidArr = Enumerable.Range(1, i).Select(x => (Guid?) Guid.NewGuid()).ToArray();
- dt.NDateArr = Enumerable.Range(1, i).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray();
-
- var bytes = marsh.Marshal(dt);
-
- var res = marsh.Unmarshal<SpecialArrayMarshalAware>(bytes);
-
- CollectionAssert.AreEquivalent(dt.NGuidArr, res.NGuidArr);
- CollectionAssert.AreEquivalent(dt.NDateArr, res.NDateArr);
- }
- }
-
- private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
- {
- if (cfg.TypeConfigurations == null)
- {
- cfg.TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof(PropertyType))
- };
- }
-
- Marshaller marsh = new Marshaller(cfg);
-
- byte[] data = marsh.Marshal(new PropertyType());
-
- IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
- PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
-
- Assert.NotNull(deserialized1);
-
- Assert.AreEqual(expKeep, deserialized1 == deserialized2);
- }
-
- private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
- HandleInner newInner)
- {
- Assert.True(newOuter != null);
- Assert.AreEqual(outer.Before, newOuter.Before);
- Assert.True(newOuter.Inner == newInner);
- Assert.AreEqual(outer.After, newOuter.After);
- Assert.AreEqual(outer.RawBefore, newOuter.RawBefore);
- Assert.True(newOuter.RawInner == newInner);
- Assert.AreEqual(outer.RawAfter, newOuter.RawAfter);
-
- Assert.True(newInner != null);
- Assert.AreEqual(inner.Before, newInner.Before);
- Assert.True(newInner.Outer == newOuter);
- Assert.AreEqual(inner.After, newInner.After);
- Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
- Assert.True(newInner.RawOuter == newOuter);
- Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
- }
-
- private static void CheckObject(Marshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
- {
- inObj.PInt1 = 1;
- inObj.PInt2 = 2;
-
- outObj.InObj = inObj;
-
- byte[] bytes = marsh.Marshal(outObj);
-
- IBinaryObject portOutObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
-
- OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
-
- Assert.AreEqual(outObj, newOutObj);
- }
-
- public class OuterObjectType
- {
- public InnerObjectType InObj { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var type = obj as OuterObjectType;
-
- return type != null && Equals(InObj, type.InObj);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return InObj != null ? InObj.GetHashCode() : 0;
- }
- }
-
- [Serializable]
- public class InnerObjectType
- {
- public int PInt1 { get; set; }
-
- public int PInt2 { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var that = obj as InnerObjectType;
-
- return that != null && (PInt1 == that.PInt1 && PInt2 == that.PInt2);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return 31 * PInt1 + PInt2;
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return "InnerObjectType[pInt1=" + PInt1 + ", pInt2=" + PInt2 + ']';
- }
- }
-
- public class CollectionsType
- {
- public ICollection Col1 { get; set; }
-
- public ArrayList Col2 { get; set; }
-
- public Hashtable Hashtable { get; set; }
-
- public Dictionary<int, string> Dict { get; set; }
-
- public InnerObjectType[] Arr { get; set; }
-
- public SortedDictionary<string, int> SortedDict { get; set; }
-
- public LinkedList<int> LinkedList { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var that = obj as CollectionsType;
-
- return that != null
- && CompareCollections(Col1, that.Col1)
- && CompareCollections(Col2, that.Col2)
- && CompareCollections(Hashtable, that.Hashtable)
- && CompareCollections(Dict, that.Dict)
- && CompareCollections(Arr, that.Arr)
- && CompareCollections(SortedDict, that.SortedDict)
- && CompareCollections(LinkedList, that.LinkedList);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- int res = 0;
-
- foreach (var col in new object[] {Col1, Col2, Hashtable, Dict, Arr, SortedDict, LinkedList})
- res = 31*res + (col != null ? col.GetHashCode() : 0);
-
- return res;
- }
- }
-
- public class GenericCollectionsType<TKey, TValue> : IBinarizable
- {
- public ICollection<TKey> Keys { get; set; }
-
- public ICollection<TValue> Values { get; set; }
-
- public IDictionary<TKey, TValue> Pairs { get; set; }
-
- public ICollection<object> Objects { get; set; }
-
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteObject("Keys", Keys);
- writer.WriteObject("Values", Values);
- writer.WriteObject("Pairs", Pairs);
- writer.WriteObject("Objects", Objects);
- }
-
- public void ReadBinary(IBinaryReader reader)
- {
- Keys = (ICollection<TKey>) reader.ReadObject<object>("Keys");
- Values = (ICollection<TValue>) reader.ReadObject<object>("Values");
- Pairs = (IDictionary<TKey, TValue>) reader.ReadObject<object>("Pairs");
- Objects = (ICollection<object>) reader.ReadObject<object>("Objects");
- }
- }
-
- public class TestList : ArrayList
- {
-
- }
-
- private static bool CompareCollections(ICollection col1, ICollection col2)
- {
- if (col1 == null && col2 == null)
- return true;
- if (col1 == null || col2 == null)
- return false;
-
- return col1.OfType<object>().SequenceEqual(col2.OfType<object>());
- }
-
- public class PrimitiveArrayFieldType
- {
- public bool[] PBool { get; set; }
-
- public sbyte[] PSbyte { get; set; }
-
- public byte[] PByte { get; set; }
-
- public short[] PShort { get; set; }
-
- public ushort[] PUshort { get; set; }
-
- public char[] PChar { get; set; }
-
- public int[] PInt { get; set; }
-
- public uint[] PUint { get; set; }
-
- public long[] PLong { get; set; }
-
- public ulong[] PUlong { get; set; }
-
- public float[] PFloat { get; set; }
-
- public double[] PDouble { get; set; }
-
- public string[] PString { get; set; }
-
- public Guid?[] PGuid { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var other = obj as PrimitiveArrayFieldType;
-
- return other != null && (PBool == other.PBool &&
- PByte == other.PByte &&
- PSbyte == other.PSbyte &&
- PShort == other.PShort &&
- PUshort == other.PUshort &&
- PInt == other.PInt &&
- PUint == other.PUint &&
- PLong == other.PLong &&
- PUlong == other.PUlong &&
- PChar == other.PChar &&
- PFloat == other.PFloat &&
- PDouble == other.PDouble &&
- PString == other.PString &&
- PGuid == other.PGuid);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return PInt != null && PInt.Length > 0 ? PInt[0].GetHashCode() : 0;
- }
- }
-
- public class SpecialArray
- {
- public Guid[] GuidArr;
- public Guid?[] NGuidArr;
- public DateTime[] DateArr;
- public DateTime?[] NDateArr;
- }
-
- public class SpecialArrayMarshalAware : SpecialArray, IBinarizable
- {
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteObject("a", GuidArr);
- writer.WriteObject("b", NGuidArr);
- writer.WriteObject("c", DateArr);
- writer.WriteObject("d", NDateArr);
- }
-
- public void ReadBinary(IBinaryReader reader)
- {
- GuidArr = reader.ReadObject<Guid[]>("a");
- NGuidArr = reader.ReadObject<Guid?[]>("b");
- DateArr = reader.ReadObject<DateTime[]>("c");
- NDateArr = reader.ReadObject<DateTime?[]>("d");
- }
- }
-
- public class EnumType
- {
- public TestEnum PEnum { get; set; }
-
- public TestEnum[] PEnumArray { get; set; }
- }
-
- [Serializable]
- public class PrimitiveFieldType
- {
- public bool PBool { get; set; }
-
- public sbyte PSbyte { get; set; }
-
- public byte PByte { get; set; }
-
- public short PShort { get; set; }
-
- public ushort PUshort { get; set; }
-
- public char PChar { get; set; }
-
- public int PInt { get; set; }
-
- public uint PUint { get; set; }
-
- public long PLong { get; set; }
-
- public ulong PUlong { get; set; }
-
- public float PFloat { get; set; }
-
- public double PDouble { get; set; }
-
- public string PString { get; set; }
-
- public Guid PGuid { get; set; }
-
- public Guid? PnGuid { get; set; }
-
- public IgniteGuid IgniteGuid { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- if (obj != null && obj is PrimitiveFieldType)
- {
- PrimitiveFieldType that = (PrimitiveFieldType)obj;
-
- return PBool == that.PBool &&
- PByte == that.PByte &&
- PSbyte == that.PSbyte &&
- PShort == that.PShort &&
- PUshort == that.PUshort &&
- PInt == that.PInt &&
- PUint == that.PUint &&
- PLong == that.PLong &&
- PUlong == that.PUlong &&
- PChar == that.PChar &&
- PFloat == that.PFloat &&
- PDouble == that.PDouble &&
- (string.Equals(PString, that.PString)) &&
- PGuid.Equals(that.PGuid) &&
- IgniteGuid.Equals(that.IgniteGuid) &&
- (PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
- }
- return false;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return PInt;
- }
- }
-
- public class PrimitiveFieldPortableType : PrimitiveFieldType, IBinarizable
- {
- public unsafe void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteBoolean("bool", PBool);
- writer.WriteByte("byte", PByte);
- writer.WriteShort("short", PShort);
- writer.WriteInt("int", PInt);
- writer.WriteLong("long", PLong);
- writer.WriteChar("char", PChar);
- writer.WriteFloat("float", PFloat);
- writer.WriteDouble("double", PDouble);
-
- sbyte sByte = PSbyte;
- ushort uShort = PUshort;
- uint uInt = PUint;
- ulong uLong = PUlong;
-
- writer.WriteByte("sbyte", *(byte*)&sByte);
- writer.WriteShort("ushort", *(short*)&uShort);
- writer.WriteInt("uint", *(int*)&uInt);
- writer.WriteLong("ulong", *(long*)&uLong);
-
- writer.WriteString("string", PString);
- writer.WriteGuid("guid", PGuid);
- writer.WriteGuid("nguid", PnGuid);
-
- writer.WriteObject("iguid", IgniteGuid);
- }
-
- public unsafe void ReadBinary(IBinaryReader reader)
- {
- PBool = reader.ReadBoolean("bool");
- PByte = reader.ReadByte("byte");
- PShort = reader.ReadShort("short");
- PInt = reader.ReadInt("int");
-
- PLong = reader.ReadLong("long");
- PChar = reader.ReadChar("char");
- PFloat = reader.ReadFloat("float");
- PDouble = reader.ReadDouble("double");
-
- byte sByte = reader.ReadByte("sbyte");
- short uShort = reader.ReadShort("ushort");
- int uInt = reader.ReadInt("uint");
- long uLong = reader.ReadLong("ulong");
-
- PSbyte = *(sbyte*)&sByte;
- PUshort = *(ushort*)&uShort;
- PUint = *(uint*)&uInt;
- PUlong = *(ulong*)&uLong;
-
- PString = reader.ReadString("string");
- PGuid = reader.ReadObject<Guid>("guid");
- PnGuid = reader.ReadGuid("nguid");
-
- IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
- }
- }
-
- public class PrimitiveFieldRawPortableType : PrimitiveFieldType, IBinarizable
- {
- public unsafe void WriteBinary(IBinaryWriter writer)
- {
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteBoolean(PBool);
- rawWriter.WriteByte(PByte);
- rawWriter.WriteShort(PShort);
- rawWriter.WriteInt(PInt);
- rawWriter.WriteLong(PLong);
- rawWriter.WriteChar(PChar);
- rawWriter.WriteFloat(PFloat);
- rawWriter.WriteDouble(PDouble);
-
- sbyte sByte = PSbyte;
- ushort uShort = PUshort;
- uint uInt = PUint;
- ulong uLong = PUlong;
-
- rawWriter.WriteByte(*(byte*)&sByte);
- rawWriter.WriteShort(*(short*)&uShort);
- rawWriter.WriteInt(*(int*)&uInt);
- rawWriter.WriteLong(*(long*)&uLong);
-
- rawWriter.WriteString(PString);
- rawWriter.WriteGuid(PGuid);
- rawWriter.WriteGuid(PnGuid);
-
- rawWriter.WriteObject(IgniteGuid);
- }
-
- public unsafe void ReadBinary(IBinaryReader reader)
- {
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- PBool = rawReader.ReadBoolean();
- PByte = rawReader.ReadByte();
- PShort = rawReader.ReadShort();
- PInt = rawReader.ReadInt();
-
- PLong = rawReader.ReadLong();
- PChar = rawReader.ReadChar();
- PFloat = rawReader.ReadFloat();
- PDouble = rawReader.ReadDouble();
-
- byte sByte = rawReader.ReadByte();
- short uShort = rawReader.ReadShort();
- int uInt = rawReader.ReadInt();
- long uLong = rawReader.ReadLong();
-
- PSbyte = *(sbyte*)&sByte;
- PUshort = *(ushort*)&uShort;
- PUint = *(uint*)&uInt;
- PUlong = *(ulong*)&uLong;
-
- PString = rawReader.ReadString();
- PGuid = rawReader.ReadGuid().Value;
- PnGuid = rawReader.ReadGuid();
-
- IgniteGuid = rawReader.ReadObject<IgniteGuid>();
- }
- }
-
- public class PrimitiveFieldsSerializer : IBinarySerializer
- {
- public unsafe void WriteBinary(object obj, IBinaryWriter writer)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- writer.WriteBoolean("bool", obj0.PBool);
- writer.WriteByte("byte", obj0.PByte);
- writer.WriteShort("short", obj0.PShort);
- writer.WriteInt("int", obj0.PInt);
- writer.WriteLong("long", obj0.PLong);
- writer.WriteChar("char", obj0.PChar);
- writer.WriteFloat("float", obj0.PFloat);
- writer.WriteDouble("double", obj0.PDouble);
-
- sbyte sByte = obj0.PSbyte;
- ushort uShort = obj0.PUshort;
- uint uInt = obj0.PUint;
- ulong uLong = obj0.PUlong;
-
- writer.WriteByte("sbyte", *(byte*)&sByte);
- writer.WriteShort("ushort", *(short*)&uShort);
- writer.WriteInt("uint", *(int*)&uInt);
- writer.WriteLong("ulong", *(long*)&uLong);
-
- writer.WriteString("string", obj0.PString);
- writer.WriteGuid("guid", obj0.PGuid);
- writer.WriteGuid("nguid", obj0.PnGuid);
-
- writer.WriteObject("iguid", obj0.IgniteGuid);
- }
-
- public unsafe void ReadBinary(object obj, IBinaryReader reader)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- obj0.PBool = reader.ReadBoolean("bool");
- obj0.PByte = reader.ReadByte("byte");
- obj0.PShort = reader.ReadShort("short");
- obj0.PInt = reader.ReadInt("int");
-
- obj0.PLong = reader.ReadLong("long");
- obj0.PChar = reader.ReadChar("char");
- obj0.PFloat = reader.ReadFloat("float");
- obj0.PDouble = reader.ReadDouble("double");
-
- byte sByte = reader.ReadByte("sbyte");
- short uShort = reader.ReadShort("ushort");
- int uInt = reader.ReadInt("uint");
- long uLong = reader.ReadLong("ulong");
-
- obj0.PSbyte = *(sbyte*)&sByte;
- obj0.PUshort = *(ushort*)&uShort;
- obj0.PUint = *(uint*)&uInt;
- obj0.PUlong = *(ulong*)&uLong;
-
- obj0.PString = reader.ReadString("string");
- obj0.PGuid = reader.ReadObject<Guid>("guid");
- obj0.PnGuid = reader.ReadGuid("nguid");
-
- obj0.IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
- }
- }
-
- public class PrimitiveFieldsRawSerializer : IBinarySerializer
- {
- public unsafe void WriteBinary(object obj, IBinaryWriter writer)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteBoolean(obj0.PBool);
- rawWriter.WriteByte(obj0.PByte);
- rawWriter.WriteShort( obj0.PShort);
- rawWriter.WriteInt( obj0.PInt);
- rawWriter.WriteLong( obj0.PLong);
- rawWriter.WriteChar(obj0.PChar);
- rawWriter.WriteFloat(obj0.PFloat);
- rawWriter.WriteDouble( obj0.PDouble);
-
- sbyte sByte = obj0.PSbyte;
- ushort uShort = obj0.PUshort;
- uint uInt = obj0.PUint;
- ulong uLong = obj0.PUlong;
-
- rawWriter.WriteByte(*(byte*)&sByte);
- rawWriter.WriteShort(*(short*)&uShort);
- rawWriter.WriteInt(*(int*)&uInt);
- rawWriter.WriteLong(*(long*)&uLong);
-
- rawWriter.WriteString(obj0.PString);
- rawWriter.WriteGuid(obj0.PGuid);
- rawWriter.WriteGuid(obj0.PnGuid);
-
- rawWriter.WriteObject(obj0.IgniteGuid);
- }
-
- public unsafe void ReadBinary(object obj, IBinaryReader reader)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- obj0.PBool = rawReader.ReadBoolean();
- obj0.PByte = rawReader.ReadByte();
- obj0.PShort = rawReader.ReadShort();
- obj0.PInt = rawReader.ReadInt();
- obj0.PLong = rawReader.ReadLong();
- obj0.PChar = rawReader.ReadChar();
- obj0.PFloat = rawReader.ReadFloat();
- obj0.PDouble = rawReader.ReadDouble();
-
- byte sByte = rawReader.ReadByte();
- short uShort = rawReader.ReadShort();
- int uInt = rawReader.ReadInt();
- long uLong = rawReader.ReadLong();
-
- obj0.PSbyte = *(sbyte*)&sByte;
- obj0.PUshort = *(ushort*)&uShort;
- obj0.PUint = *(uint*)&uInt;
- obj0.PUlong = *(ulong*)&uLong;
-
- obj0.PString = rawReader.ReadString();
- obj0.PGuid = rawReader.ReadGuid().Value;
- obj0.PnGuid = rawReader.ReadGuid();
-
- obj0.IgniteGuid = rawReader.ReadObject<IgniteGuid>();
- }
- }
-
- public class HandleOuter : IBinarizable
- {
- public string Before;
- public HandleInner Inner;
- public string After;
-
- public string RawBefore;
- public HandleInner RawInner;
- public string RawAfter;
-
- /** <inheritdoc /> */
- virtual public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteString("before", Before);
- writer.WriteObject("inner", Inner);
- writer.WriteString("after", After);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteString(RawBefore);
- rawWriter.WriteObject(RawInner);
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- virtual public void ReadBinary(IBinaryReader reader)
- {
- Before = reader.ReadString("before");
- Inner = reader.ReadObject<HandleInner>("inner");
- After = reader.ReadString("after");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- RawBefore = rawReader.ReadString();
- RawInner = rawReader.ReadObject<HandleInner>();
- RawAfter = rawReader.ReadString();
- }
- }
-
- public class HandleInner : IBinarizable
- {
- public string Before;
- public HandleOuter Outer;
- public string After;
-
- public string RawBefore;
- public HandleOuter RawOuter;
- public string RawAfter;
-
- /** <inheritdoc /> */
- virtual public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteString("before", Before);
- writer.WriteObject("outer", Outer);
- writer.WriteString("after", After);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteString(RawBefore);
- rawWriter.WriteObject(RawOuter);
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- virtual public void ReadBinary(IBinaryReader reader)
- {
- Before = reader.ReadString("before");
- Outer = reader.ReadObject<HandleOuter>("outer");
- After = reader.ReadString("after");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- RawBefore = rawReader.ReadString();
- RawOuter = rawReader.ReadObject<HandleOuter>();
- RawAfter = rawReader.ReadString();
- }
- }
-
-
- public class HandleOuterExclusive : HandleOuter
- {
- /** <inheritdoc /> */
- override public void WriteBinary(IBinaryWriter writer)
- {
- BinaryWriter writer0 = (BinaryWriter)writer;
-
- writer.WriteString("before", Before);
-
- writer0.WithDetach(w => w.WriteObject("inner", Inner));
-
- writer.WriteString("after", After);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteString(RawBefore);
-
- writer0.WithDetach(w => w.WriteObject(RawInner));
-
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- override public void ReadBinary(IBinaryReader reader)
- {
- var reader0 = (BinaryReader) reader;
-
- Before = reader0.ReadString("before");
-
- reader0.DetachNext();
- Inner = reader0.ReadObject<HandleInner>("inner");
-
- After = reader0.ReadString("after");
-
- var rawReader = (BinaryReader) reader.GetRawReader();
-
- RawBefore = rawReader.ReadString();
-
- reader0.DetachNext();
- RawInner = rawReader.ReadObject<HandleInner>();
-
- RawAfter = rawReader.ReadString();
- }
- }
-
- public class PropertyType
- {
- public int Field1;
-
- public int Field2
- {
- get;
- set;
- }
- }
-
- public enum TestEnum
- {
- Val1, Val2, Val3 = 10
- }
-
- public class DecimalReflective
- {
- /** */
- public decimal? Val;
-
- /** */
- public decimal?[] ValArr;
- }
-
- public class DecimalMarshalAware : DecimalReflective, IBinarizable
- {
- /** */
- public decimal? RawVal;
-
- /** */
- public decimal?[] RawValArr;
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteDecimal("val", Val);
- writer.WriteDecimalArray("valArr", ValArr);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteDecimal(RawVal);
- rawWriter.WriteDecimalArray(RawValArr);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Val = reader.ReadDecimal("val");
- ValArr = reader.ReadDecimalArray("valArr");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- RawVal = rawReader.ReadDecimal();
- RawValArr = rawReader.ReadDecimalArray();
- }
- }
-
- /// <summary>
- /// Date time type.
- /// </summary>
- public class DateTimeType : IBinarizable
- {
- public DateTime Utc;
-
- public DateTime? UtcNull;
-
- public DateTime?[] UtcArr;
-
- public DateTime UtcRaw;
-
- public DateTime? UtcNullRaw;
-
- public DateTime?[] UtcArrRaw;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="now">Current local time.</param>
- public DateTimeType(DateTime now)
- {
- Utc = now.ToUniversalTime();
-
- UtcNull = Utc;
-
- UtcArr = new DateTime?[] { Utc };
-
- UtcRaw = Utc;
-
- UtcNullRaw = UtcNull;
-
- UtcArrRaw = new[] { UtcArr[0] };
- }
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteTimestamp("utc", Utc);
- writer.WriteTimestamp("utcNull", UtcNull);
- writer.WriteTimestampArray("utcArr", UtcArr);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteTimestamp(UtcRaw);
- rawWriter.WriteTimestamp(UtcNullRaw);
- rawWriter.WriteTimestampArray(UtcArrRaw);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Utc = reader.ReadTimestamp("utc").Value;
- UtcNull = reader.ReadTimestamp("utc").Value;
- UtcArr = reader.ReadTimestampArray("utcArr");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- UtcRaw = rawReader.ReadTimestamp().Value;
- UtcNullRaw = rawReader.ReadTimestamp().Value;
- UtcArrRaw = rawReader.ReadTimestampArray();
- }
- }
-
- [Serializable]
- private class SerializableObject
- {
- public int Foo { get; set; }
-
- private bool Equals(SerializableObject other)
- {
- return Foo == other.Foo;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
-
- return Equals((SerializableObject) obj);
- }
-
- public override int GetHashCode()
- {
- return Foo;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
deleted file mode 100644
index 32b659e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
+++ /dev/null
@@ -1,250 +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.Tests.Portable
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Binary;
- using NUnit.Framework;
-
- /// <summary>
- /// Contains tests for portable type structure.
- /// </summary>
- [TestFixture]
- public class PortableStructureTest
- {
- /** Repeat count. */
- public static readonly int RepeatCnt = 10;
-
- /** Objects per mode. */
- public static readonly int ObjectsPerMode = 5;
-
- /// <summary>
- /// Test object write with different structures.
- /// </summary>
- [Test]
- public void TestStructure()
- {
- for (int i = 1; i <= RepeatCnt; i++)
- {
- Console.WriteLine(">>> Iteration started: " + i);
-
- // 1. Generate and shuffle objects.
- IList<BranchedType> objs = new List<BranchedType>();
-
- for (int j = 0; j < 6 * ObjectsPerMode; j++)
- objs.Add(new BranchedType((j%6) + 1));
-
- objs = IgniteUtils.Shuffle(objs);
-
- // 2. Create new marshaller.
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType));
-
- BinaryConfiguration cfg = new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg }
- };
-
- Marshaller marsh = new Marshaller(cfg);
-
- // 3. Marshal all data and ensure deserialized object is fine.
- foreach (BranchedType obj in objs)
- {
- Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');
-
- byte[] data = marsh.Marshal(obj);
-
- BranchedType other = marsh.Unmarshal<BranchedType>(data);
-
- Assert.IsTrue(obj.Equals(other));
- }
-
- Console.WriteLine();
-
- // 4. Ensure that all fields are recorded.
- var desc = marsh.GetDescriptor(typeof (BranchedType));
-
- CollectionAssert.AreEquivalent(new[] {"mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8"},
- desc.WriterTypeStructure.FieldTypes.Keys);
- }
- }
- }
-
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- public class BranchedType : IBinarizable
- {
- public int mode;
- public int f2;
- public int f3;
- public int f4;
- public int f5;
- public int f6;
- public int f7;
- public int f8;
-
- public BranchedType(int mode)
- {
- this.mode = mode;
-
- switch (mode)
- {
- case 1:
- f2 = 2;
-
- break;
-
- case 2:
- f2 = 2;
- f3 = 3;
- f4 = 4;
-
- break;
-
- case 3:
- f2 = 2;
- f3 = 3;
- f5 = 5;
-
- break;
-
- case 4:
- f2 = 2;
- f3 = 3;
- f5 = 5;
- f6 = 6;
-
- break;
-
- case 5:
- f2 = 2;
- f3 = 3;
- f7 = 7;
-
- break;
-
- case 6:
- f8 = 8;
-
- break;
- }
- }
-
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteInt("mode", mode);
-
- switch (mode)
- {
- case 1:
- writer.WriteInt("f2", f2);
-
- break;
-
- case 2:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f4", f4);
-
- break;
-
- case 3:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f5", f5);
-
- break;
-
- case 4:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f5", f5);
- writer.WriteInt("f6", f6);
-
- break;
-
- case 5:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f7", f7);
-
- break;
-
- case 6:
- writer.WriteInt("f8", f8);
-
- break;
- }
- }
-
- public void ReadBinary(IBinaryReader reader)
- {
- mode = reader.ReadInt("mode");
-
- switch (mode)
- {
- case 1:
- f2 = reader.ReadInt("f2");
-
- break;
-
- case 2:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f4 = reader.ReadInt("f4");
-
- break;
-
- case 3:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f5 = reader.ReadInt("f5");
-
- break;
-
- case 4:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f5 = reader.ReadInt("f5");
- f6 = reader.ReadInt("f6");
-
- break;
-
- case 5:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f7 = reader.ReadInt("f7");
-
- break;
-
- case 6:
- f8 = reader.ReadInt("f8");
-
- break;
- }
- }
-
- public bool Equals(BranchedType other)
- {
- return mode == other.mode && f2 == other.f2 && f3 == other.f3 && f4 == other.f4 && f5 == other.f5 &&
- f6 == other.f6 && f7 == other.f7 && f8 == other.f8;
- }
- }
-}
[8/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
IGNITE-1881: Internal portable -> binary renamings.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d69362f8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d69362f8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d69362f8
Branch: refs/heads/ignite-1282
Commit: d69362f86b3da5b29f42366938ba1c82403dcb2a
Parents: fff85cb
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Nov 17 16:58:53 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Nov 17 16:58:53 2015 +0300
----------------------------------------------------------------------
.../dotnet/PlatformDotNetConfiguration.java | 2 +-
...CacheAtomicReferenceApiSelfAbstractTest.java | 10 +-
.../platform/PlatformComputeBinarizable.java | 42 +
.../PlatformComputeBinarizableArgTask.java | 119 +
.../platform/PlatformComputeEchoTask.java | 12 +-
.../PlatformComputeJavaBinarizable.java | 39 +
.../platform/PlatformComputeJavaPortable.java | 39 -
.../platform/PlatformComputePortable.java | 42 -
.../PlatformComputePortableArgTask.java | 119 -
.../Apache.Ignite.Benchmarks.csproj | 4 +-
.../Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 4 +-
.../Binary/BinarizableReadBenchmark.cs | 125 +
.../Binary/BinarizableWriteBenchmark.cs | 135 ++
.../Interop/PlatformBenchmarkBase.cs | 8 +-
.../Portable/PortableReadBenchmark.cs | 126 -
.../Portable/PortableWriteBenchmark.cs | 135 --
.../Apache.Ignite.Core.Tests.csproj | 27 +-
.../Apache.Ignite.Core.Tests.nunit | 7 +
.../Binary/BinaryBuilderSelfTest.cs | 1721 ++++++++++++++
.../Binary/BinarySelfTest.cs | 2157 ++++++++++++++++++
.../Binary/BinaryStructureTest.cs | 250 ++
.../BinaryConfigurationTest.cs | 173 ++
.../Cache/CacheAbstractTest.cs | 94 +-
.../Cache/CacheAffinityTest.cs | 4 +-
.../Cache/CacheDynamicStartTest.cs | 6 +-
.../Cache/Query/CacheQueriesTest.cs | 80 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 210 +-
.../ContinuousQueryNoBackupAbstractTest.cs | 4 +-
.../Cache/Store/CacheStoreTest.cs | 68 +-
.../Compute/AbstractTaskTest.cs | 8 +-
.../Compute/BinarizableClosureTaskTest.cs | 185 ++
.../Compute/BinarizableTaskTest.cs | 269 +++
.../Compute/ComputeApiTest.cs | 62 +-
.../Compute/FailoverTaskSelfTest.cs | 18 +-
.../Forked/ForkedBinarizableClosureTaskTest.cs | 30 +
.../Forked/ForkedPortableClosureTaskTest.cs | 30 -
.../Compute/Forked/ForkedResourceTaskTest.cs | 3 -
.../Forked/ForkedSerializableClosureTaskTest.cs | 3 -
.../Compute/PortableClosureTaskTest.cs | 217 --
.../Compute/PortableTaskTest.cs | 269 ---
.../Compute/TaskAdapterTest.cs | 14 +-
.../Compute/TaskResultTest.cs | 46 +-
.../Config/Compute/compute-grid1.xml | 6 +-
.../Config/Compute/compute-standalone.xml | 14 +-
.../Apache.Ignite.Core.Tests/Config/binary.xml | 56 +
.../Config/cache-binarizables.xml | 78 +
.../Config/cache-portables.xml | 78 -
.../Config/cache-query-continuous.xml | 8 +-
.../Config/marshaller-explicit.xml | 47 +
.../Config/marshaller-portable.xml | 43 -
.../Config/native-client-test-cache-store.xml | 2 +-
.../Config/native-client-test-cache.xml | 51 -
.../Config/portable.xml | 56 -
.../Dataload/DataStreamerTest.cs | 42 +-
.../Apache.Ignite.Core.Tests/EventsTest.cs | 16 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 28 +-
.../Apache.Ignite.Core.Tests/FutureTest.cs | 10 +-
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 10 +-
.../Portable/PortableApiSelfTest.cs | 1777 ---------------
.../Portable/PortableSelfTest.cs | 2157 ------------------
.../Portable/PortableStructureTest.cs | 250 --
.../PortableConfigurationTest.cs | 173 --
.../Query/BinarizablePerson.cs | 69 +
.../Query/ImplicitBinarizablePerson.cs | 46 +
.../Query/ImplicitPortablePerson.cs | 46 -
.../Query/NoDefBinarizablePerson.cs | 35 +
.../Query/NoDefPortablePerson.cs | 35 -
.../Query/PortablePerson.cs | 69 -
.../Services/ServiceProxyTest.cs | 130 +-
.../Services/ServicesTest.cs | 88 +-
.../TypeResolverTest.cs | 20 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 20 +-
.../examples/Config/example-cache-query.xml | 12 +-
.../dotnet/examples/Config/example-cache.xml | 12 +-
parent/pom.xml | 1 +
75 files changed, 6133 insertions(+), 6268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
index ff5656b..f323085 100644
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Mirror of .Net class Configuration.cs
+ * Mirror of .Net class IgniteConfiguration.cs
*/
public class PlatformDotNetConfiguration implements PlatformConfiguration {
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index 416776a..278bcf9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -97,15 +97,13 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends Ignite
String initVal = "qwerty";
- IgniteAtomicReference<String> atomic = grid(0).atomicReference(atomicName, null, true);
+ IgniteAtomicReference<String> atomic = grid(0).atomicReference(atomicName, initVal, true);
- assertEquals(null, atomic.get());
+ assertEquals(initVal, atomic.get());
- boolean res = atomic.compareAndSet(null, "x");
+ atomic.compareAndSet("h", "j");
- assertEquals(null, atomic.get()); // ok
- assertTrue(res); // fail
- assertEquals("x", atomic.get()); // fail
+ assertEquals(initVal, atomic.get());
atomic.compareAndSet(initVal, null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java
new file mode 100644
index 0000000..55b3099
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.platform;
+
+/**
+ * Binarizable object for task tests.
+ */
+public class PlatformComputeBinarizable {
+ /** Field. */
+ public int field;
+
+ /**
+ * Constructor.
+ */
+ public PlatformComputeBinarizable() {
+ // No-op.
+ }
+
+ /**
+ * Constructor,
+ *
+ * @param field Field.
+ */
+ public PlatformComputeBinarizable(int field) {
+ this.field = field;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
new file mode 100644
index 0000000..77c7e3a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.platform;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task working with binarizable argument.
+ */
+public class PlatformComputeBinarizableArgTask extends ComputeTaskAdapter<Object, Integer> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
+ return Collections.singletonMap(new BinarizableArgJob(arg), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ @Nullable @Override public Integer reduce(List<ComputeJobResult> results) {
+ ComputeJobResult res = results.get(0);
+
+ if (res.getException() != null)
+ throw res.getException();
+ else
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class BinarizableArgJob extends ComputeJobAdapter implements Externalizable {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Argument. */
+ private Object arg;
+
+ /**
+ * Constructor.
+ */
+ public BinarizableArgJob() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param arg Argument.
+ */
+ private BinarizableArgJob(Object arg) {
+ this.arg = arg;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ BinaryObject arg0 = ((BinaryObject)arg);
+
+ BinaryType meta = ignite.binary().metadata(arg0.typeId());
+
+ if (meta == null)
+ throw new IgniteException("Metadata doesn't exist.");
+
+ if (meta.fields() == null || !meta.fields().contains("Field"))
+ throw new IgniteException("Field metadata doesn't exist.");
+
+ if (!F.eq("int", meta.fieldTypeName("Field")))
+ throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field"));
+
+ if (meta.affinityKeyFieldName() != null)
+ throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName());
+
+ return arg0.field("field");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(arg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ arg = in.readObject();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
index f64ca7d..fe4e01c 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
@@ -155,19 +155,19 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
return Collections.singletonMap(1, 1);
case TYPE_PORTABLE:
- return new PlatformComputePortable(1);
+ return new PlatformComputeBinarizable(1);
case TYPE_PORTABLE_JAVA:
- return new PlatformComputeJavaPortable(1);
+ return new PlatformComputeJavaBinarizable(1);
case TYPE_OBJ_ARRAY:
return new String[] { "foo", "bar", "baz" };
case TYPE_PORTABLE_ARRAY:
- return new PlatformComputePortable[] {
- new PlatformComputePortable(1),
- new PlatformComputePortable(2),
- new PlatformComputePortable(3)
+ return new PlatformComputeBinarizable[] {
+ new PlatformComputeBinarizable(1),
+ new PlatformComputeBinarizable(2),
+ new PlatformComputeBinarizable(3)
};
case TYPE_ENUM:
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java
new file mode 100644
index 0000000..ade09db
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.ignite.platform;
+
+/**
+ * Binarizable object defined only in Java.
+ */
+public class PlatformComputeJavaBinarizable extends PlatformComputeBinarizable {
+ /**
+ * Constructor.
+ */
+ public PlatformComputeJavaBinarizable() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public PlatformComputeJavaBinarizable(int field) {
+ super(field);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
deleted file mode 100644
index 7a940c4..0000000
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-package org.apache.ignite.platform;
-
-/**
- * Portable object defined only in Java.
- */
-public class PlatformComputeJavaPortable extends PlatformComputePortable {
- /**
- * Constructor.
- */
- public PlatformComputeJavaPortable() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param field Field.
- */
- public PlatformComputeJavaPortable(int field) {
- super(field);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
deleted file mode 100644
index f31f093..0000000
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
+++ /dev/null
@@ -1,42 +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.
- */
-
-package org.apache.ignite.platform;
-
-/**
- * Portable object for task tests.
- */
-public class PlatformComputePortable {
- /** Field. */
- public int field;
-
- /**
- * Constructor.
- */
- public PlatformComputePortable() {
- // No-op.
- }
-
- /**
- * Constructor,
- *
- * @param field Field.
- */
- public PlatformComputePortable(int field) {
- this.field = field;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
deleted file mode 100644
index 1e3c499..0000000
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
+++ /dev/null
@@ -1,119 +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.
- */
-
-package org.apache.ignite.platform;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.compute.ComputeJob;
-import org.apache.ignite.compute.ComputeJobAdapter;
-import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.compute.ComputeTaskAdapter;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Task working with portable argument.
- */
-public class PlatformComputePortableArgTask extends ComputeTaskAdapter<Object, Integer> {
- /** {@inheritDoc} */
- @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
- return Collections.singletonMap(new PortableArgJob(arg), F.first(subgrid));
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
- @Nullable @Override public Integer reduce(List<ComputeJobResult> results) {
- ComputeJobResult res = results.get(0);
-
- if (res.getException() != null)
- throw res.getException();
- else
- return results.get(0).getData();
- }
-
- /**
- * Job.
- */
- private static class PortableArgJob extends ComputeJobAdapter implements Externalizable {
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** Argument. */
- private Object arg;
-
- /**
- * Constructor.
- */
- public PortableArgJob() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param arg Argument.
- */
- private PortableArgJob(Object arg) {
- this.arg = arg;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object execute() {
- BinaryObject arg0 = ((BinaryObject)arg);
-
- BinaryType meta = ignite.binary().metadata(arg0.typeId());
-
- if (meta == null)
- throw new IgniteException("Metadata doesn't exist.");
-
- if (meta.fields() == null || !meta.fields().contains("Field"))
- throw new IgniteException("Field metadata doesn't exist.");
-
- if (!F.eq("int", meta.fieldTypeName("Field")))
- throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field"));
-
- if (meta.affinityKeyFieldName() != null)
- throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName());
-
- return arg0.field("field");
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(arg);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- arg = in.readObject();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
index 99737b8..14b6466 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
@@ -63,8 +63,8 @@
<Compile Include="Model\Employee.cs" />
<Compile Include="Model\Sex.cs" />
<Compile Include="Model\TestModel.cs" />
- <Compile Include="Portable\PortableReadBenchmark.cs" />
- <Compile Include="Portable\PortableWriteBenchmark.cs" />
+ <Compile Include="Binary\BinarizableReadBenchmark.cs" />
+ <Compile Include="Binary\BinarizableWriteBenchmark.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Result\BenchmarkConsoleResultWriter.cs" />
<Compile Include="Result\BenchmarkFileResultWriter.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
index 2d0d348..5d8e78a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
@@ -20,7 +20,7 @@ namespace Apache.Ignite.Benchmarks
using System;
using System.Diagnostics;
using System.Text;
- using Apache.Ignite.Benchmarks.Portable;
+ using Apache.Ignite.Benchmarks.Binary;
/// <summary>
/// Benchmark runner.
@@ -35,7 +35,7 @@ namespace Apache.Ignite.Benchmarks
public static void Main(string[] args)
{
args = new[] {
- typeof(PortableReadBenchmark).FullName,
+ typeof(BinarizableReadBenchmark).FullName,
"-ConfigPath", @"modules\platforms\dotnet\Apache.Ignite.Benchmarks\Config\benchmark.xml",
"-Threads", "1",
"-Warmup", "0",
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs
new file mode 100644
index 0000000..09e588e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs
@@ -0,0 +1,125 @@
+/*
+ * 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.Benchmarks.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Benchmarks.Model;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Memory;
+
+ /// <summary>
+ /// Binary read benchmark.
+ /// </summary>
+ internal class BinarizableReadBenchmark : BenchmarkBase
+ {
+ /** Marshaller. */
+ private readonly Marshaller _marsh;
+
+ /** Memory manager. */
+ private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
+
+ /** Memory chunk. */
+ private readonly IPlatformMemory _mem;
+
+ /** Pre-allocated address. */
+ private readonly Address _address = BenchmarkUtils.GetRandomAddress();
+
+ /** Pre-allocated model. */
+ private readonly TestModel _model = new TestModel
+ {
+ Byte = 5,
+ Boolean = true,
+ BooleanArray = new[] {true, false, false, false, true, true},
+ ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Char = 'h',
+ CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
+ Date = DateTime.Now,
+ DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
+ Decimal = decimal.MinValue,
+ DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
+ Double = double.MaxValue/2,
+ DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
+ Float = 98,
+ FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
+ Guid = Guid.NewGuid(),
+ GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
+ Int = -90,
+ IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Long = long.MinValue,
+ LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
+ Short = 67,
+ ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
+ String = "String value test 123",
+ StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarizableReadBenchmark"/> class.
+ /// </summary>
+ public BinarizableReadBenchmark()
+ {
+ _marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (Address)),
+ new BinaryTypeConfiguration(typeof (TestModel))
+ }
+ });
+
+ _mem = _memMgr.Allocate();
+
+ var stream = _mem.GetStream();
+
+ //_marsh.StartMarshal(stream).Write(_model);
+ _marsh.StartMarshal(stream).Write(_address);
+
+ stream.SynchronizeOutput();
+ }
+
+ /// <summary>
+ /// Populate descriptors.
+ /// </summary>
+ /// <param name="descs">Descriptors.</param>
+ protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
+ {
+ descs.Add(BenchmarkOperationDescriptor.Create("ReadTestModel", ReadTestModel, 1));
+ }
+
+ /// <summary>
+ /// Write address.
+ /// </summary>
+ /// <param name="state">State.</param>
+ private void ReadTestModel(BenchmarkState state)
+ {
+ //var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<TestModel>();
+
+ //if (model.Byte != _model.Byte)
+ // throw new InvalidOperationException();
+
+ var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<Address>();
+
+ if (model.FlatNumber != _address.FlatNumber)
+ throw new InvalidOperationException();
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs
new file mode 100644
index 0000000..c4d375f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs
@@ -0,0 +1,135 @@
+/*
+ * 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.Benchmarks.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Benchmarks.Model;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Memory;
+
+ /// <summary>
+ /// Binary write benchmark.
+ /// </summary>
+ internal class BinarizableWriteBenchmark : BenchmarkBase
+ {
+ /** Marshaller. */
+ private readonly Marshaller _marsh;
+
+ /** Memory manager. */
+ private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
+
+ /** Pre-allocated address. */
+ private readonly Address _address = BenchmarkUtils.GetRandomAddress();
+
+ /** Pre-allocated model. */
+ private readonly TestModel _model = new TestModel
+ {
+ Byte = 5,
+ Boolean = true,
+ BooleanArray = new[] {true, false, false, false, true, true},
+ ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Char = 'h',
+ CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
+ Date = DateTime.Now,
+ DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
+ Decimal = decimal.MinValue,
+ DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
+ Double = double.MaxValue/2,
+ DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
+ Float = 98,
+ FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
+ Guid = Guid.NewGuid(),
+ GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
+ Int = -90,
+ IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Long = long.MinValue,
+ LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
+ Short = 67,
+ ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
+ String = "String value test 123",
+ StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarizableWriteBenchmark"/> class.
+ /// </summary>
+ public BinarizableWriteBenchmark()
+ {
+ _marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (Address))
+ //new BinaryTypeConfiguration(typeof (TestModel))
+ }
+ });
+ }
+
+ /// <summary>
+ /// Populate descriptors.
+ /// </summary>
+ /// <param name="descs">Descriptors.</param>
+ protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
+ {
+ descs.Add(BenchmarkOperationDescriptor.Create("WriteAddress", WriteAddress, 1));
+ //descs.Add(BenchmarkOperationDescriptor.Create("WriteTestModel", WriteTestModel, 1));
+ }
+
+ /// <summary>
+ /// Write address.
+ /// </summary>
+ /// <param name="state">State.</param>
+ private void WriteAddress(BenchmarkState state)
+ {
+ var mem = _memMgr.Allocate();
+
+ try
+ {
+ var stream = mem.GetStream();
+
+ _marsh.StartMarshal(stream).Write(_address);
+ }
+ finally
+ {
+ mem.Release();
+ }
+ }
+ /// <summary>
+ /// Write address.
+ /// </summary>
+ /// <param name="state">State.</param>
+ private void WriteTestModel(BenchmarkState state)
+ {
+ var mem = _memMgr.Allocate();
+
+ try
+ {
+ var stream = mem.GetStream();
+
+ _marsh.StartMarshal(stream).Write(_model);
+ }
+ finally
+ {
+ mem.Release();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
index 67809d5..eeebed0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Benchmarks.Interop
var cfg = new IgniteConfiguration
{
- BinaryConfiguration = GetPortableConfiguration(),
+ BinaryConfiguration = GetBinaryConfiguration(),
JvmOptions = new List<string>
{
"-Xms2g",
@@ -75,10 +75,10 @@ namespace Apache.Ignite.Benchmarks.Interop
}
/// <summary>
- /// Get portable configuration.
+ /// Get binary configuration.
/// </summary>
- /// <returns>Portable configuration.</returns>
- private static BinaryConfiguration GetPortableConfiguration()
+ /// <returns>Gets binary configuration.</returns>
+ private static BinaryConfiguration GetBinaryConfiguration()
{
return new BinaryConfiguration
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
deleted file mode 100644
index ad9ae39..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
+++ /dev/null
@@ -1,126 +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.Benchmarks.Portable
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Benchmarks.Model;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Memory;
-
- /// <summary>
- /// Portable read benchmark.
- /// </summary>
- internal class PortableReadBenchmark : BenchmarkBase
- {
- /** Marshaller. */
- private readonly Marshaller _marsh;
-
- /** Memory manager. */
- private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
-
- /** Memory chunk. */
- private readonly IPlatformMemory _mem;
-
- /** Pre-allocated address. */
- private readonly Address _address = BenchmarkUtils.GetRandomAddress();
-
-
- /** Pre-allocated model. */
- private readonly TestModel _model = new TestModel
- {
- Byte = 5,
- Boolean = true,
- BooleanArray = new[] {true, false, false, false, true, true},
- ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Char = 'h',
- CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
- Date = DateTime.Now,
- DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
- Decimal = decimal.MinValue,
- DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
- Double = double.MaxValue/2,
- DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
- Float = 98,
- FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
- Guid = Guid.NewGuid(),
- GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
- Int = -90,
- IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Long = long.MinValue,
- LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
- Short = 67,
- ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
- String = "String value test 123",
- StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
- };
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PortableReadBenchmark"/> class.
- /// </summary>
- public PortableReadBenchmark()
- {
- _marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (Address)),
- new BinaryTypeConfiguration(typeof (TestModel))
- }
- });
-
- _mem = _memMgr.Allocate();
-
- var stream = _mem.GetStream();
-
- //_marsh.StartMarshal(stream).Write(_model);
- _marsh.StartMarshal(stream).Write(_address);
-
- stream.SynchronizeOutput();
- }
-
- /// <summary>
- /// Populate descriptors.
- /// </summary>
- /// <param name="descs">Descriptors.</param>
- protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
- {
- descs.Add(BenchmarkOperationDescriptor.Create("ReadTestModel", ReadTestModel, 1));
- }
-
- /// <summary>
- /// Write address.
- /// </summary>
- /// <param name="state">State.</param>
- private void ReadTestModel(BenchmarkState state)
- {
- //var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<TestModel>();
-
- //if (model.Byte != _model.Byte)
- // throw new InvalidOperationException();
-
- var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<Address>();
-
- if (model.FlatNumber != _address.FlatNumber)
- throw new InvalidOperationException();
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
deleted file mode 100644
index a630161..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
+++ /dev/null
@@ -1,135 +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.Benchmarks.Portable
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Benchmarks.Model;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Memory;
-
- /// <summary>
- /// Portable write benchmark.
- /// </summary>
- internal class PortableWriteBenchmark : BenchmarkBase
- {
- /** Marshaller. */
- private readonly Marshaller _marsh;
-
- /** Memory manager. */
- private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
-
- /** Pre-allocated address. */
- private readonly Address _address = BenchmarkUtils.GetRandomAddress();
-
- /** Pre-allocated model. */
- private readonly TestModel _model = new TestModel
- {
- Byte = 5,
- Boolean = true,
- BooleanArray = new[] {true, false, false, false, true, true},
- ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Char = 'h',
- CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
- Date = DateTime.Now,
- DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
- Decimal = decimal.MinValue,
- DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
- Double = double.MaxValue/2,
- DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
- Float = 98,
- FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
- Guid = Guid.NewGuid(),
- GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
- Int = -90,
- IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Long = long.MinValue,
- LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
- Short = 67,
- ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
- String = "String value test 123",
- StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
- };
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PortableWriteBenchmark"/> class.
- /// </summary>
- public PortableWriteBenchmark()
- {
- _marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (Address))
- //new PortableTypeConfiguration(typeof (TestModel))
- }
- });
- }
-
- /// <summary>
- /// Populate descriptors.
- /// </summary>
- /// <param name="descs">Descriptors.</param>
- protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
- {
- descs.Add(BenchmarkOperationDescriptor.Create("WriteAddress", WriteAddress, 1));
- //descs.Add(BenchmarkOperationDescriptor.Create("WriteTestModel", WriteTestModel, 1));
- }
-
- /// <summary>
- /// Write address.
- /// </summary>
- /// <param name="state">State.</param>
- private void WriteAddress(BenchmarkState state)
- {
- var mem = _memMgr.Allocate();
-
- try
- {
- var stream = mem.GetStream();
-
- _marsh.StartMarshal(stream).Write(_address);
- }
- finally
- {
- mem.Release();
- }
- }
- /// <summary>
- /// Write address.
- /// </summary>
- /// <param name="state">State.</param>
- private void WriteTestModel(BenchmarkState state)
- {
- var mem = _memMgr.Allocate();
-
- try
- {
- var stream = mem.GetStream();
-
- _marsh.StartMarshal(stream).Write(_model);
- }
- finally
- {
- mem.Release();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/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 10b3dcd..a5bb7a8 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
@@ -84,7 +84,7 @@
<Compile Include="Cache\Store\CacheStoreTest.cs" />
<Compile Include="Cache\Store\CacheTestParallelLoadStore.cs" />
<Compile Include="Cache\Store\CacheTestStore.cs" />
- <Compile Include="Compute\Forked\ForkedPortableClosureTaskTest.cs" />
+ <Compile Include="Compute\Forked\ForkedBinarizableClosureTaskTest.cs" />
<Compile Include="Compute\Forked\ForkedResourceTaskTest.cs" />
<Compile Include="Compute\Forked\ForkedSerializableClosureTaskTest.cs" />
<Compile Include="Compute\Forked\ForkedTaskAdapterTest.cs" />
@@ -94,8 +94,8 @@
<Compile Include="Compute\ComputeMultithreadedTest.cs" />
<Compile Include="Compute\IgniteExceptionTaskSelfTest.cs" />
<Compile Include="Compute\FailoverTaskSelfTest.cs" />
- <Compile Include="Compute\PortableClosureTaskTest.cs" />
- <Compile Include="Compute\PortableTaskTest.cs" />
+ <Compile Include="Compute\BinarizableClosureTaskTest.cs" />
+ <Compile Include="Compute\BinarizableTaskTest.cs" />
<Compile Include="Compute\ResourceTaskTest.cs" />
<Compile Include="Compute\SerializableClosureTaskTest.cs" />
<Compile Include="Compute\TaskAdapterTest.cs" />
@@ -116,21 +116,21 @@
<Compile Include="IgniteManagerTest.cs" />
<Compile Include="MarshallerTest.cs" />
<Compile Include="MessagingTest.cs" />
- <Compile Include="PortableConfigurationTest.cs" />
- <Compile Include="Portable\PortableStructureTest.cs" />
+ <Compile Include="BinaryConfigurationTest.cs" />
+ <Compile Include="Binary\BinaryStructureTest.cs" />
<Compile Include="SerializationTest.cs" />
<Compile Include="IgniteStartStopTest.cs" />
<Compile Include="TestUtils.cs" />
<Compile Include="Memory\InteropMemoryTest.cs" />
- <Compile Include="Portable\PortableApiSelfTest.cs" />
- <Compile Include="Portable\PortableSelfTest.cs" />
+ <Compile Include="Binary\BinaryBuilderSelfTest.cs" />
+ <Compile Include="Binary\BinarySelfTest.cs" />
<Compile Include="Process\IgniteProcess.cs" />
<Compile Include="Process\IgniteProcessConsoleOutputReader.cs" />
<Compile Include="Process\IIgniteProcessOutputReader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Query\ImplicitPortablePerson.cs" />
- <Compile Include="Query\NoDefPortablePerson.cs" />
- <Compile Include="Query\PortablePerson.cs" />
+ <Compile Include="Query\ImplicitBinarizablePerson.cs" />
+ <Compile Include="Query\NoDefBinarizablePerson.cs" />
+ <Compile Include="Query\BinarizablePerson.cs" />
<Compile Include="Services\ServicesTest.cs" />
<Compile Include="Services\ServicesTestAsync.cs" />
<Compile Include="Services\ServiceProxyTest.cs" />
@@ -161,7 +161,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <Content Include="Config\cache-portables.xml">
+ <Content Include="Config\cache-binarizables.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\cache-query-continuous.xml">
@@ -207,7 +207,7 @@
<Content Include="Config\marshaller-invalid.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
- <Content Include="Config\marshaller-portable.xml">
+ <Content Include="Config\marshaller-explicit.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\native-client-test-cache-affinity.xml">
@@ -222,7 +222,7 @@
<Content Include="Config\native-client-test-cache.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
- <Content Include="Config\portable.xml">
+ <Content Include="Config\binary.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\start-test-grid1.xml">
@@ -241,6 +241,7 @@
</Content>
</ItemGroup>
<ItemGroup>
+ <None Include="Apache.Ignite.Core.Tests.nunit" />
<None Include="Apache.Ignite.Core.Tests.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit
new file mode 100644
index 0000000..7aeb108
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit
@@ -0,0 +1,7 @@
+<NUnitProject>
+ <Settings activeconfig="Debug" />
+ <Config name="Debug" binpathtype="Auto">
+ <assembly path="bin\x64\Debug\Apache.Ignite.Core.Tests.exe" />
+ </Config>
+ <Config name="Release" binpathtype="Auto" />
+</NUnitProject>
\ No newline at end of file
[6/8] ignite git commit: IGNITE-1881: Internal portable -> binary
renamings.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
new file mode 100644
index 0000000..102afd1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -0,0 +1,2157 @@
+/*
+ * 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 NonReadonlyMemberInGetHashCode
+// ReSharper disable CompareOfFloatsByEqualityOperator
+// ReSharper disable PossibleInvalidOperationException
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Tests.Binary
+{
+ 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.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+ using NUnit.Framework;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixture]
+ public class BinarySelfTest {
+ /** */
+ private Marshaller _marsh;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public void BeforeTest()
+ {
+ _marsh = new Marshaller(null);
+ }
+
+ /**
+ * <summary>Check write of primitive boolean.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveBool()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(false)), false);
+ Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
+
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive boolean array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveBoolArray()
+ {
+ bool[] vals = { true, false };
+
+ Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
+
+ bool?[] vals2 = { true, false };
+
+ Assert.AreEqual(_marsh.Unmarshal<bool?[]>(_marsh.Marshal(vals2)), vals2);
+ }
+
+ /**
+ * <summary>Check write of primitive sbyte.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveSbyte()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal((sbyte)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MinValue)), sbyte.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive sbyte array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveSbyteArray()
+ {
+ sbyte[] vals = { sbyte.MinValue, 0, 1, sbyte.MaxValue };
+ sbyte[] newVals = _marsh.Unmarshal<sbyte[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive byte.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveByte()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal((byte)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MinValue)), byte.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive byte array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveByteArray()
+ {
+ byte[] vals = { byte.MinValue, 0, 1, byte.MaxValue };
+ byte[] newVals = _marsh.Unmarshal<byte[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive short.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveShort()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal((short)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MinValue)), short.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive short array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveShortArray()
+ {
+ short[] vals = { short.MinValue, 0, 1, short.MaxValue };
+ short[] newVals = _marsh.Unmarshal<short[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive ushort.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUshort()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal((ushort)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MinValue)), ushort.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive short array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUshortArray()
+ {
+ ushort[] vals = { ushort.MinValue, 0, 1, ushort.MaxValue };
+ ushort[] newVals = _marsh.Unmarshal<ushort[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive char.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveChar()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal((char)1)), (char)1);
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MinValue)), char.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveCharArray()
+ {
+ char[] vals = { char.MinValue, (char)0, (char)1, char.MaxValue };
+ char[] newVals = _marsh.Unmarshal<char[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive int.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveInt()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MinValue)), int.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveIntArray()
+ {
+ int[] vals = { int.MinValue, 0, 1, int.MaxValue };
+ int[] newVals = _marsh.Unmarshal<int[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive uint.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUint()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal((uint)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MinValue)), uint.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUintArray()
+ {
+ uint[] vals = { uint.MinValue, 0, 1, uint.MaxValue };
+ uint[] newVals = _marsh.Unmarshal<uint[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive long.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveLong()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal((long)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MinValue)), long.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive long array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveLongArray()
+ {
+ long[] vals = { long.MinValue, 0, 1, long.MaxValue };
+ long[] newVals = _marsh.Unmarshal<long[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive ulong.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUlong()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal((ulong)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MinValue)), ulong.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive ulong array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUlongArray()
+ {
+ ulong[] vals = { ulong.MinValue, 0, 1, ulong.MaxValue };
+ ulong[] newVals = _marsh.Unmarshal<ulong[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive float.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveFloat()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal((float)1)), (float)1);
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MinValue)), float.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive float array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveFloatArray()
+ {
+ float[] vals = { float.MinValue, 0, 1, float.MaxValue };
+ float[] newVals = _marsh.Unmarshal<float[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive double.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDouble()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal((double)1)), (double)1);
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MinValue)), double.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive double array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDoubleArray()
+ {
+ double[] vals = { double.MinValue, 0, 1, double.MaxValue };
+ double[] newVals = _marsh.Unmarshal<double[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of decimal.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDecimal()
+ {
+ decimal val;
+
+ // Test positibe and negative.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Zero)), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, true, 0))), val);
+
+ // Test 32, 64 and 96 bits + mixed.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, true, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, true, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, true, 0))), val);
+
+ // Test extremes.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("65536"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-65536"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("4294967296"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-4294967296"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("281474976710656"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-281474976710656"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("18446744073709551616"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-18446744073709551616"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("1208925819614629174706176"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-1208925819614629174706176"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MaxValue)), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MinValue)), val);
+
+ // Test scale.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("11,12"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
+
+ // Test null.
+ Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal((decimal?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of decimal array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDecimalArray()
+ {
+ decimal?[] vals = { decimal.One, decimal.Parse("11,12") };
+ var newVals = _marsh.Unmarshal<decimal?[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of string.</summary>
+ */
+ [Test]
+ public void TestWriteString()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal((string) null)), null);
+ }
+
+ /**
+ * <summary>Check write of string array.</summary>
+ */
+ [Test]
+ public void TestWriteStringArray()
+ {
+ string[] vals = { "str1", null, "", "str2", null};
+ string[] newVals = _marsh.Unmarshal<string[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of Guid.</summary>
+ */
+ [Test]
+ public void TestWriteGuid()
+ {
+ Guid guid = Guid.NewGuid();
+ Guid? nGuid = guid;
+
+ Assert.AreEqual(_marsh.Unmarshal<Guid>(_marsh.Marshal(guid)), guid);
+ Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), nGuid);
+
+ nGuid = null;
+
+ // ReSharper disable once ExpressionIsAlwaysNull
+ Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), null);
+ }
+
+ /**
+ * <summary>Check write of string array.</summary>
+ */
+ [Test]
+ public void TestWriteGuidArray()
+ {
+ Guid?[] vals = { Guid.NewGuid(), null, Guid.Empty, Guid.NewGuid(), null };
+ Guid?[] newVals = _marsh.Unmarshal<Guid?[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of enum.</summary>
+ */
+ [Test]
+ public void TestWriteEnum()
+ {
+ TestEnum val = TestEnum.Val1;
+
+ Assert.AreEqual(_marsh.Unmarshal<TestEnum>(_marsh.Marshal(val)), val);
+ }
+
+ /**
+ * <summary>Check write of enum.</summary>
+ */
+ [Test]
+ public void TestWriteEnumArray()
+ {
+ TestEnum[] vals = { TestEnum.Val2, TestEnum.Val3 };
+ TestEnum[] newVals = _marsh.Unmarshal<TestEnum[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /// <summary>
+ /// Test object with dates.
+ /// </summary>
+ [Test]
+ public void TestDateObject()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(DateTimeType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ DateTime now = DateTime.Now;
+
+ DateTimeType obj = new DateTimeType(now);
+
+ DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
+
+ Assert.AreEqual(obj.Utc, otherObj.Utc);
+ Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
+ Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
+
+ Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
+ Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
+ Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
+ }
+
+ /// <summary>
+ /// Tests the DateTime marshalling.
+ /// </summary>
+ [Test]
+ public void TestDateTime()
+ {
+ var time = DateTime.Now;
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
+
+ var timeUtc = DateTime.UtcNow;
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), timeUtc);
+
+ // Check exception with non-UTC date
+ var stream = new BinaryHeapStream(128);
+ var writer = _marsh.StartMarshal(stream);
+ Assert.Throws<InvalidOperationException>(() => writer.WriteTimestamp(DateTime.Now));
+ }
+
+ /**
+ * <summary>Check generic collections.</summary>
+ */
+ [Test]
+ public void TestGenericCollections()
+ {
+ var list = new List<string> {"1"};
+
+ var data = _marsh.Marshal(list);
+
+ var newObjList = _marsh.Unmarshal<IList<string>>(data);
+
+ CollectionAssert.AreEquivalent(list, newObjList);
+ }
+
+ /// <summary>
+ /// Tests marshal aware type with generic collections.
+ /// </summary>
+ [Test]
+ public void TestGenericCollectionsType()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (PrimitiveFieldType)),
+ new BinaryTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
+ }
+ });
+
+ var obj = new GenericCollectionsType<PrimitiveFieldType, SerializableObject>
+ {
+ Keys = new[] {new PrimitiveFieldType(), new PrimitiveFieldType()},
+ Values =
+ new List<SerializableObject>
+ {
+ new SerializableObject {Foo = 1},
+ new SerializableObject {Foo = 5}
+ },
+ Pairs = new Dictionary<PrimitiveFieldType, SerializableObject>
+ {
+ {new PrimitiveFieldType(), new SerializableObject {Foo = 10}},
+ {new PrimitiveFieldType {PByte = 10}, new SerializableObject {Foo = 20}}
+ },
+ Objects = new object[] {1, 2, "3", 4.4}
+ };
+
+ var data = marsh.Marshal(obj);
+
+ var result = marsh.Unmarshal<GenericCollectionsType<PrimitiveFieldType, SerializableObject>>(data);
+
+ CollectionAssert.AreEquivalent(obj.Keys, result.Keys);
+ CollectionAssert.AreEquivalent(obj.Values, result.Values);
+ CollectionAssert.AreEquivalent(obj.Pairs, result.Pairs);
+ CollectionAssert.AreEquivalent(obj.Objects, result.Objects);
+ }
+
+ /**
+ * <summary>Check property read.</summary>
+ */
+ [Test]
+ public void TestProperty()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PropertyType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PropertyType obj = new PropertyType
+ {
+ Field1 = 1,
+ Field2 = 2
+ };
+
+ byte[] data = marsh.Marshal(obj);
+
+ PropertyType newObj = marsh.Unmarshal<PropertyType>(data);
+
+ Assert.AreEqual(obj.Field1, newObj.Field1);
+ Assert.AreEqual(obj.Field2, newObj.Field2);
+
+ IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
+ Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
+ }
+
+ /**
+ * <summary>Check write of primitive fields through reflection.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsReflective()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through binary interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsBinary()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldBinaryType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldBinaryType obj = new PrimitiveFieldBinaryType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through binary interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsRawBinary()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldRawBinaryType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldRawBinaryType obj = new PrimitiveFieldRawBinaryType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through binary interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsSerializer()
+ {
+ var typeCfgs = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (PrimitiveFieldType))
+ {
+ Serializer = new PrimitiveFieldsSerializer()
+ }
+ };
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check decimals.</summary>
+ */
+ [Test]
+ public void TestDecimalFields()
+ {
+ BinaryConfiguration cfg = new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (DecimalReflective)),
+ new BinaryTypeConfiguration(typeof (DecimalMarshalAware))
+ }
+ };
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ // 1. Test reflective stuff.
+ DecimalReflective obj1 = new DecimalReflective
+ {
+ Val = decimal.Zero,
+ ValArr = new decimal?[] {decimal.One, decimal.MinusOne}
+ };
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj1), BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal?[]>("valArr"));
+
+ Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
+ Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
+
+ // 2. Test marshal aware stuff.
+ DecimalMarshalAware obj2 = new DecimalMarshalAware();
+
+ obj2.Val = decimal.Zero;
+ obj2.ValArr = new decimal?[] { decimal.One, decimal.MinusOne };
+ obj2.RawVal = decimal.MaxValue;
+ obj2.RawValArr = new decimal?[] { decimal.MinusOne, decimal.One} ;
+
+ portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj2), BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal?[]>("valArr"));
+
+ Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
+ Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
+ Assert.AreEqual(obj2.RawVal, portObj.Deserialize<DecimalMarshalAware>().RawVal);
+ Assert.AreEqual(obj2.RawValArr, portObj.Deserialize<DecimalMarshalAware>().RawValArr);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through raw serializer.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsRawSerializer()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ BinaryTypeConfiguration typeCfg =
+ new BinaryTypeConfiguration(typeof(PrimitiveFieldType));
+
+ typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
+
+ typeCfgs.Add(typeCfg);
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ private void CheckPrimitiveFields(Marshaller marsh, PrimitiveFieldType obj)
+ {
+ obj.PBool = true;
+ obj.PByte = 2;
+ obj.PSbyte = 3;
+ obj.PShort = 4;
+ obj.PUshort = 5;
+ obj.PInt = 6;
+ obj.PUint = 7;
+ obj.PLong = 8;
+ obj.PUlong = 9;
+ obj.PChar = 'a';
+ obj.PFloat = 10;
+ obj.PDouble = 11;
+ obj.PString = "abc";
+ obj.PGuid = Guid.NewGuid();
+ obj.PnGuid = Guid.NewGuid();
+ obj.IgniteGuid = new IgniteGuid(Guid.NewGuid(), 123);
+
+ CheckPrimitiveFieldsSerialization(marsh, obj);
+ }
+
+ private void CheckPrimitiveFieldsSerialization(Marshaller marsh, PrimitiveFieldType obj)
+ {
+ byte[] bytes = marsh.Marshal(obj);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
+
+ Assert.AreEqual(obj, newObj);
+ }
+
+ /**
+ * <summary>Check write of object with enums.</summary>
+ */
+ [Test]
+ public void TestEnumsReflective()
+ {
+ Marshaller marsh =
+ new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations =
+ new List<BinaryTypeConfiguration> {new BinaryTypeConfiguration(typeof (EnumType))}
+ });
+
+ EnumType obj = new EnumType
+ {
+ PEnum = TestEnum.Val1,
+ PEnumArray = new[] {TestEnum.Val2, TestEnum.Val3}
+ };
+
+ byte[] bytes = marsh.Marshal(obj);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ EnumType newObj = portObj.Deserialize<EnumType>();
+
+ Assert.AreEqual(obj.PEnum, newObj.PEnum);
+ Assert.AreEqual(obj.PEnumArray, newObj.PEnumArray);
+ }
+
+ /**
+ * <summary>Check write of object with collections.</summary>
+ */
+ [Test]
+ public void TestCollectionsReflective()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (CollectionsType)),
+ new BinaryTypeConfiguration(typeof (InnerObjectType))
+ }
+ });
+
+ var obj = new CollectionsType
+ {
+ Hashtable = new Hashtable {{1, 2}, {3, 4}},
+ LinkedList = new LinkedList<int>(new[] {1, 2, 3}),
+ SortedDict = new SortedDictionary<string, int> {{"1", 2}},
+ Dict = new Dictionary<int, string> {{1, "2"}},
+ Arr = new[] {new InnerObjectType()}
+ };
+
+ var list = new ArrayList
+ {
+ true,
+ (byte) 1,
+ (short) 2,
+ 'a',
+ 3,
+ (long) 4,
+ (float) 5,
+ (double) 6,
+ "string",
+ Guid.NewGuid(),
+ new InnerObjectType
+ {
+ PInt1 = 1,
+ PInt2 = 2
+ }
+ };
+
+ obj.Col1 = list;
+
+ byte[] bytes = marsh.Marshal(obj);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ CollectionsType newObj = portObj.Deserialize<CollectionsType>();
+
+ Assert.AreEqual(obj, newObj);
+
+ obj.Col1 = null;
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+
+ obj.Col1 = list;
+ obj.Col2 = list;
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+
+ obj.Col2 = new TestList();
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+ }
+
+ /**
+ * <summary>Check write of object fields through reflective serializer.</summary>
+ */
+ [Test]
+ public void TestObjectReflective()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(OuterObjectType)));
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(InnerObjectType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
+ }
+
+ /**
+ * <summary>Test handles.</summary>
+ */
+ [Test]
+ public void TestHandles()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleInner)));
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleOuter)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ HandleOuter outer = new HandleOuter();
+
+ outer.Before = "outBefore";
+ outer.After = "outAfter";
+ outer.RawBefore = "outRawBefore";
+ outer.RawAfter = "outRawAfter";
+
+ HandleInner inner = new HandleInner();
+
+ inner.Before = "inBefore";
+ inner.After = "inAfter";
+ inner.RawBefore = "inRawBefore";
+ inner.RawAfter = "inRawAfter";
+
+ outer.Inner = inner;
+ outer.RawInner = inner;
+
+ inner.Outer = outer;
+ inner.RawOuter = outer;
+
+ byte[] bytes = marsh.Marshal(outer);
+
+ IBinaryObject outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
+ HandleInner newInner = newOuter.Inner;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+
+ // Get inner object by field.
+ IBinaryObject innerObj = outerObj.GetField<IBinaryObject>("inner");
+
+ newInner = innerObj.Deserialize<HandleInner>();
+ newOuter = newInner.Outer;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+
+ // Get outer object from inner object by handle.
+ outerObj = innerObj.GetField<IBinaryObject>("outer");
+
+ newOuter = outerObj.Deserialize<HandleOuter>();
+ newInner = newOuter.Inner;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+ }
+
+ /**
+ * <summary>Test handles with exclusive writes.</summary>
+ */
+ [Test]
+ public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asbinary)
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (HandleInner)),
+ new BinaryTypeConfiguration(typeof (HandleOuterExclusive))
+ }
+ });
+
+ var inner = new HandleInner
+ {
+ Before = "inBefore",
+ After = "inAfter",
+ RawBefore = "inRawBefore",
+ RawAfter = "inRawAfter"
+ };
+
+ var outer = new HandleOuterExclusive
+ {
+ Before = "outBefore",
+ After = "outAfter",
+ RawBefore = "outRawBefore",
+ RawAfter = "outRawAfter",
+ Inner = inner,
+ RawInner = inner
+ };
+
+ inner.Outer = outer;
+ inner.RawOuter = outer;
+
+ var bytes = asbinary
+ ? marsh.Marshal(new IgniteBinary(marsh).ToBinary<IBinaryObject>(outer))
+ : marsh.Marshal(outer);
+
+ IBinaryObject outerObj;
+
+ if (detached)
+ {
+ var reader = new BinaryReader(marsh, new Dictionary<long, IBinaryTypeDescriptor>(),
+ new BinaryHeapStream(bytes), BinaryMode.ForceBinary, null);
+
+ reader.DetachNext();
+
+ outerObj = reader.Deserialize<IBinaryObject>();
+ }
+ else
+ outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
+
+ Assert.IsFalse(newOuter == newOuter.Inner.Outer);
+ Assert.IsFalse(newOuter == newOuter.Inner.RawOuter);
+ Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
+ Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
+
+ Assert.IsFalse(newOuter.Inner == newOuter.RawInner);
+
+ Assert.IsTrue(newOuter.Inner.Outer == newOuter.Inner.RawOuter);
+ Assert.IsTrue(newOuter.RawInner.Outer == newOuter.RawInner.RawOuter);
+
+ Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.Inner);
+ Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.RawInner);
+ Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.Inner);
+ Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.RawInner);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedDefault()
+ {
+ CheckKeepSerialized(new BinaryConfiguration(), true);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedDefaultFalse()
+ {
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.DefaultKeepDeserialized = false;
+
+ CheckKeepSerialized(cfg, false);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedTypeCfgFalse()
+ {
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
+
+ typeCfg.KeepDeserialized = false;
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
+
+ CheckKeepSerialized(cfg, false);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedTypeCfgTrue()
+ {
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
+ typeCfg.KeepDeserialized = true;
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+ cfg.DefaultKeepDeserialized = false;
+
+ cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
+
+ CheckKeepSerialized(cfg, true);
+ }
+
+ /// <summary>
+ /// Test correct serialization/deserialization of arrays of special types.
+ /// </summary>
+ [Test]
+ public void TestSpecialArrays()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArray)));
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArrayMarshalAware)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ Guid[] guidArr = { Guid.NewGuid() };
+ Guid?[] nGuidArr = { Guid.NewGuid() };
+ DateTime[] dateArr = { DateTime.Now.ToUniversalTime() };
+ DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
+
+ // Use special object.
+ SpecialArray obj1 = new SpecialArray
+ {
+ GuidArr = guidArr,
+ NGuidArr = nGuidArr,
+ DateArr = dateArr,
+ NDateArr = nDateArr
+ };
+
+ byte[] bytes = marsh.Marshal(obj1);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.IsNotNull(portObj.Deserialize<SpecialArray>());
+
+ Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
+ Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
+ Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
+ Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("nDateArr"));
+
+ obj1 = portObj.Deserialize<SpecialArray>();
+
+ Assert.AreEqual(guidArr, obj1.GuidArr);
+ Assert.AreEqual(nGuidArr, obj1.NGuidArr);
+ Assert.AreEqual(dateArr, obj1.DateArr);
+ Assert.AreEqual(nDateArr, obj1.NDateArr);
+
+ // Use special with IGridbinaryMarshalAware.
+ SpecialArrayMarshalAware obj2 = new SpecialArrayMarshalAware();
+
+ obj2.GuidArr = guidArr;
+ obj2.NGuidArr = nGuidArr;
+ obj2.DateArr = dateArr;
+ obj2.NDateArr = nDateArr;
+
+ bytes = marsh.Marshal(obj2);
+
+ portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
+ Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
+ Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("c"));
+ Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("d"));
+
+ obj2 = portObj.Deserialize<SpecialArrayMarshalAware>();
+
+ Assert.AreEqual(guidArr, obj2.GuidArr);
+ Assert.AreEqual(nGuidArr, obj2.NGuidArr);
+ Assert.AreEqual(dateArr, obj2.DateArr);
+ Assert.AreEqual(nDateArr, obj2.NDateArr);
+ }
+
+ /// <summary>
+ /// Writes objects of various sizes to test schema compaction
+ /// (where field offsets can be stored as 1, 2 or 4 bytes).
+ /// </summary>
+ [Test]
+ public void TestCompactSchema()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (SpecialArray)),
+ new BinaryTypeConfiguration(typeof (SpecialArrayMarshalAware))
+ }
+ });
+
+ var dt = new SpecialArrayMarshalAware();
+
+ foreach (var i in new[] {1, 5, 10, 13, 14, 15, 100, 200, 1000, 5000, 15000, 30000})
+ {
+ dt.NGuidArr = Enumerable.Range(1, i).Select(x => (Guid?) Guid.NewGuid()).ToArray();
+ dt.NDateArr = Enumerable.Range(1, i).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray();
+
+ var bytes = marsh.Marshal(dt);
+
+ var res = marsh.Unmarshal<SpecialArrayMarshalAware>(bytes);
+
+ CollectionAssert.AreEquivalent(dt.NGuidArr, res.NGuidArr);
+ CollectionAssert.AreEquivalent(dt.NDateArr, res.NDateArr);
+ }
+ }
+
+ private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
+ {
+ if (cfg.TypeConfigurations == null)
+ {
+ cfg.TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof(PropertyType))
+ };
+ }
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ byte[] data = marsh.Marshal(new PropertyType());
+
+ IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
+ PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
+
+ Assert.NotNull(deserialized1);
+
+ Assert.AreEqual(expKeep, deserialized1 == deserialized2);
+ }
+
+ private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
+ HandleInner newInner)
+ {
+ Assert.True(newOuter != null);
+ Assert.AreEqual(outer.Before, newOuter.Before);
+ Assert.True(newOuter.Inner == newInner);
+ Assert.AreEqual(outer.After, newOuter.After);
+ Assert.AreEqual(outer.RawBefore, newOuter.RawBefore);
+ Assert.True(newOuter.RawInner == newInner);
+ Assert.AreEqual(outer.RawAfter, newOuter.RawAfter);
+
+ Assert.True(newInner != null);
+ Assert.AreEqual(inner.Before, newInner.Before);
+ Assert.True(newInner.Outer == newOuter);
+ Assert.AreEqual(inner.After, newInner.After);
+ Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
+ Assert.True(newInner.RawOuter == newOuter);
+ Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
+ }
+
+ private static void CheckObject(Marshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
+ {
+ inObj.PInt1 = 1;
+ inObj.PInt2 = 2;
+
+ outObj.InObj = inObj;
+
+ byte[] bytes = marsh.Marshal(outObj);
+
+ IBinaryObject portOutObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
+
+ OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
+
+ Assert.AreEqual(outObj, newOutObj);
+ }
+
+ public class OuterObjectType
+ {
+ public InnerObjectType InObj { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var type = obj as OuterObjectType;
+
+ return type != null && Equals(InObj, type.InObj);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return InObj != null ? InObj.GetHashCode() : 0;
+ }
+ }
+
+ [Serializable]
+ public class InnerObjectType
+ {
+ public int PInt1 { get; set; }
+
+ public int PInt2 { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var that = obj as InnerObjectType;
+
+ return that != null && (PInt1 == that.PInt1 && PInt2 == that.PInt2);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return 31 * PInt1 + PInt2;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return "InnerObjectType[pInt1=" + PInt1 + ", pInt2=" + PInt2 + ']';
+ }
+ }
+
+ public class CollectionsType
+ {
+ public ICollection Col1 { get; set; }
+
+ public ArrayList Col2 { get; set; }
+
+ public Hashtable Hashtable { get; set; }
+
+ public Dictionary<int, string> Dict { get; set; }
+
+ public InnerObjectType[] Arr { get; set; }
+
+ public SortedDictionary<string, int> SortedDict { get; set; }
+
+ public LinkedList<int> LinkedList { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var that = obj as CollectionsType;
+
+ return that != null
+ && CompareCollections(Col1, that.Col1)
+ && CompareCollections(Col2, that.Col2)
+ && CompareCollections(Hashtable, that.Hashtable)
+ && CompareCollections(Dict, that.Dict)
+ && CompareCollections(Arr, that.Arr)
+ && CompareCollections(SortedDict, that.SortedDict)
+ && CompareCollections(LinkedList, that.LinkedList);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ int res = 0;
+
+ foreach (var col in new object[] {Col1, Col2, Hashtable, Dict, Arr, SortedDict, LinkedList})
+ res = 31*res + (col != null ? col.GetHashCode() : 0);
+
+ return res;
+ }
+ }
+
+ public class GenericCollectionsType<TKey, TValue> : IBinarizable
+ {
+ public ICollection<TKey> Keys { get; set; }
+
+ public ICollection<TValue> Values { get; set; }
+
+ public IDictionary<TKey, TValue> Pairs { get; set; }
+
+ public ICollection<object> Objects { get; set; }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteObject("Keys", Keys);
+ writer.WriteObject("Values", Values);
+ writer.WriteObject("Pairs", Pairs);
+ writer.WriteObject("Objects", Objects);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Keys = (ICollection<TKey>) reader.ReadObject<object>("Keys");
+ Values = (ICollection<TValue>) reader.ReadObject<object>("Values");
+ Pairs = (IDictionary<TKey, TValue>) reader.ReadObject<object>("Pairs");
+ Objects = (ICollection<object>) reader.ReadObject<object>("Objects");
+ }
+ }
+
+ public class TestList : ArrayList
+ {
+
+ }
+
+ private static bool CompareCollections(ICollection col1, ICollection col2)
+ {
+ if (col1 == null && col2 == null)
+ return true;
+ if (col1 == null || col2 == null)
+ return false;
+
+ return col1.OfType<object>().SequenceEqual(col2.OfType<object>());
+ }
+
+ public class PrimitiveArrayFieldType
+ {
+ public bool[] PBool { get; set; }
+
+ public sbyte[] PSbyte { get; set; }
+
+ public byte[] PByte { get; set; }
+
+ public short[] PShort { get; set; }
+
+ public ushort[] PUshort { get; set; }
+
+ public char[] PChar { get; set; }
+
+ public int[] PInt { get; set; }
+
+ public uint[] PUint { get; set; }
+
+ public long[] PLong { get; set; }
+
+ public ulong[] PUlong { get; set; }
+
+ public float[] PFloat { get; set; }
+
+ public double[] PDouble { get; set; }
+
+ public string[] PString { get; set; }
+
+ public Guid?[] PGuid { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var other = obj as PrimitiveArrayFieldType;
+
+ return other != null && (PBool == other.PBool &&
+ PByte == other.PByte &&
+ PSbyte == other.PSbyte &&
+ PShort == other.PShort &&
+ PUshort == other.PUshort &&
+ PInt == other.PInt &&
+ PUint == other.PUint &&
+ PLong == other.PLong &&
+ PUlong == other.PUlong &&
+ PChar == other.PChar &&
+ PFloat == other.PFloat &&
+ PDouble == other.PDouble &&
+ PString == other.PString &&
+ PGuid == other.PGuid);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return PInt != null && PInt.Length > 0 ? PInt[0].GetHashCode() : 0;
+ }
+ }
+
+ public class SpecialArray
+ {
+ public Guid[] GuidArr;
+ public Guid?[] NGuidArr;
+ public DateTime[] DateArr;
+ public DateTime?[] NDateArr;
+ }
+
+ public class SpecialArrayMarshalAware : SpecialArray, IBinarizable
+ {
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteObject("a", GuidArr);
+ writer.WriteObject("b", NGuidArr);
+ writer.WriteObject("c", DateArr);
+ writer.WriteObject("d", NDateArr);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ GuidArr = reader.ReadObject<Guid[]>("a");
+ NGuidArr = reader.ReadObject<Guid?[]>("b");
+ DateArr = reader.ReadObject<DateTime[]>("c");
+ NDateArr = reader.ReadObject<DateTime?[]>("d");
+ }
+ }
+
+ public class EnumType
+ {
+ public TestEnum PEnum { get; set; }
+
+ public TestEnum[] PEnumArray { get; set; }
+ }
+
+ [Serializable]
+ public class PrimitiveFieldType
+ {
+ public bool PBool { get; set; }
+
+ public sbyte PSbyte { get; set; }
+
+ public byte PByte { get; set; }
+
+ public short PShort { get; set; }
+
+ public ushort PUshort { get; set; }
+
+ public char PChar { get; set; }
+
+ public int PInt { get; set; }
+
+ public uint PUint { get; set; }
+
+ public long PLong { get; set; }
+
+ public ulong PUlong { get; set; }
+
+ public float PFloat { get; set; }
+
+ public double PDouble { get; set; }
+
+ public string PString { get; set; }
+
+ public Guid PGuid { get; set; }
+
+ public Guid? PnGuid { get; set; }
+
+ public IgniteGuid IgniteGuid { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj != null && obj is PrimitiveFieldType)
+ {
+ PrimitiveFieldType that = (PrimitiveFieldType)obj;
+
+ return PBool == that.PBool &&
+ PByte == that.PByte &&
+ PSbyte == that.PSbyte &&
+ PShort == that.PShort &&
+ PUshort == that.PUshort &&
+ PInt == that.PInt &&
+ PUint == that.PUint &&
+ PLong == that.PLong &&
+ PUlong == that.PUlong &&
+ PChar == that.PChar &&
+ PFloat == that.PFloat &&
+ PDouble == that.PDouble &&
+ (string.Equals(PString, that.PString)) &&
+ PGuid.Equals(that.PGuid) &&
+ IgniteGuid.Equals(that.IgniteGuid) &&
+ (PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
+ }
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return PInt;
+ }
+ }
+
+ public class PrimitiveFieldBinaryType : PrimitiveFieldType, IBinarizable
+ {
+ public unsafe void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteBoolean("bool", PBool);
+ writer.WriteByte("byte", PByte);
+ writer.WriteShort("short", PShort);
+ writer.WriteInt("int", PInt);
+ writer.WriteLong("long", PLong);
+ writer.WriteChar("char", PChar);
+ writer.WriteFloat("float", PFloat);
+ writer.WriteDouble("double", PDouble);
+
+ sbyte sByte = PSbyte;
+ ushort uShort = PUshort;
+ uint uInt = PUint;
+ ulong uLong = PUlong;
+
+ writer.WriteByte("sbyte", *(byte*)&sByte);
+ writer.WriteShort("ushort", *(short*)&uShort);
+ writer.WriteInt("uint", *(int*)&uInt);
+ writer.WriteLong("ulong", *(long*)&uLong);
+
+ writer.WriteString("string", PString);
+ writer.WriteGuid("guid", PGuid);
+ writer.WriteGuid("nguid", PnGuid);
+
+ writer.WriteObject("iguid", IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(IBinaryReader reader)
+ {
+ PBool = reader.ReadBoolean("bool");
+ PByte = reader.ReadByte("byte");
+ PShort = reader.ReadShort("short");
+ PInt = reader.ReadInt("int");
+
+ PLong = reader.ReadLong("long");
+ PChar = reader.ReadChar("char");
+ PFloat = reader.ReadFloat("float");
+ PDouble = reader.ReadDouble("double");
+
+ byte sByte = reader.ReadByte("sbyte");
+ short uShort = reader.ReadShort("ushort");
+ int uInt = reader.ReadInt("uint");
+ long uLong = reader.ReadLong("ulong");
+
+ PSbyte = *(sbyte*)&sByte;
+ PUshort = *(ushort*)&uShort;
+ PUint = *(uint*)&uInt;
+ PUlong = *(ulong*)&uLong;
+
+ PString = reader.ReadString("string");
+ PGuid = reader.ReadObject<Guid>("guid");
+ PnGuid = reader.ReadGuid("nguid");
+
+ IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
+ }
+ }
+
+ public class PrimitiveFieldRawBinaryType : PrimitiveFieldType, IBinarizable
+ {
+ public unsafe void WriteBinary(IBinaryWriter writer)
+ {
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteBoolean(PBool);
+ rawWriter.WriteByte(PByte);
+ rawWriter.WriteShort(PShort);
+ rawWriter.WriteInt(PInt);
+ rawWriter.WriteLong(PLong);
+ rawWriter.WriteChar(PChar);
+ rawWriter.WriteFloat(PFloat);
+ rawWriter.WriteDouble(PDouble);
+
+ sbyte sByte = PSbyte;
+ ushort uShort = PUshort;
+ uint uInt = PUint;
+ ulong uLong = PUlong;
+
+ rawWriter.WriteByte(*(byte*)&sByte);
+ rawWriter.WriteShort(*(short*)&uShort);
+ rawWriter.WriteInt(*(int*)&uInt);
+ rawWriter.WriteLong(*(long*)&uLong);
+
+ rawWriter.WriteString(PString);
+ rawWriter.WriteGuid(PGuid);
+ rawWriter.WriteGuid(PnGuid);
+
+ rawWriter.WriteObject(IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(IBinaryReader reader)
+ {
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ PBool = rawReader.ReadBoolean();
+ PByte = rawReader.ReadByte();
+ PShort = rawReader.ReadShort();
+ PInt = rawReader.ReadInt();
+
+ PLong = rawReader.ReadLong();
+ PChar = rawReader.ReadChar();
+ PFloat = rawReader.ReadFloat();
+ PDouble = rawReader.ReadDouble();
+
+ byte sByte = rawReader.ReadByte();
+ short uShort = rawReader.ReadShort();
+ int uInt = rawReader.ReadInt();
+ long uLong = rawReader.ReadLong();
+
+ PSbyte = *(sbyte*)&sByte;
+ PUshort = *(ushort*)&uShort;
+ PUint = *(uint*)&uInt;
+ PUlong = *(ulong*)&uLong;
+
+ PString = rawReader.ReadString();
+ PGuid = rawReader.ReadGuid().Value;
+ PnGuid = rawReader.ReadGuid();
+
+ IgniteGuid = rawReader.ReadObject<IgniteGuid>();
+ }
+ }
+
+ public class PrimitiveFieldsSerializer : IBinarySerializer
+ {
+ public unsafe void WriteBinary(object obj, IBinaryWriter writer)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ writer.WriteBoolean("bool", obj0.PBool);
+ writer.WriteByte("byte", obj0.PByte);
+ writer.WriteShort("short", obj0.PShort);
+ writer.WriteInt("int", obj0.PInt);
+ writer.WriteLong("long", obj0.PLong);
+ writer.WriteChar("char", obj0.PChar);
+ writer.WriteFloat("float", obj0.PFloat);
+ writer.WriteDouble("double", obj0.PDouble);
+
+ sbyte sByte = obj0.PSbyte;
+ ushort uShort = obj0.PUshort;
+ uint uInt = obj0.PUint;
+ ulong uLong = obj0.PUlong;
+
+ writer.WriteByte("sbyte", *(byte*)&sByte);
+ writer.WriteShort("ushort", *(short*)&uShort);
+ writer.WriteInt("uint", *(int*)&uInt);
+ writer.WriteLong("ulong", *(long*)&uLong);
+
+ writer.WriteString("string", obj0.PString);
+ writer.WriteGuid("guid", obj0.PGuid);
+ writer.WriteGuid("nguid", obj0.PnGuid);
+
+ writer.WriteObject("iguid", obj0.IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(object obj, IBinaryReader reader)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ obj0.PBool = reader.ReadBoolean("bool");
+ obj0.PByte = reader.ReadByte("byte");
+ obj0.PShort = reader.ReadShort("short");
+ obj0.PInt = reader.ReadInt("int");
+
+ obj0.PLong = reader.ReadLong("long");
+ obj0.PChar = reader.ReadChar("char");
+ obj0.PFloat = reader.ReadFloat("float");
+ obj0.PDouble = reader.ReadDouble("double");
+
+ byte sByte = reader.ReadByte("sbyte");
+ short uShort = reader.ReadShort("ushort");
+ int uInt = reader.ReadInt("uint");
+ long uLong = reader.ReadLong("ulong");
+
+ obj0.PSbyte = *(sbyte*)&sByte;
+ obj0.PUshort = *(ushort*)&uShort;
+ obj0.PUint = *(uint*)&uInt;
+ obj0.PUlong = *(ulong*)&uLong;
+
+ obj0.PString = reader.ReadString("string");
+ obj0.PGuid = reader.ReadObject<Guid>("guid");
+ obj0.PnGuid = reader.ReadGuid("nguid");
+
+ obj0.IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
+ }
+ }
+
+ public class PrimitiveFieldsRawSerializer : IBinarySerializer
+ {
+ public unsafe void WriteBinary(object obj, IBinaryWriter writer)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteBoolean(obj0.PBool);
+ rawWriter.WriteByte(obj0.PByte);
+ rawWriter.WriteShort( obj0.PShort);
+ rawWriter.WriteInt( obj0.PInt);
+ rawWriter.WriteLong( obj0.PLong);
+ rawWriter.WriteChar(obj0.PChar);
+ rawWriter.WriteFloat(obj0.PFloat);
+ rawWriter.WriteDouble( obj0.PDouble);
+
+ sbyte sByte = obj0.PSbyte;
+ ushort uShort = obj0.PUshort;
+ uint uInt = obj0.PUint;
+ ulong uLong = obj0.PUlong;
+
+ rawWriter.WriteByte(*(byte*)&sByte);
+ rawWriter.WriteShort(*(short*)&uShort);
+ rawWriter.WriteInt(*(int*)&uInt);
+ rawWriter.WriteLong(*(long*)&uLong);
+
+ rawWriter.WriteString(obj0.PString);
+ rawWriter.WriteGuid(obj0.PGuid);
+ rawWriter.WriteGuid(obj0.PnGuid);
+
+ rawWriter.WriteObject(obj0.IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(object obj, IBinaryReader reader)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ obj0.PBool = rawReader.ReadBoolean();
+ obj0.PByte = rawReader.ReadByte();
+ obj0.PShort = rawReader.ReadShort();
+ obj0.PInt = rawReader.ReadInt();
+ obj0.PLong = rawReader.ReadLong();
+ obj0.PChar = rawReader.ReadChar();
+ obj0.PFloat = rawReader.ReadFloat();
+ obj0.PDouble = rawReader.ReadDouble();
+
+ byte sByte = rawReader.ReadByte();
+ short uShort = rawReader.ReadShort();
+ int uInt = rawReader.ReadInt();
+ long uLong = rawReader.ReadLong();
+
+ obj0.PSbyte = *(sbyte*)&sByte;
+ obj0.PUshort = *(ushort*)&uShort;
+ obj0.PUint = *(uint*)&uInt;
+ obj0.PUlong = *(ulong*)&uLong;
+
+ obj0.PString = rawReader.ReadString();
+ obj0.PGuid = rawReader.ReadGuid().Value;
+ obj0.PnGuid = rawReader.ReadGuid();
+
+ obj0.IgniteGuid = rawReader.ReadObject<IgniteGuid>();
+ }
+ }
+
+ public class HandleOuter : IBinarizable
+ {
+ public string Before;
+ public HandleInner Inner;
+ public string After;
+
+ public string RawBefore;
+ public HandleInner RawInner;
+ public string RawAfter;
+
+ /** <inheritdoc /> */
+ virtual public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteString("before", Before);
+ writer.WriteObject("inner", Inner);
+ writer.WriteString("after", After);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteString(RawBefore);
+ rawWriter.WriteObject(RawInner);
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ virtual public void ReadBinary(IBinaryReader reader)
+ {
+ Before = reader.ReadString("before");
+ Inner = reader.ReadObject<HandleInner>("inner");
+ After = reader.ReadString("after");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ RawBefore = rawReader.ReadString();
+ RawInner = rawReader.ReadObject<HandleInner>();
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+ public class HandleInner : IBinarizable
+ {
+ public string Before;
+ public HandleOuter Outer;
+ public string After;
+
+ public string RawBefore;
+ public HandleOuter RawOuter;
+ public string RawAfter;
+
+ /** <inheritdoc /> */
+ virtual public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteString("before", Before);
+ writer.WriteObject("outer", Outer);
+ writer.WriteString("after", After);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteString(RawBefore);
+ rawWriter.WriteObject(RawOuter);
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ virtual public void ReadBinary(IBinaryReader reader)
+ {
+ Before = reader.ReadString("before");
+ Outer = reader.ReadObject<HandleOuter>("outer");
+ After = reader.ReadString("after");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ RawBefore = rawReader.ReadString();
+ RawOuter = rawReader.ReadObject<HandleOuter>();
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+
+ public class HandleOuterExclusive : HandleOuter
+ {
+ /** <inheritdoc /> */
+ override public void WriteBinary(IBinaryWriter writer)
+ {
+ BinaryWriter writer0 = (BinaryWriter)writer;
+
+ writer.WriteString("before", Before);
+
+ writer0.WithDetach(w => w.WriteObject("inner", Inner));
+
+ writer.WriteString("after", After);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteString(RawBefore);
+
+ writer0.WithDetach(w => w.WriteObject(RawInner));
+
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ override public void ReadBinary(IBinaryReader reader)
+ {
+ var reader0 = (BinaryReader) reader;
+
+ Before = reader0.ReadString("before");
+
+ reader0.DetachNext();
+ Inner = reader0.ReadObject<HandleInner>("inner");
+
+ After = reader0.ReadString("after");
+
+ var rawReader = (BinaryReader) reader.GetRawReader();
+
+ RawBefore = rawReader.ReadString();
+
+ reader0.DetachNext();
+ RawInner = rawReader.ReadObject<HandleInner>();
+
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+ public class PropertyType
+ {
+ public int Field1;
+
+ public int Field2
+ {
+ get;
+ set;
+ }
+ }
+
+ public enum TestEnum
+ {
+ Val1, Val2, Val3 = 10
+ }
+
+ public class DecimalReflective
+ {
+ /** */
+ public decimal? Val;
+
+ /** */
+ public decimal?[] ValArr;
+ }
+
+ public class DecimalMarshalAware : DecimalReflective, IBinarizable
+ {
+ /** */
+ public decimal? RawVal;
+
+ /** */
+ public decimal?[] RawValArr;
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteDecimal("val", Val);
+ writer.WriteDecimalArray("valArr", ValArr);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteDecimal(RawVal);
+ rawWriter.WriteDecimalArray(RawValArr);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Val = reader.ReadDecimal("val");
+ ValArr = reader.ReadDecimalArray("valArr");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ RawVal = rawReader.ReadDecimal();
+ RawValArr = rawReader.ReadDecimalArray();
+ }
+ }
+
+ /// <summary>
+ /// Date time type.
+ /// </summary>
+ public class DateTimeType : IBinarizable
+ {
+ public DateTime Utc;
+
+ public DateTime? UtcNull;
+
+ public DateTime?[] UtcArr;
+
+ public DateTime UtcRaw;
+
+ public DateTime? UtcNullRaw;
+
+ public DateTime?[] UtcArrRaw;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="now">Current local time.</param>
+ public DateTimeType(DateTime now)
+ {
+ Utc = now.ToUniversalTime();
+
+ UtcNull = Utc;
+
+ UtcArr = new DateTime?[] { Utc };
+
+ UtcRaw = Utc;
+
+ UtcNullRaw = UtcNull;
+
+ UtcArrRaw = new[] { UtcArr[0] };
+ }
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteTimestamp("utc", Utc);
+ writer.WriteTimestamp("utcNull", UtcNull);
+ writer.WriteTimestampArray("utcArr", UtcArr);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteTimestamp(UtcRaw);
+ rawWriter.WriteTimestamp(UtcNullRaw);
+ rawWriter.WriteTimestampArray(UtcArrRaw);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Utc = reader.ReadTimestamp("utc").Value;
+ UtcNull = reader.ReadTimestamp("utc").Value;
+ UtcArr = reader.ReadTimestampArray("utcArr");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ UtcRaw = rawReader.ReadTimestamp().Value;
+ UtcNullRaw = rawReader.ReadTimestamp().Value;
+ UtcArrRaw = rawReader.ReadTimestampArray();
+ }
+ }
+
+ [Serializable]
+ private class SerializableObject
+ {
+ public int Foo { get; set; }
+
+ private bool Equals(SerializableObject other)
+ {
+ return Foo == other.Foo;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+
+ return Equals((SerializableObject) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Foo;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
new file mode 100644
index 0000000..78ee8c0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
@@ -0,0 +1,250 @@
+/*
+ * 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 System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Contains tests for binary type structure.
+ /// </summary>
+ [TestFixture]
+ public class BinaryStructureTest
+ {
+ /** Repeat count. */
+ public static readonly int RepeatCnt = 10;
+
+ /** Objects per mode. */
+ public static readonly int ObjectsPerMode = 5;
+
+ /// <summary>
+ /// Test object write with different structures.
+ /// </summary>
+ [Test]
+ public void TestStructure()
+ {
+ for (int i = 1; i <= RepeatCnt; i++)
+ {
+ Console.WriteLine(">>> Iteration started: " + i);
+
+ // 1. Generate and shuffle objects.
+ IList<BranchedType> objs = new List<BranchedType>();
+
+ for (int j = 0; j < 6 * ObjectsPerMode; j++)
+ objs.Add(new BranchedType((j%6) + 1));
+
+ objs = IgniteUtils.Shuffle(objs);
+
+ // 2. Create new marshaller.
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType));
+
+ BinaryConfiguration cfg = new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg }
+ };
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ // 3. Marshal all data and ensure deserialized object is fine.
+ foreach (BranchedType obj in objs)
+ {
+ Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');
+
+ byte[] data = marsh.Marshal(obj);
+
+ BranchedType other = marsh.Unmarshal<BranchedType>(data);
+
+ Assert.IsTrue(obj.Equals(other));
+ }
+
+ Console.WriteLine();
+
+ // 4. Ensure that all fields are recorded.
+ var desc = marsh.GetDescriptor(typeof (BranchedType));
+
+ CollectionAssert.AreEquivalent(new[] {"mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8"},
+ desc.WriterTypeStructure.FieldTypes.Keys);
+ }
+ }
+ }
+
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public class BranchedType : IBinarizable
+ {
+ public int mode;
+ public int f2;
+ public int f3;
+ public int f4;
+ public int f5;
+ public int f6;
+ public int f7;
+ public int f8;
+
+ public BranchedType(int mode)
+ {
+ this.mode = mode;
+
+ switch (mode)
+ {
+ case 1:
+ f2 = 2;
+
+ break;
+
+ case 2:
+ f2 = 2;
+ f3 = 3;
+ f4 = 4;
+
+ break;
+
+ case 3:
+ f2 = 2;
+ f3 = 3;
+ f5 = 5;
+
+ break;
+
+ case 4:
+ f2 = 2;
+ f3 = 3;
+ f5 = 5;
+ f6 = 6;
+
+ break;
+
+ case 5:
+ f2 = 2;
+ f3 = 3;
+ f7 = 7;
+
+ break;
+
+ case 6:
+ f8 = 8;
+
+ break;
+ }
+ }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("mode", mode);
+
+ switch (mode)
+ {
+ case 1:
+ writer.WriteInt("f2", f2);
+
+ break;
+
+ case 2:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f4", f4);
+
+ break;
+
+ case 3:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f5", f5);
+
+ break;
+
+ case 4:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f5", f5);
+ writer.WriteInt("f6", f6);
+
+ break;
+
+ case 5:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f7", f7);
+
+ break;
+
+ case 6:
+ writer.WriteInt("f8", f8);
+
+ break;
+ }
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ mode = reader.ReadInt("mode");
+
+ switch (mode)
+ {
+ case 1:
+ f2 = reader.ReadInt("f2");
+
+ break;
+
+ case 2:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f4 = reader.ReadInt("f4");
+
+ break;
+
+ case 3:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f5 = reader.ReadInt("f5");
+
+ break;
+
+ case 4:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f5 = reader.ReadInt("f5");
+ f6 = reader.ReadInt("f6");
+
+ break;
+
+ case 5:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f7 = reader.ReadInt("f7");
+
+ break;
+
+ case 6:
+ f8 = reader.ReadInt("f8");
+
+ break;
+ }
+ }
+
+ public bool Equals(BranchedType other)
+ {
+ return mode == other.mode && f2 == other.f2 && f3 == other.f3 && f4 == other.f4 && f5 == other.f5 &&
+ f6 == other.f6 && f7 == other.f7 && f8 == other.f8;
+ }
+ }
+}