diff --git a/itests/org.openhab.binding.nest.tests/itest.bndrun b/itests/org.openhab.binding.nest.tests/itest.bndrun index dc3ad5423ba5c..e07be3e6ca32c 100644 --- a/itests/org.openhab.binding.nest.tests/itest.bndrun +++ b/itests/org.openhab.binding.nest.tests/itest.bndrun @@ -14,6 +14,8 @@ Fragment-Host: org.openhab.binding.nest bnd.identity;id='org.openhab.core.storage.json',\ bnd.identity;id='org.openhab.core.storage.mapdb' +-runproperties: logback.configurationFile=file:${.}/logback.xml + # # done # diff --git a/itests/org.openhab.binding.nest.tests/logback.xml b/itests/org.openhab.binding.nest.tests/logback.xml new file mode 100644 index 0000000000000..161b219083ce0 --- /dev/null +++ b/itests/org.openhab.binding.nest.tests/logback.xml @@ -0,0 +1,16 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + diff --git a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestThingHandlerOSGiTest.java b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestThingHandlerOSGiTest.java index 0c1a8503cf4c8..93a7fc05af1dc 100644 --- a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestThingHandlerOSGiTest.java +++ b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/handler/NestThingHandlerOSGiTest.java @@ -260,7 +260,8 @@ protected ThingUID getThingUID() { } protected void putStreamingEventData(String json) throws IOException { - String singleLineJson = json.replaceAll("\n\\s+", "").replaceAll("\n", ""); + String singleLineJson = json.replaceAll("\n\r\\s+", "").replaceAll("\n\\s+", "").replaceAll("\n\r", "") + .replaceAll("\n", ""); servlet.queueEvent(PUT, singleLineJson); } diff --git a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/data/NestDataUtil.java b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/data/NestDataUtil.java index a6278b0b7afef..1e53e3b0061f9 100644 --- a/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/data/NestDataUtil.java +++ b/itests/org.openhab.binding.nest.tests/src/main/java/org/openhab/binding/nest/internal/data/NestDataUtil.java @@ -12,12 +12,13 @@ */ package org.openhab.binding.nest.internal.data; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; -import java.io.StringWriter; import java.io.UnsupportedEncodingException; +import java.util.stream.Collectors; import javax.measure.Unit; import javax.measure.quantity.Temperature; @@ -89,13 +90,7 @@ public static String fromFile(String fileName, Unit temperatureUnit public static String fromFile(String fileName) throws IOException { try (Reader reader = openDataReader(fileName)) { - StringWriter writer = new StringWriter(); - char[] buffer = new char[1024 * 4]; - int n = 0; - while (-1 != (n = reader.read(buffer))) { - writer.write(buffer, 0, n); - } - return writer.toString(); + return new BufferedReader(reader).lines().parallel().collect(Collectors.joining("\n")); } }