Repository: ignite Updated Branches: refs/heads/master 06c4068bb -> 4963e2d54
IGNITE-6264 .NET: Verify Java API parity with a test Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4963e2d5 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4963e2d5 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4963e2d5 Branch: refs/heads/master Commit: 4963e2d54fc509f59cc80138fc66571507a029ec Parents: 06c4068 Author: Pavel Tupitsyn <ptupit...@apache.org> Authored: Mon Dec 4 19:39:30 2017 +0300 Committer: Pavel Tupitsyn <ptupit...@apache.org> Committed: Mon Dec 4 19:39:30 2017 +0300 ---------------------------------------------------------------------- .../Apache.Ignite.Core.Tests.csproj | 11 +++ .../ApiParity/BinaryParityTest.cs | 48 +++++++++++ .../ApiParity/CacheAffinityParityTest.cs | 39 +++++++++ .../ApiParity/CacheParityTest.cs | 76 +++++++++++++++++ .../ApiParity/ClusterParityTest.cs | 50 +++++++++++ .../ApiParity/ComputeParityTest.cs | 51 +++++++++++ .../ApiParity/EventsParityTest.cs | 50 +++++++++++ .../ApiParity/IgniteParityTest.cs | 79 +++++++++++++++++ .../ApiParity/MessagingParityTest.cs | 39 +++++++++ .../ApiParity/ParityTest.cs | 90 +++++++++++++++++--- .../ApiParity/ServicesParityTest.cs | 39 +++++++++ .../ApiParity/StreamerParityTest.cs | 54 ++++++++++++ .../ApiParity/TransactionsParityTest.cs | 39 +++++++++ 13 files changed, 652 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/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 77b2e6e..648df7e 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 @@ -69,13 +69,24 @@ <Reference Include="System.Xml.Linq" /> </ItemGroup> <ItemGroup> + <Compile Include="ApiParity\BinaryParityTest.cs" /> + <Compile Include="ApiParity\CacheAffinityParityTest.cs" /> + <Compile Include="ApiParity\CacheParityTest.cs" /> <Compile Include="ApiParity\ClientConnectorConfigurationParityTest.cs" /> + <Compile Include="ApiParity\ClusterParityTest.cs" /> + <Compile Include="ApiParity\ComputeParityTest.cs" /> <Compile Include="ApiParity\DataRegionConfigurationParityTest.cs" /> <Compile Include="ApiParity\DataStorageConfigurationParityTest.cs" /> + <Compile Include="ApiParity\EventsParityTest.cs" /> <Compile Include="ApiParity\IgniteConfigurationParityTest.cs" /> + <Compile Include="ApiParity\IgniteParityTest.cs" /> + <Compile Include="ApiParity\MessagingParityTest.cs" /> <Compile Include="ApiParity\ParityTest.cs" /> <Compile Include="ApiParity\CacheConfigurationParityTest.cs" /> <Compile Include="ApiParity\QueryEntityConfigurationParityTest.cs" /> + <Compile Include="ApiParity\ServicesParityTest.cs" /> + <Compile Include="ApiParity\StreamerParityTest.cs" /> + <Compile Include="ApiParity\TransactionsParityTest.cs" /> <Compile Include="AssertExtensions.cs" /> <Compile Include="Binary\BinaryBuilderSelfTestSimpleName.cs" /> <Compile Include="Binary\BinaryDateTimeTest.cs" /> http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/BinaryParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/BinaryParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/BinaryParityTest.cs new file mode 100644 index 0000000..87d1f91 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/BinaryParityTest.cs @@ -0,0 +1,48 @@ +/* + * 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.ApiParity +{ + using System.Collections.Generic; + using Apache.Ignite.Core.Binary; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="IBinary"/> has all APIs from Java Ignite interface. + /// </summary> + public class BinaryParityTest + { + /** Known name mappings. */ + private static readonly Dictionary<string, string> KnownMappings = new Dictionary<string, string> + { + {"type", "GetBinaryType"}, + {"types", "GetBinaryTypes"} + }; + + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestBinary() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteBinary.java", + typeof(IBinary), + knownMappings: KnownMappings); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheAffinityParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheAffinityParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheAffinityParityTest.cs new file mode 100644 index 0000000..f0ae286 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheAffinityParityTest.cs @@ -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. + */ + +namespace Apache.Ignite.Core.Tests.ApiParity +{ + using Apache.Ignite.Core.Cache; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="ICacheAffinity"/> has all APIs from Java Ignite interface. + /// </summary> + public class CacheAffinityParityTest + { + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestCacheAffinity() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\cache\affinity\Affinity.java", + typeof(ICacheAffinity)); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs new file mode 100644 index 0000000..7b568bd --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/CacheParityTest.cs @@ -0,0 +1,76 @@ +/* + * 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.ApiParity +{ + using Apache.Ignite.Core.Cache; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="ICache{TK,TV}"/> has all APIs from Java Ignite interface. + /// </summary> + public class CacheParityTest + { + /** Members that are not needed on .NET side. */ + private static readonly string[] UnneededMembers = + { + // Java-specific. + "close", + "mxBean", + "localMxBean", + "indexReadyFuture", + + // No needed, see IIgnite.DestroyCache + "destroy", + + // The following look pointless, same as get, getAll, etc: + "Entry", + "EntryAsync", + "Entries", + "EntriesAsync", + + // Questionable methods: + "AllOutTx", + "AllOutTxAsync" + }; + + /** Members that are missing on .NET side and should be added in future. */ + private static readonly string[] MissingMembers = + { + "queryMetrics", // IGNITE-6681 + "resetQueryMetrics", // IGNITE-6681 + "queryDetailMetrics", // IGNITE-6680 + "resetQueryDetailMetrics", // IGNITE-6680 + "sizeLong", // IGNITE-6563 + "sizeLongAsync", // IGNITE-6563 + "localSizeLong", // IGNITE-6563 + }; + + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestCache() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteCache.java", + typeof(ICache<,>), + UnneededMembers, + MissingMembers); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ClusterParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ClusterParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ClusterParityTest.cs new file mode 100644 index 0000000..59a80c3 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ClusterParityTest.cs @@ -0,0 +1,50 @@ +/* + * 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.ApiParity +{ + using Apache.Ignite.Core.Cluster; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="ICluster"/> has all APIs from Java Ignite interface. + /// </summary> + public class ClusterParityTest + { + /** Members that are not needed on .NET side. */ + private static readonly string[] UnneededMembers = + { + "nodeLocalMap", + "startNodes", + "startNodesAsync", + "stopNodes", + "restartNodes" + }; + + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestCluster() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteCluster.java", + typeof(ICluster), + UnneededMembers); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs new file mode 100644 index 0000000..e3f47ae --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ComputeParityTest.cs @@ -0,0 +1,51 @@ +/* + * 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.ApiParity +{ + using Apache.Ignite.Core.Compute; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="ICompute"/> has all APIs from Java Ignite interface. + /// </summary> + public class ComputeParityTest + { + /** Methods that are not needed on .NET side. */ + private static readonly string[] UnneededMethods = + { + "withExecutor", // Java-specific. + "localDeployTask", // Java-specific (classloaders) + "localTasks", // Java-specific (classloaders) + "undeployTask", // Java-specific (classloaders) + "withName", // Java-specific (classloaders) + "activeTaskFutures" + }; + + /// <summary> + /// Tests API parity. + /// </summary> + [Test] + public void TestCompute() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteCompute.java", + typeof(ICompute), + UnneededMethods); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/EventsParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/EventsParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/EventsParityTest.cs new file mode 100644 index 0000000..98e9e25 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/EventsParityTest.cs @@ -0,0 +1,50 @@ +/* + * 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.ApiParity +{ + using Apache.Ignite.Core.Events; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="IEvents"/> has all APIs from Java Ignite interface. + /// </summary> + public class EventsParityTest + { + /** Members that are missing on .NET side and should be added in future. */ + private static readonly string[] MissingMembers = + { + // IGNITE-1683 + "remoteListen", + "remoteListenAsync", + "stopRemoteListen", + "stopRemoteListenAsync", + }; + + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestEvents() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteEvents.java", + typeof(IEvents), + knownMissingMembers: MissingMembers); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteParityTest.cs new file mode 100644 index 0000000..29cfda3 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/IgniteParityTest.cs @@ -0,0 +1,79 @@ +/* + * 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.ApiParity +{ + using System.Collections.Generic; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="IIgnite"/> has all APIs from Java Ignite interface. + /// </summary> + public class IgniteParityTest + { + /** Methods that are not needed on .NET side. */ + private static readonly string[] UnneededMembers = + { + "scheduler", + "close", + "executorService", + "fileSystem", + "fileSystems" + }; + + /** Members that are missing on .NET side and should be added in future. */ + private static readonly string[] MissingMembers = + { + "version", // IGNITE-7101 + + "createCaches", // IGNITE-7100 + "orCreateCaches", // IGNITE-7100 + "destroyCaches", // IGNITE-7100 + + "addCacheConfiguration", // IGNITE-7102 + + // Data structures. + "atomicStamped", // IGNITE-7104 + "countDownLatch", // IGNITE-1418 + "semaphore", // IGNITE-7103 + "reentrantLock", // IGNITE-7105 + "queue", // IGNITE-1417 + "set" // IGNITE-6834 + }; + + /** Known name mappings. */ + private static readonly Dictionary<string, string> KnownMappings = new Dictionary<string, string> + { + {"message", "GetMessaging"}, + {"log", "Logger"} + }; + + /// <summary> + /// Tests the IIgnite parity. + /// </summary> + [Test] + public void TestIgnite() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\Ignite.java", + typeof(IIgnite), + UnneededMembers, + MissingMembers, + KnownMappings); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/MessagingParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/MessagingParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/MessagingParityTest.cs new file mode 100644 index 0000000..1d940fc --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/MessagingParityTest.cs @@ -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. + */ + +namespace Apache.Ignite.Core.Tests.ApiParity +{ + using Apache.Ignite.Core.Messaging; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="IMessaging"/> has all APIs from Java Ignite interface. + /// </summary> + public class MessagingParityTest + { + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestMessaging() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteMessaging.java", + typeof(IMessaging)); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ParityTest.cs index 068d22e..63aa96f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ParityTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ParityTest.cs @@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Tests.ApiParity using System.Collections.Generic; using System.IO; using System.Linq; + using System.Reflection; using System.Text; using System.Text.RegularExpressions; using Apache.Ignite.Core.Impl.Common; @@ -35,8 +36,13 @@ namespace Apache.Ignite.Core.Tests.ApiParity private static readonly Regex JavaPropertyRegex = new Regex("(@Deprecated)?\\s+public [^=^\r^\n]+ (\\w+)\\(\\) {", RegexOptions.Compiled); + /** Interface method regex. */ + private static readonly Regex JavaInterfaceMethodRegex = + new Regex("(@Deprecated)?\\s+(@Override)?\\s+public [^=^\r^\n]+ (\\w+)\\(.*?\\)", + RegexOptions.Compiled | RegexOptions.Singleline); + /** Properties that are not needed on .NET side. */ - private static readonly string[] UnneededProperties = + private static readonly string[] UnneededMethods = { "toString", "hashCode", @@ -52,38 +58,78 @@ namespace Apache.Ignite.Core.Tests.ApiParity IEnumerable<string> knownMissingProperties = null, Dictionary<string, string> knownMappings = null) { - var path = Path.Combine(IgniteHome.Resolve(null), javaFilePath); - - Assert.IsTrue(File.Exists(path)); + var path = GetFullPath(javaFilePath); var dotNetProperties = type.GetProperties() - .ToDictionary(x => x.Name, x => x, StringComparer.OrdinalIgnoreCase); + .ToDictionary(x => x.Name, x => (MemberInfo) x, StringComparer.OrdinalIgnoreCase); var javaProperties = GetJavaProperties(path) .Except(excludedProperties ?? Enumerable.Empty<string>()); - var missingProperties = javaProperties - .Where(jp => !GetNameVariants(jp, knownMappings).Any(dotNetProperties.ContainsKey)) + CheckParity(type, knownMissingProperties, knownMappings, javaProperties, dotNetProperties); + } + + /// <summary> + /// Tests the configuration parity. + /// </summary> + public static void CheckInterfaceParity(string javaFilePath, + Type type, + IEnumerable<string> excludedMembers = null, + IEnumerable<string> knownMissingMembers = null, + Dictionary<string, string> knownMappings = null) + { + var path = GetFullPath(javaFilePath); + + var dotNetMembers = type.GetMembers() + .GroupBy(x => x.Name) + .ToDictionary(x => x.Key, x => x.First(), StringComparer.OrdinalIgnoreCase); + + var javaMethods = GetJavaInterfaceMethods(path) + .Except(excludedMembers ?? Enumerable.Empty<string>()); + + CheckParity(type, knownMissingMembers, knownMappings, javaMethods, dotNetMembers); + } + + /// <summary> + /// Gets the full path. + /// </summary> + private static string GetFullPath(string javaFilePath) + { + var path = Path.Combine(IgniteHome.Resolve(null), javaFilePath); + Assert.IsTrue(File.Exists(path)); + + return path; + } + + /// <summary> + /// Checks the parity. + /// </summary> + private static void CheckParity(Type type, IEnumerable<string> knownMissingMembers, + IDictionary<string, string> knownMappings, IEnumerable<string> javaMethods, + IDictionary<string, MemberInfo> dotNetMembers) + { + var missingMembers = javaMethods + .Where(jp => !GetNameVariants(jp, knownMappings).Any(dotNetMembers.ContainsKey)) .ToDictionary(x => x, x => x, StringComparer.OrdinalIgnoreCase); - var knownMissing = (knownMissingProperties ?? Enumerable.Empty<string>()) + var knownMissing = (knownMissingMembers ?? Enumerable.Empty<string>()) .ToDictionary(x => x, x => x, StringComparer.OrdinalIgnoreCase); var sb = new StringBuilder(); - foreach (var javaMissingProp in missingProperties) + foreach (var javaMissingProp in missingMembers) { if (!knownMissing.ContainsKey(javaMissingProp.Key)) { - sb.AppendFormat("{0}.{1} property is missing in .NET.\n", type.Name, javaMissingProp.Key); + sb.AppendFormat("{0}.{1} member is missing in .NET.\n", type.Name, javaMissingProp.Key); } } foreach (var dotnetMissingProp in knownMissing) { - if (!missingProperties.ContainsKey(dotnetMissingProp.Key)) + if (!missingMembers.ContainsKey(dotnetMissingProp.Key)) { - sb.AppendFormat("{0}.{1} property is missing in Java, but is specified as known in .NET.\n", + sb.AppendFormat("{0}.{1} member is missing in Java, but is specified as known in .NET.\n", type.Name, dotnetMissingProp.Key); } } @@ -106,7 +152,21 @@ namespace Apache.Ignite.Core.Tests.ApiParity .Where(m => m.Groups[1].Value == string.Empty) .Select(m => m.Groups[2].Value.Replace("get", "")) .Where(x => !x.Contains(" void ")) - .Except(UnneededProperties); + .Except(UnneededMethods); + } + + /// <summary> + /// Gets the java interface methods from file. + /// </summary> + private static IEnumerable<string> GetJavaInterfaceMethods(string path) + { + var text = File.ReadAllText(path); + + return JavaInterfaceMethodRegex.Matches(text) + .OfType<Match>() + .Where(m => m.Groups[1].Value == string.Empty) + .Select(m => m.Groups[3].Value.Replace("get", "")) + .Except(UnneededMethods); } /// <summary> @@ -116,6 +176,10 @@ namespace Apache.Ignite.Core.Tests.ApiParity IDictionary<string, string> knownMappings) { yield return javaPropertyName; + + yield return "get" + javaPropertyName; + + yield return "is" + javaPropertyName; yield return javaPropertyName.Replace("PoolSize", "ThreadPoolSize"); http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ServicesParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ServicesParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ServicesParityTest.cs new file mode 100644 index 0000000..d8c0938 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/ServicesParityTest.cs @@ -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. + */ + +namespace Apache.Ignite.Core.Tests.ApiParity +{ + using Apache.Ignite.Core.Services; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="IServices"/> has all APIs from Java Ignite interface. + /// </summary> + public class ServicesParityTest + { + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestServices() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteServices.java", + typeof(IServices)); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/StreamerParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/StreamerParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/StreamerParityTest.cs new file mode 100644 index 0000000..8e795e5 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/StreamerParityTest.cs @@ -0,0 +1,54 @@ +/* + * 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.ApiParity +{ + using System.Collections.Generic; + using Apache.Ignite.Core.Datastream; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="IDataStreamer{TK,TV}"/> has all APIs from Java Ignite interface. + /// </summary> + public class StreamerParityTest + { + /** Members that are not needed on .NET side. */ + private static readonly string[] UnneededMembers = + { + "deployClass" + }; + + /** Known name mappings. */ + private static readonly Dictionary<string, string> KnownMappings = new Dictionary<string, string> + { + {"keepBinary", "WithKeepBinary"}, + {"future", "Task"} + }; + + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestStreamer() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteDataStreamer.java", + typeof(IDataStreamer<,>), + UnneededMembers, knownMappings: KnownMappings); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4963e2d5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TransactionsParityTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TransactionsParityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TransactionsParityTest.cs new file mode 100644 index 0000000..7c19569 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ApiParity/TransactionsParityTest.cs @@ -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. + */ + +namespace Apache.Ignite.Core.Tests.ApiParity +{ + using Apache.Ignite.Core.Transactions; + using NUnit.Framework; + + /// <summary> + /// Tests that <see cref="ITransactions"/> has all APIs from Java Ignite interface. + /// </summary> + public class TransactionsParityTest + { + /// <summary> + /// Tests the API parity. + /// </summary> + [Test] + public void TestTransactions() + { + ParityTest.CheckInterfaceParity( + @"modules\core\src\main\java\org\apache\ignite\IgniteTransactions.java", + typeof(ITransactions)); + } + } +} \ No newline at end of file