Skip to content

armgit / core

Public Imported from GitHub
0

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

Test improvements

Rich Turnera51e22aa1797
diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
index 57f99bda7..e29316a89 100644
--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
@@ -3,7 +3,6 @@ package org.openremote.test.notification
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.databind.node.TextNode
import com.google.firebase.messaging.Message
-import org.openremote.container.web.WebService
import org.openremote.manager.asset.AssetProcessingService
import org.openremote.manager.asset.AssetStorageService
import org.openremote.manager.asset.console.ConsoleResourceImpl
@@ -13,17 +12,18 @@ import org.openremote.manager.notification.PushNotificationHandler
import org.openremote.manager.rules.geofence.ORConsoleGeofenceAssetAdapter
import org.openremote.manager.security.ManagerIdentityService
import org.openremote.manager.setup.SetupService
-import org.openremote.model.query.UserQuery
-import org.openremote.model.query.filter.TenantPredicate
-import org.openremote.model.util.TextUtil
-import org.openremote.test.setup.KeycloakTestSetup
-import org.openremote.test.setup.ManagerTestSetup
+import org.openremote.manager.web.ManagerWebService
import org.openremote.model.attribute.AttributeRef
import org.openremote.model.console.ConsoleProvider
import org.openremote.model.console.ConsoleRegistration
import org.openremote.model.console.ConsoleResource
import org.openremote.model.notification.*
+import org.openremote.model.query.UserQuery
+import org.openremote.model.query.filter.TenantPredicate
+import org.openremote.model.util.TextUtil
import org.openremote.test.ManagerContainerTrait
+import org.openremote.test.setup.KeycloakTestSetup
+import org.openremote.test.setup.ManagerTestSetup
import org.simplejavamail.email.Email
import spock.lang.Specification
import spock.util.concurrent.PollingConditions
@@ -56,7 +56,7 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)
def notificationService = container.getService(NotificationService.class)
def pushNotificationHandler = container.getService(PushNotificationHandler.class)
- def consoleResource = (ConsoleResourceImpl)container.getService(WebService.class).getApiSingletons().find {it instanceof ConsoleResourceImpl}
+ def consoleResource = (ConsoleResourceImpl)container.getService(ManagerWebService.class).apiSingletons.find {it instanceof ConsoleResourceImpl}
and: "the clock is stopped for testing purposes"
stopPseudoClock()
diff --git a/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy
index af6c00f95..53b2c063c 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/TcpClientTest.groovy
@@ -41,6 +41,14 @@ class TcpClientTest extends Specification implements ManagerContainerTrait {
given: "expected conditions"
def conditions = new PollingConditions(timeout: 10, delay: 0.2)
+ and: "the IO client reconnect time is set low for test purposes"
+ def initialMillis = AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS
+ def maxMillis = AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS
+ def jitterMillis = AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS
+ AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS = 500
+ AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS = 500
+ AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS = 0
+
and: "the container is started"
def container = startContainer(defaultConfig(), [])
@@ -186,6 +194,9 @@ class TcpClientTest extends Specification implements ManagerContainerTrait {
}
cleanup: "the server should be stopped"
+ AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS = initialMillis
+ AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS = maxMillis
+ AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS = jitterMillis
client.disconnect()
echoServer.stop()
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy
index fceb797e6..082a53a58 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy
@@ -253,6 +253,18 @@ class WebTargetTest extends Specification {
assert grant2.scope == grant.scope
assert ((OAuthPasswordGrant)grant2).username == grant.username
assert ((OAuthPasswordGrant)grant2).password == grant.password
+
+ when: "serialised"
+ Map<String, Object> map = new HashMap<>();
+ String v = "{\"test\": 123}"
+ map.put("value", v)
+ String mapStr = ValueUtil.JSON.writeValueAsString(map)
+
+ and: "deserialised"
+ def newMap = ValueUtil.JSON.readValue(mapStr, Map.class)
+
+ then: "should work"
+ assert newMap != null
}
def "Check Basic authentication"() {
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.groovy
index 0050f0316..63c0fa5c5 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
@@ -44,6 +44,14 @@ class UdpClientTest extends Specification implements ManagerContainerTrait {
given: "expected conditions"
def conditions = new PollingConditions(timeout: 10, delay: 0.2)
+ and: "the IO client reconnect time is set low for test purposes"
+ def initialMillis = AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS
+ def maxMillis = AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS
+ def jitterMillis = AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS
+ AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS = 500
+ AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS = 500
+ AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS = 0
+
and: "the container is started"
def clientPort = findEphemeralPort()
def container = startContainer(defaultConfig(), [])
@@ -164,6 +172,9 @@ class UdpClientTest extends Specification implements ManagerContainerTrait {
}
cleanup: "the server should be stopped"
+ AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS = initialMillis
+ AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS = maxMillis
+ AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS = jitterMillis
client.disconnect()
echoServer.stop()
}
diff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy
index df11253fc..2e9c1f874 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy
@@ -75,6 +75,13 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
given: "expected conditions"
def conditions = new PollingConditions(timeout: 10, delay: 0.2)
+ and: "the IO client reconnect time is set low for test purposes"
+ def initialMillis = AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS
+ def maxMillis = AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS
+ def jitterMillis = AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS
+ AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS = 500
+ AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS = 500
+ AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS = 0
and: "the container is started"
def container = startContainer(defaultConfig(), defaultServices())
@@ -209,6 +216,9 @@ class WebsocketClientTest extends Specification implements ManagerContainerTrait
}
cleanup: "the server should be stopped"
+ AbstractNettyIOClient.RECONNECT_DELAY_INITIAL_MILLIS = initialMillis
+ AbstractNettyIOClient.RECONNECT_DELAY_MAX_MILLIS = maxMillis
+ AbstractNettyIOClient.RECONNECT_DELAY_JITTER_MILLIS = jitterMillis
if (client != null) {
client.disconnect()
}