[networkupstools] Fix NutApiTest failing on Windows (#12564)
On Windows the PrintWriter used in the NutConnector adds different line endings causing some tests to fail. Signed-off-by: Wouter Born <github@maindrain.net>pull/12573/head
parent
0f56369b2a
commit
79245b5d89
|
@ -24,6 +24,7 @@ import java.net.URISyntaxException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
@ -49,7 +50,7 @@ public class NutApiTest {
|
||||||
@Override
|
@Override
|
||||||
protected Socket newSocket() {
|
protected Socket newSocket() {
|
||||||
return socket;
|
return socket;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +59,10 @@ public class NutApiTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testListVariables() throws IOException, NutException, URISyntaxException {
|
public void testListVariables() throws IOException, NutException, URISyntaxException {
|
||||||
final String expectedCommands = new String(
|
final String expectedCommands = Files
|
||||||
Files.readAllBytes(Paths.get(getClass().getResource("var_list_commands.txt").toURI())));
|
.readAllLines(Paths.get(getClass().getResource("var_list_commands.txt").toURI())).stream()
|
||||||
final StringBuffer actualCommands = new StringBuffer();
|
.collect(Collectors.joining(System.lineSeparator()));
|
||||||
|
final StringBuilder actualCommands = new StringBuilder();
|
||||||
try (InputStream in = getClass().getResourceAsStream("var_list.txt"); OutputStream out = new OutputStream() {
|
try (InputStream in = getClass().getResourceAsStream("var_list.txt"); OutputStream out = new OutputStream() {
|
||||||
@Override
|
@Override
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
|
@ -84,9 +86,10 @@ public class NutApiTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetVariable() throws IOException, NutException, URISyntaxException {
|
public void testGetVariable() throws IOException, NutException, URISyntaxException {
|
||||||
final String expectedCommands = new String(
|
final String expectedCommands = Files
|
||||||
Files.readAllBytes(Paths.get(getClass().getResource("var_get_commands.txt").toURI())));
|
.readAllLines(Paths.get(getClass().getResource("var_get_commands.txt").toURI())).stream()
|
||||||
final StringBuffer actualCommands = new StringBuffer();
|
.collect(Collectors.joining(System.lineSeparator()));
|
||||||
|
final StringBuilder actualCommands = new StringBuilder();
|
||||||
try (InputStream in = getClass().getResourceAsStream("var_get.txt"); OutputStream out = new OutputStream() {
|
try (InputStream in = getClass().getResourceAsStream("var_get.txt"); OutputStream out = new OutputStream() {
|
||||||
@Override
|
@Override
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
USERNAME test
|
USERNAME test
|
||||||
PASSWORD pwd
|
PASSWORD pwd
|
||||||
GET VAR ups1 ups.status
|
GET VAR ups1 ups.status
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
USERNAME test
|
USERNAME test
|
||||||
PASSWORD pwd
|
PASSWORD pwd
|
||||||
LIST VAR ups1
|
LIST VAR ups1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue