import static org.junit.Assert.assertEquals;

import java.io.ByteArrayOutputStream;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.javaault.compiler.api.CompilerException;
import org.javault.simplecompiler.SimpleJavaCompiler;
import org.junit.Before;
import org.junit.Test;

public class SimpleJavaCompilerTest {

	private SimpleJavaCompiler simpleJavaCompiler;

	@Before
	public void setup() {
		simpleJavaCompiler = new SimpleJavaCompiler();
	}

	@Test
	public void testCompileHelloWorld() throws IOException, CompilerException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
		String helloWorld = "" +
				"public class HelloWorld {\n" +
				"  public static void main(String[] args) {\n" +
				"    System.out.println(\"Hello World, from a generated program!\");\n" +
				"  }\n" +
				"}\n";

		Class<?> codeGenTest = simpleJavaCompiler.compileSource("HelloWorld", helloWorld);

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		System.setOut(new PrintStream(baos));
		
		Method main = codeGenTest.getMethod("main", String[].class);
		main.invoke(null, new Object[]{null});

		System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
		
		String generatedOutput = baos.toString("UTF-8");
		
		assertEquals("Hello World, from a generated program!\n", generatedOutput);
	}
}

@@ -826,18 +826,46 @@
 oWorld %7B
-%5Cn
+%22 + System.lineSeparator() + %22
 %22 +%0A%09%09%09%09
@@ -907,18 +907,46 @@
  args) %7B
-%5Cn
+%22 + System.lineSeparator() + %22
 %22 +%0A%09%09%09%09
@@ -1017,36 +1017,120 @@
 %5C%22);
-%5Cn%22 +%0A%09%09%09%09%22  %7D%5Cn%22 +%0A%09%09%09%09%22%7D%5Cn
+%22 + System.lineSeparator() + %22%22 +%0A%09%09%09%09%22  %7D%22 + System.lineSeparator() + %22%22 +%0A%09%09%09%09%22%7D%22 + System.lineSeparator() + %22
 %22;%0A%0A
@@ -1614,10 +1614,38 @@
 ram!
-%5Cn
+%22 + System.lineSeparator() + %22
 %22, g

Fix newline for windows