From c115cc6879bdd7c9eb05fe6a5b87d4bd2992ce87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Fri, 19 Apr 2024 15:36:17 +0200 Subject: [PATCH 1/3] Migrate from TestNG to JUnit5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Pupier --- opc-ua-sdk/dictionary-reader/pom.xml | 3 +- opc-ua-sdk/integration-tests/pom.xml | 2 - opc-ua-sdk/pom.xml | 1 - opc-ua-sdk/sdk-server/pom.xml | 10 ++- .../milo/opcua/sdk/core/AccessLevelTest.java | 6 +- .../sdk/core/CefactEngineeringUnitsTest.java | 8 +-- .../milo/opcua/sdk/core/NumericRangeTest.java | 41 ++++++------ .../milo/opcua/sdk/core/ReferenceTest.java | 6 +- .../sdk/server/LifecycleManagerTest.java | 6 +- .../api/config/OpcUaServerConfigTest.java | 7 ++- .../conversions/AbstractConversionTest.java | 10 +-- .../conversions/BooleanConversionsTest.java | 6 +- .../conversions/ByteConversionsTest.java | 14 ++--- .../ByteStringConversionsTest.java | 7 ++- .../conversions/DateTimeConversionsTest.java | 8 +-- .../ExpandedNodeIdConversionsTest.java | 14 ++--- .../conversions/GuidConversionsTest.java | 6 +- .../conversions/ImplicitConversionsTest.java | 8 +-- .../LocalizedTextConversionsTest.java | 8 +-- .../conversions/NodeIdConversionsTest.java | 10 +-- .../QualifiedNameConversionsTest.java | 10 +-- .../server/events/operators/EqualsTest.java | 14 ++--- .../server/events/operators/IsNullTest.java | 13 ++-- .../opcua/sdk/server/nodes/UaNodeTest.java | 14 ++--- .../delegates/AttributeDelegateChainTest.java | 6 +- .../InstanceDeclarationHierarchyTest.java | 6 +- .../nodes/factories/NodeFactoryTest.java | 12 ++-- .../filters/AttributeFilterChainTest.java | 8 +-- .../sdk/server/util/HostnameUtilTest.java | 6 +- opc-ua-sdk/sdk-tests/pom.xml | 5 +- .../api/identity/AnonymousProviderTest.java | 14 ++--- .../client/config/OpcUaClientConfigTest.java | 13 ++-- .../sdk/client/session/SessionFsmTest.java | 8 +-- .../ClientHandleSequenceTest.java | 14 +++-- opc-ua-stack/bsd-parser-gson/pom.xml | 5 +- .../binaryschema/gson/JsonBsdParserTest.java | 9 +-- opc-ua-stack/bsd-parser/pom.xml | 5 +- .../opcua/binaryschema/BsdParserTest.java | 20 +++--- .../binaryschema/GenericBsdParserTest.java | 2 +- opc-ua-stack/pom.xml | 2 +- opc-ua-stack/stack-core/pom.xml | 10 ++- .../milo/opcua/stack/SequenceHeaderTest.java | 15 +++-- .../opcua/stack/SerializationFixture2.java | 4 +- .../stack/SymmetricSecurityHeaderTest.java | 15 +++-- .../opcua/stack/core/AttributeIdTest.java | 9 +-- .../stack/core/channel/ChunkDecoderTest.java | 10 +-- .../channel/messages/HelloMessageTest.java | 11 ++-- .../DefaultCertificateManagerTest.java | 12 ++-- .../security/DefaultTrustListManagerTest.java | 8 +-- .../OpcUaBinaryStreamDecoderTest.java | 9 +-- .../OpcUaXmlStreamDecoderTest.java | 6 +- .../binary/BinaryDecoderTest.java | 17 ++--- .../binary/BinarySerializationFixture.java | 4 +- .../binary/DataValueSerializationTest.java | 17 ++--- .../DiagnosticInfoSerializationTest.java | 14 ++--- .../ExpandedNodeIdSerializationTest.java | 14 +++-- .../ExtensionObjectSerializationTest.java | 16 ++--- .../binary/GuidSerializationTest.java | 16 ++--- .../LocalizedTextSerializationTest.java | 16 ++--- .../binary/NodeIdSerializationTest.java | 16 ++--- .../binary/OpcUaBinaryStreamEncoderTest.java | 13 ++-- .../binary/StringSerializationTest.java | 12 ++-- .../binary/VariantSerializationTest.java | 41 ++++++------ .../binary/XmlElementSerializationTest.java | 16 ++--- .../core/types/builtin/ByteStringTest.java | 6 +- .../core/types/builtin/DateTimeTest.java | 6 +- .../types/builtin/ExpandedNodeIdTest.java | 18 +++--- .../stack/core/types/builtin/NodeIdTest.java | 21 ++++--- .../core/types/builtin/QualifiedNameTest.java | 7 ++- .../stack/core/types/builtin/VariantTest.java | 12 ++-- .../ApplicationDescriptionTest.java | 5 +- .../opcua/stack/core/util/ArrayUtilTest.java | 39 +++++++----- .../stack/core/util/CertificateUtilTest.java | 6 +- .../stack/core/util/EndpointUtilTest.java | 6 +- .../stack/core/util/ExecutionQueueTest.java | 8 +-- .../milo/opcua/stack/core/util/LazyTest.java | 8 +-- .../opcua/stack/core/util/NonceUtilTest.java | 12 ++-- .../CertificateValidationUtilTest.java | 45 +++++++------- opc-ua-stack/stack-tests/pom.xml | 10 ++- .../opcua/stack/ChunkSerializationTest.java | 31 +++++----- .../stack/ClientCertificateValidatorIT.java | 6 +- .../milo/opcua/stack/ClientServerTest.java | 62 +++++++++++-------- .../milo/opcua/stack/SecurityFixture.java | 4 +- .../opcua/stack/StackIntegrationTest.java | 16 ++--- .../config/UaStackClientConfigTest.java | 8 +-- .../server/EndpointConfigurationTest.java | 23 +++---- pom.xml | 12 ++++ 87 files changed, 570 insertions(+), 489 deletions(-) diff --git a/opc-ua-sdk/dictionary-reader/pom.xml b/opc-ua-sdk/dictionary-reader/pom.xml index 90610d5c9c..420259f634 100644 --- a/opc-ua-sdk/dictionary-reader/pom.xml +++ b/opc-ua-sdk/dictionary-reader/pom.xml @@ -34,8 +34,7 @@ org.junit.jupiter - junit-jupiter-engine - 5.5.2 + junit-jupiter test diff --git a/opc-ua-sdk/integration-tests/pom.xml b/opc-ua-sdk/integration-tests/pom.xml index b5a1b65715..3cfcaf7e49 100644 --- a/opc-ua-sdk/integration-tests/pom.xml +++ b/opc-ua-sdk/integration-tests/pom.xml @@ -43,13 +43,11 @@ org.junit.jupiter junit-jupiter-api - 5.6.2 test org.junit.jupiter junit-jupiter-engine - 5.6.2 test diff --git a/opc-ua-sdk/pom.xml b/opc-ua-sdk/pom.xml index fa4d152d47..4aa736489f 100644 --- a/opc-ua-sdk/pom.xml +++ b/opc-ua-sdk/pom.xml @@ -14,7 +14,6 @@ 22.0.0 1.7.32 - 6.11 2.25.1 diff --git a/opc-ua-sdk/sdk-server/pom.xml b/opc-ua-sdk/sdk-server/pom.xml index a4f89628d7..6ac24eb743 100644 --- a/opc-ua-sdk/sdk-server/pom.xml +++ b/opc-ua-sdk/sdk-server/pom.xml @@ -47,9 +47,13 @@ - org.testng - testng - ${testng.version} + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-params test diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java index 61d33ce189..868a1d5d66 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java @@ -10,10 +10,10 @@ package org.eclipse.milo.opcua.sdk.core; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; public class AccessLevelTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java index 512e8e952c..3d3cf88492 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java @@ -10,11 +10,11 @@ package org.eclipse.milo.opcua.sdk.core; -import org.eclipse.milo.opcua.stack.core.types.structured.EUInformation; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import org.eclipse.milo.opcua.stack.core.types.structured.EUInformation; +import org.junit.jupiter.api.Test; public class CefactEngineeringUnitsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java index 40e2dbc210..8241f74682 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java @@ -10,20 +10,24 @@ package org.eclipse.milo.opcua.sdk.core; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import org.eclipse.milo.opcua.stack.core.UaException; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class NumericRangeTest { - @Test(dataProvider = "getArray1dRanges") + @ParameterizedTest + @MethodSource("getArray1dRanges") public void testArray1d(String range, int[] expected) throws UaException { NumericRange nr = NumericRange.parse(range); Variant value = new Variant(array1d); @@ -34,7 +38,8 @@ public void testArray1d(String range, int[] expected) throws UaException { assertTrue(Arrays.equals(expected, (int[]) result)); } - @Test(dataProvider = "getArray2dRanges") + @ParameterizedTest + @MethodSource("getArray2dRanges") public void testArray2d(String range, int[][] expected) throws UaException { NumericRange nr = NumericRange.parse(range); Variant value = new Variant(array2d); @@ -45,7 +50,8 @@ public void testArray2d(String range, int[][] expected) throws UaException { assertTrue(Arrays.deepEquals(expected, (int[][]) result)); } - @Test(dataProvider = "getArray3dRanges") + @ParameterizedTest + @MethodSource("getArray3dRanges") public void testArray3d(String range, int[][][] expected) throws UaException { NumericRange nr = NumericRange.parse(range); Variant value = new Variant(array3d); @@ -65,7 +71,7 @@ public void testArrayBeyondEnd() throws UaException { Object result = NumericRange.readFromValueAtRange(value, nr); assertTrue(result instanceof int[]); - assertEquals(result, array); + assertArrayEquals((int[]) result, array); } @Test @@ -163,9 +169,10 @@ public void testByteStringBeyondEnd() throws UaException { assertEquals(result, byteString); } - @Test(dataProvider = "getInvalidRanges", expectedExceptions = UaException.class) + @ParameterizedTest + @MethodSource("getInvalidRanges") public void testInvalidRange(String indexRange) throws UaException { - NumericRange.parse(indexRange); + assertThrows(UaException.class, () -> NumericRange.parse(indexRange)); } @@ -208,8 +215,7 @@ public void testWriteByteString() throws UaException { assertEquals(updated, new ByteString(new byte[]{0, 2, 4, 3})); } - @DataProvider - private static Object[][] getInvalidRanges() { + public static Object[][] getInvalidRanges() { return new Object[][]{ {"0:0"}, {"1:1"}, @@ -223,8 +229,7 @@ private static Object[][] getInvalidRanges() { private static final int[] array1d = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - @DataProvider - private static Object[][] getArray1dRanges() { + public static Object[][] getArray1dRanges() { return new Object[][]{ {"0:3", new int[]{0, 1, 2, 3}}, {"4:9", new int[]{4, 5, 6, 7, 8, 9}}, @@ -246,8 +251,7 @@ private static Object[][] getArray1dRanges() { {12, 13, 14, 15} }; - @DataProvider - private static Object[][] getArray2dRanges() { + public static Object[][] getArray2dRanges() { return new Object[][]{ {"0:1,0:1", new int[][]{{0, 1}, {4, 5}}}, {"1:2,1:3", new int[][]{{5, 6, 7}, {9, 10, 11}}}, @@ -263,8 +267,7 @@ private static Object[][] getArray2dRanges() { {{20, 21}, {22, 23}, {24, 25}, {26, 27}} }; - @DataProvider - private static Object[][] getArray3dRanges() { + public static Object[][] getArray3dRanges() { return new Object[][]{ {"0:1,0:1,0:1", new int[][][]{ {{0, 1}, {2, 3}}, diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java index 0422bb065e..14c318ddbf 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java @@ -10,13 +10,13 @@ package org.eclipse.milo.opcua.sdk.core; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.UUID; import org.eclipse.milo.opcua.stack.core.Identifiers; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class ReferenceTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java index e73a8cc074..c093b3ff65 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java @@ -10,11 +10,11 @@ package org.eclipse.milo.opcua.sdk.server; -import java.util.concurrent.atomic.AtomicInteger; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.testng.annotations.Test; +import java.util.concurrent.atomic.AtomicInteger; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class LifecycleManagerTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java index cb1272706f..481b097c52 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java @@ -10,20 +10,21 @@ package org.eclipse.milo.opcua.sdk.server.api.config; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.IOException; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import com.google.common.io.Files; import org.eclipse.milo.opcua.sdk.server.identity.AnonymousIdentityValidator; import org.eclipse.milo.opcua.stack.core.security.DefaultCertificateManager; import org.eclipse.milo.opcua.stack.core.security.DefaultTrustListManager; import org.eclipse.milo.opcua.stack.core.types.builtin.DateTime; import org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo; import org.eclipse.milo.opcua.stack.server.security.DefaultServerCertificateValidator; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; +import com.google.common.io.Files; public class OpcUaServerConfigTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java index 6249d81a7b..c954cc252d 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java @@ -10,14 +10,14 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; + import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.fail; +import org.junit.jupiter.api.Test; abstract class AbstractConversionTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java index 126dd1b1ee..e1a4b2aae1 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java @@ -10,8 +10,6 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.BooleanConversions.booleanToByte; import static org.eclipse.milo.opcua.sdk.server.events.conversions.BooleanConversions.booleanToDouble; import static org.eclipse.milo.opcua.sdk.server.events.conversions.BooleanConversions.booleanToFloat; @@ -27,7 +25,9 @@ import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ulong; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; public class BooleanConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java index 38dd18d436..e96fa83799 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java @@ -10,10 +10,6 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.eclipse.milo.opcua.stack.core.BuiltinDataType; -import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.ByteConversions.byteToBoolean; import static org.eclipse.milo.opcua.sdk.server.events.conversions.ByteConversions.byteToDouble; import static org.eclipse.milo.opcua.sdk.server.events.conversions.ByteConversions.byteToFloat; @@ -30,9 +26,13 @@ import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ulong; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte; +import org.junit.jupiter.api.Test; public class ByteConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java index c90011127e..e6c5b7c415 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java @@ -10,14 +10,15 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.nio.ByteBuffer; import java.util.UUID; -import io.netty.buffer.ByteBufUtil; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; +import io.netty.buffer.ByteBufUtil; public class ByteStringConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java index 7a175e9997..5ea591fcb3 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java @@ -10,14 +10,14 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.util.Calendar; import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.types.builtin.DateTime; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import org.junit.jupiter.api.Test; public class DateTimeConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java index 29a666dc9d..6c3cff8085 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java @@ -10,17 +10,17 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; -import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; -import org.eclipse.milo.opcua.stack.core.util.Namespaces; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.ExpandedNodeIdConversions.expandedNodeIdToNodeId; import static org.eclipse.milo.opcua.sdk.server.events.conversions.ExpandedNodeIdConversions.expandedNodeIdToString; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; +import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; +import org.eclipse.milo.opcua.stack.core.util.Namespaces; +import org.junit.jupiter.api.Test; public class ExpandedNodeIdConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java index 2c8ff97635..f4c237b68b 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java @@ -10,13 +10,13 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.nio.ByteBuffer; import java.util.UUID; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class GuidConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ImplicitConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ImplicitConversionsTest.java index f4a62afb7a..667ee0e5e2 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ImplicitConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ImplicitConversionsTest.java @@ -10,12 +10,12 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.eclipse.milo.opcua.stack.core.BuiltinDataType; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.ImplicitConversions.convert; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; +import org.junit.jupiter.api.Test; public class ImplicitConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java index 07990b8a58..dc7c3368d9 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java @@ -10,11 +10,11 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.LocalizedTextConversions.localizedTextToString; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.junit.jupiter.api.Test; public class LocalizedTextConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java index ef535e1783..33f9437153 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java @@ -10,13 +10,13 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; -import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.NodeIdConversions.nodeIdToExpandedNodeId; import static org.eclipse.milo.opcua.sdk.server.events.conversions.NodeIdConversions.nodeIdToString; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; +import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; +import org.junit.jupiter.api.Test; public class NodeIdConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java index 90acb69b60..c6233431af 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java @@ -10,13 +10,13 @@ package org.eclipse.milo.opcua.sdk.server.events.conversions; -import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; -import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.sdk.server.events.conversions.QualifiedNameConversions.qualifiedNameToLocalizedText; import static org.eclipse.milo.opcua.sdk.server.events.conversions.QualifiedNameConversions.qualifiedNameToString; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; +import org.junit.jupiter.api.Test; public class QualifiedNameConversionsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/EqualsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/EqualsTest.java index 5e2bd34e1b..e697a22306 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/EqualsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/EqualsTest.java @@ -10,18 +10,18 @@ package org.eclipse.milo.opcua.sdk.server.events.operators; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.eclipse.milo.opcua.sdk.server.events.OperatorContext; import org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; import org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand; import org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand; -import org.testng.annotations.Test; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; public class EqualsTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/IsNullTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/IsNullTest.java index ea690fdebb..6d72ccb8df 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/IsNullTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/operators/IsNullTest.java @@ -10,18 +10,19 @@ package org.eclipse.milo.opcua.sdk.server.events.operators; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.eclipse.milo.opcua.sdk.server.events.OperatorContext; import org.eclipse.milo.opcua.sdk.server.model.nodes.objects.BaseEventTypeNode; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; import org.eclipse.milo.opcua.stack.core.types.structured.FilterOperand; import org.eclipse.milo.opcua.stack.core.types.structured.LiteralOperand; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; public class IsNullTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java index 3f05d9f0db..fb730af277 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java @@ -10,6 +10,10 @@ package org.eclipse.milo.opcua.sdk.server.nodes; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.milo.opcua.sdk.core.Reference; import org.eclipse.milo.opcua.sdk.server.ObjectTypeManager; import org.eclipse.milo.opcua.sdk.server.OpcUaServer; @@ -28,19 +32,15 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; public class UaNodeTest { private OpcUaServer server; - @BeforeTest + @BeforeEach public void setup() throws Exception { server = Mockito.mock(OpcUaServer.class); diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java index cfae1ed7da..b97065b61c 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java @@ -10,6 +10,8 @@ package org.eclipse.milo.opcua.sdk.server.nodes.delegates; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.List; @@ -30,9 +32,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class AttributeDelegateChainTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/InstanceDeclarationHierarchyTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/InstanceDeclarationHierarchyTest.java index b8e7ec5eec..ac4dfe0980 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/InstanceDeclarationHierarchyTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/InstanceDeclarationHierarchyTest.java @@ -10,6 +10,8 @@ package org.eclipse.milo.opcua.sdk.server.nodes.factories; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.util.List; import java.util.Optional; @@ -25,11 +27,9 @@ import org.eclipse.milo.opcua.stack.core.NamespaceTable; import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertNotNull; public class InstanceDeclarationHierarchyTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/NodeFactoryTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/NodeFactoryTest.java index e553b07bb2..fbe388e01e 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/NodeFactoryTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/factories/NodeFactoryTest.java @@ -10,6 +10,9 @@ package org.eclipse.milo.opcua.sdk.server.nodes.factories; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; @@ -37,13 +40,10 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.jetbrains.annotations.Nullable; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mockito.stubbing.Answer; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; public class NodeFactoryTest { @@ -51,7 +51,7 @@ public class NodeFactoryTest { private UaNodeManager nodeManager; private NodeFactory nodeFactory; - @BeforeTest + @BeforeEach public void setup() throws Exception { server = Mockito.mock(OpcUaServer.class); diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java index 4b1f70fd61..08da46555f 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java @@ -10,6 +10,9 @@ package org.eclipse.milo.opcua.sdk.server.nodes.filters; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.milo.opcua.sdk.core.AccessLevel; @@ -27,10 +30,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; public class AttributeFilterChainTest { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/util/HostnameUtilTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/util/HostnameUtilTest.java index 504199c829..2afd896562 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/util/HostnameUtilTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/util/HostnameUtilTest.java @@ -10,11 +10,11 @@ package org.eclipse.milo.opcua.sdk.server.util; -import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertNotEquals; -import org.testng.annotations.Test; +import java.util.Set; -import static org.testng.Assert.assertNotEquals; +import org.junit.jupiter.api.Test; public class HostnameUtilTest { diff --git a/opc-ua-sdk/sdk-tests/pom.xml b/opc-ua-sdk/sdk-tests/pom.xml index 35ca415ff6..197ebb0d05 100644 --- a/opc-ua-sdk/sdk-tests/pom.xml +++ b/opc-ua-sdk/sdk-tests/pom.xml @@ -34,9 +34,8 @@ test - org.testng - testng - ${testng.version} + org.junit.jupiter + junit-jupiter test diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java index 17a7b400be..af98ae2c8f 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java @@ -10,17 +10,17 @@ package org.eclipse.milo.opcua.sdk.client.api.identity; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; import org.eclipse.milo.opcua.stack.core.types.enumerated.UserTokenType; import org.eclipse.milo.opcua.stack.core.types.structured.AnonymousIdentityToken; import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; import org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; public class AnonymousProviderTest { @@ -105,7 +105,7 @@ public void testGetIdentityToken_NoMatch_Throws() { AnonymousProvider p = new AnonymousProvider(); - assertThrows(() -> p.getIdentityToken(endpoint, ByteString.NULL_VALUE)); + assertThrows(Exception.class, () -> p.getIdentityToken(endpoint, ByteString.NULL_VALUE)); } } diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java index 36fdb67a1d..e6ae963ae9 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java @@ -10,17 +10,18 @@ package org.eclipse.milo.opcua.sdk.client.config; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig; import org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; import org.eclipse.milo.opcua.stack.core.types.enumerated.UserTokenType; import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; import org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy; -import org.testng.annotations.Test; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; +import org.junit.jupiter.api.Test; public class OpcUaClientConfigTest { @@ -107,7 +108,7 @@ public void testCopyAndModify() { assertEquals(copy.getKeepAliveFailuresAllowed(), uint(2)); assertEquals(copy.getKeepAliveInterval(), uint(10000)); assertEquals(copy.getKeepAliveTimeout(), uint(15000)); - assertEquals(copy.getSessionLocaleIds(), new String[]{"en", "es"}); + assertArrayEquals(copy.getSessionLocaleIds(), new String[]{"en", "es"}); assertEquals(copy.getSubscriptionWatchdogMultiplier(), 3.0); } diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/session/SessionFsmTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/session/SessionFsmTest.java index 54b3052b12..59b7b7f0a0 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/session/SessionFsmTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/session/SessionFsmTest.java @@ -10,6 +10,9 @@ package org.eclipse.milo.opcua.sdk.client.session; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.eclipse.milo.opcua.sdk.client.OpcUaClient; import org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfig; import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; @@ -17,10 +20,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; import org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode; import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; -import org.testng.annotations.Test; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.testng.Assert.assertNotNull; +import org.junit.jupiter.api.Test; public class SessionFsmTest { diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java index 12c35f82cf..bbbbaa81a3 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java @@ -10,13 +10,14 @@ package org.eclipse.milo.opcua.sdk.client.subscriptions; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaSubscription.ClientHandleSequence; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; -import org.testng.annotations.Test; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; public class ClientHandleSequenceTest { @@ -38,7 +39,8 @@ public void testInUsePredicate() { } // Slow; enable to test manually. - @Test(enabled = false) + @Test + @Disabled public void testThrowsIfAllUsed() { ClientHandleSequence sequence = new ClientHandleSequence(h -> true); diff --git a/opc-ua-stack/bsd-parser-gson/pom.xml b/opc-ua-stack/bsd-parser-gson/pom.xml index 15fd5d9fd0..0c22e6b066 100644 --- a/opc-ua-stack/bsd-parser-gson/pom.xml +++ b/opc-ua-stack/bsd-parser-gson/pom.xml @@ -28,9 +28,8 @@ - org.testng - testng - ${testng.version} + org.junit.jupiter + junit-jupiter test diff --git a/opc-ua-stack/bsd-parser-gson/src/test/java/org/eclipse/milo/opcua/binaryschema/gson/JsonBsdParserTest.java b/opc-ua-stack/bsd-parser-gson/src/test/java/org/eclipse/milo/opcua/binaryschema/gson/JsonBsdParserTest.java index 68441f3974..79641db380 100644 --- a/opc-ua-stack/bsd-parser-gson/src/test/java/org/eclipse/milo/opcua/binaryschema/gson/JsonBsdParserTest.java +++ b/opc-ua-stack/bsd-parser-gson/src/test/java/org/eclipse/milo/opcua/binaryschema/gson/JsonBsdParserTest.java @@ -10,14 +10,15 @@ package org.eclipse.milo.opcua.binaryschema.gson; +import org.eclipse.milo.opcua.binaryschema.BsdParserTest; +import org.eclipse.milo.opcua.binaryschema.parser.BsdParser; +import org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec; +import org.junit.jupiter.api.Test; + import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonPrimitive; -import org.eclipse.milo.opcua.binaryschema.BsdParserTest; -import org.eclipse.milo.opcua.binaryschema.parser.BsdParser; -import org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec; -import org.testng.annotations.Test; public class JsonBsdParserTest extends BsdParserTest { diff --git a/opc-ua-stack/bsd-parser/pom.xml b/opc-ua-stack/bsd-parser/pom.xml index 97c57c2439..d2fd564fe4 100644 --- a/opc-ua-stack/bsd-parser/pom.xml +++ b/opc-ua-stack/bsd-parser/pom.xml @@ -41,9 +41,8 @@ - org.testng - testng - ${testng.version} + org.junit.jupiter + junit-jupiter test diff --git a/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java b/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java index 229f4ad9ee..ebbac33e98 100644 --- a/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java +++ b/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java @@ -10,11 +10,9 @@ package org.eclipse.milo.opcua.binaryschema; -import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Table; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.ByteBufUtil; -import io.netty.buffer.Unpooled; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.eclipse.milo.opcua.binaryschema.parser.BsdParser; import org.eclipse.milo.opcua.binaryschema.parser.DictionaryDescription; import org.eclipse.milo.opcua.stack.core.NamespaceTable; @@ -28,10 +26,14 @@ import org.eclipse.milo.opcua.stack.core.types.OpcUaBinaryDataTypeDictionary; import org.eclipse.milo.opcua.stack.core.types.OpcUaDataTypeManager; import org.eclipse.milo.opcua.stack.core.util.Namespaces; -import org.testng.annotations.BeforeSuite; +import org.junit.jupiter.api.BeforeEach; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.Table; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; public abstract class BsdParserTest { @@ -105,7 +107,7 @@ public BsdParserTest() { */ protected abstract BsdParser createBsdParser(); - @BeforeSuite + @BeforeEach public void parseTypeDictionary() throws Exception { BsdParser parser = createBsdParser(); diff --git a/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/GenericBsdParserTest.java b/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/GenericBsdParserTest.java index 125c158866..18cb167b6b 100644 --- a/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/GenericBsdParserTest.java +++ b/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/GenericBsdParserTest.java @@ -13,7 +13,7 @@ import org.eclipse.milo.opcua.binaryschema.parser.BsdParser; import org.eclipse.milo.opcua.stack.core.serialization.codecs.OpcUaBinaryDataTypeCodec; import org.eclipse.milo.opcua.stack.core.types.structured.Range; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class GenericBsdParserTest extends BsdParserTest { diff --git a/opc-ua-stack/pom.xml b/opc-ua-stack/pom.xml index 14eac55de4..3381914fe8 100644 --- a/opc-ua-stack/pom.xml +++ b/opc-ua-stack/pom.xml @@ -28,7 +28,7 @@ 22.0.0 4.1.108.Final 1.7.32 - 6.9.10 + 5.10.2 diff --git a/opc-ua-stack/stack-core/pom.xml b/opc-ua-stack/stack-core/pom.xml index 9afc65b780..fa8c021973 100644 --- a/opc-ua-stack/stack-core/pom.xml +++ b/opc-ua-stack/stack-core/pom.xml @@ -102,9 +102,13 @@ - org.testng - testng - ${testng.version} + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-params test diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SequenceHeaderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SequenceHeaderTest.java index a1158eb70b..bdb1109a29 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SequenceHeaderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SequenceHeaderTest.java @@ -10,15 +10,16 @@ package org.eclipse.milo.opcua.stack; -import com.google.common.primitives.UnsignedInteger; import org.eclipse.milo.opcua.stack.core.channel.headers.SequenceHeader; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import com.google.common.primitives.UnsignedInteger; public class SequenceHeaderTest extends SerializationFixture2 { - @DataProvider(name = "parameters") - public Object[][] getParameters() { + public static Object[][] getParameters() { return new Object[][]{ {0, 0}, {Integer.MAX_VALUE - 1, Integer.MAX_VALUE - 1}, @@ -28,7 +29,9 @@ public Object[][] getParameters() { }; } - @Test(dataProvider = "parameters", description = "SequenceHeader is serializable.") + @ParameterizedTest + @MethodSource("getParameters") + @DisplayName("SequenceHeader is serializable.") public void testSerialization(long sequenceNumber, long requestId) { SequenceHeader header = new SequenceHeader(sequenceNumber, requestId); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java index f817466d72..2cead5c390 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java @@ -10,14 +10,14 @@ package org.eclipse.milo.opcua.stack; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.function.BiFunction; import java.util.function.Function; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import static org.testng.Assert.assertEquals; - public class SerializationFixture2 { protected void assertSerializable(T encoded, diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SymmetricSecurityHeaderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SymmetricSecurityHeaderTest.java index 66968f5371..810d8aac1c 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SymmetricSecurityHeaderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SymmetricSecurityHeaderTest.java @@ -10,15 +10,16 @@ package org.eclipse.milo.opcua.stack; -import com.google.common.primitives.UnsignedInteger; import org.eclipse.milo.opcua.stack.core.channel.headers.SymmetricSecurityHeader; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import com.google.common.primitives.UnsignedInteger; public class SymmetricSecurityHeaderTest extends SerializationFixture2 { - @DataProvider(name = "parameters") - public Object[][] getParameters() { + public static Object[][] getParameters() { return new Object[][]{ {0}, {Integer.MAX_VALUE - 1}, @@ -28,7 +29,9 @@ public Object[][] getParameters() { }; } - @Test(dataProvider = "parameters", description = "SymmetricSecurityHeader is serializable.") + @ParameterizedTest + @MethodSource("getParameters") + @DisplayName("SymmetricSecurityHeader is serializable.") public void testSerialization(long value) { SymmetricSecurityHeader header = new SymmetricSecurityHeader(value); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java index 2bbc3960ff..517c65eb5d 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java @@ -10,13 +10,14 @@ package org.eclipse.milo.opcua.stack.core; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + import java.util.List; -import com.google.common.collect.Lists; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; +import com.google.common.collect.Lists; public class AttributeIdTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/ChunkDecoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/ChunkDecoderTest.java index d7fc05cab6..b04f15a347 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/ChunkDecoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/ChunkDecoderTest.java @@ -10,12 +10,12 @@ package org.eclipse.milo.opcua.stack.core.channel; -import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.stack.core.channel.ChunkDecoder.LegacySequenceNumberValidator.validateSequenceNumber; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; +import org.junit.jupiter.api.Test; public class ChunkDecoderTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/messages/HelloMessageTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/messages/HelloMessageTest.java index e7b14169f9..d6e674d939 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/messages/HelloMessageTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/channel/messages/HelloMessageTest.java @@ -10,13 +10,14 @@ package org.eclipse.milo.opcua.stack.core.channel.messages; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.eclipse.milo.opcua.stack.core.UaException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertThrows; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; public class HelloMessageTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultCertificateManagerTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultCertificateManagerTest.java index 7d6fafb3f0..709905cad3 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultCertificateManagerTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultCertificateManagerTest.java @@ -10,23 +10,23 @@ package org.eclipse.milo.opcua.stack.core.security; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.security.KeyPair; import java.security.cert.X509Certificate; -import org.testng.annotations.Test; - -import static org.testng.Assert.expectThrows; +import org.junit.jupiter.api.Test; public class DefaultCertificateManagerTest { @Test public void testNullPrivateKeyOrCertificateFails() { - expectThrows( - Exception.class, + assertThrows( + Exception.class, () -> new DefaultCertificateManager((KeyPair) null, (X509Certificate) null) ); - expectThrows( + assertThrows( Exception.class, () -> new DefaultCertificateManager().add(null, (X509Certificate) null) ); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java index 46b55bbb9b..d11e4cab35 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java @@ -10,16 +10,16 @@ package org.eclipse.milo.opcua.stack.core.security; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.io.File; import java.io.IOException; import java.nio.file.Files; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; public class DefaultTrustListManagerTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaBinaryStreamDecoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaBinaryStreamDecoderTest.java index 00780512b6..45901c7287 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaBinaryStreamDecoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaBinaryStreamDecoderTest.java @@ -10,12 +10,13 @@ package org.eclipse.milo.opcua.stack.core.serialization; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.eclipse.milo.opcua.stack.core.UaSerializationException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertThrows; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; public class OpcUaBinaryStreamDecoderTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaXmlStreamDecoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaXmlStreamDecoderTest.java index 6a472181a3..2eb3c37a79 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaXmlStreamDecoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/OpcUaXmlStreamDecoderTest.java @@ -10,11 +10,11 @@ package org.eclipse.milo.opcua.stack.core.serialization; -import java.io.StringReader; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.testng.annotations.Test; +import java.io.StringReader; -import static org.testng.Assert.assertNotNull; +import org.junit.jupiter.api.Test; public class OpcUaXmlStreamDecoderTest { @Test diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java index 3a8901ae75..eedfa68974 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java @@ -10,6 +10,11 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + import org.eclipse.milo.opcua.stack.core.Identifiers; import org.eclipse.milo.opcua.stack.core.NamespaceTable; import org.eclipse.milo.opcua.stack.core.serialization.TestSerializationContext; @@ -19,15 +24,13 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; import org.eclipse.milo.opcua.stack.core.types.enumerated.ApplicationType; import org.eclipse.milo.opcua.stack.core.types.structured.Argument; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; public class BinaryDecoderTest extends BinarySerializationFixture { - @Test(description = "a null array, once encoded, should decode to a null array") + @Test + @DisplayName("a null array, once encoded, should decode to a null array") public void testDecodeNullArray() { Argument argument = new Argument( "test", @@ -71,7 +74,7 @@ public void testEnumArray() { writer.writeEnumArray(null, array); ApplicationType[] decoded = (ApplicationType[]) reader.readEnumArray(null, ApplicationType.class); - assertEquals(decoded, array); + assertArrayEquals(decoded, array); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinarySerializationFixture.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinarySerializationFixture.java index 0446f863da..2db2e4a218 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinarySerializationFixture.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinarySerializationFixture.java @@ -15,7 +15,7 @@ import org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamDecoder; import org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder; import org.eclipse.milo.opcua.stack.core.serialization.TestSerializationContext; -import org.testng.annotations.BeforeMethod; +import org.junit.jupiter.api.BeforeEach; public abstract class BinarySerializationFixture { @@ -23,7 +23,7 @@ public abstract class BinarySerializationFixture { OpcUaBinaryStreamEncoder writer; OpcUaBinaryStreamDecoder reader; - @BeforeMethod + @BeforeEach public void setUp() { buffer = Unpooled.buffer(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java index bb915895d2..dd33c0dd70 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java @@ -10,7 +10,9 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import io.netty.buffer.ByteBuf; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamDecoder; import org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder; import org.eclipse.milo.opcua.stack.core.serialization.TestSerializationContext; @@ -19,18 +21,18 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; import org.eclipse.milo.opcua.stack.core.util.BufferUtil; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; +import io.netty.buffer.ByteBuf; public class DataValueSerializationTest { private final OpcUaBinaryStreamEncoder encoder = new OpcUaBinaryStreamEncoder(new TestSerializationContext()); private final OpcUaBinaryStreamDecoder decoder = new OpcUaBinaryStreamDecoder(new TestSerializationContext()); - @Test(dataProvider = "getValues") + @ParameterizedTest + @MethodSource("getValues") public void testDataValueRoundTrip(DataValue value) { ByteBuf buffer = BufferUtil.pooledBuffer(); encoder.setBuffer(buffer); @@ -42,8 +44,7 @@ public void testDataValueRoundTrip(DataValue value) { assertEquals(decodedValue, value); } - @DataProvider - public Object[][] getValues() { + public static Object[][] getValues() { return new Object[][]{ { new DataValue( diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java index 62242bc52d..11abc6453e 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java @@ -10,17 +10,16 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.eclipse.milo.opcua.stack.core.types.builtin.DiagnosticInfo; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class DiagnosticInfoSerializationTest extends BinarySerializationFixture { - @DataProvider(name = "DiagnosticInfoProvider") - public Object[][] getDiagnosticInfos() { + public static Object[][] getDiagnosticInfos() { return new Object[][]{ {null}, {new DiagnosticInfo(1, -1, -1, -1, null, null, null)}, @@ -34,7 +33,8 @@ public Object[][] getDiagnosticInfos() { }; } - @Test(dataProvider = "DiagnosticInfoProvider") + @ParameterizedTest + @MethodSource("getDiagnosticInfos") public void testDiagnosticInfoRoundTrip(DiagnosticInfo diagnosticInfo) { writer.writeDiagnosticInfo(diagnosticInfo); DiagnosticInfo decoded = reader.readDiagnosticInfo(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java index c1b34e1afd..45b86fed77 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java @@ -15,17 +15,17 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.util.Namespaces; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ExpandedNodeIdSerializationTest extends BinarySerializationFixture { - @DataProvider - public Object[][] getExpandedNodeIds() { + public static Object[][] getExpandedNodeIds() { return new Object[][]{ {new ExpandedNodeId(ushort(0), null, uint(0))}, {new ExpandedNodeId(ushort(0), null, "hello, world")}, @@ -42,7 +42,9 @@ public Object[][] getExpandedNodeIds() { }; } - @Test(dataProvider = "getExpandedNodeIds", description = "ExpandedNodeId is round-trip serializable.") + @ParameterizedTest + @MethodSource("getExpandedNodeIds") + @DisplayName("ExpandedNodeId is round-trip serializable.") public void testExpandedNodeIdRoundTrip(ExpandedNodeId nodeId) throws Exception { writer.writeExpandedNodeId(nodeId); ExpandedNodeId decoded = reader.readExpandedNodeId(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java index 92c5c9b142..059f31e4f7 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java @@ -10,26 +10,28 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.XmlElement; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ExtensionObjectSerializationTest extends BinarySerializationFixture { - @DataProvider - public Object[][] getExtensionObjects() { + public static Object[][] getExtensionObjects() { return new Object[][]{ {new ExtensionObject(ByteString.of(new byte[]{1, 2, 3, 4}), new NodeId(1, 2))}, {new ExtensionObject(XmlElement.of("hello"), new NodeId(1, 2))}, }; } - @Test(dataProvider = "getExtensionObjects", description = "ExtensionObject is round-trip serializable.") + @ParameterizedTest + @MethodSource("getExtensionObjects") + @DisplayName("ExtensionObject is round-trip serializable.") public void testExtensionObjectRoundTrip(ExtensionObject xo) throws Exception { writer.writeExtensionObject(xo); ExtensionObject decoded = reader.readExtensionObject(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java index 52909d88e2..77f63b8226 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java @@ -10,17 +10,17 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import java.util.UUID; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.util.UUID; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class GuidSerializationTest extends BinarySerializationFixture { - @DataProvider(name = "GuidProvider") - public Object[][] getGuids() { + public static Object[][] getGuids() { return new Object[][]{ {UUID.fromString("C496578A-0DFE-4b8f-870A-745238C6AEAE")}, {UUID.fromString("72962B91-FA75-4ae6-8D28-B404DC7DAF63")}, @@ -30,7 +30,9 @@ public Object[][] getGuids() { }; } - @Test(dataProvider = "GuidProvider", description = "Guid is round-trip serializable.") + @ParameterizedTest + @MethodSource("getGuids") + @DisplayName("Guid is round-trip serializable.") public void testGuidRoundTrip(UUID uuid) throws Exception { writer.writeGuid(uuid); UUID decoded = reader.readGuid(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java index 3ecc7b626c..4c668bc892 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java @@ -10,16 +10,16 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.testng.Assert.assertEquals; +import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class LocalizedTextSerializationTest extends BinarySerializationFixture { - @DataProvider - public Object[][] getLocalizedTexts() { + public static Object[][] getLocalizedTexts() { return new Object[][]{ {new LocalizedText(null, null)}, {new LocalizedText("locale", null)}, @@ -28,7 +28,9 @@ public Object[][] getLocalizedTexts() { }; } - @Test(dataProvider = "getLocalizedTexts", description = "LocalizedText is round-trip serializable.") + @ParameterizedTest + @MethodSource("getLocalizedTexts") + @DisplayName("LocalizedText is round-trip serializable.") public void testLocalizedText(LocalizedText localizedText) throws Exception { writer.writeLocalizedText(localizedText); LocalizedText decoded = reader.readLocalizedText(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java index e5ea145114..450f47c5cf 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java @@ -10,19 +10,19 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.UUID; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class NodeIdSerializationTest extends BinarySerializationFixture { - @DataProvider - public Object[][] getNodeIds() { + public static Object[][] getNodeIds() { return new Object[][]{ {new NodeId(0, 0)}, {new NodeId(0, 1)}, @@ -46,7 +46,9 @@ public Object[][] getNodeIds() { }; } - @Test(dataProvider = "getNodeIds", description = "NodeId is round-trip serializable.") + @ParameterizedTest + @MethodSource("getNodeIds") + @DisplayName("NodeId is round-trip serializable.") public void testNodeIdRoundTrip(NodeId nodeId) throws Exception { writer.writeNodeId(nodeId); NodeId decoded = reader.readNodeId(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java index da7b21ea7a..205996b383 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java @@ -10,21 +10,22 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamEncoder; import org.eclipse.milo.opcua.stack.core.serialization.TestSerializationContext; -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; public class OpcUaBinaryStreamEncoderTest { ByteBuf buffer; OpcUaBinaryStreamEncoder writer; - @BeforeTest + @BeforeAll public void initializeTest() { buffer = Unpooled.buffer(); writer = new OpcUaBinaryStreamEncoder(new TestSerializationContext()).setBuffer(buffer); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java index b30347f229..9a03523947 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java @@ -10,15 +10,14 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class StringSerializationTest extends BinarySerializationFixture { - @DataProvider(name = "StringProvider") - public Object[][] getStrings() { + public static Object[][] getStrings() { return new Object[][]{ {null}, {""}, @@ -27,7 +26,8 @@ public Object[][] getStrings() { }; } - @Test(dataProvider = "StringProvider") + @ParameterizedTest + @MethodSource("getStrings") public void testStringRoundTrip(String value) { writer.writeString(value); String decoded = reader.readString(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java index c72c906e95..cdfc8557dd 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java @@ -10,8 +10,11 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.serialization.OpcUaBinaryStreamDecoder; import org.eclipse.milo.opcua.stack.core.serialization.TestSerializationContext; @@ -19,19 +22,17 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; import org.eclipse.milo.opcua.stack.core.types.structured.ServiceCounterDataType; -import org.testng.Assert; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; public class VariantSerializationTest extends BinarySerializationFixture { - @DataProvider(name = "VariantProvider") - public Object[][] getVariants() { + public static Object[][] getVariants() { return new Object[][]{ {new Variant(null)}, {new Variant("hello, world")}, @@ -46,7 +47,8 @@ public Object[][] getVariants() { }; } - @Test(dataProvider = "VariantProvider") + @ParameterizedTest + @MethodSource("getVariants") public void testVariantRoundTrip(Variant variant) { writer.writeVariant(variant); Variant decoded = reader.readVariant(); @@ -68,12 +70,11 @@ public void testVariant_UaStructure() { ExtensionObject extensionObject = (ExtensionObject) decoded.getValue(); ServiceCounterDataType sc2 = (ServiceCounterDataType) extensionObject.decode(new TestSerializationContext()); - Assert.assertEquals(sc1.getTotalCount(), sc2.getTotalCount()); - Assert.assertEquals(sc1.getErrorCount(), sc2.getErrorCount()); + assertEquals(sc1.getTotalCount(), sc2.getTotalCount()); + assertEquals(sc1.getErrorCount(), sc2.getErrorCount()); } - @DataProvider(name = "PrimitiveArrayVariantProvider") - public Object[][] getPrimitiveArrayVariants() { + public static Object[][] getPrimitiveArrayVariants() { return new Object[][]{ {new Variant(new int[]{0, 1, 2, 3}), new Variant(new Integer[]{0, 1, 2, 3})}, @@ -89,8 +90,9 @@ public Object[][] getPrimitiveArrayVariants() { }; } - @Test(dataProvider = "PrimitiveArrayVariantProvider", - description = "Test that after primitive array types given to variants come out as expected after encoding/decoding.") + @ParameterizedTest + @MethodSource("getPrimitiveArrayVariants") + @DisplayName("Test that after primitive array types given to variants come out as expected after encoding/decoding.") public void testPrimitiveArrayVariantRoundTrip(Variant variant, Variant expected) { writer.writeVariant(variant); Variant decoded = reader.readVariant(); @@ -98,7 +100,8 @@ public void testPrimitiveArrayVariantRoundTrip(Variant variant, Variant expected assertEquals(decoded, expected); } - @Test(description = "Test that a Variant containing a null array encoded with a negative array size to indicate a null value decodes properly.") + @Test + @DisplayName("Test that a Variant containing a null array encoded with a negative array size to indicate a null value decodes properly.") public void testNullArrayEncodedWithNegativeArraySize() { ByteBuf buffer = Unpooled.buffer(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java index 2e3cafa1ec..39082752c9 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java @@ -10,23 +10,25 @@ package org.eclipse.milo.opcua.stack.core.serialization.binary; -import org.eclipse.milo.opcua.stack.core.types.builtin.XmlElement; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.testng.Assert.assertEquals; +import org.eclipse.milo.opcua.stack.core.types.builtin.XmlElement; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class XmlElementSerializationTest extends BinarySerializationFixture { - @DataProvider(name = "XmlElementProvider") - public Object[][] getXmlElements() { + public static Object[][] getXmlElements() { return new Object[][]{ {new XmlElement(null)}, {new XmlElement("hello, world")}, }; } - @Test(dataProvider = "XmlElementProvider", description = "XmlElement is round-trip serializable.") + @ParameterizedTest + @MethodSource("getXmlElements") + @DisplayName("XmlElement is round-trip serializable.") public void testXmlElementRoundTrip(XmlElement element) throws Exception { writer.writeXmlElement(element); XmlElement decoded = reader.readXmlElement(); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java index d7029a5ea8..5ec141b7c4 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java @@ -10,10 +10,10 @@ package org.eclipse.milo.opcua.stack.core.types.builtin; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; +import org.junit.jupiter.api.Test; public class ByteStringTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java index 795ad90d1f..a745bcad39 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java @@ -13,15 +13,15 @@ package org.eclipse.milo.opcua.stack.core.types.builtin; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.time.Instant; import java.time.LocalDateTime; import java.time.Month; import java.time.ZoneId; import java.time.ZonedDateTime; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class DateTimeTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java index d9171f4ee8..d70dfad549 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java @@ -10,19 +10,19 @@ package org.eclipse.milo.opcua.stack.core.types.builtin; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.UUID; import org.eclipse.milo.opcua.stack.core.NamespaceTable; import org.eclipse.milo.opcua.stack.core.util.Namespaces; -import org.testng.annotations.Test; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; public class ExpandedNodeIdTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java index a4004484e6..f19b71de72 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java @@ -10,8 +10,18 @@ package org.eclipse.milo.opcua.stack.core.types.builtin; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Random; import java.util.UUID; + import javax.xml.bind.DatatypeConverter; import org.eclipse.milo.opcua.stack.core.NamespaceTable; @@ -20,16 +30,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort; import org.eclipse.milo.opcua.stack.core.util.Namespaces; -import org.testng.annotations.Test; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; public class NodeIdTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java index 43da238749..a4cac5f800 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java @@ -10,8 +10,9 @@ package org.eclipse.milo.opcua.stack.core.types.builtin; -import org.testng.Assert; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; public class QualifiedNameTest { @@ -27,7 +28,7 @@ public void testToStringAndBack2() { private void assertSymmetry(String string) { String reString = QualifiedName.parse(string).toParseableString(); - Assert.assertEquals(reString, string); + assertEquals(reString, string); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/VariantTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/VariantTest.java index 5229f3fd5a..25cce87cd8 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/VariantTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/VariantTest.java @@ -10,7 +10,9 @@ package org.eclipse.milo.opcua.stack.core.types.builtin; -import org.testng.annotations.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.junit.jupiter.api.Test; public class VariantTest { @@ -24,14 +26,14 @@ public void variantCanContainVariantArray() { new Variant(new Variant[]{new Variant(0), new Variant(1), new Variant(2)}); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void variantCannotContainVariant() { - new Variant(new Variant(null)); + assertThrows(IllegalArgumentException.class, () -> new Variant(new Variant(null))); } - @Test(expectedExceptions = IllegalArgumentException.class) + @Test public void variantCannotContainDiagnosticInfo() { - new Variant(DiagnosticInfo.NULL_VALUE); + assertThrows(IllegalArgumentException.class, () -> new Variant(DiagnosticInfo.NULL_VALUE)); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java index 566e8b517e..2d3d2171a9 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java @@ -10,11 +10,12 @@ package org.eclipse.milo.opcua.stack.core.types.structured; +import static org.junit.jupiter.api.Assertions.assertEquals; + import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; import org.eclipse.milo.opcua.stack.core.types.enumerated.ApplicationType; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; public class ApplicationDescriptionTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java index 1eed69a82b..f24156cd21 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java @@ -10,17 +10,17 @@ package org.eclipse.milo.opcua.stack.core.util; -import java.lang.reflect.Array; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; +import java.lang.reflect.Array; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; public class ArrayUtilTest { - @DataProvider(name = "arrays") - public Object[][] getArrays() { + public static Object[][] getArrays() { return new Object[][]{ {new Integer[]{0, 1, 2, 3, 4, 5, 6, 7}}, {new int[]{0, 1, 2, 3, 4, 5, 6, 7}}, @@ -29,15 +29,20 @@ public Object[][] getArrays() { }; } - @Test(dataProvider = "arrays") + @ParameterizedTest + @MethodSource("getArrays") public void testRoundTrip(Object array) throws Exception { Object flattened = ArrayUtil.flatten(array); Object unflattened = ArrayUtil.unflatten(flattened, ArrayUtil.getDimensions(array)); - - assertEquals(unflattened, array); + if (array instanceof Object[]) { + assertArrayEquals((Object[]) unflattened, (Object[]) array); + } else if (array instanceof int[]){ + assertArrayEquals((int[]) unflattened, (int[]) array); + } } - @Test(dataProvider = "arrays") + @ParameterizedTest + @MethodSource("getArrays") public void testFlatten(Object array) throws Exception { Object flattened = ArrayUtil.flatten(array); @@ -46,8 +51,7 @@ public void testFlatten(Object array) throws Exception { } } - @DataProvider(name = "dimensions") - public Object[][] getDimensions() { + public static Object[][] getDimensions() { return new Object[][]{ {new int[0], new int[]{0}}, {new int[1], new int[]{1}}, @@ -58,13 +62,13 @@ public Object[][] getDimensions() { }; } - @Test(dataProvider = "dimensions") + @ParameterizedTest + @MethodSource("getDimensions") public void testGetDimensions(Object array, int[] dimensions) throws Exception { - assertEquals(ArrayUtil.getDimensions(array), dimensions); + assertArrayEquals(ArrayUtil.getDimensions(array), dimensions); } - @DataProvider(name = "typedArrays") - public Object[][] getTypedArrays() { + public static Object[][] getTypedArrays() { return new Object[][]{ {new int[1], int.class}, {new int[2][2], int.class}, @@ -78,7 +82,8 @@ public Object[][] getTypedArrays() { }; } - @Test(dataProvider = "typedArrays") + @ParameterizedTest + @MethodSource("getTypedArrays") public void testGetType(Object array, Class type) throws Exception { assertEquals(ArrayUtil.getType(array), type); } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java index 4b31b248ef..7a20cf3e6d 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java @@ -15,11 +15,11 @@ import java.util.List; import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import static com.google.common.collect.Lists.newArrayList; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class CertificateUtilTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java index 7def65528c..6d94330e0f 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java @@ -10,10 +10,10 @@ package org.eclipse.milo.opcua.stack.core.util; -import org.testng.annotations.Test; - import static org.eclipse.milo.opcua.stack.core.util.EndpointUtil.updateUrl; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; public class EndpointUtilTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java index cf33e04fd0..1ec939a8a4 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java @@ -10,16 +10,16 @@ package org.eclipse.milo.opcua.stack.core.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; +import org.junit.jupiter.api.Test; public class ExecutionQueueTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java index cce416ba22..a621f1e04e 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java @@ -10,13 +10,13 @@ package org.eclipse.milo.opcua.stack.core.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; +import org.junit.jupiter.api.Test; public class LazyTest { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java index af31c09027..bb8328ba01 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java @@ -10,14 +10,14 @@ package org.eclipse.milo.opcua.stack.core.util; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.milo.opcua.stack.core.UaException; import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.assertTrue; +import org.junit.jupiter.api.Test; public class NonceUtilTest { @@ -52,7 +52,7 @@ public void testNonceGeneration() throws UaException { public void testShortNonceThrows() { ByteString nonce = NonceUtil.generateNonce(NonceUtil.MINIMUM_NONCE_LENGTH - 1); - assertThrows(() -> NonceUtil.validateNonce(nonce)); + assertThrows(Exception.class, () -> NonceUtil.validateNonce(nonce)); } @Test diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java index 60fa026c0b..848d74943d 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java @@ -10,6 +10,18 @@ package org.eclipse.milo.opcua.stack.core.util.validation; +import static com.google.common.collect.Lists.newArrayList; +import static com.google.common.collect.Sets.newHashSet; +import static java.util.Collections.emptySet; +import static org.eclipse.milo.opcua.stack.core.util.validation.CertificateValidationUtil.buildTrustedCertPath; +import static org.eclipse.milo.opcua.stack.core.util.validation.CertificateValidationUtil.validateTrustedCertPath; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.InputStream; import java.security.KeyStore; import java.security.KeyStoreException; @@ -33,19 +45,8 @@ import org.eclipse.milo.opcua.stack.core.StatusCodes; import org.eclipse.milo.opcua.stack.core.UaException; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; - -import static com.google.common.collect.Lists.newArrayList; -import static com.google.common.collect.Sets.newHashSet; -import static java.util.Collections.emptySet; -import static org.eclipse.milo.opcua.stack.core.util.validation.CertificateValidationUtil.buildTrustedCertPath; -import static org.eclipse.milo.opcua.stack.core.util.validation.CertificateValidationUtil.validateTrustedCertPath; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.expectThrows; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class CertificateValidationUtilTest { @@ -66,7 +67,7 @@ public class CertificateValidationUtilTest { private X509Certificate leafIntermediateSigned; private X509Certificate uriWithSpaces; - @BeforeSuite + @BeforeAll public void loadKeyStore() throws Exception { keyStore = KeyStore.getInstance("PKCS12"); @@ -99,7 +100,7 @@ public void testBuildTrustedCertPath_LeafSelfSigned() throws Exception { public void testBuildTrustedCertPath_LeafSelfSigned_NotTrusted() { List certificateChain = newArrayList(leafSelfSigned); - expectThrows( + assertThrows( UaException.class, () -> buildTrustedCertPath( certificateChain, @@ -196,7 +197,7 @@ public void testBuildAndValidate_LeafIntermediateSigned_Revoked() { { List certificateChain = newArrayList(leafIntermediateSigned); - UaException e = expectThrows(UaException.class, () -> { + UaException e = assertThrows(UaException.class, () -> { HashSet x509CRLS = newHashSet( generateCrl( caIntermediate, @@ -239,7 +240,7 @@ public void testBuildAndValidate_LeafIntermediateSigned_Revoked() { { List certificateChain = newArrayList(leafIntermediateSigned); - UaException e = expectThrows(UaException.class, () -> { + UaException e = assertThrows(UaException.class, () -> { HashSet x509CRLS = newHashSet( generateCrl( caRoot, @@ -277,7 +278,7 @@ public void testBuildAndValidate_LeafIntermediateSigned_Revoked() { @Test public void testBuildTrustedCertPath_NoTrusted_NoIssuers() { - expectThrows(UaException.class, () -> + assertThrows(UaException.class, () -> buildTrustedCertPath( newArrayList(leafSelfSigned), emptySet(), @@ -285,7 +286,7 @@ public void testBuildTrustedCertPath_NoTrusted_NoIssuers() { ) ); - expectThrows(UaException.class, () -> + assertThrows(UaException.class, () -> buildTrustedCertPath( newArrayList(leafIntermediateSigned), emptySet(), @@ -293,7 +294,7 @@ public void testBuildTrustedCertPath_NoTrusted_NoIssuers() { ) ); - expectThrows(UaException.class, () -> + assertThrows(UaException.class, () -> buildTrustedCertPath( newArrayList(leafIntermediateSigned, caIntermediate), emptySet(), @@ -301,7 +302,7 @@ public void testBuildTrustedCertPath_NoTrusted_NoIssuers() { ) ); - expectThrows(UaException.class, () -> + assertThrows(UaException.class, () -> buildTrustedCertPath( newArrayList(leafIntermediateSigned, caIntermediate, caRoot), emptySet(), @@ -361,7 +362,7 @@ public void testBuildAndValidate_IssuerRevoked() { { List certificateChain = newArrayList(leafIntermediateSigned); - UaException e = expectThrows(UaException.class, () -> { + UaException e = assertThrows(UaException.class, () -> { HashSet x509CRLS = newHashSet( generateCrl( caRoot, diff --git a/opc-ua-stack/stack-tests/pom.xml b/opc-ua-stack/stack-tests/pom.xml index 34fd57761c..5ecc3298a7 100644 --- a/opc-ua-stack/stack-tests/pom.xml +++ b/opc-ua-stack/stack-tests/pom.xml @@ -28,9 +28,13 @@ test - org.testng - testng - ${testng.version} + org.junit.jupiter + junit-jupiter + test + + + org.junit.jupiter + junit-jupiter-params test diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java index 6c6f19edef..3fbee01e25 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java @@ -10,12 +10,15 @@ package org.eclipse.milo.opcua.stack; +import static org.eclipse.milo.opcua.stack.core.channel.EncodingLimits.DEFAULT_MAX_CHUNK_SIZE; +import static org.eclipse.milo.opcua.stack.core.channel.EncodingLimits.DEFAULT_MAX_MESSAGE_SIZE; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + import java.security.Security; import java.util.ArrayList; import java.util.List; -import io.netty.buffer.ByteBuf; -import io.netty.util.ReferenceCountUtil; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.eclipse.milo.opcua.stack.client.transport.uasc.ClientSecureChannel; import org.eclipse.milo.opcua.stack.core.channel.ChannelParameters; @@ -31,15 +34,15 @@ import org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode; import org.eclipse.milo.opcua.stack.core.util.BufferUtil; import org.eclipse.milo.opcua.stack.core.util.LongSequence; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static org.eclipse.milo.opcua.stack.core.channel.EncodingLimits.DEFAULT_MAX_CHUNK_SIZE; -import static org.eclipse.milo.opcua.stack.core.channel.EncodingLimits.DEFAULT_MAX_MESSAGE_SIZE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.fail; +import io.netty.buffer.ByteBuf; +import io.netty.util.ReferenceCountUtil; + public class ChunkSerializationTest extends SecureChannelFixture { @@ -95,8 +98,7 @@ public class ChunkSerializationTest extends SecureChannelFixture { ); - @DataProvider - public Object[][] getAsymmetricSecurityParameters() { + public static Object[][] getAsymmetricSecurityParameters() { return new Object[][]{ {SecurityPolicy.None, MessageSecurityMode.None, 128}, {SecurityPolicy.Basic128Rsa15, MessageSecurityMode.Sign, 128}, @@ -251,7 +253,8 @@ public void testSymmetric4096() throws Exception { } - @Test(dataProvider = "getAsymmetricSecurityParameters") + @ParameterizedTest + @MethodSource("getAsymmetricSecurityParameters") public void testAsymmetricMessage(SecurityPolicy securityPolicy, MessageSecurityMode messageSecurity, int messageSize) throws Exception { @@ -324,8 +327,7 @@ public void testAsymmetricMessage(SecurityPolicy securityPolicy, } } - @DataProvider - public Object[][] getSymmetricSecurityParameters() { + public static Object[][] getSymmetricSecurityParameters() { return new Object[][]{ {SecurityPolicy.None, MessageSecurityMode.None}, {SecurityPolicy.Basic128Rsa15, MessageSecurityMode.Sign}, @@ -341,7 +343,8 @@ public Object[][] getSymmetricSecurityParameters() { }; } - @Test(dataProvider = "getSymmetricSecurityParameters") + @ParameterizedTest + @MethodSource("getSymmetricSecurityParameters") public void testSymmetricMessage(SecurityPolicy securityPolicy, MessageSecurityMode messageSecurity) throws Exception { diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientCertificateValidatorIT.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientCertificateValidatorIT.java index 07cf0ee315..3fcb21ce59 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientCertificateValidatorIT.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientCertificateValidatorIT.java @@ -10,6 +10,8 @@ package org.eclipse.milo.opcua.stack; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.security.cert.X509Certificate; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -20,11 +22,9 @@ import org.eclipse.milo.opcua.stack.core.UaException; import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; - -import static org.testng.Assert.assertTrue; public class ClientCertificateValidatorIT extends StackIntegrationTest { diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java index 104b0c3aa2..a14ac9191a 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java @@ -10,6 +10,17 @@ package org.eclipse.milo.opcua.stack; +import static com.google.common.collect.Lists.newArrayList; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ulong; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; +import static org.eclipse.milo.opcua.stack.core.util.ConversionUtil.a; +import static org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; + import java.security.Security; import java.security.cert.X509Certificate; import java.util.Collections; @@ -19,7 +30,6 @@ import java.util.UUID; import java.util.concurrent.CompletableFuture; -import com.beust.jcommander.internal.Lists; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.eclipse.milo.opcua.stack.client.DiscoveryClient; import org.eclipse.milo.opcua.stack.client.UaStackClient; @@ -57,23 +67,15 @@ import org.eclipse.milo.opcua.stack.server.EndpointConfiguration; import org.eclipse.milo.opcua.stack.server.UaStackServer; import org.eclipse.milo.opcua.stack.server.UaStackServerConfig; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import static com.google.common.collect.Lists.newArrayList; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ulong; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ushort; -import static org.eclipse.milo.opcua.stack.core.util.ConversionUtil.a; -import static org.eclipse.milo.opcua.stack.core.util.ConversionUtil.l; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertThrows; -import static org.testng.Assert.fail; +import com.google.common.collect.Lists; public class ClientServerTest extends SecurityFixture { @@ -85,8 +87,7 @@ public class ClientServerTest extends SecurityFixture { private static final UInteger DEFAULT_TIMEOUT_HINT = uint(60000); - @DataProvider - public Object[][] getVariants() { + public static Object[][] getVariants() { return new Object[][]{ {new Variant(true)}, {new Variant((byte) 1)}, @@ -122,7 +123,7 @@ public Object[][] getVariants() { private UaStackServer server; - @BeforeSuite + @BeforeEach public void setUpClientServer() throws Exception { super.setUp(); @@ -143,7 +144,7 @@ public void setUpClientServer() throws Exception { .toArray(new EndpointDescription[0]); } - @AfterSuite + @AfterEach public void tearDownClientServer() throws Exception { server.shutdown().get(); } @@ -170,7 +171,8 @@ private void setReadRequestHandler(Variant variant) { }); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_NoSecurity(Variant input) throws Exception { EndpointDescription endpoint = endpoints[0]; @@ -182,7 +184,8 @@ public void testClientServerRoundTrip_TestStack_NoSecurity(Variant input) throws connectAndTest(input, client); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_Basic128Rsa15_Sign(Variant input) throws Exception { EndpointDescription endpoint = endpoints[1]; @@ -194,7 +197,8 @@ public void testClientServerRoundTrip_TestStack_Basic128Rsa15_Sign(Variant input connectAndTest(input, client); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_Basic256_Sign(Variant input) throws Exception { EndpointDescription endpoint = endpoints[2]; @@ -206,7 +210,8 @@ public void testClientServerRoundTrip_TestStack_Basic256_Sign(Variant input) thr connectAndTest(input, client); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_Basic256Sha256_Sign(Variant input) throws Exception { EndpointDescription endpoint = endpoints[3]; @@ -218,7 +223,8 @@ public void testClientServerRoundTrip_TestStack_Basic256Sha256_Sign(Variant inpu connectAndTest(input, client); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_Basic128Rsa15_SignAndEncrypt(Variant input) throws Exception { EndpointDescription endpoint = endpoints[4]; @@ -230,7 +236,8 @@ public void testClientServerRoundTrip_TestStack_Basic128Rsa15_SignAndEncrypt(Var connectAndTest(input, client); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_Basic256_SignAndEncrypt(Variant input) throws Exception { EndpointDescription endpoint = endpoints[5]; @@ -242,7 +249,8 @@ public void testClientServerRoundTrip_TestStack_Basic256_SignAndEncrypt(Variant connectAndTest(input, client); } - @Test(dataProvider = "getVariants") + @ParameterizedTest + @MethodSource("getVariants") public void testClientServerRoundTrip_TestStack_Basic256Sha256_SignAndEncrypt(Variant input) throws Exception { EndpointDescription endpoint = endpoints[6]; @@ -339,7 +347,7 @@ public void testClientDisconnect() throws Exception { client.disconnect().get(); - assertThrows(() -> client.sendRequest(request).get()); + assertThrows(Exception.class, () -> client.sendRequest(request).get()); } @Test diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/SecurityFixture.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/SecurityFixture.java index e5527e833d..3dd5fec997 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/SecurityFixture.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/SecurityFixture.java @@ -19,7 +19,7 @@ import org.eclipse.milo.opcua.stack.core.security.CertificateManager; import org.eclipse.milo.opcua.stack.server.security.ServerCertificateValidator; -import org.testng.annotations.BeforeSuite; +import org.junit.jupiter.api.BeforeEach; public abstract class SecurityFixture { @@ -48,7 +48,7 @@ public abstract class SecurityFixture { protected volatile CertificateManager serverCertificateManager; protected volatile ServerCertificateValidator serverCertificateValidator; - @BeforeSuite + @BeforeEach public void setUp() throws Exception { KeyStore keyStore = KeyStore.getInstance("PKCS12"); diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/StackIntegrationTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/StackIntegrationTest.java index dcbe424f49..5eab098e23 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/StackIntegrationTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/StackIntegrationTest.java @@ -10,6 +10,9 @@ package org.eclipse.milo.opcua.stack; +import static com.google.common.collect.Lists.newArrayList; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; + import java.security.KeyPair; import java.security.Security; import java.security.cert.X509Certificate; @@ -35,14 +38,11 @@ import org.eclipse.milo.opcua.stack.server.UaStackServer; import org.eclipse.milo.opcua.stack.server.UaStackServerConfig; import org.eclipse.milo.opcua.stack.server.UaStackServerConfigBuilder; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; - -import static com.google.common.collect.Lists.newArrayList; -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; public abstract class StackIntegrationTest extends SecurityFixture { @@ -66,7 +66,7 @@ public abstract class StackIntegrationTest extends SecurityFixture { protected UaStackClient stackClient; protected UaStackServer stackServer; - @BeforeSuite + @BeforeEach public void setUpClientServer() throws Exception { super.setUp(); @@ -173,7 +173,7 @@ public void setUpClientServer() throws Exception { stackClient.connect().get(); } - @AfterSuite + @AfterEach public void tearDownClientServer() throws Exception { stackClient.disconnect().get(); stackServer.shutdown().get(); diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java index 9760aa9849..d4d68b6687 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java @@ -10,6 +10,9 @@ package org.eclipse.milo.opcua.stack.client.config; +import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.security.cert.X509Certificate; import java.util.List; import java.util.Optional; @@ -22,10 +25,7 @@ import org.eclipse.milo.opcua.stack.core.types.enumerated.UserTokenType; import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription; import org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy; -import org.testng.annotations.Test; - -import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; -import static org.testng.Assert.assertEquals; +import org.junit.jupiter.api.Test; public class UaStackClientConfigTest extends SecurityFixture { diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java index 8b56c7b248..4af592abbf 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java @@ -10,21 +10,22 @@ package org.eclipse.milo.opcua.stack.server; -import com.google.common.collect.ImmutableList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; import org.eclipse.milo.opcua.stack.core.transport.TransportProfile; import org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode; import org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.expectThrows; +import com.google.common.collect.ImmutableList; public class EndpointConfigurationTest { @Test public void securityMismatchThrows() { - expectThrows( + assertThrows( IllegalArgumentException.class, () -> // mismatch between securityPolicy and securityMode @@ -34,7 +35,7 @@ public void securityMismatchThrows() { .build() ); - expectThrows( + assertThrows( IllegalArgumentException.class, () -> // mismatch between securityPolicy and securityMode @@ -47,7 +48,7 @@ public void securityMismatchThrows() { @Test public void missingCertificateThrows() { - expectThrows( + assertThrows( IllegalStateException.class, () -> // missing certificate @@ -60,7 +61,7 @@ public void missingCertificateThrows() { @Test public void unsupportedTransportThrows() { - expectThrows( + assertThrows( IllegalArgumentException.class, () -> EndpointConfiguration.newBuilder() @@ -68,7 +69,7 @@ public void unsupportedTransportThrows() { .build() ); - expectThrows( + assertThrows( IllegalArgumentException.class, () -> EndpointConfiguration.newBuilder() @@ -76,7 +77,7 @@ public void unsupportedTransportThrows() { .build() ); - expectThrows( + assertThrows( IllegalArgumentException.class, () -> EndpointConfiguration.newBuilder() @@ -84,7 +85,7 @@ public void unsupportedTransportThrows() { .build() ); - expectThrows( + assertThrows( IllegalArgumentException.class, () -> EndpointConfiguration.newBuilder() diff --git a/pom.xml b/pom.xml index c0eb3f050f..aa324b9293 100644 --- a/pom.xml +++ b/pom.xml @@ -399,6 +399,18 @@ + + + + + org.junit + junit-bom + 5.10.2 + pom + import + + + From b75b70428e65344bce59fff475f3326df24b6bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Fri, 19 Apr 2024 17:03:17 +0200 Subject: [PATCH 2/3] Invert parameters of assertEquals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Pupier --- .../dtd/DataTypeDictionaryReaderTest.java | 2 +- .../opcua/sdk/client/AddressSpaceTest.java | 12 ++-- .../milo/opcua/sdk/client/UaNodeTest.java | 10 ++-- .../opcua/sdk/client/UaObjectNodeTest.java | 2 +- .../opcua/sdk/client/UaVariableNodeTest.java | 2 +- .../sdk/client/methods/UaMethodTest.java | 16 ++--- .../AbstractManagedItemTest.java | 58 +++++++++---------- .../BatchModifyMonitoredItemsTest.java | 18 +++--- .../BatchSetMonitoringModeTest.java | 16 ++--- .../subscriptions/ManagedDataItemTest.java | 38 ++++++------ .../subscriptions/ManagedEventItemTest.java | 2 +- .../ManagedSubscriptionTest.java | 50 ++++++++-------- .../milo/opcua/sdk/core/DataTypeTreeTest.java | 24 ++++---- .../AbstractMethodInvocationHandlerTest.java | 12 ++-- .../server/api/util/AttributeWriterTest.java | 8 +-- .../sdk/server/util/GroupMapCollateTest.java | 2 +- .../milo/opcua/sdk/core/AccessLevelTest.java | 6 +- .../sdk/core/CefactEngineeringUnitsTest.java | 2 +- .../milo/opcua/sdk/core/NumericRangeTest.java | 10 ++-- .../milo/opcua/sdk/core/ReferenceTest.java | 2 +- .../sdk/server/LifecycleManagerTest.java | 26 ++++----- .../api/config/OpcUaServerConfigTest.java | 8 +-- .../conversions/AbstractConversionTest.java | 6 +- .../conversions/BooleanConversionsTest.java | 44 +++++++------- .../conversions/ByteConversionsTest.java | 46 +++++++-------- .../ByteStringConversionsTest.java | 5 +- .../conversions/DateTimeConversionsTest.java | 12 ++-- .../ExpandedNodeIdConversionsTest.java | 6 +- .../conversions/GuidConversionsTest.java | 4 +- .../LocalizedTextConversionsTest.java | 2 +- .../conversions/NodeIdConversionsTest.java | 4 +- .../QualifiedNameConversionsTest.java | 6 +- .../opcua/sdk/server/nodes/UaNodeTest.java | 10 ++-- .../delegates/AttributeDelegateChainTest.java | 10 ++-- .../filters/AttributeFilterChainTest.java | 8 +-- .../milo/opcua/sdk/client/OpcUaClientIT.java | 4 +- .../api/identity/AnonymousProviderTest.java | 4 +- .../client/config/OpcUaClientConfigTest.java | 38 ++++++------ .../ClientHandleSequenceTest.java | 10 ++-- .../opcua/binaryschema/BsdParserTest.java | 4 +- .../opcua/stack/SerializationFixture2.java | 2 +- .../opcua/stack/core/AttributeIdTest.java | 28 ++++----- .../security/DefaultTrustListManagerTest.java | 8 +-- .../binary/BinaryDecoderTest.java | 4 +- .../binary/DataValueSerializationTest.java | 2 +- .../DiagnosticInfoSerializationTest.java | 2 +- .../ExpandedNodeIdSerializationTest.java | 2 +- .../ExtensionObjectSerializationTest.java | 2 +- .../binary/GuidSerializationTest.java | 2 +- .../LocalizedTextSerializationTest.java | 2 +- .../binary/NodeIdSerializationTest.java | 2 +- .../binary/OpcUaBinaryStreamEncoderTest.java | 8 +-- .../binary/StringSerializationTest.java | 2 +- .../binary/VariantSerializationTest.java | 8 +-- .../binary/XmlElementSerializationTest.java | 2 +- .../core/types/builtin/ByteStringTest.java | 2 +- .../core/types/builtin/DateTimeTest.java | 14 ++--- .../types/builtin/ExpandedNodeIdTest.java | 22 +++---- .../stack/core/types/builtin/NodeIdTest.java | 20 +++---- .../core/types/builtin/QualifiedNameTest.java | 2 +- .../ApplicationDescriptionTest.java | 2 +- .../opcua/stack/core/util/ArrayUtilTest.java | 4 +- .../stack/core/util/CertificateUtilTest.java | 12 ++-- .../stack/core/util/EndpointUtilTest.java | 35 ++++++----- .../stack/core/util/ExecutionQueueTest.java | 2 +- .../milo/opcua/stack/core/util/LazyTest.java | 12 ++-- .../opcua/stack/core/util/NonceUtilTest.java | 8 +-- .../CertificateValidationUtilTest.java | 6 +- .../opcua/stack/ChunkSerializationTest.java | 8 +-- .../milo/opcua/stack/ClientServerTest.java | 4 +- .../config/UaStackClientConfigTest.java | 34 +++++------ .../server/EndpointConfigurationTest.java | 4 +- 72 files changed, 407 insertions(+), 409 deletions(-) diff --git a/opc-ua-sdk/dictionary-reader/src/test/java/org/eclipse/milo/opcua/sdk/client/dtd/DataTypeDictionaryReaderTest.java b/opc-ua-sdk/dictionary-reader/src/test/java/org/eclipse/milo/opcua/sdk/client/dtd/DataTypeDictionaryReaderTest.java index 18bb30d441..29374423f9 100644 --- a/opc-ua-sdk/dictionary-reader/src/test/java/org/eclipse/milo/opcua/sdk/client/dtd/DataTypeDictionaryReaderTest.java +++ b/opc-ua-sdk/dictionary-reader/src/test/java/org/eclipse/milo/opcua/sdk/client/dtd/DataTypeDictionaryReaderTest.java @@ -124,7 +124,7 @@ private void testReadDataTypeDictionaryBytes(ByteString dictionary, int fragment fragmentSize ).get(); - Assertions.assertEquals(typeDictionaryBs, dictionary); + Assertions.assertEquals(dictionary, typeDictionaryBs); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java index 6a791d3fa0..364d7aa337 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java @@ -71,7 +71,7 @@ public void browseWithBrowseDirection() throws UaException { List nodes = addressSpace.browseNodes(serverNode, browseOptions); - assertEquals(1, nodes.size()); + assertEquals(nodes.size(), 1); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.ObjectsFolder))); } @@ -84,7 +84,7 @@ public void browseWithBrowseDirection() throws UaException { List nodes = addressSpace.browseNodes(objectsFolderNode, browseOptions); - assertEquals(7, nodes.size()); + assertEquals(nodes.size(), 7); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.RootFolder))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server))); } @@ -103,7 +103,7 @@ public void browseWithReferenceType() throws UaException { List nodes = addressSpace.browseNodes(serverNode, browseOptions); - assertEquals(5, nodes.size()); + assertEquals(nodes.size(), 5); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server_ServerArray))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server_NamespaceArray))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server_ServiceLevel))); @@ -214,7 +214,7 @@ public void getObjectNode() throws UaException { ServerTypeNode serverNode = (ServerTypeNode) addressSpace.getObjectNode(Identifiers.Server); assertNotNull(serverNode); - assertEquals(Identifiers.Server, serverNode.getNodeId()); + assertEquals(serverNode.getNodeId(), Identifiers.Server); // should be cached now, check instance equality assertSame(serverNode, addressSpace.getObjectNode(Identifiers.Server)); @@ -237,7 +237,7 @@ public void getVariableNode() throws UaException { addressSpace.getVariableNode(Identifiers.Server_ServerStatus); assertNotNull(serverNode); - assertEquals(Identifiers.Server_ServerStatus, serverNode.getNodeId()); + assertEquals(serverNode.getNodeId(), Identifiers.Server_ServerStatus); // should be cached now, check instance equality assertSame(serverNode, addressSpace.getVariableNode(Identifiers.Server_ServerStatus)); @@ -260,7 +260,7 @@ public void getNodeThatDoesNotExist() { () -> client.getAddressSpace().getNode(NodeId.parse("ns=2;s=DoesNotExist")) ); - assertEquals(StatusCodes.Bad_NodeIdUnknown, exception.getStatusCode().getValue()); + assertEquals(exception.getStatusCode().getValue(), StatusCodes.Bad_NodeIdUnknown); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaNodeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaNodeTest.java index fe03114969..b6c5c7a868 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaNodeTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaNodeTest.java @@ -49,7 +49,7 @@ public void browse() throws UaException { .build(); List references = serverNode.browse(browseOptions); - assertEquals(5, references.size()); + assertEquals(references.size(), 5); assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_ServerArray))); assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_NamespaceArray))); assertTrue(references.stream().anyMatch(n -> n.getNodeId().equalTo(Identifiers.Server_ServiceLevel))); @@ -69,7 +69,7 @@ public void browseNodes() throws UaException { List nodes = serverNode.browseNodes(browseOptions); - assertEquals(5, nodes.size()); + assertEquals(nodes.size(), 5); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server_ServerArray))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server_NamespaceArray))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.Server_ServiceLevel))); @@ -109,7 +109,7 @@ public void write() throws UaException { Integer i2 = (Integer) testNode.readValue().getValue().getValue(); - assertEquals(i1 + 1, i2); + assertEquals(i2, i1 + 1); StatusCode statusCode = testNode.writeAttribute( AttributeId.Value, @@ -146,7 +146,7 @@ public void synchronize() throws UaException { testNode.synchronize(EnumSet.of(AttributeId.Value)); - assertEquals(42, testNode.readValue().getValue().getValue()); + assertEquals(testNode.readValue().getValue().getValue(), 42); } @Test @@ -161,7 +161,7 @@ public void serverNode_ServerStatusNode_BuildInfo() throws UaException { BuildInfo buildInfo2 = serverNode.getServerStatusNode().readBuildInfo(); assertNotNull(buildInfo2); - assertEquals(buildInfo1, buildInfo2); + assertEquals(buildInfo2, buildInfo1); } @Test diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaObjectNodeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaObjectNodeTest.java index f0c330b75a..4664ad7106 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaObjectNodeTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaObjectNodeTest.java @@ -42,7 +42,7 @@ public void getTypeDefinition() throws UaException { UaObjectTypeNode objectTypeNode = objectNode.getTypeDefinition(); - assertEquals(Identifiers.ServerType, objectTypeNode.getNodeId()); + assertEquals(objectTypeNode.getNodeId(), Identifiers.ServerType); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaVariableNodeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaVariableNodeTest.java index 1876378bca..0e63214467 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaVariableNodeTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/UaVariableNodeTest.java @@ -46,7 +46,7 @@ public void getTypeDefinition() throws UaException { UaVariableTypeNode variableTypeNode = variableNode.getTypeDefinition(); - assertEquals(Identifiers.ServerStatusType, variableTypeNode.getNodeId()); + assertEquals(variableTypeNode.getNodeId(), Identifiers.ServerStatusType); } @Test diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java index 9d1e9cecc8..b964b582f8 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java @@ -49,11 +49,11 @@ public void findMethod() throws UaException { Argument[] inputArguments = getMonitoredItems.getInputArguments(); Argument[] outputArguments = getMonitoredItems.getOutputArguments(); - assertEquals(1, inputArguments.length); - assertEquals("SubscriptionId", inputArguments[0].getName()); - assertEquals(2, outputArguments.length); - assertEquals("ServerHandles", outputArguments[0].getName()); - assertEquals("ClientHandles", outputArguments[1].getName()); + assertEquals(inputArguments.length, 1); + assertEquals(inputArguments[0].getName(), "SubscriptionId"); + assertEquals(outputArguments.length, 2); + assertEquals(outputArguments[0].getName(), "ServerHandles"); + assertEquals(outputArguments[1].getName(), "ClientHandles"); Variant[] outputs = getMonitoredItems.call( new Variant[]{ @@ -127,7 +127,7 @@ public void callMethodWithHasComponentReference() throws UaException { new Variant[]{new Variant(16.0)} ); - assertEquals(4.0, outputs[0].getValue()); + assertEquals(outputs[0].getValue(), 4.0); } @Test @@ -141,7 +141,7 @@ public void callMethodWithHasOrderedComponentReference() throws UaException { new Variant[]{new Variant(16.0)} ); - assertEquals(4.0, outputs[0].getValue()); + assertEquals(outputs[0].getValue(), 4.0); } @Test @@ -155,7 +155,7 @@ public void callMethodWithNoInputsOrOutputs() throws UaException { new Variant[0] ); - assertEquals(0, outputs.length); + assertEquals(outputs.length, 0); } @Test diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/AbstractManagedItemTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/AbstractManagedItemTest.java index 3d9badfbd7..80dc67179d 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/AbstractManagedItemTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/AbstractManagedItemTest.java @@ -57,16 +57,16 @@ public void delete() throws UaException { @Test public void monitoringMode() throws UaException { ManagedItem managedItem = createManagedItem(); - assertEquals(MonitoringMode.Reporting, managedItem.getMonitoringMode()); + assertEquals(managedItem.getMonitoringMode(), MonitoringMode.Reporting); managedItem.setMonitoringMode(MonitoringMode.Sampling); - assertEquals(MonitoringMode.Sampling, managedItem.getMonitoringMode()); + assertEquals(managedItem.getMonitoringMode(), MonitoringMode.Sampling); managedItem.setMonitoringMode(MonitoringMode.Disabled); - assertEquals(MonitoringMode.Disabled, managedItem.getMonitoringMode()); + assertEquals(managedItem.getMonitoringMode(), MonitoringMode.Disabled); managedItem.setMonitoringMode(MonitoringMode.Reporting); - assertEquals(MonitoringMode.Reporting, managedItem.getMonitoringMode()); + assertEquals(managedItem.getMonitoringMode(), MonitoringMode.Reporting); } @Test @@ -85,12 +85,12 @@ public void monitoringModeBatch() throws UaException, ExecutionException, Interr assertTrue(result.isOperationResultGood()); }); - assertEquals(Unit.VALUE, f1.get()); - assertEquals(Unit.VALUE, f2.get()); - assertEquals(MonitoringMode.Sampling, managedItem1.getMonitoringMode()); - assertEquals(MonitoringMode.Sampling, managedItem2.getMonitoringMode()); + assertEquals(f1.get(), Unit.VALUE); + assertEquals(f2.get(), Unit.VALUE); + assertEquals(managedItem1.getMonitoringMode(), MonitoringMode.Sampling); + assertEquals(managedItem2.getMonitoringMode(), MonitoringMode.Sampling); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } @Test @@ -98,11 +98,11 @@ public void queueSize() throws UaException { UInteger initialQueueSize = subscription.getDefaultQueueSize(); ManagedItem managedItem = createManagedItem(); - assertEquals(initialQueueSize, managedItem.getQueueSize()); + assertEquals(managedItem.getQueueSize(), initialQueueSize); UInteger newQueueSize = initialQueueSize.add(1); - assertEquals(newQueueSize, managedItem.setQueueSize(newQueueSize)); - assertEquals(newQueueSize, managedItem.getQueueSize()); + assertEquals(managedItem.setQueueSize(newQueueSize), newQueueSize); + assertEquals(managedItem.getQueueSize(), newQueueSize); } @Test @@ -122,13 +122,13 @@ public void queueSizeBatch() throws UaException, ExecutionException, Interrupted assertTrue(result.isOperationResultGood()); }); - assertEquals(uint(10), f1.get()); - assertEquals(uint(10), managedItem1.getQueueSize()); + assertEquals(f1.get(), uint(10)); + assertEquals(managedItem1.getQueueSize(), uint(10)); - assertEquals(uint(20), f2.get()); - assertEquals(uint(20), managedItem2.getQueueSize()); + assertEquals(f2.get(), uint(20)); + assertEquals(managedItem2.getQueueSize(), uint(20)); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } @Test @@ -136,13 +136,13 @@ public void timestampsToReturn() throws UaException { TimestampsToReturn timestamps = subscription.getDefaultTimestamps(); ManagedItem managedItem = createManagedItem(); - assertEquals(timestamps, managedItem.getTimestampsToReturn()); + assertEquals(managedItem.getTimestampsToReturn(), timestamps); TimestampsToReturn newTimestamps = TimestampsToReturn.Neither; assertNotEquals(timestamps, newTimestamps); managedItem.setTimestampsToReturn(newTimestamps); - assertEquals(newTimestamps, managedItem.getTimestampsToReturn()); + assertEquals(managedItem.getTimestampsToReturn(), newTimestamps); } @Test @@ -162,13 +162,13 @@ public void timestampsToReturnBatch() throws UaException, ExecutionException, In assertTrue(result.isOperationResultGood()); }); - assertEquals(Unit.VALUE, f1.get()); - assertEquals(TimestampsToReturn.Neither, managedItem1.getTimestampsToReturn()); + assertEquals(f1.get(), Unit.VALUE); + assertEquals(managedItem1.getTimestampsToReturn(), TimestampsToReturn.Neither); - assertEquals(Unit.VALUE, f2.get()); - assertEquals(TimestampsToReturn.Neither, managedItem2.getTimestampsToReturn()); + assertEquals(f2.get(), Unit.VALUE); + assertEquals(managedItem2.getTimestampsToReturn(), TimestampsToReturn.Neither); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } @Test @@ -177,10 +177,10 @@ public void discardOldest() throws UaException { ManagedItem managedItem = createManagedItem(); - assertEquals(defaultDiscardOldest, managedItem.getDiscardOldest()); + assertEquals(managedItem.getDiscardOldest(), defaultDiscardOldest); managedItem.setDiscardOldest(!defaultDiscardOldest); - assertEquals(!defaultDiscardOldest, managedItem.getDiscardOldest()); + assertEquals(managedItem.getDiscardOldest(), !defaultDiscardOldest); } @Test @@ -200,13 +200,13 @@ public void discardOldestBatch() throws UaException, ExecutionException, Interru assertTrue(result.isOperationResultGood()); }); - assertEquals(Unit.VALUE, f1.get()); + assertEquals(f1.get(), Unit.VALUE); assertFalse(managedItem1.getDiscardOldest()); - assertEquals(Unit.VALUE, f2.get()); + assertEquals(f2.get(), Unit.VALUE); assertFalse(managedItem2.getDiscardOldest()); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchModifyMonitoredItemsTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchModifyMonitoredItemsTest.java index 84510c5f87..80796e6528 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchModifyMonitoredItemsTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchModifyMonitoredItemsTest.java @@ -74,14 +74,14 @@ public void mixedOperationResults() throws UaException, ExecutionException, Inte if (i % 2 == 0) { assertTrue(result.isOperationResultGood()); assertTrue(future.get().isOperationResultGood()); - assertEquals(5000.0, items.get(i).getRevisedSamplingInterval()); + assertEquals(items.get(i).getRevisedSamplingInterval(), 5000.0); } else { assertFalse(result.isOperationResultGood()); assertFalse(future.get().isOperationResultGood()); } } - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } @Test @@ -113,12 +113,12 @@ public void multipleTimestampsToReturn() throws UaException, InterruptedExceptio assertTrue(result.isOperationResultGood()); } - assertEquals(TimestampsToReturn.Server, item1.getTimestampsToReturn()); - assertEquals(TimestampsToReturn.Both, item2.getTimestampsToReturn()); - assertEquals(TimestampsToReturn.Neither, item3.getTimestampsToReturn()); - assertEquals(TimestampsToReturn.Source, item4.getTimestampsToReturn()); + assertEquals(item1.getTimestampsToReturn(), TimestampsToReturn.Server); + assertEquals(item2.getTimestampsToReturn(), TimestampsToReturn.Both); + assertEquals(item3.getTimestampsToReturn(), TimestampsToReturn.Neither); + assertEquals(item4.getTimestampsToReturn(), TimestampsToReturn.Source); - assertEquals(4, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 4); } @Test @@ -141,8 +141,8 @@ public void operationResultCount() throws Exception { // test case there are 3 operations to the same item, which only // results in underlying modify operation but the batch should return // an operation result for each. - assertEquals(3, batch.execute().size()); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.execute().size(), 3); + assertEquals(batch.getServiceInvocationCount(), 1); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchSetMonitoringModeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchSetMonitoringModeTest.java index 958d5f0402..aa61939fde 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchSetMonitoringModeTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/BatchSetMonitoringModeTest.java @@ -48,11 +48,11 @@ public void multipleOperations() throws UaException, InterruptedException { assertTrue(result.isOperationResultGood()); } - assertEquals(MonitoringMode.Sampling, item1.getMonitoringMode()); - assertEquals(MonitoringMode.Sampling, item2.getMonitoringMode()); - assertEquals(MonitoringMode.Sampling, item3.getMonitoringMode()); + assertEquals(item1.getMonitoringMode(), MonitoringMode.Sampling); + assertEquals(item2.getMonitoringMode(), MonitoringMode.Sampling); + assertEquals(item3.getMonitoringMode(), MonitoringMode.Sampling); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } @Test @@ -81,11 +81,11 @@ public void multipleServiceInvocations() throws UaException, InterruptedExceptio assertTrue(result.isOperationResultGood()); } - assertEquals(MonitoringMode.Sampling, item1.getMonitoringMode()); - assertEquals(MonitoringMode.Reporting, item2.getMonitoringMode()); - assertEquals(MonitoringMode.Disabled, item3.getMonitoringMode()); + assertEquals(item1.getMonitoringMode(), MonitoringMode.Sampling); + assertEquals(item2.getMonitoringMode(), MonitoringMode.Reporting); + assertEquals(item3.getMonitoringMode(), MonitoringMode.Disabled); - assertEquals(3, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 3); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedDataItemTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedDataItemTest.java index bd5865f597..214f40003d 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedDataItemTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedDataItemTest.java @@ -43,19 +43,19 @@ public void getStatusCode() throws UaException { assertTrue(dataItem1.getStatusCode().isGood()); ManagedDataItem dataItem2 = subscription.createDataItem(NodeId.parse("ns=2;s=FooBarDoesNotExist")); - assertEquals(StatusCodes.Bad_NodeIdUnknown, dataItem2.getStatusCode().getValue()); + assertEquals(dataItem2.getStatusCode().getValue(), StatusCodes.Bad_NodeIdUnknown); } @Test public void samplingInterval() throws Exception { ManagedDataItem dataItem1 = createManagedItem(); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem1.getSamplingInterval()); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem1.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem1.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(dataItem1.getSamplingInterval(), subscription.getDefaultSamplingInterval()); + assertEquals(dataItem1.getMonitoredItem().getRequestedSamplingInterval(), subscription.getDefaultSamplingInterval()); + assertEquals(dataItem1.getMonitoredItem().getRevisedSamplingInterval(), subscription.getDefaultSamplingInterval()); - assertEquals(5000.0, dataItem1.setSamplingInterval(5000.0)); - assertEquals(5000.0, dataItem1.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(5000.0, dataItem1.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(dataItem1.setSamplingInterval(5000.0), 5000.0); + assertEquals(dataItem1.getMonitoredItem().getRequestedSamplingInterval(), 5000.0); + assertEquals(dataItem1.getMonitoredItem().getRevisedSamplingInterval(), 5000.0); } @Test @@ -64,9 +64,9 @@ public void samplingIntervalBatch() throws Exception { subscription.getDataItems().forEach( item -> { - assertEquals(1000.0, item.getSamplingInterval()); - assertEquals(1000.0, item.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(1000.0, item.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(item.getSamplingInterval(), 1000.0); + assertEquals(item.getMonitoredItem().getRequestedSamplingInterval(), 1000.0); + assertEquals(item.getMonitoredItem().getRevisedSamplingInterval(), 1000.0); } ); @@ -85,18 +85,18 @@ public void samplingIntervalBatch() throws Exception { futures.forEach(f -> { assertTrue(f.isDone() && !f.isCompletedExceptionally()); - f.thenAccept(v -> assertEquals(5000.0, v)); + f.thenAccept(v -> assertEquals(v), 5000.0); }); subscription.getDataItems().forEach( item -> { - assertEquals(5000.0, item.getSamplingInterval()); - assertEquals(5000.0, item.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(5000.0, item.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(item.getSamplingInterval(), 5000.0); + assertEquals(item.getMonitoredItem().getRequestedSamplingInterval(), 5000.0); + assertEquals(item.getMonitoredItem().getRevisedSamplingInterval(), 5000.0); } ); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } { @@ -113,13 +113,13 @@ public void samplingIntervalBatch() throws Exception { subscription.getDataItems().forEach( item -> { - assertEquals(1000.0, item.getSamplingInterval()); - assertEquals(1000.0, item.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(1000.0, item.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(item.getSamplingInterval(), 1000.0); + assertEquals(item.getMonitoredItem().getRequestedSamplingInterval(), 1000.0); + assertEquals(item.getMonitoredItem().getRevisedSamplingInterval(), 1000.0); } ); - assertEquals(1, batch.getServiceInvocationCount()); + assertEquals(batch.getServiceInvocationCount(), 1); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedEventItemTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedEventItemTest.java index 293ea3f0e4..709fe792b1 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedEventItemTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedEventItemTest.java @@ -67,7 +67,7 @@ public void getStatusCode() throws UaException { NodeId.parse("ns=2;s=FooBarDoesNotExist"), eventFilter ); - assertEquals(StatusCodes.Bad_NodeIdUnknown, dataItem2.getStatusCode().getValue()); + assertEquals(dataItem2.getStatusCode().getValue(), StatusCodes.Bad_NodeIdUnknown); } @Test diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedSubscriptionTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedSubscriptionTest.java index aa0a082312..749df7e888 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedSubscriptionTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ManagedSubscriptionTest.java @@ -98,9 +98,9 @@ public void createWithSamplingInterval() throws UaException { ManagedDataItem dataItem = subscription.createDataItem(5000.0, readValueId); - assertEquals(5000.0, dataItem.getSamplingInterval()); - assertEquals(5000.0, dataItem.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(5000.0, dataItem.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(dataItem.getSamplingInterval(), 5000.0); + assertEquals(dataItem.getMonitoredItem().getRequestedSamplingInterval(), 5000.0); + assertEquals(dataItem.getMonitoredItem().getRevisedSamplingInterval(), 5000.0); } @Test @@ -108,10 +108,10 @@ public void setPublishingInterval() throws UaException { double original = subscription.getPublishingInterval(); double revised1 = subscription.setPublishingInterval(100.0); - assertEquals(100.0, revised1); + assertEquals(revised1, 100.0); double revised2 = subscription.setPublishingInterval(original); - assertEquals(original, revised2); + assertEquals(revised2, original); } @Test @@ -128,24 +128,24 @@ public void defaultMonitoringMode() throws UaException { ManagedDataItem dataItem1 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(MonitoringMode.Reporting, dataItem1.getMonitoringMode()); - assertEquals(MonitoringMode.Reporting, dataItem1.getMonitoredItem().getMonitoringMode()); + assertEquals(dataItem1.getMonitoringMode(), MonitoringMode.Reporting); + assertEquals(dataItem1.getMonitoredItem().getMonitoringMode(), MonitoringMode.Reporting); subscription.setDefaultMonitoringMode(MonitoringMode.Sampling); ManagedDataItem dataItem2 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(MonitoringMode.Sampling, dataItem2.getMonitoringMode()); - assertEquals(MonitoringMode.Sampling, dataItem2.getMonitoredItem().getMonitoringMode()); + assertEquals(dataItem2.getMonitoringMode(), MonitoringMode.Sampling); + assertEquals(dataItem2.getMonitoredItem().getMonitoringMode(), MonitoringMode.Sampling); subscription.setDefaultMonitoringMode(MonitoringMode.Disabled); ManagedDataItem dataItem3 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(MonitoringMode.Disabled, dataItem3.getMonitoringMode()); - assertEquals(MonitoringMode.Disabled, dataItem3.getMonitoredItem().getMonitoringMode()); + assertEquals(dataItem3.getMonitoringMode(), MonitoringMode.Disabled); + assertEquals(dataItem3.getMonitoredItem().getMonitoringMode(), MonitoringMode.Disabled); } @Test @@ -153,22 +153,22 @@ public void defaultSamplingInterval() throws UaException { ManagedDataItem dataItem1 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem1.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem1.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(dataItem1.getMonitoredItem().getRequestedSamplingInterval(), subscription.getDefaultSamplingInterval()); + assertEquals(dataItem1.getMonitoredItem().getRevisedSamplingInterval(), subscription.getDefaultSamplingInterval()); subscription.setDefaultSamplingInterval(100.0); ManagedDataItem dataItem2 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem2.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem2.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(dataItem2.getMonitoredItem().getRequestedSamplingInterval(), subscription.getDefaultSamplingInterval()); + assertEquals(dataItem2.getMonitoredItem().getRevisedSamplingInterval(), subscription.getDefaultSamplingInterval()); subscription.setDefaultSamplingInterval(5000.0); ManagedDataItem dataItem3 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem3.getMonitoredItem().getRequestedSamplingInterval()); - assertEquals(subscription.getDefaultSamplingInterval(), dataItem3.getMonitoredItem().getRevisedSamplingInterval()); + assertEquals(dataItem3.getMonitoredItem().getRequestedSamplingInterval(), subscription.getDefaultSamplingInterval()); + assertEquals(dataItem3.getMonitoredItem().getRevisedSamplingInterval(), subscription.getDefaultSamplingInterval()); } @Test @@ -176,15 +176,15 @@ public void defaultQueueSize() throws UaException { ManagedDataItem dataItem1 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultQueueSize(), dataItem1.getMonitoredItem().getRequestedQueueSize()); - assertEquals(subscription.getDefaultQueueSize(), dataItem1.getMonitoredItem().getRevisedQueueSize()); + assertEquals(dataItem1.getMonitoredItem().getRequestedQueueSize(), subscription.getDefaultQueueSize()); + assertEquals(dataItem1.getMonitoredItem().getRevisedQueueSize(), subscription.getDefaultQueueSize()); subscription.setDefaultQueueSize(uint(subscription.getDefaultQueueSize().intValue() + 1)); ManagedDataItem dataItem2 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultQueueSize(), dataItem2.getMonitoredItem().getRequestedQueueSize()); - assertEquals(subscription.getDefaultQueueSize(), dataItem2.getMonitoredItem().getRevisedQueueSize()); + assertEquals(dataItem2.getMonitoredItem().getRequestedQueueSize(), subscription.getDefaultQueueSize()); + assertEquals(dataItem2.getMonitoredItem().getRevisedQueueSize(), subscription.getDefaultQueueSize()); } @Test @@ -192,7 +192,7 @@ public void defaultDataFilter() throws UaException { ManagedDataItem dataItem1 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultDataFilter(), dataItem1.getMonitoredItem().getMonitoringFilter()); + assertEquals(dataItem1.getMonitoredItem().getMonitoringFilter(), subscription.getDefaultDataFilter()); subscription.setDefaultDataFilter( new DataChangeFilter( @@ -206,7 +206,7 @@ public void defaultDataFilter() throws UaException { Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultDataFilter(), dataItem2.getMonitoredItem().getMonitoringFilter()); + assertEquals(dataItem2.getMonitoredItem().getMonitoringFilter(), subscription.getDefaultDataFilter()); } @Test @@ -214,13 +214,13 @@ public void defaultTimestamp() throws UaException { ManagedDataItem dataItem1 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultTimestamps(), dataItem1.getMonitoredItem().getTimestamps()); + assertEquals(dataItem1.getMonitoredItem().getTimestamps(), subscription.getDefaultTimestamps()); subscription.setDefaultTimestamps(TimestampsToReturn.Neither); ManagedDataItem dataItem2 = subscription.createDataItem( Identifiers.Server_ServerStatus_CurrentTime ); - assertEquals(subscription.getDefaultTimestamps(), dataItem2.getMonitoredItem().getTimestamps()); + assertEquals(dataItem2.getMonitoredItem().getTimestamps(), subscription.getDefaultTimestamps()); } @Test diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java index 37ecbd49eb..163cf80a91 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java @@ -91,7 +91,7 @@ private void checkSubtypes(NodeId dataTypeId, Class expectedBackingClass) { nodeIdNode.traverse(dataType -> { Class backingClass = dataTypeTree.getBackingClass(dataType.getNodeId()); System.out.println(dataType.getBrowseName().toParseableString() + " : " + backingClass); - assertEquals(expectedBackingClass, backingClass); + assertEquals(backingClass, expectedBackingClass); }); } @@ -101,21 +101,21 @@ public void testGetBuiltinType() { for (BuiltinDataType expectedType : BuiltinDataType.values()) { BuiltinDataType builtinType = dataTypeTree.getBuiltinType(expectedType.getNodeId()); - assertEquals(expectedType, builtinType); + assertEquals(builtinType, expectedType); } // Check that subtypes resolve to their builtin types - assertEquals(BuiltinDataType.String, dataTypeTree.getBuiltinType(Identifiers.NumericRange)); - assertEquals(BuiltinDataType.DateTime, dataTypeTree.getBuiltinType(Identifiers.Date)); - assertEquals(BuiltinDataType.ByteString, dataTypeTree.getBuiltinType(Identifiers.Image)); - assertEquals(BuiltinDataType.ByteString, dataTypeTree.getBuiltinType(Identifiers.ImageBMP)); - assertEquals(BuiltinDataType.NodeId, dataTypeTree.getBuiltinType(Identifiers.SessionAuthenticationToken)); - assertEquals(BuiltinDataType.ExtensionObject, dataTypeTree.getBuiltinType(Identifiers.TrustListDataType)); - assertEquals(BuiltinDataType.Double, dataTypeTree.getBuiltinType(Identifiers.Duration)); - assertEquals(BuiltinDataType.UInt32, dataTypeTree.getBuiltinType(Identifiers.IntegerId)); - assertEquals(BuiltinDataType.UInt64, dataTypeTree.getBuiltinType(Identifiers.BitFieldMaskDataType)); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.NumericRange), BuiltinDataType.String); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.Date), BuiltinDataType.DateTime); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.Image), BuiltinDataType.ByteString); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.ImageBMP), BuiltinDataType.ByteString); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.SessionAuthenticationToken), BuiltinDataType.NodeId); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.TrustListDataType), BuiltinDataType.ExtensionObject); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.Duration), BuiltinDataType.Double); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.IntegerId), BuiltinDataType.UInt32); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.BitFieldMaskDataType), BuiltinDataType.UInt64); // note: enumerations resolve to BaseDataType aka Variant - assertEquals(BuiltinDataType.Variant, dataTypeTree.getBuiltinType(Identifiers.NamingRuleType)); + assertEquals(dataTypeTree.getBuiltinType(Identifiers.NamingRuleType), BuiltinDataType.Variant); } @Test diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/methods/AbstractMethodInvocationHandlerTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/methods/AbstractMethodInvocationHandlerTest.java index 6258d3a780..c5d0842029 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/methods/AbstractMethodInvocationHandlerTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/methods/AbstractMethodInvocationHandlerTest.java @@ -40,8 +40,8 @@ public void inputArgumentResultsIsEmptyOnSuccess() throws ExecutionException, In new Variant[]{new Variant(1)} )).get(); - assertEquals(StatusCode.GOOD, result.getStatusCode()); - assertEquals(0, result.getInputArgumentResults().length); + assertEquals(result.getStatusCode(), StatusCode.GOOD); + assertEquals(result.getInputArgumentResults().length, 0); } @Test @@ -59,8 +59,8 @@ public void implementationCanValidateArguments() throws UaException { System.out.println("result: " + e.getStatusCode()); System.out.println("inputArgumentResults: " + Arrays.toString(e.getInputArgumentResults())); - assertEquals(StatusCodes.Bad_InvalidArgument, e.getStatusCode().getValue()); - assertEquals(StatusCodes.Bad_OutOfRange, e.getInputArgumentResults()[0].getValue()); + assertEquals(e.getStatusCode().getValue(), StatusCodes.Bad_InvalidArgument); + assertEquals(e.getInputArgumentResults()[0].getValue(), StatusCodes.Bad_OutOfRange); } } @@ -74,7 +74,7 @@ void wrongNumberOfArguments() throws ExecutionException, InterruptedException { new Variant[]{} )).get(); - assertEquals(StatusCodes.Bad_ArgumentsMissing, result.getStatusCode().getValue()); + assertEquals(result.getStatusCode().getValue(), StatusCodes.Bad_ArgumentsMissing); } // too many arguments @@ -85,7 +85,7 @@ void wrongNumberOfArguments() throws ExecutionException, InterruptedException { new Variant[]{new Variant(1), new Variant(2)} )).get(); - assertEquals(StatusCodes.Bad_TooManyArguments, result.getStatusCode().getValue()); + assertEquals(result.getStatusCode().getValue(), StatusCodes.Bad_TooManyArguments); } } diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/util/AttributeWriterTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/util/AttributeWriterTest.java index 862a6bc2df..e22d917752 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/util/AttributeWriterTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/server/api/util/AttributeWriterTest.java @@ -27,7 +27,7 @@ void writeNullAllowed() throws Exception { DataValue.valueOnly(Variant.NULL_VALUE) ).get(); - assertEquals(StatusCode.GOOD, statusCode); + assertEquals(statusCode, StatusCode.GOOD); } @Test @@ -37,7 +37,7 @@ void writeNullDisallowed() throws Exception { DataValue.valueOnly(Variant.NULL_VALUE) ).get(); - assertEquals(new StatusCode(StatusCodes.Bad_TypeMismatch), statusCode); + assertEquals(statusCode, new StatusCode(StatusCodes.Bad_TypeMismatch)); } @Test @@ -48,7 +48,7 @@ void writeNullNotConfigured() throws Exception { DataValue.valueOnly(Variant.NULL_VALUE) ).get(); - assertEquals(new StatusCode(StatusCodes.Bad_TypeMismatch), statusCode); + assertEquals(statusCode, new StatusCode(StatusCodes.Bad_TypeMismatch)); } @Test @@ -58,7 +58,7 @@ void writeByteStringToUByteArray() throws Exception { DataValue.valueOnly(new Variant(ByteString.of(new byte[]{1, 2, 3}))) ).get(); - assertEquals(StatusCode.GOOD, statusCode); + assertEquals(statusCode, StatusCode.GOOD); } @BeforeAll diff --git a/opc-ua-sdk/sdk-core/src/test/java/org/eclipse/milo/opcua/sdk/server/util/GroupMapCollateTest.java b/opc-ua-sdk/sdk-core/src/test/java/org/eclipse/milo/opcua/sdk/server/util/GroupMapCollateTest.java index 7262b7065a..1528b70099 100644 --- a/opc-ua-sdk/sdk-core/src/test/java/org/eclipse/milo/opcua/sdk/server/util/GroupMapCollateTest.java +++ b/opc-ua-sdk/sdk-core/src/test/java/org/eclipse/milo/opcua/sdk/server/util/GroupMapCollateTest.java @@ -49,7 +49,7 @@ public void testGroupMapCollate() throws ExecutionException, InterruptedExceptio List strings = stringsFuture.get(); for (int j = 0; j < strings.size(); j++) { - assertEquals(String.valueOf(j), strings.get(j)); + assertEquals(strings.get(j), String.valueOf(j)); } System.out.println("--"); } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java index 868a1d5d66..1a7b66cf28 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/AccessLevelTest.java @@ -20,10 +20,10 @@ public class AccessLevelTest { @Test public void testToValue() { for (AccessLevel accessLevel : AccessLevel.values()) { - assertEquals(AccessLevel.toValue(accessLevel), ubyte(accessLevel.getValue())); + assertEquals(ubyte(accessLevel.getValue()), AccessLevel.toValue(accessLevel)); } - assertEquals(AccessLevel.toValue(AccessLevel.NONE), ubyte(0)); + assertEquals(ubyte(0), AccessLevel.toValue(AccessLevel.NONE)); assertEquals( AccessLevel.toValue(AccessLevel.READ_ONLY).intValue(), @@ -48,7 +48,7 @@ public void testToValue() { @Test public void testFromValue() { - assertEquals(AccessLevel.fromValue(0), AccessLevel.NONE); + assertEquals(AccessLevel.NONE, AccessLevel.fromValue(0)); assertEquals( AccessLevel.fromValue( diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java index 3d3cf88492..09059b1ce9 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/CefactEngineeringUnitsTest.java @@ -23,7 +23,7 @@ public void test() { assertTrue(CefactEngineeringUnits.getAll().length > 0); for (EUInformation eu : CefactEngineeringUnits.getAll()) { - assertEquals(CefactEngineeringUnits.getByUnitId(eu.getUnitId()), eu); + assertEquals(eu, CefactEngineeringUnits.getByUnitId(eu.getUnitId())); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java index 8241f74682..75d3bf3f83 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/NumericRangeTest.java @@ -123,7 +123,7 @@ public void testStringBeyondEnd() throws UaException { Object result = NumericRange.readFromValueAtRange(value, nr); assertTrue(result instanceof String); - assertEquals(result, string); + assertEquals(string, result); } @Test @@ -134,7 +134,7 @@ public void testByteString1d() throws UaException { Object result = NumericRange.readFromValueAtRange(value, nr); assertTrue(result instanceof ByteString); - assertEquals(result, new ByteString(new byte[]{2, 3})); + assertEquals(new ByteString(new byte[]{2, 3}), result); } @Test @@ -166,7 +166,7 @@ public void testByteStringBeyondEnd() throws UaException { Object result = NumericRange.readFromValueAtRange(value, nr); assertTrue(result instanceof ByteString); - assertEquals(result, byteString); + assertEquals(byteString, result); } @ParameterizedTest @@ -200,7 +200,7 @@ public void testWriteString() throws UaException { Object updated = NumericRange.writeToValueAtRange(current, update, range); assertTrue(updated instanceof String); - assertEquals(updated, "aZzZzZg"); + assertEquals("aZzZzZg", updated); } @Test @@ -212,7 +212,7 @@ public void testWriteByteString() throws UaException { Object updated = NumericRange.writeToValueAtRange(current, update, range); assertTrue(updated instanceof ByteString); - assertEquals(updated, new ByteString(new byte[]{0, 2, 4, 3})); + assertEquals(new ByteString(new byte[]{0, 2, 4, 3}), updated); } public static Object[][] getInvalidRanges() { diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java index 14c318ddbf..69d787d9a8 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/core/ReferenceTest.java @@ -36,7 +36,7 @@ public void testEquality() { reference1.getDirection() ); - assertEquals(reference1, reference2); + assertEquals(reference2, reference1); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java index c093b3ff65..8494ff3aed 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/LifecycleManagerTest.java @@ -44,8 +44,8 @@ public void shutdown() { manager.startup(); manager.shutdown(); - assertEquals(startupCount.get(), 2); - assertEquals(shutdownCount.get(), 2); + assertEquals(2, startupCount.get()); + assertEquals(2, shutdownCount.get()); } @Test @@ -76,8 +76,8 @@ public void shutdown() { Lifecycle shutdown = manager.addShutdownTask(shutdownCount::incrementAndGet); manager.removeLifecycle(shutdown); - assertEquals(startupCount.get(), 0); - assertEquals(shutdownCount.get(), 0); + assertEquals(0, startupCount.get()); + assertEquals(0, shutdownCount.get()); } @Test @@ -85,9 +85,9 @@ public void testStartupOrder() { LifecycleManager manager = new LifecycleManager(); AtomicInteger i = new AtomicInteger(0); - manager.addStartupTask(() -> assertEquals(i.getAndIncrement(), 0)); - manager.addStartupTask(() -> assertEquals(i.getAndIncrement(), 1)); - manager.addStartupTask(() -> assertEquals(i.getAndIncrement(), 2)); + manager.addStartupTask(() -> assertEquals(0), i.getAndIncrement()); + manager.addStartupTask(() -> assertEquals(1), i.getAndIncrement()); + manager.addStartupTask(() -> assertEquals(2), i.getAndIncrement()); manager.startup(); manager.shutdown(); @@ -98,9 +98,9 @@ public void testShutdownOrderLinear() { LifecycleManager manager = new LifecycleManager(); AtomicInteger i = new AtomicInteger(0); - manager.addShutdownTask(() -> assertEquals(i.getAndIncrement(), 0)); - manager.addShutdownTask(() -> assertEquals(i.getAndIncrement(), 1)); - manager.addShutdownTask(() -> assertEquals(i.getAndIncrement(), 2)); + manager.addShutdownTask(() -> assertEquals(0), i.getAndIncrement()); + manager.addShutdownTask(() -> assertEquals(1), i.getAndIncrement()); + manager.addShutdownTask(() -> assertEquals(2), i.getAndIncrement()); manager.startup(); manager.shutdown(); @@ -111,9 +111,9 @@ public void testShutdownOrderInverse() { LifecycleManager manager = new LifecycleManager(LifecycleManager.ShutdownOrder.INVERSE); AtomicInteger i = new AtomicInteger(0); - manager.addShutdownTask(() -> assertEquals(i.getAndIncrement(), 2)); - manager.addShutdownTask(() -> assertEquals(i.getAndIncrement(), 1)); - manager.addShutdownTask(() -> assertEquals(i.getAndIncrement(), 0)); + manager.addShutdownTask(() -> assertEquals(2), i.getAndIncrement()); + manager.addShutdownTask(() -> assertEquals(1), i.getAndIncrement()); + manager.addShutdownTask(() -> assertEquals(0), i.getAndIncrement()); manager.startup(); manager.shutdown(); diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java index 481b097c52..9b00aaeb9b 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/api/config/OpcUaServerConfigTest.java @@ -46,10 +46,10 @@ public void testCopy() throws IOException { OpcUaServerConfig copy = OpcUaServerConfig.copy(original).build(); - assertEquals(copy.getIdentityValidator(), original.getIdentityValidator()); - assertEquals(copy.getBuildInfo(), original.getBuildInfo()); - assertEquals(copy.getLimits(), original.getLimits()); - assertEquals(copy.getScheduledExecutorService(), original.getScheduledExecutorService()); + assertEquals(original.getIdentityValidator(), copy.getIdentityValidator()); + assertEquals(original.getBuildInfo(), copy.getBuildInfo()); + assertEquals(original.getLimits(), copy.getLimits()); + assertEquals(original.getScheduledExecutorService(), copy.getScheduledExecutorService()); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java index c954cc252d..f8eadf7adc 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/AbstractConversionTest.java @@ -44,7 +44,7 @@ public void testAllConversions() { System.out.println(String.format("%s -> %s [%s]", sourceType, targetType, conversionType)); for (Conversion conversion : conversions) { - assertEquals(targetType, conversion.targetType); + assertEquals(conversion.targetType, targetType); S fromValue = getSourceClass().cast(conversion.fromValue); Object targetValue = conversion.targetValue; @@ -53,7 +53,7 @@ public void testAllConversions() { System.out.println(String.format("\tfromValue=%s targetValue=%s", fromValue, targetValue)); - assertEquals(convertedValue, targetValue); + assertEquals(targetValue, convertedValue); } } else { if (conversions.length != 0) { @@ -101,7 +101,7 @@ public void testImplicitConversionsCalledExplicitly() { "[%s] fromValue=%s targetType=%s targetValue=%s", conversionType, fromValue, targetType, conversion.targetValue)); - assertEquals(convertedValue, conversion.targetValue); + assertEquals(conversion.targetValue, convertedValue); } } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java index e1a4b2aae1..ce6e975757 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/BooleanConversionsTest.java @@ -33,68 +33,68 @@ public class BooleanConversionsTest { @Test public void testBooleanToByte() { - assertEquals(booleanToByte(false), ubyte(0)); - assertEquals(booleanToByte(true), ubyte(1)); + assertEquals(ubyte(0), booleanToByte(false)); + assertEquals(ubyte(1), booleanToByte(true)); } @Test public void testBooleanToDouble() { - assertEquals(booleanToDouble(false), 0.0); - assertEquals(booleanToDouble(true), 1.0); + assertEquals(0.0, booleanToDouble(false)); + assertEquals(1.0, booleanToDouble(true)); } @Test public void testBooleanToFloat() { - assertEquals(booleanToFloat(false), 0.0f); - assertEquals(booleanToFloat(true), 1.0f); + assertEquals(0.0f, booleanToFloat(false)); + assertEquals(1.0f, booleanToFloat(true)); } @Test public void testBooleanToInt16() { - assertEquals((short) booleanToInt16(false), 0); - assertEquals((short) booleanToInt16(true), 1); + assertEquals(0, (short) booleanToInt16(false)); + assertEquals(1, (short) booleanToInt16(true)); } @Test public void testBooleanToInt32() { - assertEquals((int) booleanToInt32(false), 0); - assertEquals((int) booleanToInt32(true), 1); + assertEquals(0, (int) booleanToInt32(false)); + assertEquals(1, (int) booleanToInt32(true)); } @Test public void testBooleanToInt64() { - assertEquals((long) booleanToInt64(false), 0); - assertEquals((long) booleanToInt64(true), 1); + assertEquals(0, (long) booleanToInt64(false)); + assertEquals(1, (long) booleanToInt64(true)); } @Test public void testBooleanToSByte() { - assertEquals((byte) booleanToSByte(false), 0); - assertEquals((byte) booleanToSByte(true), 1); + assertEquals(0, (byte) booleanToSByte(false)); + assertEquals(1, (byte) booleanToSByte(true)); } @Test public void testBooleanToString() { - assertEquals(booleanToString(true), "1"); - assertEquals(booleanToString(false), "0"); + assertEquals("1", booleanToString(true)); + assertEquals("0", booleanToString(false)); } @Test public void testBooleanToUInt16() { - assertEquals(booleanToUInt16(false), ushort(0)); - assertEquals(booleanToUInt16(true), ushort(1)); + assertEquals(ushort(0), booleanToUInt16(false)); + assertEquals(ushort(1), booleanToUInt16(true)); } @Test public void testBooleanToUInt32() { - assertEquals(booleanToUInt32(false), uint(0)); - assertEquals(booleanToUInt32(true), uint(1)); + assertEquals(uint(0), booleanToUInt32(false)); + assertEquals(uint(1), booleanToUInt32(true)); } @Test public void testBooleanToUInt64() { - assertEquals(booleanToUInt64(false), ulong(0)); - assertEquals(booleanToUInt64(true), ulong(1)); + assertEquals(ulong(0), booleanToUInt64(false)); + assertEquals(ulong(1), booleanToUInt64(true)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java index e96fa83799..7c909ca127 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteConversionsTest.java @@ -57,75 +57,75 @@ public void testConversions() { assertNotNull(targetType); - assertEquals(explicitConversion(b, targetType), expected); + assertEquals(expected, explicitConversion(b, targetType)); } } @Test public void testByteToBoolean() { - assertEquals(byteToBoolean(ubyte(0)), Boolean.FALSE); - assertEquals(byteToBoolean(ubyte(1)), Boolean.TRUE); + assertEquals(Boolean.FALSE, byteToBoolean(ubyte(0))); + assertEquals(Boolean.TRUE, byteToBoolean(ubyte(1))); } @Test public void testByteToDouble() { - assertEquals(byteToDouble(ubyte(0)), 0.0d); - assertEquals(byteToDouble(ubyte(1)), 1.0d); + assertEquals(0.0d, byteToDouble(ubyte(0))); + assertEquals(1.0d, byteToDouble(ubyte(1))); } @Test public void testByteToFloat() { - assertEquals(byteToFloat(ubyte(0)), 0.0f); - assertEquals(byteToFloat(ubyte(1)), 1.0f); + assertEquals(0.0f, byteToFloat(ubyte(0))); + assertEquals(1.0f, byteToFloat(ubyte(1))); } @Test public void testByteToInt16() { - assertEquals(byteToInt16(ubyte(0)), Short.valueOf((short) 0)); - assertEquals(byteToInt16(ubyte(1)), Short.valueOf((short) 1)); + assertEquals(Short.valueOf((short) 0), byteToInt16(ubyte(0))); + assertEquals(Short.valueOf((short) 1), byteToInt16(ubyte(1))); } @Test public void testByteToInt32() { - assertEquals(byteToInt32(ubyte(0)), Integer.valueOf(0)); - assertEquals(byteToInt32(ubyte(1)), Integer.valueOf(1)); + assertEquals(Integer.valueOf(0), byteToInt32(ubyte(0))); + assertEquals(Integer.valueOf(1), byteToInt32(ubyte(1))); } @Test public void testByteToInt64() { - assertEquals(byteToInt64(ubyte(0)), Long.valueOf(0)); - assertEquals(byteToInt64(ubyte(1)), Long.valueOf(1)); + assertEquals(Long.valueOf(0), byteToInt64(ubyte(0))); + assertEquals(Long.valueOf(1), byteToInt64(ubyte(1))); } @Test public void testByteToSByte() { - assertEquals(byteToSByte(ubyte(0)), Byte.valueOf((byte) 0)); - assertEquals(byteToSByte(ubyte(Byte.MAX_VALUE)), Byte.valueOf(Byte.MAX_VALUE)); + assertEquals(Byte.valueOf((byte) 0), byteToSByte(ubyte(0))); + assertEquals(Byte.valueOf(Byte.MAX_VALUE), byteToSByte(ubyte(Byte.MAX_VALUE))); assertNull(byteToSByte(ubyte(Byte.MAX_VALUE + 1))); } @Test public void testByteToString() { - assertEquals(byteToString(ubyte(0)), "0"); - assertEquals(byteToString(ubyte(1)), "1"); + assertEquals("0", byteToString(ubyte(0))); + assertEquals("1", byteToString(ubyte(1))); } @Test public void testByteToUInt16() { - assertEquals(byteToUInt16(UByte.MIN), ushort(UByte.MIN_VALUE)); - assertEquals(byteToUInt16(UByte.MAX), ushort(UByte.MAX_VALUE)); + assertEquals(ushort(UByte.MIN_VALUE), byteToUInt16(UByte.MIN)); + assertEquals(ushort(UByte.MAX_VALUE), byteToUInt16(UByte.MAX)); } @Test public void testByteToUInt32() { - assertEquals(byteToUInt32(UByte.MIN), uint(UByte.MIN_VALUE)); - assertEquals(byteToUInt32(UByte.MAX), uint(UByte.MAX_VALUE)); + assertEquals(uint(UByte.MIN_VALUE), byteToUInt32(UByte.MIN)); + assertEquals(uint(UByte.MAX_VALUE), byteToUInt32(UByte.MAX)); } @Test public void testByteToUInt64() { - assertEquals(byteToUInt64(UByte.MIN), ulong(UByte.MIN_VALUE)); - assertEquals(byteToUInt64(UByte.MAX), ulong(UByte.MAX_VALUE)); + assertEquals(ulong(UByte.MIN_VALUE), byteToUInt64(UByte.MIN)); + assertEquals(ulong(UByte.MAX_VALUE), byteToUInt64(UByte.MAX)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java index e6c5b7c415..f0241e5b93 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ByteStringConversionsTest.java @@ -32,15 +32,14 @@ public void testByteStringToGuid() { UUID uuid = new UUID(msb, lsb); - assertEquals(uuid, ByteStringConversions.byteStringToGuid(bs)); + assertEquals(ByteStringConversions.byteStringToGuid(bs), uuid); } @Test public void testByteStringToString() { ByteString bs = ByteString.of(new byte[]{0x01, 0x02, 0x03}); - assertEquals(ByteBufUtil.hexDump(bs.bytesOrEmpty()), - ByteStringConversions.byteStringToString(bs)); + assertEquals(ByteStringConversions.byteStringToString(bs), ByteBufUtil.hexDump(bs.bytesOrEmpty())); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java index 5ea591fcb3..6c66073aeb 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/DateTimeConversionsTest.java @@ -45,12 +45,12 @@ public void testDateTimeToString() { Calendar c2 = Calendar.getInstance(); c2.setTime(now.getJavaDate()); - assertEquals(c1.get(Calendar.YEAR), c2.get(Calendar.YEAR)); - assertEquals(c1.get(Calendar.MONTH), c2.get(Calendar.MONTH)); - assertEquals(c1.get(Calendar.DAY_OF_MONTH), c2.get(Calendar.DAY_OF_MONTH)); - assertEquals(c1.get(Calendar.HOUR_OF_DAY), c2.get(Calendar.HOUR_OF_DAY)); - assertEquals(c1.get(Calendar.MINUTE), c2.get(Calendar.MINUTE)); - assertEquals(c1.get(Calendar.SECOND), c2.get(Calendar.SECOND)); + assertEquals(c2.get(Calendar.YEAR), c1.get(Calendar.YEAR)); + assertEquals(c2.get(Calendar.MONTH), c1.get(Calendar.MONTH)); + assertEquals(c2.get(Calendar.DAY_OF_MONTH), c1.get(Calendar.DAY_OF_MONTH)); + assertEquals(c2.get(Calendar.HOUR_OF_DAY), c1.get(Calendar.HOUR_OF_DAY)); + assertEquals(c2.get(Calendar.MINUTE), c1.get(Calendar.MINUTE)); + assertEquals(c2.get(Calendar.SECOND), c1.get(Calendar.SECOND)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java index 6c3cff8085..b3d8450272 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/ExpandedNodeIdConversionsTest.java @@ -32,7 +32,7 @@ public void testExpandedNodeIdToNodeId() { NodeId nodeId = new NodeId(0, "bar"); - assertEquals(expandedNodeIdToNodeId(nodeId.expanded()), nodeId); + assertEquals(nodeId, expandedNodeIdToNodeId(nodeId.expanded())); } @Test @@ -40,8 +40,8 @@ public void testExpandedNodeIdToString() { ExpandedNodeId e1 = new ExpandedNodeId(ushort(0), Namespaces.OPC_UA, "foo", uint(2)); ExpandedNodeId e2 = new NodeId(1, "bar").expanded(); - assertEquals(expandedNodeIdToString(e1), e1.toParseableString()); - assertEquals(expandedNodeIdToString(e2), e2.toParseableString()); + assertEquals(e1.toParseableString(), expandedNodeIdToString(e1)); + assertEquals(e2.toParseableString(), expandedNodeIdToString(e2)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java index f4c237b68b..3b404ae8a5 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/GuidConversionsTest.java @@ -31,14 +31,14 @@ public void testGuidToByteString() { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(msb).putLong(lsb); - assertEquals(bs, ByteString.of(bb.array())); + assertEquals(ByteString.of(bb.array()), bs); } @Test public void testGuidToString() { UUID uuid = UUID.randomUUID(); - assertEquals(uuid.toString(), GuidConversions.guidToString(uuid)); + assertEquals(GuidConversions.guidToString(uuid), uuid.toString()); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java index dc7c3368d9..49e73b8917 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/LocalizedTextConversionsTest.java @@ -22,7 +22,7 @@ public class LocalizedTextConversionsTest { public void testLocalizedTextToString() { LocalizedText text = new LocalizedText("en-us", "foo"); - assertEquals(localizedTextToString(text), "foo"); + assertEquals("foo", localizedTextToString(text)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java index 33f9437153..98755f32a1 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/NodeIdConversionsTest.java @@ -25,14 +25,14 @@ public void testNodeIdToExpandedNodeId() { NodeId nodeId = new NodeId(0, "foo"); ExpandedNodeId expanded = nodeId.expanded(); - assertEquals(nodeIdToExpandedNodeId(nodeId), expanded); + assertEquals(expanded, nodeIdToExpandedNodeId(nodeId)); } @Test public void testNodeIdToString() { NodeId nodeId = new NodeId(0, "foo"); - assertEquals(nodeIdToString(nodeId), nodeId.toParseableString()); + assertEquals(nodeId.toParseableString(), nodeIdToString(nodeId)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java index c6233431af..305cd4e4dc 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/events/conversions/QualifiedNameConversionsTest.java @@ -24,7 +24,7 @@ public class QualifiedNameConversionsTest { public void testQualifiedNameToString() { QualifiedName name = new QualifiedName(0, "foo"); - assertEquals(qualifiedNameToString(name), "foo"); + assertEquals("foo", qualifiedNameToString(name)); } @Test @@ -33,8 +33,8 @@ public void testQualifiedNameToLocalizedText() { LocalizedText text = qualifiedNameToLocalizedText(name); - assertEquals(text.getLocale(), ""); - assertEquals(text.getText(), "foo"); + assertEquals("", text.getLocale()); + assertEquals("foo", text.getText()); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java index fb730af277..a84e3ba5ba 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/UaNodeTest.java @@ -102,7 +102,7 @@ public NodeManager getNodeManager() { }; assertFalse(nodeManager.containsNode(nodeId)); - assertEquals(0, nodeManager.getReferences(nodeId).size()); + assertEquals(nodeManager.getReferences(nodeId).size(), 0); UaObjectNode objectNode = UaObjectNode.builder(nodeContext) .setNodeId(nodeId) @@ -127,8 +127,8 @@ public NodeManager getNodeManager() { objectNode.delete(); assertFalse(nodeManager.containsNode(nodeId)); - assertEquals(0, nodeManager.getReferences(nodeId).size()); - assertEquals(0, nodeManager.getReferences(Identifiers.ObjectNode).size()); + assertEquals(nodeManager.getReferences(nodeId).size(), 0); + assertEquals(nodeManager.getReferences(Identifiers.ObjectNode).size(), 0); } @Test @@ -139,7 +139,7 @@ public void testCreateDeleteComplexInstance() throws UaException { server.getAddressSpaceManager().register(nodeManager); assertFalse(nodeManager.containsNode(nodeId)); - assertEquals(0, nodeManager.getReferences(nodeId).size()); + assertEquals(nodeManager.getReferences(nodeId).size(), 0); NodeFactory nodeFactory = new NodeFactory( new UaNodeContext() { @@ -172,7 +172,7 @@ public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browse analogItem.delete(); assertFalse(nodeManager.containsNode(nodeId)); - assertEquals(0, nodeManager.getReferences(nodeId).size()); + assertEquals(nodeManager.getReferences(nodeId).size(), 0); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java index b97065b61c..aa3722de44 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/delegates/AttributeDelegateChainTest.java @@ -102,12 +102,12 @@ public NamespaceTable getNamespaceTable() { node.setValue(new DataValue(new Variant("foo"))); DataValue value = delegate.getValue(new AttributeContext(null, null), node); - assertEquals(value.getValue().getValue(), "foo"); + assertEquals("foo", value.getValue().getValue()); - assertEquals(list.get(0), "child3"); - assertEquals(list.get(1), "child2"); - assertEquals(list.get(2), "child1"); - assertEquals(list.get(3), "root"); + assertEquals("child3", list.get(0)); + assertEquals("child2", list.get(1)); + assertEquals("child1", list.get(2)); + assertEquals("root", list.get(3)); } } diff --git a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java index 08da46555f..0e54e58c6e 100644 --- a/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java +++ b/opc-ua-sdk/sdk-server/src/test/java/org/eclipse/milo/opcua/sdk/server/nodes/filters/AttributeFilterChainTest.java @@ -63,7 +63,7 @@ public void testAddFirst() { ); DataValue value = (DataValue) chain.getAttribute(null, AttributeId.Value); - assertEquals(value.getValue().getValue(), "B"); + assertEquals("B", value.getValue().getValue()); } @Test @@ -76,7 +76,7 @@ public void testAddLast() { ); DataValue value = (DataValue) chain.getAttribute(null, AttributeId.Value); - assertEquals(value.getValue().getValue(), "Last"); + assertEquals("Last", value.getValue().getValue()); } @Test @@ -93,7 +93,7 @@ public void testEmptyChain() { node.setValue(new DataValue(new Variant("foo"))); DataValue value = (DataValue) node.getFilterChain().getAttribute(node, AttributeId.Value); - assertEquals(value.getValue().getValue(), "foo"); + assertEquals("foo", value.getValue().getValue()); } @Test @@ -123,7 +123,7 @@ public void testObservable() { ) ); - assertEquals(node.getValue().getValue().getValue(), "foo"); + assertEquals("foo", node.getValue().getValue().getValue()); assertTrue(observed.get()); } diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientIT.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientIT.java index f051dc3091..04575e0d64 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientIT.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/OpcUaClientIT.java @@ -424,7 +424,7 @@ // Thread.sleep(5000); // // // one update for the initial subscribe, another after transfer -// assertEquals(updateCount.get(), 2); +// assertEquals(2, updateCount.get()); // // assertTrue(subscriptionTransferred.get()); // @@ -686,7 +686,7 @@ // .map(UaException::getStatusCode) // .orElse(StatusCode.BAD); // -// assertEquals(statusCode.getValue(), StatusCodes.Bad_SessionIdInvalid); +// assertEquals(StatusCodes.Bad_SessionIdInvalid, statusCode.getValue()); // } // // Thread.sleep(1000); diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java index af98ae2c8f..47b1a14700 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/api/identity/AnonymousProviderTest.java @@ -42,7 +42,7 @@ public void testGetIdentityToken() throws Exception { SignedIdentityToken signedIdentityToken = p.getIdentityToken(endpoint, ByteString.NULL_VALUE); - assertEquals(signedIdentityToken.getToken().getPolicyId(), "anonymous"); + assertEquals("anonymous", signedIdentityToken.getToken().getPolicyId()); assertTrue(signedIdentityToken.getToken() instanceof AnonymousIdentityToken); } @@ -64,7 +64,7 @@ public void testGetIdentityToken_EmptyPolicyId() throws Exception { SignedIdentityToken signedIdentityToken = p.getIdentityToken(endpoint, ByteString.NULL_VALUE); - assertEquals(signedIdentityToken.getToken().getPolicyId(), ""); + assertEquals("", signedIdentityToken.getToken().getPolicyId()); assertTrue(signedIdentityToken.getToken() instanceof AnonymousIdentityToken); } diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java index e6ae963ae9..bd871ea9b7 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java @@ -57,17 +57,17 @@ public void testCopy() { OpcUaClientConfig copy = OpcUaClientConfig.copy(original).build(); - assertEquals(copy.getSessionName(), original.getSessionName()); - assertEquals(copy.getSessionTimeout(), original.getSessionTimeout()); - assertEquals(copy.getRequestTimeout(), original.getRequestTimeout()); - assertEquals(copy.getMaxResponseMessageSize(), original.getMaxResponseMessageSize()); - assertEquals(copy.getMaxPendingPublishRequests(), original.getMaxPendingPublishRequests()); - assertEquals(copy.getIdentityProvider(), original.getIdentityProvider()); - assertEquals(copy.getKeepAliveFailuresAllowed(), original.getKeepAliveFailuresAllowed()); - assertEquals(copy.getKeepAliveInterval(), original.getKeepAliveInterval()); - assertEquals(copy.getKeepAliveTimeout(), original.getKeepAliveTimeout()); - assertEquals(copy.getSessionLocaleIds(), original.getSessionLocaleIds()); - assertEquals(copy.getSubscriptionWatchdogMultiplier(), original.getSubscriptionWatchdogMultiplier()); + assertEquals(original.getSessionName(), copy.getSessionName()); + assertEquals(original.getSessionTimeout(), copy.getSessionTimeout()); + assertEquals(original.getRequestTimeout(), copy.getRequestTimeout()); + assertEquals(original.getMaxResponseMessageSize(), copy.getMaxResponseMessageSize()); + assertEquals(original.getMaxPendingPublishRequests(), copy.getMaxPendingPublishRequests()); + assertEquals(original.getIdentityProvider(), copy.getIdentityProvider()); + assertEquals(original.getKeepAliveFailuresAllowed(), copy.getKeepAliveFailuresAllowed()); + assertEquals(original.getKeepAliveInterval(), copy.getKeepAliveInterval()); + assertEquals(original.getKeepAliveTimeout(), copy.getKeepAliveTimeout()); + assertEquals(original.getSessionLocaleIds(), copy.getSessionLocaleIds()); + assertEquals(original.getSubscriptionWatchdogMultiplier(), copy.getSubscriptionWatchdogMultiplier()); } @Test @@ -101,15 +101,15 @@ public void testCopyAndModify() { assertNotEquals(copy.getIdentityProvider(), original.getIdentityProvider()); assertNotEquals(copy.getSessionLocaleIds(), original.getSessionLocaleIds()); - assertEquals(copy.getSessionTimeout(), uint(0)); - assertEquals(copy.getRequestTimeout(), uint(0)); - assertEquals(copy.getMaxResponseMessageSize(), uint(0)); - assertEquals(copy.getMaxPendingPublishRequests(), uint(0)); - assertEquals(copy.getKeepAliveFailuresAllowed(), uint(2)); - assertEquals(copy.getKeepAliveInterval(), uint(10000)); - assertEquals(copy.getKeepAliveTimeout(), uint(15000)); + assertEquals(uint(0), copy.getSessionTimeout()); + assertEquals(uint(0), copy.getRequestTimeout()); + assertEquals(uint(0), copy.getMaxResponseMessageSize()); + assertEquals(uint(0), copy.getMaxPendingPublishRequests()); + assertEquals(uint(2), copy.getKeepAliveFailuresAllowed()); + assertEquals(uint(10000), copy.getKeepAliveInterval()); + assertEquals(uint(15000), copy.getKeepAliveTimeout()); assertArrayEquals(copy.getSessionLocaleIds(), new String[]{"en", "es"}); - assertEquals(copy.getSubscriptionWatchdogMultiplier(), 3.0); + assertEquals(3.0, copy.getSubscriptionWatchdogMultiplier()); } } diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java index bbbbaa81a3..d0bb5c9402 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/subscriptions/ClientHandleSequenceTest.java @@ -25,17 +25,17 @@ public class ClientHandleSequenceTest { public void testRollover() { ClientHandleSequence sequence = new ClientHandleSequence(h -> false, UInteger.MAX_VALUE - 1); - assertEquals(uint(UInteger.MAX_VALUE - 1), sequence.nextClientHandle()); - assertEquals(UInteger.MAX, sequence.nextClientHandle()); - assertEquals(uint(0), sequence.nextClientHandle()); - assertEquals(uint(1), sequence.nextClientHandle()); + assertEquals(sequence.nextClientHandle(), uint(UInteger.MAX_VALUE - 1)); + assertEquals(sequence.nextClientHandle(), UInteger.MAX); + assertEquals(sequence.nextClientHandle(), uint(0)); + assertEquals(sequence.nextClientHandle(), uint(1)); } @Test public void testInUsePredicate() { ClientHandleSequence sequence = new ClientHandleSequence(h -> h.longValue() < 10); - assertEquals(uint(10), sequence.nextClientHandle()); + assertEquals(sequence.nextClientHandle(), uint(10)); } // Slow; enable to test manually. diff --git a/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java b/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java index ebbac33e98..14917f16f6 100644 --- a/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java +++ b/opc-ua-stack/bsd-parser/src/test/java/org/eclipse/milo/opcua/binaryschema/BsdParserTest.java @@ -148,7 +148,7 @@ protected void assertRoundTrip(String type, Object originalValue, OpcUaBinaryDat System.out.println("encodedValue:\t" + ByteBufUtil.hexDump(encodedValue)); Object decodedValue = codec.decode(context, new OpcUaBinaryStreamDecoder(context).setBuffer(buffer)); - assertEquals(decodedValue, originalValue); + assertEquals(originalValue, decodedValue); System.out.println("decodedValue:\t" + decodedValue); } @@ -175,7 +175,7 @@ protected void assertRoundTripUsingToString( System.out.println("encodedValue:\t" + ByteBufUtil.hexDump(encodedValue)); Object decodedValue = codec.decode(context, new OpcUaBinaryStreamDecoder(context).setBuffer(buffer)); - assertEquals(decodedValue.toString(), originalValue.toString()); + assertEquals(originalValue.toString(), decodedValue.toString()); System.out.println("decodedValue:\t" + decodedValue); } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java index 2cead5c390..9f2e4bd468 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/SerializationFixture2.java @@ -28,7 +28,7 @@ protected void assertSerializable(T encoded, T decoded = decoder.apply(encoder.apply(encoded, buffer)); - assertEquals(encoded, decoded); + assertEquals(decoded, encoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java index 517c65eb5d..17f5b217e2 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/AttributeIdTest.java @@ -26,7 +26,7 @@ public void testFrom() { for (AttributeId attributeId : AttributeId.values()) { int id = attributeId.id(); - assertEquals(attributeId, AttributeId.from(id).get()); + assertEquals(AttributeId.from(id).get(), attributeId); } assertFalse(AttributeId.from(-1).isPresent()); @@ -38,19 +38,19 @@ public void testFrom() { public void testOrdering() { List attributes = Lists.newArrayList(AttributeId.VARIABLE_TYPE_ATTRIBUTES); - assertEquals(AttributeId.NodeId, attributes.get(0)); - assertEquals(AttributeId.NodeClass, attributes.get(1)); - assertEquals(AttributeId.BrowseName, attributes.get(2)); - assertEquals(AttributeId.DisplayName, attributes.get(3)); - assertEquals(AttributeId.Description, attributes.get(4)); - assertEquals(AttributeId.WriteMask, attributes.get(5)); - assertEquals(AttributeId.UserWriteMask, attributes.get(6)); - - assertEquals(AttributeId.Value, attributes.get(7)); - assertEquals(AttributeId.DataType, attributes.get(8)); - assertEquals(AttributeId.ValueRank, attributes.get(9)); - assertEquals(AttributeId.ArrayDimensions, attributes.get(10)); - assertEquals(AttributeId.IsAbstract, attributes.get(11)); + assertEquals(attributes.get(0), AttributeId.NodeId); + assertEquals(attributes.get(1), AttributeId.NodeClass); + assertEquals(attributes.get(2), AttributeId.BrowseName); + assertEquals(attributes.get(3), AttributeId.DisplayName); + assertEquals(attributes.get(4), AttributeId.Description); + assertEquals(attributes.get(5), AttributeId.WriteMask); + assertEquals(attributes.get(6), AttributeId.UserWriteMask); + + assertEquals(attributes.get(7), AttributeId.Value); + assertEquals(attributes.get(8), AttributeId.DataType); + assertEquals(attributes.get(9), AttributeId.ValueRank); + assertEquals(attributes.get(10), AttributeId.ArrayDimensions); + assertEquals(attributes.get(11), AttributeId.IsAbstract); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java index d11e4cab35..5913b8e26a 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/security/DefaultTrustListManagerTest.java @@ -54,19 +54,19 @@ public void testPruneRejectedCertificateDir() throws Exception { File[] rejectedFiles = rejectedDir.listFiles(); assertNotNull(rejectedFiles); - assertEquals(rejectedFiles.length, DefaultTrustListManager.MAX_REJECTED_CERTIFICATES); + assertEquals(DefaultTrustListManager.MAX_REJECTED_CERTIFICATES, rejectedFiles.length); trustListManager.pruneOldRejectedCertificates(); rejectedFiles = rejectedDir.listFiles(); assertNotNull(rejectedFiles); - assertEquals(rejectedFiles.length, DefaultTrustListManager.MAX_REJECTED_CERTIFICATES - 1); + assertEquals(DefaultTrustListManager.MAX_REJECTED_CERTIFICATES - 1, rejectedFiles.length); } @Test public void testSanitizeForUseInFilename_Wildcard() throws Exception { String sanitized = DefaultTrustListManager.sanitizeForUseInFilename("*.digitalpetri.com"); - assertEquals(sanitized, "_.digitalpetri.com"); + assertEquals("_.digitalpetri.com", sanitized); } @Test @@ -85,7 +85,7 @@ public void testSanitizeForUseInFilename_WindowsReserved() throws Exception { */ String sanitized = DefaultTrustListManager.sanitizeForUseInFilename("<>:\"/\\|?*"); - assertEquals(sanitized, "%3C%3E%3A%22%2F%5C%7C%3F_"); + assertEquals("%3C%3E%3A%22%2F%5C%7C%3F_", sanitized); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java index eedfa68974..d2514ae3ba 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java @@ -52,7 +52,7 @@ public void testDecodeNullArray() { codec.encode(new TestSerializationContext(), writer, argument); Argument decoded = codec.decode(new TestSerializationContext(), reader); - assertEquals(decoded.getName(), argument.getName()); + assertEquals(argument.getName(), decoded.getName()); assertNull(decoded.getArrayDimensions()); } @@ -62,7 +62,7 @@ public void testEnumScalar() { writer.writeEnum(null, ApplicationType.Client); ApplicationType decoded = reader.readEnum(null, ApplicationType.class); - assertEquals(decoded, ApplicationType.Client); + assertEquals(ApplicationType.Client, decoded); } @Test diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java index dd33c0dd70..666840dd1a 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DataValueSerializationTest.java @@ -41,7 +41,7 @@ public void testDataValueRoundTrip(DataValue value) { decoder.setBuffer(buffer); DataValue decodedValue = decoder.readDataValue(); - assertEquals(decodedValue, value); + assertEquals(value, decodedValue); } public static Object[][] getValues() { diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java index 11abc6453e..b1793e7266 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/DiagnosticInfoSerializationTest.java @@ -39,7 +39,7 @@ public void testDiagnosticInfoRoundTrip(DiagnosticInfo diagnosticInfo) { writer.writeDiagnosticInfo(diagnosticInfo); DiagnosticInfo decoded = reader.readDiagnosticInfo(); - assertEquals(decoded, diagnosticInfo); + assertEquals(diagnosticInfo, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java index 45b86fed77..1dca52f35d 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExpandedNodeIdSerializationTest.java @@ -49,7 +49,7 @@ public void testExpandedNodeIdRoundTrip(ExpandedNodeId nodeId) throws Exception writer.writeExpandedNodeId(nodeId); ExpandedNodeId decoded = reader.readExpandedNodeId(); - assertEquals(decoded, nodeId); + assertEquals(nodeId, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java index 059f31e4f7..051b161d5a 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/ExtensionObjectSerializationTest.java @@ -36,7 +36,7 @@ public void testExtensionObjectRoundTrip(ExtensionObject xo) throws Exception { writer.writeExtensionObject(xo); ExtensionObject decoded = reader.readExtensionObject(); - assertEquals(decoded, xo); + assertEquals(xo, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java index 77f63b8226..8f3ecf5dd8 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/GuidSerializationTest.java @@ -37,7 +37,7 @@ public void testGuidRoundTrip(UUID uuid) throws Exception { writer.writeGuid(uuid); UUID decoded = reader.readGuid(); - assertEquals(decoded, uuid); + assertEquals(uuid, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java index 4c668bc892..e8fe376b9e 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/LocalizedTextSerializationTest.java @@ -35,7 +35,7 @@ public void testLocalizedText(LocalizedText localizedText) throws Exception { writer.writeLocalizedText(localizedText); LocalizedText decoded = reader.readLocalizedText(); - assertEquals(decoded, localizedText); + assertEquals(localizedText, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java index 450f47c5cf..eabdab10a2 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/NodeIdSerializationTest.java @@ -53,7 +53,7 @@ public void testNodeIdRoundTrip(NodeId nodeId) throws Exception { writer.writeNodeId(nodeId); NodeId decoded = reader.readNodeId(); - assertEquals(decoded, nodeId); + assertEquals(nodeId, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java index 205996b383..8f7fa73b24 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/OpcUaBinaryStreamEncoderTest.java @@ -42,7 +42,7 @@ public void testWriteBit() throws Exception { writer.writeBit(0); writer.writeBit(0); writer.writeBit(0); - assertEquals(buffer.readUnsignedByte(), 0b00001111); + assertEquals(0b00001111, buffer.readUnsignedByte()); } { writer.writeBit(0); @@ -53,7 +53,7 @@ public void testWriteBit() throws Exception { writer.writeBit(1); writer.writeBit(1); writer.writeBit(1); - assertEquals(buffer.readUnsignedByte(), 0b11110000); + assertEquals(0b11110000, buffer.readUnsignedByte()); } { writer.writeBit(0); @@ -64,7 +64,7 @@ public void testWriteBit() throws Exception { writer.writeBit(1); writer.writeBit(0); writer.writeBit(1); - assertEquals(buffer.readUnsignedByte(), 0b10101010); + assertEquals(0b10101010, buffer.readUnsignedByte()); } { writer.writeBit(1); @@ -75,7 +75,7 @@ public void testWriteBit() throws Exception { writer.writeBit(0); writer.writeBit(1); writer.writeBit(0); - assertEquals(buffer.readUnsignedByte(), 0b01010101); + assertEquals(0b01010101, buffer.readUnsignedByte()); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java index 9a03523947..77da4dd14e 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/StringSerializationTest.java @@ -32,7 +32,7 @@ public void testStringRoundTrip(String value) { writer.writeString(value); String decoded = reader.readString(); - assertEquals(decoded, value); + assertEquals(value, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java index cdfc8557dd..3ebd066ddb 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/VariantSerializationTest.java @@ -53,7 +53,7 @@ public void testVariantRoundTrip(Variant variant) { writer.writeVariant(variant); Variant decoded = reader.readVariant(); - assertEquals(decoded, variant); + assertEquals(variant, decoded); } @Test @@ -70,8 +70,8 @@ public void testVariant_UaStructure() { ExtensionObject extensionObject = (ExtensionObject) decoded.getValue(); ServiceCounterDataType sc2 = (ServiceCounterDataType) extensionObject.decode(new TestSerializationContext()); - assertEquals(sc1.getTotalCount(), sc2.getTotalCount()); - assertEquals(sc1.getErrorCount(), sc2.getErrorCount()); + assertEquals(sc2.getTotalCount(), sc1.getTotalCount()); + assertEquals(sc2.getErrorCount(), sc1.getErrorCount()); } public static Object[][] getPrimitiveArrayVariants() { @@ -97,7 +97,7 @@ public void testPrimitiveArrayVariantRoundTrip(Variant variant, Variant expected writer.writeVariant(variant); Variant decoded = reader.readVariant(); - assertEquals(decoded, expected); + assertEquals(expected, decoded); } @Test diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java index 39082752c9..406ae4e128 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/XmlElementSerializationTest.java @@ -33,7 +33,7 @@ public void testXmlElementRoundTrip(XmlElement element) throws Exception { writer.writeXmlElement(element); XmlElement decoded = reader.readXmlElement(); - assertEquals(decoded, element); + assertEquals(element, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java index 5ec141b7c4..78182251fb 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ByteStringTest.java @@ -23,7 +23,7 @@ public void testByteStringEquals() { ByteString bs2 = ByteString.of(new byte[]{1, 2, 3, 4}); ByteString bs3 = ByteString.of(new byte[]{1, 2, 3, 4, 5}); - assertEquals(bs1, bs2); + assertEquals(bs2, bs1); assertNotEquals(bs1, bs3); assertNotEquals(bs2, bs3); diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java index a745bcad39..2e45844815 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/DateTimeTest.java @@ -38,13 +38,13 @@ public void getJavaInstant() { ZonedDateTime outputZdt = ZonedDateTime.ofInstant(outputInstant, ZoneId.systemDefault()); - assertEquals(outputZdt.getYear(), inputZdt.getYear()); - assertEquals(outputZdt.getMonth(), inputZdt.getMonth()); - assertEquals(outputZdt.getDayOfMonth(), inputZdt.getDayOfMonth()); - assertEquals(outputZdt.getHour(), inputZdt.getHour()); - assertEquals(outputZdt.getMinute(), inputZdt.getMinute()); - assertEquals(outputZdt.getSecond(), inputZdt.getSecond()); - assertEquals(outputZdt.getNano(), 123_456_700); + assertEquals(inputZdt.getYear(), outputZdt.getYear()); + assertEquals(inputZdt.getMonth(), outputZdt.getMonth()); + assertEquals(inputZdt.getDayOfMonth(), outputZdt.getDayOfMonth()); + assertEquals(inputZdt.getHour(), outputZdt.getHour()); + assertEquals(inputZdt.getMinute(), outputZdt.getMinute()); + assertEquals(inputZdt.getSecond(), outputZdt.getSecond()); + assertEquals(123_456_700, outputZdt.getNano()); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java index d70dfad549..b8f3061cb9 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/ExpandedNodeIdTest.java @@ -120,13 +120,13 @@ public void testEqualityWithNodeId() { @Test public void testToParseableString() { String withoutNamespaceUri = new ExpandedNodeId(ushort(1), null, uint(0)).toParseableString(); - assertEquals(withoutNamespaceUri, "ns=1;i=0"); + assertEquals("ns=1;i=0", withoutNamespaceUri); String withNamespaceUri = new ExpandedNodeId(ushort(0), "urn:test", uint(0)).toParseableString(); - assertEquals(withNamespaceUri, "nsu=urn:test;i=0"); + assertEquals("nsu=urn:test;i=0", withNamespaceUri); String withServerIndex = new ExpandedNodeId(ushort(0), "urn:test", uint(0), uint(1)).toParseableString(); - assertEquals(withServerIndex, "svr=1;nsu=urn:test;i=0"); + assertEquals("svr=1;nsu=urn:test;i=0", withServerIndex); } @Test @@ -136,7 +136,7 @@ public void absolute() { ExpandedNodeId absolute = xni.absolute(new NamespaceTable()).orElseThrow(RuntimeException::new); assertTrue(absolute.isAbsolute()); - assertEquals(Namespaces.OPC_UA, absolute.getNamespaceUri()); + assertEquals(absolute.getNamespaceUri(), Namespaces.OPC_UA); } @Test @@ -147,7 +147,7 @@ public void relative() { ExpandedNodeId relative = xni.relative(new NamespaceTable()).orElseThrow(RuntimeException::new); assertTrue(relative.isRelative()); assertNull(relative.getNamespaceUri()); - assertEquals(ushort(0), relative.getNamespaceIndex()); + assertEquals(relative.getNamespaceIndex(), ushort(0)); } @Test @@ -155,14 +155,14 @@ public void parseImplicitNamespaceZero() { ExpandedNodeId xni = ExpandedNodeId.parse("i=2256"); assertNotNull(xni); - assertEquals(xni.getNamespaceIndex(), ushort(0)); + assertEquals(ushort(0), xni.getNamespaceIndex()); } @Test public void toParseableExplicitNamespaceZero() { ExpandedNodeId xni = new ExpandedNodeId(ushort(0), null, "test"); - assertEquals("ns=0;s=test", xni.toParseableString()); + assertEquals(xni.toParseableString(), "ns=0;s=test"); } @Test @@ -176,7 +176,7 @@ public void parseNamespaceUriContainingEquals() { "http://softing.com/dataFEEDSIS/nsuri?conn=Demo&uri=http://opcfoundation.org/UA/" ); - assertEquals(xni.getIdentifier(), uint(85)); + assertEquals(uint(85), xni.getIdentifier()); } @Test @@ -185,8 +185,8 @@ public void parseIdentifierContainingSemiColons() { "nsu=http://foo.com/bar;s=O=::/#pc;B=::/#pc;S=pc;" ); - assertEquals(xni.getNamespaceUri(), "http://foo.com/bar"); - assertEquals(xni.getIdentifier(), "O=::/#pc;B=::/#pc;S=pc;"); + assertEquals("http://foo.com/bar", xni.getNamespaceUri()); + assertEquals("O=::/#pc;B=::/#pc;S=pc;", xni.getIdentifier()); } @Test @@ -199,7 +199,7 @@ public void reindex() { ExpandedNodeId xni2 = xni1.reindex(namespaceTable, "test2"); - assertEquals(ushort(2), xni2.getNamespaceIndex()); + assertEquals(xni2.getNamespaceIndex(), ushort(2)); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java index f19b71de72..9ca927b3a4 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/NodeIdTest.java @@ -40,7 +40,7 @@ public void testParseLargerThanIntMax() { NodeId nodeId = NodeId.parse("ns=1;i=" + i); assertNotNull(nodeId); - assertEquals(nodeId.getIdentifier(), uint(i)); + assertEquals(uint(i), nodeId.getIdentifier()); } @Test @@ -65,8 +65,8 @@ public void testParseNamespaceIndex() { for (int i = 0; i < UShort.MAX_VALUE; i++) { NodeId nodeId = NodeId.parseOrNull("ns=" + i + ";i=" + i); assertNotNull(nodeId); - assertEquals(nodeId.getNamespaceIndex(), ushort(i)); - assertEquals(nodeId.getIdentifier(), uint(i)); + assertEquals(ushort(i), nodeId.getNamespaceIndex()); + assertEquals(uint(i), nodeId.getIdentifier()); } } @@ -95,12 +95,12 @@ public void testParseGuid() { { NodeId nodeId = NodeId.parseOrNull("g=" + uuid.toString()); assertNotNull(nodeId); - assertEquals(nodeId.getIdentifier(), uuid); + assertEquals(uuid, nodeId.getIdentifier()); } { NodeId nodeId = NodeId.parseOrNull("ns=0;g=" + uuid.toString()); assertNotNull(nodeId); - assertEquals(nodeId.getIdentifier(), uuid); + assertEquals(uuid, nodeId.getIdentifier()); } } } @@ -117,12 +117,12 @@ public void testParseByteString() { { NodeId nodeId = NodeId.parseOrNull("b=" + bss); assertNotNull(nodeId); - assertEquals(nodeId.getIdentifier(), ByteString.of(bs)); + assertEquals(ByteString.of(bs), nodeId.getIdentifier()); } { NodeId nodeId = NodeId.parseOrNull("ns=0;b=" + bss); assertNotNull(nodeId); - assertEquals(nodeId.getIdentifier(), ByteString.of(bs)); + assertEquals(ByteString.of(bs), nodeId.getIdentifier()); } } } @@ -181,15 +181,15 @@ public void testExpandedWithNamespaceTable() { NodeId nodeId = new NodeId(1, "foo"); ExpandedNodeId xni = nodeId.expanded(namespaceTable); - assertEquals(xni.getNamespaceUri(), "urn:test"); + assertEquals("urn:test", xni.getNamespaceUri()); } @Test public void parseIdentifierContainingSemiColons() { NodeId nodeId = NodeId.parse("ns=14;s=O=::/#pc;B=::/#pc;S=pc;"); - assertEquals(nodeId.getNamespaceIndex(), ushort(14)); - assertEquals(nodeId.getIdentifier(), "O=::/#pc;B=::/#pc;S=pc;"); + assertEquals(ushort(14), nodeId.getNamespaceIndex()); + assertEquals("O=::/#pc;B=::/#pc;S=pc;", nodeId.getIdentifier()); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java index a4cac5f800..d90fa5c64f 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/QualifiedNameTest.java @@ -28,7 +28,7 @@ public void testToStringAndBack2() { private void assertSymmetry(String string) { String reString = QualifiedName.parse(string).toParseableString(); - assertEquals(reString, string); + assertEquals(string, reString); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java index 2d3d2171a9..2ea5986a5e 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/structured/ApplicationDescriptionTest.java @@ -41,7 +41,7 @@ public void testApplicationDescriptionEquals() { new String[]{"a", "b", "c"} ); - assertEquals(applicationDescription1, applicationDescription2); + assertEquals(applicationDescription2, applicationDescription1); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java index f24156cd21..e8afae4da5 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java @@ -47,7 +47,7 @@ public void testFlatten(Object array) throws Exception { Object flattened = ArrayUtil.flatten(array); for (int i = 0; i < Array.getLength(flattened); i++) { - assertEquals(Array.get(flattened, i), i); + assertEquals(i, Array.get(flattened, i)); } } @@ -85,7 +85,7 @@ public static Object[][] getTypedArrays() { @ParameterizedTest @MethodSource("getTypedArrays") public void testGetType(Object array, Class type) throws Exception { - assertEquals(ArrayUtil.getType(array), type); + assertEquals(type, ArrayUtil.getType(array)); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java index 7a20cf3e6d..72faaa20a3 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/CertificateUtilTest.java @@ -65,26 +65,26 @@ public void testGetSubjectAltNameField() { .getSubjectAltNameField(certificate, CertificateUtil.SUBJECT_ALT_NAME_IP_ADDRESS) .get(0); - assertEquals(uri, "urn:eclipse:milo:test"); - assertEquals(dnsName, "localhost"); - assertEquals(ipAddress, "127.0.0.1"); + assertEquals("urn:eclipse:milo:test", uri); + assertEquals("localhost", dnsName); + assertEquals("127.0.0.1", ipAddress); } @Test public void testGetSanUri() { - assertEquals(CertificateUtil.getSanUri(certificate).orElse(null), "urn:eclipse:milo:test"); + assertEquals("urn:eclipse:milo:test", CertificateUtil.getSanUri(certificate).orElse(null)); } @Test public void testGetSanDnsNames() { List sanDnsNames = CertificateUtil.getSanDnsNames(certificate); - assertEquals(sanDnsNames, newArrayList("localhost", "hostname")); + assertEquals(newArrayList("localhost", "hostname"), sanDnsNames); } @Test public void testGetSanIpAddresses() { List sanDnsNames = CertificateUtil.getSanIpAddresses(certificate); - assertEquals(sanDnsNames, newArrayList("127.0.0.1", "127.0.0.2")); + assertEquals(newArrayList("127.0.0.1", "127.0.0.2"), sanDnsNames); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java index 6d94330e0f..ad96ab58f8 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/EndpointUtilTest.java @@ -19,25 +19,24 @@ public class EndpointUtilTest { @Test public void testGetPath() { - assertEquals(EndpointUtil.getPath("opc.tcp://localhost:4840/foo"), "/foo"); - assertEquals(EndpointUtil.getPath("opc.tcp://localhost:4840/foo/"), "/foo"); - assertEquals(EndpointUtil.getPath("opc.tcp://invalid_host:4840/foo"), "/foo"); - assertEquals(EndpointUtil.getPath("opc.tcp://invalid_host:4840/foo/"), "/foo"); + assertEquals("/foo", EndpointUtil.getPath("opc.tcp://localhost:4840/foo")); + assertEquals("/foo", EndpointUtil.getPath("opc.tcp://localhost:4840/foo/")); + assertEquals("/foo", EndpointUtil.getPath("opc.tcp://invalid_host:4840/foo")); + assertEquals("/foo", EndpointUtil.getPath("opc.tcp://invalid_host:4840/foo/")); } @Test public void testGetPath_EmptyAndSlash() { - assertEquals(EndpointUtil.getPath("opc.tcp://localhost:4840"), "/"); - assertEquals(EndpointUtil.getPath("opc.tcp://localhost:4840/"), "/"); - assertEquals(EndpointUtil.getPath("opc.tcp://invalid_host:4840"), "/"); - assertEquals(EndpointUtil.getPath("opc.tcp://invalid_host:4840/"), "/"); + assertEquals("/", EndpointUtil.getPath("opc.tcp://localhost:4840")); + assertEquals("/", EndpointUtil.getPath("opc.tcp://localhost:4840/")); + assertEquals("/", EndpointUtil.getPath("opc.tcp://invalid_host:4840")); + assertEquals("/", EndpointUtil.getPath("opc.tcp://invalid_host:4840/")); } @Test public void testGetPath_Invalid() { - assertEquals(EndpointUtil.getPath("opc.tcp://localhost:4840/no spaces allowed"), - "/no spaces allowed"); + assertEquals("/no spaces allowed", EndpointUtil.getPath("opc.tcp://localhost:4840/no spaces allowed")); } @Test @@ -59,17 +58,17 @@ public void testIpv6() { String withPath = "opc.tcp://[fe80::9289:e377:bacb:f608%enp0s31f6]:4840/foo"; String withoutPath = "opc.tcp://[fe80::9289:e377:bacb:f608%enp0s31f6]:4840"; - assertEquals(EndpointUtil.getScheme(withPath), "opc.tcp"); - assertEquals(EndpointUtil.getScheme(withoutPath), "opc.tcp"); + assertEquals("opc.tcp", EndpointUtil.getScheme(withPath)); + assertEquals("opc.tcp", EndpointUtil.getScheme(withoutPath)); - assertEquals(EndpointUtil.getHost(withPath), "[fe80::9289:e377:bacb:f608%enp0s31f6]"); - assertEquals(EndpointUtil.getHost(withoutPath), "[fe80::9289:e377:bacb:f608%enp0s31f6]"); + assertEquals("[fe80::9289:e377:bacb:f608%enp0s31f6]", EndpointUtil.getHost(withPath)); + assertEquals("[fe80::9289:e377:bacb:f608%enp0s31f6]", EndpointUtil.getHost(withoutPath)); - assertEquals(EndpointUtil.getPort(withPath), 4840); - assertEquals(EndpointUtil.getPort(withoutPath), 4840); + assertEquals(4840, EndpointUtil.getPort(withPath)); + assertEquals(4840, EndpointUtil.getPort(withoutPath)); - assertEquals(EndpointUtil.getPath(withPath), "/foo"); - assertEquals(EndpointUtil.getPath(withoutPath), "/"); + assertEquals("/foo", EndpointUtil.getPath(withPath)); + assertEquals("/", EndpointUtil.getPath(withoutPath)); } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java index 1ec939a8a4..fd4c5b4419 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ExecutionQueueTest.java @@ -62,7 +62,7 @@ public void testWithConcurrency() throws InterruptedException { } latch.await(); - assertEquals(count.get(), 100000); + assertEquals(100000, count.get()); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java index a621f1e04e..cae841f427 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/LazyTest.java @@ -27,10 +27,10 @@ public void lazyRetainsNonNullValue() { Object instance = new Object(); Object o1 = lazy.getOrCompute(() -> instance); - assertEquals(o1, instance); + assertEquals(instance, o1); Object o2 = lazy.getOrCompute(() -> instance); - assertEquals(o2, instance); + assertEquals(instance, o2); } @Test @@ -62,10 +62,10 @@ public Object get() { }; Object o1 = lazy.getOrCompute(supplier); - assertEquals(o1, instance); + assertEquals(instance, o1); Object o2 = lazy.getOrCompute(supplier); - assertEquals(o2, instance); + assertEquals(instance, o2); } @Test @@ -91,12 +91,12 @@ public Object get() { }; Object o1 = lazy.getOrCompute(supplier); - assertEquals(o1, instance1); + assertEquals(instance1, o1); lazy.reset(); Object o2 = lazy.getOrCompute(supplier); - assertEquals(o2, instance2); + assertEquals(instance2, o2); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java index bb8328ba01..f87d05fc92 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/NonceUtilTest.java @@ -28,13 +28,13 @@ public void testSecureChannelNonceGeneration() { switch (securityPolicy) { case None: - assertEquals(nonce.length(), 0); + assertEquals(0, nonce.length()); break; case Basic128Rsa15: - assertEquals(nonce.length(), 16); + assertEquals(16, nonce.length()); break; default: - assertEquals(nonce.length(), 32); + assertEquals(32, nonce.length()); } } } @@ -43,7 +43,7 @@ public void testSecureChannelNonceGeneration() { public void testNonceGeneration() throws UaException { for (int i = 32; i < 256; i++) { ByteString nonce = NonceUtil.generateNonce(i); - assertEquals(nonce.length(), i); + assertEquals(i, nonce.length()); NonceUtil.validateNonce(nonce); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java index 848d74943d..a600892aea 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/validation/CertificateValidationUtilTest.java @@ -230,7 +230,7 @@ public void testBuildAndValidate_LeafIntermediateSigned_Revoked() { ); }); - assertEquals(e.getStatusCode(), new StatusCode(StatusCodes.Bad_CertificateRevoked)); + assertEquals(new StatusCode(StatusCodes.Bad_CertificateRevoked), e.getStatusCode()); } // chain: leaf @@ -272,7 +272,7 @@ public void testBuildAndValidate_LeafIntermediateSigned_Revoked() { ); }); - assertEquals(e.getStatusCode(), new StatusCode(StatusCodes.Bad_CertificateIssuerRevoked)); + assertEquals(new StatusCode(StatusCodes.Bad_CertificateIssuerRevoked), e.getStatusCode()); } } @@ -394,7 +394,7 @@ public void testBuildAndValidate_IssuerRevoked() { ); }); - assertEquals(e.getStatusCode(), new StatusCode(StatusCodes.Bad_CertificateIssuerRevoked)); + assertEquals(new StatusCode(StatusCodes.Bad_CertificateIssuerRevoked), e.getStatusCode()); } } diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java index 3fbee01e25..78ca40da66 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ChunkSerializationTest.java @@ -179,7 +179,7 @@ public void testAsymmetric4096() throws Exception { ByteBuf message = decodedMessage.getMessage(); messageBuffer.readerIndex(0); - assertEquals(message, messageBuffer); + assertEquals(messageBuffer, message); ReferenceCountUtil.release(message); ReferenceCountUtil.release(messageBuffer); @@ -242,7 +242,7 @@ public void testSymmetric4096() throws Exception { ByteBuf message = decodedMessage.getMessage(); messageBuffer.readerIndex(0); - assertEquals(message, messageBuffer); + assertEquals(messageBuffer, message); ReferenceCountUtil.release(message); ReferenceCountUtil.release(messageBuffer); @@ -317,7 +317,7 @@ public void testAsymmetricMessage(SecurityPolicy securityPolicy, ByteBuf message = decodedMessage.getMessage(); messageBuffer.readerIndex(0); - assertEquals(message, messageBuffer); + assertEquals(messageBuffer, message); ReferenceCountUtil.release(message); ReferenceCountUtil.release(messageBuffer); @@ -415,7 +415,7 @@ public void testSymmetricMessage(SecurityPolicy securityPolicy, ByteBuf message = decodedMessage.getMessage(); messageBuffer.readerIndex(0); - assertEquals(message, messageBuffer); + assertEquals(messageBuffer, message); ReferenceCountUtil.release(messageBuffer); ReferenceCountUtil.release(message); diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java index a14ac9191a..42dbd0a501 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/ClientServerTest.java @@ -464,7 +464,7 @@ public void testClientTimeout() throws Exception { .extractStatusCode(t) .orElse(StatusCode.BAD); - assertEquals(statusCode.getValue(), StatusCodes.Bad_Timeout); + assertEquals(StatusCodes.Bad_Timeout, statusCode.getValue()); } } @@ -520,7 +520,7 @@ private void connectAndTest(Variant input, UaStackClient client) throws Interrup FutureUtils.sequence(responses).get().forEach(response -> { Variant value = l(response.getResults()).get(0).getValue(); - assertEquals(value, input); + assertEquals(input, value); }); client.disconnect().get(); diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java index d4d68b6687..9eda581270 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/client/config/UaStackClientConfigTest.java @@ -77,16 +77,16 @@ public void testCopy() { UaStackClientConfig copy = UaStackClientConfig.copy(original).build(); - assertEquals(copy.getKeyPair(), original.getKeyPair()); - assertEquals(copy.getCertificate(), original.getCertificate()); - assertEquals(copy.getCertificateChain(), original.getCertificateChain()); - assertEquals(copy.getCertificateValidator(), original.getCertificateValidator()); - assertEquals(copy.getEncodingLimits(), original.getEncodingLimits()); - assertEquals(copy.getChannelLifetime(), original.getChannelLifetime()); - assertEquals(copy.getExecutor(), original.getExecutor()); - assertEquals(copy.getEventLoop(), original.getEventLoop()); - assertEquals(copy.getWheelTimer(), original.getWheelTimer()); - assertEquals(copy.getAcknowledgeTimeout(), original.getAcknowledgeTimeout()); + assertEquals(original.getKeyPair(), copy.getKeyPair()); + assertEquals(original.getCertificate(), copy.getCertificate()); + assertEquals(original.getCertificateChain(), copy.getCertificateChain()); + assertEquals(original.getCertificateValidator(), copy.getCertificateValidator()); + assertEquals(original.getEncodingLimits(), copy.getEncodingLimits()); + assertEquals(original.getChannelLifetime(), copy.getChannelLifetime()); + assertEquals(original.getExecutor(), copy.getExecutor()); + assertEquals(original.getEventLoop(), copy.getEventLoop()); + assertEquals(original.getWheelTimer(), copy.getWheelTimer()); + assertEquals(original.getAcknowledgeTimeout(), copy.getAcknowledgeTimeout()); } @Test @@ -116,13 +116,13 @@ public void testCopyAndModify() { .setAcknowledgeTimeout(uint(12345)) ); - assertEquals(copy.getKeyPair(), Optional.empty()); - assertEquals(copy.getCertificate(), Optional.empty()); - assertEquals(copy.getCertificateChain(), Optional.empty()); - assertEquals(copy.getCertificateValidator(), null); - assertEquals(copy.getEncodingLimits(), null); - assertEquals(copy.getChannelLifetime(), uint(0)); - assertEquals(copy.getAcknowledgeTimeout(), uint(12345)); + assertEquals(Optional.empty(), copy.getKeyPair()); + assertEquals(Optional.empty(), copy.getCertificate()); + assertEquals(Optional.empty(), copy.getCertificateChain()); + assertEquals(null, copy.getCertificateValidator()); + assertEquals(null, copy.getEncodingLimits()); + assertEquals(uint(0), copy.getChannelLifetime()); + assertEquals(uint(12345), copy.getAcknowledgeTimeout()); } } diff --git a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java index 4af592abbf..173656b770 100644 --- a/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java +++ b/opc-ua-stack/stack-tests/src/test/java/org/eclipse/milo/opcua/stack/server/EndpointConfigurationTest.java @@ -100,8 +100,8 @@ public void missingTokenPolicyDefaultsToAnonymous() { EndpointConfiguration.newBuilder().build(); ImmutableList tokenPolicies = endpointConfiguration.getTokenPolicies(); - assertEquals(tokenPolicies.size(), 1); - assertEquals(tokenPolicies.get(0), EndpointConfiguration.Builder.USER_TOKEN_POLICY_ANONYMOUS); + assertEquals(1, tokenPolicies.size()); + assertEquals(EndpointConfiguration.Builder.USER_TOKEN_POLICY_ANONYMOUS, tokenPolicies.get(0)); } } From a4bfeba9fc1aee5c6e8ab5f3b983d2c98a979585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pupier?= Date: Fri, 19 Apr 2024 17:07:02 +0200 Subject: [PATCH 3/3] Swap parameters for assertArrayEquals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Pupier --- .../milo/opcua/sdk/client/methods/UaMethodTest.java | 8 ++++---- .../opcua/sdk/client/config/OpcUaClientConfigTest.java | 2 +- .../core/serialization/binary/BinaryDecoderTest.java | 2 +- .../eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java index b964b582f8..b015dcf01d 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/methods/UaMethodTest.java @@ -63,8 +63,8 @@ public void findMethod() throws UaException { UInteger[] expected0 = {dataItem.getMonitoredItem().getMonitoredItemId()}; UInteger[] expected1 = {dataItem.getMonitoredItem().getClientHandle()}; - assertArrayEquals(expected0, (UInteger[]) outputs[0].getValue()); - assertArrayEquals(expected1, (UInteger[]) outputs[1].getValue()); + assertArrayEquals((UInteger[]) outputs[0].getValue(), expected0); + assertArrayEquals((UInteger[]) outputs[1].getValue(), expected1); } @Test @@ -85,8 +85,8 @@ public void callMethod() throws UaException { UInteger[] expected0 = {dataItem.getMonitoredItem().getMonitoredItemId()}; UInteger[] expected1 = {dataItem.getMonitoredItem().getClientHandle()}; - assertArrayEquals(expected0, (UInteger[]) outputs[0].getValue()); - assertArrayEquals(expected1, (UInteger[]) outputs[1].getValue()); + assertArrayEquals((UInteger[]) outputs[0].getValue(), expected0); + assertArrayEquals((UInteger[]) outputs[1].getValue(), expected1); } @Test diff --git a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java index bd871ea9b7..e3b7e6b5dc 100644 --- a/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java +++ b/opc-ua-sdk/sdk-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/config/OpcUaClientConfigTest.java @@ -108,7 +108,7 @@ public void testCopyAndModify() { assertEquals(uint(2), copy.getKeepAliveFailuresAllowed()); assertEquals(uint(10000), copy.getKeepAliveInterval()); assertEquals(uint(15000), copy.getKeepAliveTimeout()); - assertArrayEquals(copy.getSessionLocaleIds(), new String[]{"en", "es"}); + assertArrayEquals(new String[]{"en", "es"}, copy.getSessionLocaleIds()); assertEquals(3.0, copy.getSubscriptionWatchdogMultiplier()); } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java index d2514ae3ba..3597f36a8b 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/serialization/binary/BinaryDecoderTest.java @@ -74,7 +74,7 @@ public void testEnumArray() { writer.writeEnumArray(null, array); ApplicationType[] decoded = (ApplicationType[]) reader.readEnumArray(null, ApplicationType.class); - assertArrayEquals(decoded, array); + assertArrayEquals(array, decoded); } } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java index e8afae4da5..45556b8c71 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/util/ArrayUtilTest.java @@ -35,9 +35,9 @@ public void testRoundTrip(Object array) throws Exception { Object flattened = ArrayUtil.flatten(array); Object unflattened = ArrayUtil.unflatten(flattened, ArrayUtil.getDimensions(array)); if (array instanceof Object[]) { - assertArrayEquals((Object[]) unflattened, (Object[]) array); + assertArrayEquals((Object[]) array, (Object[]) unflattened); } else if (array instanceof int[]){ - assertArrayEquals((int[]) unflattened, (int[]) array); + assertArrayEquals((int[]) array, (int[]) unflattened); } } @@ -65,7 +65,7 @@ public static Object[][] getDimensions() { @ParameterizedTest @MethodSource("getDimensions") public void testGetDimensions(Object array, int[] dimensions) throws Exception { - assertArrayEquals(ArrayUtil.getDimensions(array), dimensions); + assertArrayEquals(dimensions, ArrayUtil.getDimensions(array)); } public static Object[][] getTypedArrays() {