// 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;
        compressCLI.setDisableMicroOptimizations(false);
        compressCLI.setPreserveUnecessarySemicolons(true);
        compressCLI.setOutputPath(_outputLocation.getAbsolutePath());
        compressCLI.setConfigurationFromString(_configuration);
        compressCLI.setBaseInputPath(_inputLocation.getAbsolutePath());
        compressCLI.setJsURIFragment("/js");
        compressCLI.setCssURIFragment("/css");

        compressCLI.execute();

        File cssDir = new File(_outputLocation, "css");
        assertTrue(cssDir.exists());
        assertEquals(4, cssDir.listFiles().length);

        File jsDir = new File(_outputLocation, "js");
        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();
// 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;

        compressCLI.setDisableMicroOptimizations(false);
        compressCLI.setPreserveUnecessarySemicolons(true);
        compressCLI.setOutputPath(_outputLocation.getAbsolutePath());
        compressCLI.setConfigurationFromString(_configuration);
        compressCLI.setBaseInputPath(_inputLocation.getAbsolutePath());
        compressCLI.setJsURIFragment("/js");
        compressCLI.setCssURIFragment("/css");

        compressCLI.execute();

        File cssDir = new File(_outputLocation, "css");
        assertTrue(cssDir.exists());
        assertEquals(4, cssDir.listFiles().length);

        File jsDir = new File(_outputLocation, "js");
        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());