package com.cflint.integration;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import org.junit.Test;

import com.cflint.main.CFLintMain;

public class TestIntegrationFolder {

	@Test
	public void testFolder() throws Exception{
	    
	    URL url = TestIntegrationFolder.class.getResource("/cflint.definition.json");
	    final String path=new File(url.toURI()).getParentFile().getParentFile().getParent();
	    CFLintMain.main(
				new String[]{
				"--folder",
				"src/test/resources/com/cflint/integration",
				"--json",
				"--jsonfile",
				"src/test/resources/com/cflint/integration/output.json"
				});
        final String expected = loadFile(new File("src/test/resources/com/cflint/integration/output.expected.json"));
        final String actual = loadFile(new File("src/test/resources/com/cflint/integration/output.json"));
        assertEquals( 
                expected.replaceAll("\\\\","/").replaceAll("/+","/").replaceAll("\r\n", "\n"),
                actual.replaceAll("\\\\","/").replaceAll("/+","/").replaceAll("\r\n", "\n"));

	}
	
	   public static String loadFile(File file) throws IOException {
	        InputStream is = new FileInputStream(file);
	        byte[] b = new byte[is.available()];
	        is.read(b);
	        is.close();
	        return new String(b);
	    }
}

@@ -1077,16 +1077,51 @@
 %22, %22%5Cn%22)
+.replaceAll(%22%5C%5Cs%5C%22file%5C%22.+%5C%5CR%22, %22%22)
 ,%0A      
@@ -1205,16 +1205,51 @@
 %22, %22%5Cn%22)
+.replaceAll(%22%5C%5Cs%5C%22file%5C%22.+%5C%5CR%22, %22%22)
 );%0A%0A%09%7D%0A%09

fix test