Skip to content

Commit

Permalink
[nest] Fix integration tests fail on Windows (#5909)
Browse files Browse the repository at this point in the history
* Convert line endings read from files so tests work on Linux/Windows
* Reduce logging output by suppressing org.eclipse.jetty with logback configuration

Fixes #5906

Signed-off-by: Wouter Born <[email protected]>
  • Loading branch information
wborn authored and J-N-K committed Aug 11, 2019
1 parent 005a269 commit 679948d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions itests/org.openhab.binding.nest.tests/itest.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
16 changes: 16 additions & 0 deletions itests/org.openhab.binding.nest.tests/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="org.eclipse.jetty" level="info">
<appender-ref ref="STDOUT" />
</logger>

<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,13 +90,7 @@ public static String fromFile(String fileName, Unit<Temperature> 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"));
}
}

Expand Down

0 comments on commit 679948d

Please sign in to comment.