String newLine = System.getProperty("line.separator");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String inputString = "def" + newLine + "def" + newLine + "abc" + newLine + "abc" + newLine + "def" + newLine;
byte[] input = inputString.getBytes();
String outputString = ("abc" + newLine + "def" + newLine);
SortAction sort = new SortAction();
Field unique = SortAction.class.getDeclaredField("unique");
unique.setAccessible(true);
unique.set(sort, true);
sort.sort(new ByteArrayInputStream(input), new PrintStream(baos));
assertEquals(outputString, new String(baos.toByteArray()));
}