Skip to content

Commit

Permalink
Migrate from TestNG to JUnit5
Browse files Browse the repository at this point in the history
- all compilation issues fixed
- remains few failing tests

Signed-off-by: Aurélien Pupier <[email protected]>
  • Loading branch information
apupier committed Apr 19, 2024
1 parent 7bd466e commit 8db1853
Show file tree
Hide file tree
Showing 87 changed files with 570 additions and 489 deletions.
3 changes: 1 addition & 2 deletions opc-ua-sdk/dictionary-reader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
2 changes: 0 additions & 2 deletions opc-ua-sdk/integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
1 change: 0 additions & 1 deletion opc-ua-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<properties>
<annotations.version>22.0.0</annotations.version>
<slf4j.version>1.7.32</slf4j.version>
<testng.version>6.11</testng.version>
<mockito.version>2.25.1</mockito.version>
</properties>

Expand Down
10 changes: 7 additions & 3 deletions opc-ua-sdk/sdk-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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));
}


Expand Down Expand Up @@ -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"},
Expand All @@ -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}},
Expand All @@ -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}}},
Expand All @@ -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}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<S> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Loading

0 comments on commit 8db1853

Please sign in to comment.