100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Test reliability and cross platform support
Rich Turner39a6af7b245a
diff --git a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovyindex d0cfbdd3d..7260dd942 100644--- a/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy+++ b/test/src/main/groovy/org/openremote/test/ManagerContainerTrait.groovy@@ -17,6 +17,7 @@ import static org.openremote.container.timer.TimerService.Clock.PSEUDOimport static org.openremote.container.timer.TimerService.Clock.REALimport static org.openremote.container.timer.TimerService.TIMER_CLOCK_TYPEimport static org.openremote.container.web.WebService.WEBSERVER_LISTEN_PORT+import static org.openremote.manager.mqtt.MqttBrokerService.MQTT_SERVER_LISTEN_HOSTimport static org.openremote.manager.setup.SetupTasks.*trait ManagerContainerTrait extends ContainerTrait {@@ -32,6 +33,7 @@ trait ManagerContainerTrait extends ContainerTrait {(SETUP_IMPORT_DEMO_USERS) : "true",(SETUP_IMPORT_DEMO_SCENES) : "false",(SETUP_IMPORT_DEMO_RULES) : "false",+ (MQTT_SERVER_LISTEN_HOST) : "127.0.0.1", // Works best for cross platform test running(TIMER_CLOCK_TYPE) : PSEUDO.name()]}diff --git a/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy b/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovyindex 47b7164a0..5c2017b54 100644--- a/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy+++ b/test/src/test/groovy/org/openremote/test/mqtt/MqttBrokerTest.groovy@@ -10,6 +10,7 @@ import org.openremote.manager.mqtt.MqttBrokerServiceimport org.openremote.manager.setup.SetupServiceimport org.openremote.manager.setup.builtin.ManagerDemoSetupimport org.openremote.model.attribute.AttributeEvent+import org.openremote.model.attribute.AttributeRefimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport org.openremote.test.RawClient@@ -295,7 +296,12 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {.write(0x01) // QoS level 1.flush()- and: "time advances"+ then: "the subscription should be established"+ conditions.eventually {+ assert mqttBrokerService.mqttConnectionMap.get(mqttClientId).assetAttributeSubscriptions.containsKey(new AttributeRef(managerDemoSetup.apartment1HallwayId, "motionSensor"))+ }++ when: "time advances"advancePseudoClock(1, TimeUnit.SECONDS, container)and: "that attribute changed"@@ -353,7 +359,12 @@ class MqttBrokerTest extends Specification implements ManagerContainerTrait {.write(0x01) // QoS level 1.flush()- and: "time advances"+ then: "the subscription should be established"+ conditions.eventually {+ assert mqttBrokerService.mqttConnectionMap.get(mqttClientId).assetAttributeValueSubscriptions.containsKey(new AttributeRef(managerDemoSetup.apartment1HallwayId, "motionSensor"))+ }++ when: "time advances"advancePseudoClock(1, TimeUnit.SECONDS, container)and: "that attribute changed"diff --git a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovyindex fb362a9dd..c9f8a59b8 100644--- a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy@@ -71,7 +71,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTrawhen: "a simple UDP echo server is started"def echoServerPort = findEphemeralPort()def clientPort = findEphemeralPort()- AbstractUdpServer echoServer = new UdpStringServer(protocolExecutorService, new InetSocketAddress(echoServerPort), ";", Integer.MAX_VALUE, true)+ AbstractUdpServer echoServer = new UdpStringServer(protocolExecutorService, new InetSocketAddress("127.0.0.1", echoServerPort), ";", Integer.MAX_VALUE, true)def echoSkipCount = 0def clientActualPort = nulldef lastCommand = null@@ -107,7 +107,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTra.addMeta(new MetaItem(UdpClientProtocol.META_PROTOCOL_HOST,- Values.create("255.255.255.255")+ Values.create("127.0.0.1")),new MetaItem(UdpClientProtocol.META_PROTOCOL_PORT,diff --git a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientTest.groovyindex 0317fe1c4..fbb7c25e7 100644--- a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientTest.groovy@@ -53,9 +53,10 @@ class UdpClientTest extends Specification implements ManagerContainerTrait {and: "a simple UDP echo server"def echoServerPort = findEphemeralPort()- def echoServer = new UdpStringServer(protocolExecutorService, new InetSocketAddress(echoServerPort), ";", Integer.MAX_VALUE, true)+ def echoServer = new UdpStringServer(protocolExecutorService, new InetSocketAddress("127.0.0.1", echoServerPort), ";", Integer.MAX_VALUE, true)echoServer.addMessageConsumer({- message, channel, sender -> echoServer.sendMessage(message, sender)+ message, channel, sender ->+ echoServer.sendMessage(message, sender)})and: "we add callback consumers on the server"@@ -66,7 +67,7 @@ class UdpClientTest extends Specification implements ManagerContainerTrait {and: "a simple UDP broadcast client"UdpIoClient<String> client = new UdpIoClient<String>(- "255.255.255.255",+ "127.0.0.1",echoServerPort,clientPort,protocolExecutorService)@@ -82,7 +83,8 @@ class UdpClientTest extends Specification implements ManagerContainerTrait {def connectionStatus = client.getConnectionStatus()String lastMessageclient.addMessageConsumer({- message -> lastMessage = message+ message ->+ lastMessage = message})client.addConnectionStatusConsumer({status -> connectionStatus = status@@ -140,8 +142,8 @@ class UdpClientTest extends Specification implements ManagerContainerTrait {assert connectionStatus == ConnectionStatus.CONNECTED}- when: "the server sends a broadcast message"- echoServer.sendMessage("Is there anyone there?", SocketUtils.socketAddress("255.255.255.255", clientPort))+ when: "the server sends a message to the loopback interface"+ echoServer.sendMessage("Is there anyone there?", SocketUtils.socketAddress("127.0.0.1", clientPort))then: "we should receive the message"conditions.eventually {