/**
 * Copyright Alex Objelean
 */
package ro.isdc.wro.model.resource.processor;

import org.apache.commons.io.IOUtils;
import org.junit.Test;
import ro.isdc.wro.model.resource.ResourceType;
import ro.isdc.wro.model.resource.processor.decorator.ExceptionHandlingProcessorDecorator;
import ro.isdc.wro.model.resource.processor.impl.css.CssMinProcessor;
import ro.isdc.wro.util.WroTestUtils;

import java.io.*;
import java.net.URL;


/**
 * @author Alex Objelean
 */
public class TestCssMinProcessor {
  @Test
  public void testFromFolder()
    throws Exception {
    final ResourcePostProcessor processor = new CssMinProcessor();

    final URL url = getClass().getResource("cssmin");

    final File testFolder = new File(url.getFile(), "test");
    final File expectedFolder = new File(url.getFile(), "expected");
    WroTestUtils.compareFromDifferentFoldersByExtension(testFolder, expectedFolder, "css", processor);
  }

  @Test
  public void shouldHandleWrongCss()
      throws Exception {
    final ResourcePostProcessor processor = new ExceptionHandlingProcessorDecorator(new CssMinProcessor());
    
    final URL url = getClass().getResource("cssmin");
    
    final File testFolder = new File(url.getFile(), "test");
    final File expectedFolder = new File(url.getFile(), "expectedInvalid");
    WroTestUtils.compareFromDifferentFoldersByExtension(testFolder, expectedFolder, "css", processor);
  }
  
  @Test
  public void shouldSupportCorrectResourceTypes() {
    WroTestUtils.assertProcessorSupportResourceTypes(new CssMinProcessor(), ResourceType.CSS);
  }

  @Test
  public void shouldNotRemoveLastCharWhenAddingSemiColon() throws IOException {
      ResourcePostProcessor processor = new CssMinProcessor();
      URL url = getClass().getResource("cssmin");

      File testFile = new File(url.getFile(), "test/addingSemi.css");
      File expectedFile = new File(url.getFile(), "expected/addingSemi.css");
      StringWriter minifiedWriter = new StringWriter();
      processor.process(new FileReader(testFile), minifiedWriter);

      String minified = minifiedWriter.toString();

      String expected = IOUtils.toString(new FileInputStream(expectedFile));
      WroTestUtils.compare(expected, minified);
  }
}

@@ -86,38 +86,43 @@
 ort 
-org.apache.commons.io.IOUtils;
+java.io.File;%0Aimport java.net.URL;%0A
 %0Aimp
@@ -141,16 +141,17 @@
 t.Test;%0A
+%0A
 import r
@@ -394,48 +394,8 @@
 s;%0A%0A
-import java.io.*;%0Aimport java.net.URL;%0A%0A
 %0A/**
@@ -1533,663 +1533,7 @@
 %0A  %7D
-%0A%0A  @Test%0A  public void shouldNotRemoveLastCharWhenAddingSemiColon() throws IOException %7B%0A      ResourcePostProcessor processor = new CssMinProcessor();%0A      URL url = getClass().getResource(%22cssmin%22);%0A%0A      File testFile = new File(url.getFile(), %22test/addingSemi.css%22);%0A      File expectedFile = new File(url.getFile(), %22expected/addingSemi.css%22);%0A      StringWriter minifiedWriter = new StringWriter();%0A      processor.process(new FileReader(testFile), minifiedWriter);%0A%0A      String minified = minifiedWriter.toString();%0A%0A      String expected = IOUtils.toString(new FileInputStream(expectedFile));%0A      WroTestUtils.compare(expected, minified);%0A  %7D
 %0A%7D%0A

remove redundant test