package com.googlecode.jslint4java.maven;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.io.File;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

import com.googlecode.jslint4java.formatter.JSLintResultFormatter;
import com.googlecode.jslint4java.formatter.JSLintXmlFormatter;

public class ReportWriterTest {

    @Rule
    public TemporaryFolder tmpf = new TemporaryFolder();

    private final JSLintResultFormatter formatter = new JSLintXmlFormatter();

    private ReportWriter createReportWriter(String filename) {
        return new ReportWriter(new File(tmpf.getRoot(), filename), formatter);
    }

    @Test
    public void createsNonEmptyFile() {
        ReportWriter rw = createReportWriter("report.xml");
        rw.open();
        rw.close();
        assertThat(rw.getReportFile().exists(), is(true));
        assertThat(rw.getReportFile().length(), is(not(0L)));
    }
}

@@ -960,11 +960,301 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void makesParentDirectory() %7B%0A        File parent = new File(tmpf.getRoot(), %22somedir%22);%0A        ReportWriter rw = new ReportWriter(new File(parent, %22report.xml%22), formatter);%0A        rw.open();%0A        rw.close();%0A        assertThat(parent.exists(), is(true));%0A    %7D
 %0A%7D%0A

Check ReportWriter makes parent directories.