Skip to content

Commit 82fc1ba

Browse files
system24sevenkevinherronapupier
authored
Migrate TestNG tests to JUnit 5 (#1358)
Migrates TestNG tests to JUnit 5, fixes broken tests, temporarily disables some mock-based tests. Signed-off-by: system24seven <[email protected]> Co-authored-by: Kevin Herron <[email protected]> Co-authored-by: Aurélien Pupier <[email protected]>
1 parent 368a5d3 commit 82fc1ba

File tree

79 files changed

+757
-733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+757
-733
lines changed

.github/workflows/maven-verify.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Run `mvn verify` on JDK 17
2+
3+
on:
4+
pull_request:
5+
branches: [ "dev/1.0" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up JDK 17
14+
uses: actions/setup-java@v4
15+
with:
16+
java-version: '17'
17+
distribution: 'temurin'
18+
cache: maven
19+
20+
- name: Build and Verify with Maven
21+
run: mvn -B verify

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Jenkins](https://img.shields.io/jenkins/build/https/ci.eclipse.org/milo/job/Milo_Deploy.svg)](https://ci.eclipse.org/milo/)
33
[![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.milo/milo.svg)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.eclipse.milo%22%20AND%20a%3A%22milo%22)
44

5-
Milo is an open-source implementation of OPC UA (currently targeting 1.03). It includes a high-performance stack (channels, serialization, data structures, security) as well as client and server SDKs built on top of the stack.
5+
Milo is an open-source implementation of OPC UA (currently targeting 1.05). It includes a high-performance stack (channels, serialization, data structures, security) as well as client and server SDKs built on top of the stack.
66

77
Stack Overflow tag: [milo](http://stackoverflow.com/questions/tagged/milo)
88

@@ -27,7 +27,7 @@ Releases are published to Maven Central and snapshots to Sonatype.
2727
<dependency>
2828
<groupId>org.eclipse.milo</groupId>
2929
<artifactId>milo-sdk-client</artifactId>
30-
<version>0.6.10</version>
30+
<version>1.0.0</version>
3131
</dependency>
3232
```
3333

@@ -37,7 +37,7 @@ Releases are published to Maven Central and snapshots to Sonatype.
3737
<dependency>
3838
<groupId>org.eclipse.milo</groupId>
3939
<artifactId>milo-sdk-server</artifactId>
40-
<version>0.6.10</version>
40+
<version>1.0.0</version>
4141
</dependency>
4242
```
4343

opc-ua-sdk/dtd-core/src/test/java/org/eclipse/milo/opcua/sdk/core/dtd/AbstractBsdCodecTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected void assertRoundTripUsingToString(
151151
System.out.println("encodedValue:\t" + ByteBufUtil.hexDump(encodedValue));
152152

153153
Object decodedValue = codec.decode(context, new OpcUaBinaryDecoder(context).setBuffer(buffer));
154-
assertEquals(decodedValue.toString(), originalValue.toString());
154+
assertEquals(originalValue.toString(), decodedValue.toString());
155155
System.out.println("decodedValue:\t" + decodedValue);
156156
}
157157
}

opc-ua-sdk/dtd-reader/src/test/java/org/eclipse/milo/opcua/sdk/client/dtd/BinaryDataTypeDictionaryReaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,6 @@ private void testReadDataTypeDictionaryBytes(ByteString dictionary, int fragment
130130
ByteString typeDictionaryBs =
131131
dictionaryReader.readDataTypeDictionaryBytes(NodeId.NULL_VALUE, fragmentSize).get();
132132

133-
Assertions.assertEquals(typeDictionaryBs, dictionary);
133+
Assertions.assertEquals(dictionary, typeDictionaryBs);
134134
}
135135
}

opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 the Eclipse Milo Authors
2+
* Copyright (c) 2025 the Eclipse Milo Authors
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -10,12 +10,7 @@
1010

1111
package org.eclipse.milo.opcua.sdk.client;
1212

13-
import static org.junit.jupiter.api.Assertions.assertEquals;
14-
import static org.junit.jupiter.api.Assertions.assertFalse;
15-
import static org.junit.jupiter.api.Assertions.assertNotNull;
16-
import static org.junit.jupiter.api.Assertions.assertSame;
17-
import static org.junit.jupiter.api.Assertions.assertThrows;
18-
import static org.junit.jupiter.api.Assertions.assertTrue;
13+
import static org.junit.jupiter.api.Assertions.*;
1914

2015
import java.util.EnumSet;
2116
import java.util.List;
@@ -53,8 +48,7 @@ public void browse() throws UaException {
5348
n.getNodeClass()));
5449

5550
if (n instanceof UaVariableNode) {
56-
System.out.println(
57-
"\u2514\u2500 value = " + ((UaVariableNode) n).getValue().getValue());
51+
System.out.println("└─ value = " + ((UaVariableNode) n).getValue().getValue());
5852
}
5953
});
6054
}
@@ -190,11 +184,11 @@ public void getNode() throws UaException {
190184

191185
UaNode serverNode = addressSpace.getNode(NodeIds.Server);
192186
assertNotNull(serverNode);
193-
assertTrue(serverNode instanceof ServerTypeNode);
187+
assertInstanceOf(ServerTypeNode.class, serverNode);
194188

195189
UaNode serverStatusNode = addressSpace.getNode(NodeIds.Server_ServerStatus);
196190
assertNotNull(serverStatusNode);
197-
assertTrue(serverStatusNode instanceof ServerStatusTypeNode);
191+
assertInstanceOf(ServerStatusTypeNode.class, serverStatusNode);
198192
}
199193

200194
@Test

opc-ua-sdk/sdk-server/pom.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
~ Copyright (c) 2024 the Eclipse Milo Authors
3+
~ Copyright (c) 2025 the Eclipse Milo Authors
44
~
55
~ This program and the accompanying materials are made
66
~ available under the terms of the Eclipse Public License 2.0
@@ -46,19 +46,16 @@
4646
<dependency>
4747
<groupId>org.junit.jupiter</groupId>
4848
<artifactId>junit-jupiter-api</artifactId>
49-
<version>${junit.version}</version>
5049
<scope>test</scope>
5150
</dependency>
5251
<dependency>
5352
<groupId>org.junit.jupiter</groupId>
5453
<artifactId>junit-jupiter-engine</artifactId>
55-
<version>${junit.version}</version>
5654
<scope>test</scope>
5755
</dependency>
5856
<dependency>
59-
<groupId>org.testng</groupId>
60-
<artifactId>testng</artifactId>
61-
<version>${testng.version}</version>
57+
<groupId>org.junit.jupiter</groupId>
58+
<artifactId>junit-jupiter-params</artifactId>
6259
<scope>test</scope>
6360
</dependency>
6461
<dependency>
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 the Eclipse Milo Authors
2+
* Copyright (c) 2025 the Eclipse Milo Authors
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -11,53 +11,53 @@
1111
package org.eclipse.milo.opcua.sdk.core;
1212

1313
import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.ubyte;
14-
import static org.testng.Assert.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertEquals;
1515

16-
import org.testng.annotations.Test;
16+
import org.junit.jupiter.api.Test;
1717

1818
public class AccessLevelTest {
1919

2020
@Test
2121
public void testToValue() {
2222
for (AccessLevel accessLevel : AccessLevel.values()) {
23-
assertEquals(AccessLevel.toValue(accessLevel), ubyte(accessLevel.getValue()));
23+
assertEquals(ubyte(accessLevel.getValue()), AccessLevel.toValue(accessLevel));
2424
}
2525

26-
assertEquals(AccessLevel.toValue(AccessLevel.NONE), ubyte(0));
26+
assertEquals(ubyte(0), AccessLevel.toValue(AccessLevel.NONE));
2727

2828
assertEquals(
29-
AccessLevel.toValue(AccessLevel.READ_ONLY).intValue(), AccessLevel.CurrentRead.getValue());
29+
AccessLevel.CurrentRead.getValue(), AccessLevel.toValue(AccessLevel.READ_ONLY).intValue());
3030

3131
assertEquals(
32-
AccessLevel.toValue(AccessLevel.READ_WRITE).intValue(),
33-
AccessLevel.CurrentRead.getValue() | AccessLevel.CurrentWrite.getValue());
32+
AccessLevel.CurrentRead.getValue() | AccessLevel.CurrentWrite.getValue(),
33+
AccessLevel.toValue(AccessLevel.READ_WRITE).intValue());
3434

3535
assertEquals(
36-
AccessLevel.toValue(AccessLevel.HISTORY_READ_ONLY).intValue(),
37-
AccessLevel.HistoryRead.getValue());
36+
AccessLevel.HistoryRead.getValue(),
37+
AccessLevel.toValue(AccessLevel.HISTORY_READ_ONLY).intValue());
3838

3939
assertEquals(
40-
AccessLevel.toValue(AccessLevel.HISTORY_READ_WRITE).intValue(),
41-
AccessLevel.HistoryRead.getValue() | AccessLevel.HistoryWrite.getValue());
40+
AccessLevel.HistoryRead.getValue() | AccessLevel.HistoryWrite.getValue(),
41+
AccessLevel.toValue(AccessLevel.HISTORY_READ_WRITE).intValue());
4242
}
4343

4444
@Test
4545
public void testFromValue() {
46-
assertEquals(AccessLevel.fromValue(0), AccessLevel.NONE);
46+
assertEquals(AccessLevel.NONE, AccessLevel.fromValue(0));
4747

48-
assertEquals(AccessLevel.fromValue(AccessLevel.CurrentRead.getValue()), AccessLevel.READ_ONLY);
48+
assertEquals(AccessLevel.READ_ONLY, AccessLevel.fromValue(AccessLevel.CurrentRead.getValue()));
4949

5050
assertEquals(
51+
AccessLevel.READ_WRITE,
5152
AccessLevel.fromValue(
52-
AccessLevel.CurrentRead.getValue() | AccessLevel.CurrentWrite.getValue()),
53-
AccessLevel.READ_WRITE);
53+
AccessLevel.CurrentRead.getValue() | AccessLevel.CurrentWrite.getValue()));
5454

5555
assertEquals(
56-
AccessLevel.fromValue(AccessLevel.HistoryRead.getValue()), AccessLevel.HISTORY_READ_ONLY);
56+
AccessLevel.HISTORY_READ_ONLY, AccessLevel.fromValue(AccessLevel.HistoryRead.getValue()));
5757

5858
assertEquals(
59+
AccessLevel.HISTORY_READ_WRITE,
5960
AccessLevel.fromValue(
60-
AccessLevel.HistoryRead.getValue() | AccessLevel.HistoryWrite.getValue()),
61-
AccessLevel.HISTORY_READ_WRITE);
61+
AccessLevel.HistoryRead.getValue() | AccessLevel.HistoryWrite.getValue()));
6262
}
6363
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 the Eclipse Milo Authors
2+
* Copyright (c) 2025 the Eclipse Milo Authors
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -10,11 +10,11 @@
1010

1111
package org.eclipse.milo.opcua.sdk.core;
1212

13-
import static org.testng.Assert.assertEquals;
14-
import static org.testng.Assert.assertTrue;
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertTrue;
1515

1616
import org.eclipse.milo.opcua.stack.core.types.structured.EUInformation;
17-
import org.testng.annotations.Test;
17+
import org.junit.jupiter.api.Test;
1818

1919
public class CefactEngineeringUnitsTest {
2020

@@ -23,7 +23,7 @@ public void test() {
2323
assertTrue(CefactEngineeringUnits.getAll().length > 0);
2424

2525
for (EUInformation eu : CefactEngineeringUnits.getAll()) {
26-
assertEquals(CefactEngineeringUnits.getByUnitId(eu.getUnitId()), eu);
26+
assertEquals(eu, CefactEngineeringUnits.getByUnitId(eu.getUnitId()));
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)