package com.github.sbugat.nqueens;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.assertj.core.api.Assertions;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.github.sbugat.nqueens.solvers.bruteforce.BruteForceNQueensSolverArray;
import com.github.sbugat.nqueens.tools.SequenceTools;

public class GenericNQueensSolverTest {

	private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();

	@Before
	public void setUpStreams() {
		System.setOut(new PrintStream(outContent));
	}

	@After
	public void cleanUpStreams() {
		System.setOut(null);
	}

	@Test
	public void testNQueensSolver() throws IOException {

		final GenericNQueensSolver genericNQueensSolver = new BruteForceNQueensSolverArray(5, true);

		// Solve with the chessboard size and compare the number of solutions with the expected sequence
		final long solutionCount = genericNQueensSolver.solve();
		Assertions.assertThat(solutionCount).isEqualTo(SequenceTools.getExpectedSolutions(genericNQueensSolver.getChessboardSize()));

		// Compare standard output
		final byte[] encoded = Files.readAllBytes(Paths.get("src/test/resources/GenericNQueensSolverTest-expected-output.txt"));
		Assertions.assertThat(outContent.toString()).isEqualTo(new String(encoded, StandardCharsets.ISO_8859_1));
	}

	@Test(expected = IllegalArgumentException.class)
	public void testNQueensSolverIllegalArgumentException() {

		new BruteForceNQueensSolverArray(0, true);
	}
}

@@ -44,25 +44,79 @@
 java.io.
-ByteArray
+File;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.File
 OutputSt
@@ -586,69 +586,64 @@
 nal 
-ByteArrayOutputStream outContent = new ByteArrayOutputStream(
+File STANDARD_OUTPUT_FILE = new File(%22target/stdout.txt%22
 );%0A%0A
@@ -670,32 +670,61 @@
 d setUpStreams()
+ throws FileNotFoundException
  %7B%0A%09%09System.setO
@@ -742,26 +742,58 @@
 tStream(
-outContent
+new FileOutputStream(STANDARD_OUTPUT_FILE)
 ));%0A%09%7D%0A%0A
@@ -1484,40 +1484,40 @@
 hat(
-outContent.toString()).isEqualTo
+STANDARD_OUTPUT_FILE).hasContent
 (new
@@ -1554,18 +1554,13 @@
 ets.
-ISO_8859_1
+UTF_8
 ));%0A

Change test to be platform-independent