Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from TestNG to JUnit5 #1263

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private void testReadDataTypeDictionaryBytes(ByteString dictionary, int fragment
fragmentSize
).get();

Assertions.assertEquals(typeDictionaryBs, dictionary);
Assertions.assertEquals(dictionary, typeDictionaryBs);
}

}
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void browseWithBrowseDirection() throws UaException {

List<? extends UaNode> nodes = addressSpace.browseNodes(serverNode, browseOptions);

assertEquals(1, nodes.size());
assertEquals(nodes.size(), 1);
assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(Identifiers.ObjectsFolder)));
}

Expand All @@ -84,7 +84,7 @@ public void browseWithBrowseDirection() throws UaException {

List<? extends UaNode> 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)));
}
Expand All @@ -103,7 +103,7 @@ public void browseWithReferenceType() throws UaException {

List<? extends UaNode> 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)));
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void browse() throws UaException {
.build();

List<ReferenceDescription> 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)));
Expand All @@ -69,7 +69,7 @@ public void browseNodes() throws UaException {

List<? extends UaNode> 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)));
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void getTypeDefinition() throws UaException {

UaObjectTypeNode objectTypeNode = objectNode.getTypeDefinition();

assertEquals(Identifiers.ServerType, objectTypeNode.getNodeId());
assertEquals(objectTypeNode.getNodeId(), Identifiers.ServerType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void getTypeDefinition() throws UaException {

UaVariableTypeNode variableTypeNode = variableNode.getTypeDefinition();

assertEquals(Identifiers.ServerStatusType, variableTypeNode.getNodeId());
assertEquals(variableTypeNode.getNodeId(), Identifiers.ServerStatusType);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]{
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -155,7 +155,7 @@ public void callMethodWithNoInputsOrOutputs() throws UaException {
new Variant[0]
);

assertEquals(0, outputs.length);
assertEquals(outputs.length, 0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -85,24 +85,24 @@ 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
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
Expand All @@ -122,27 +122,27 @@ 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
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
}

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

}
Loading