// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
// 
//     public static String readFile(Class clazz, String resource) throws IOException {
//         return IOUtils.toString(clazz.getResourceAsStream(resource));
//     }
// 
//     public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
//         if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
//             return;
//         }
//         assertEquals(expected, actual);
//     }
// 
//     // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
//     // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
//     public static String normalizeWhiteSpace(String s) {
//         return s.replaceAll("\\s+", "").trim();
//     }
// }


import java.io.File;
import java.io.FileInputStream;
import com.switchfly.compress.TestingUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
        assertTrue(jsDir.exists());
        assertEquals(4, jsDir.listFiles().length);
    }

    @Test
    public void testMinifyAndObfuscateCss() throws Exception {
        File input = new File(getClass().getResource("input.css").getFile());

        CompressCLI compressCLI = new CompressCLI();
        compressCLI.minifyAndObfuscateFile(input, _outputFile, false);

        assertTrue(_outputFile.exists());

        String actual = IOUtils.toString(new FileInputStream(_outputFile));
        String expected = IOUtils.toString(getClass().getResourceAsStream("inputMinified.css")).trim();
        TestingUtil.assertEqualsIgnoreWhitespace(expected, actual.trim());
    }

    @Test
    public void testMinifyAndObfuscateJs() throws Exception {
        File input = new File(getClass().getResource("input.js").getFile());

        CompressCLI compressCLI = new CompressCLI();
        compressCLI.minifyAndObfuscateFile(input, _outputFile, true);

        assertTrue(_outputFile.exists());

        String actual = IOUtils.toString(new FileInputStream(_outputFile));
        String expected = IOUtils.toString(getClass().getResourceAsStream("inputMinified.js")).trim();

// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
// 
//     public static String readFile(Class clazz, String resource) throws IOException {
//         return IOUtils.toString(clazz.getResourceAsStream(resource));
//     }
// 
//     public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
//         if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
//             return;
//         }
//         assertEquals(expected, actual);
//     }
// 
//     // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
//     // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
//     public static String normalizeWhiteSpace(String s) {
//         return s.replaceAll("\\s+", "").trim();
//     }
// }


// Path: compress/src/test/java/com/switchfly/compress/cli/CompressCLITest.java
import java.io.File;
import java.io.FileInputStream;
import com.switchfly.compress.TestingUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

        assertTrue(jsDir.exists());
        assertEquals(4, jsDir.listFiles().length);
    }

    @Test
    public void testMinifyAndObfuscateCss() throws Exception {
        File input = new File(getClass().getResource("input.css").getFile());

        CompressCLI compressCLI = new CompressCLI();
        compressCLI.minifyAndObfuscateFile(input, _outputFile, false);

        assertTrue(_outputFile.exists());

        String actual = IOUtils.toString(new FileInputStream(_outputFile));
        String expected = IOUtils.toString(getClass().getResourceAsStream("inputMinified.css")).trim();
        TestingUtil.assertEqualsIgnoreWhitespace(expected, actual.trim());
    }

    @Test
    public void testMinifyAndObfuscateJs() throws Exception {
        File input = new File(getClass().getResource("input.js").getFile());

        CompressCLI compressCLI = new CompressCLI();
        compressCLI.minifyAndObfuscateFile(input, _outputFile, true);

        assertTrue(_outputFile.exists());

        String actual = IOUtils.toString(new FileInputStream(_outputFile));
        String expected = IOUtils.toString(getClass().getResourceAsStream("inputMinified.js")).trim();

        TestingUtil.assertEqualsIgnoreWhitespace(expected, actual.trim());