Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Fix KNX protocol test registration race (#3495)

Wouter Borndb857a7f857d
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
index cfc9718a4..642646984 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
@@ -135,7 +135,15 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {
then: "the living room thing to be fully deployed"
conditions.eventually {
- assert ((KNXProtocol) agentService.getProtocolInstance(knxAgent1.id)).attributeStatusMap.get(new AttributeRef(knxThing.id, "light1ToggleOnOff")) != null
+ def protocol = (KNXProtocol) agentService.getProtocolInstance(knxAgent1.id)
+ def attributeRef = new AttributeRef(knxThing.id, "light1ToggleOnOff")
+ synchronized (protocol.attributeStatusMap) {
+ assert protocol.attributeStatusMap.get(attributeRef) != null
+ }
+ // Status monitoring is registered before commands, so wait for both before writing.
+ synchronized (protocol.attributeActionMap) {
+ assert protocol.attributeActionMap.get(attributeRef) != null
+ }
}
when: "change light1ToggleOnOff value to 'true'"
diff --git a/test/src/test/java/org/openremote/test/protocol/KNXTestingNetworkLink.java b/test/src/test/java/org/openremote/test/protocol/KNXTestingNetworkLink.java
index 8872fa1b8..6696483db 100644
--- a/test/src/test/java/org/openremote/test/protocol/KNXTestingNetworkLink.java
+++ b/test/src/test/java/org/openremote/test/protocol/KNXTestingNetworkLink.java
@@ -34,8 +34,8 @@ public class KNXTestingNetworkLink extends AbstractLink {
private static final Logger LOG = Logger.getLogger(KNXTestingNetworkLink.class.getName());
- private static KNXTestingNetworkLink instance;
- private String lastDataReceived;
+ private static volatile KNXTestingNetworkLink instance;
+ private volatile String lastDataReceived;
public KNXTestingNetworkLink(Object... args) throws KNXFormatException {
super(