// Path: apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java
// public class Resources {
//     /**
//      * Private constructor, to prevent accidental instantiation.
//      */
//     private Resources() {
//         // Does nothing
//     }
// 
//     public static final String SRC_TEST_RESOURCES = "src/test/resources";
//     public static final String SRC_MAIN_RESOURCES = "src/main/resources";
//     private static final File TEST_RESOURCE_BASE_PATH = new File(SRC_TEST_RESOURCES);
//     private static final File RESOURCE_BASE_PATH = new File(SRC_MAIN_RESOURCES);
// 
//     /**
//      * Locates a test resource file in the class path.
//      */
//     public static File getResourceFile(String pResource) throws IOException {
//         return getResourceFromBase(TEST_RESOURCE_BASE_PATH, pResource);
//     }
// 
//     /**
//      * Locates a main resource file in the class path.
//      */
//     public static File getMainResourceFile(String pResource) throws IOException {
//         return getResourceFromBase(RESOURCE_BASE_PATH, pResource);
//     }
// 
//     /**
//      * Try to to load the given file from baseDir, in case of errors try to add module names to fix behaviour from within IntelliJ.
//      */
//     private static File getResourceFromBase(File baseDir, String pResource) throws IOException {
//         File f = new File(baseDir, pResource);
//         if (!f.isFile()) {
//             throw new FileNotFoundException("Unable to locate resource file: " + pResource);
//         }
//         return f;
//     }
// 
//     /**
//      * Locates a set of resource files in the class path.
//      * In case of errors try to add module names to fix behaviour from within IntelliJ.
//      */
//     public static File[] getResourceFiles(String pResource) throws IOException {
//         File f = new File(TEST_RESOURCE_BASE_PATH, pResource);
//         if (!f.isDirectory()) {
//             throw new FileNotFoundException("Unable to locate resource directory: " + pResource);
//         }
// 
//         return f.listFiles(new FileFilter() {
//             public boolean accept(File pathname) {
//                 return pathname.isFile();
//             }
//         });
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns an {@link InputStream}.
//      */
//     public static InputStream getResourceStream(String pResource) throws IOException {
//         return new FileInputStream(getResourceFile(pResource));
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns a {@link Reader}.
//      */
//     public static Reader getResourceReader(String pResource) throws IOException {
//         return new InputStreamReader(getResourceStream(pResource), StandardCharsets.UTF_8);
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns a {@link BufferedReader}.
//      */
//     public static BufferedReader getBufferedResourceReader(String pResource) throws IOException {
//         return new BufferedReader(getResourceReader(pResource));
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns a {@link BufferedReader}.
//      */
//     public static BufferedReader getBufferedReader(File file) throws IOException {
//         return new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
//     }
// 
//     /**
//      * Locates the name of a directory, which contains the given
//      * resource file.
//      */
//     public static String getResourceDirectory(String pResource) throws IOException {
//         final File resource = getResourceFile(pResource);
//         final File dir = resource.getParentFile();
//         return DocumentImplUtils.toName(dir);
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.apache.commons.io.IOUtils;
import org.apache.rat.test.utils.Resources;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
        final String firstLine = "package API::TestAPI;";
        final String secondLine = ""; 
        final String thirdLine = "#" + FIRST_LICENSE_LINE;

        commonTestTemplate(filename, new FileCreator() {
                    public void createFile(Writer writer)
                            throws IOException {
                        writer.write(firstLine + "\n");
                        writer.write("print \"Hello world\"\n");
                    }
                },
                checkLines(firstLine, secondLine, thirdLine));
    }    

    @Test
    public void addLicenseToTclWithoutHashBang()
            throws IOException {
        String filename = "tmp.tcl";
        String firstLine = "#" + FIRST_LICENSE_LINE;

        commonTestTemplate(filename, new FileCreator() {
                    public void createFile(Writer writer)
                            throws IOException {
                        writer.write("puts \"Hello world\"\n");
                    }
                },
                checkLines(firstLine, null));
    }

    @Test
// Path: apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java
// public class Resources {
//     /**
//      * Private constructor, to prevent accidental instantiation.
//      */
//     private Resources() {
//         // Does nothing
//     }
// 
//     public static final String SRC_TEST_RESOURCES = "src/test/resources";
//     public static final String SRC_MAIN_RESOURCES = "src/main/resources";
//     private static final File TEST_RESOURCE_BASE_PATH = new File(SRC_TEST_RESOURCES);
//     private static final File RESOURCE_BASE_PATH = new File(SRC_MAIN_RESOURCES);
// 
//     /**
//      * Locates a test resource file in the class path.
//      */
//     public static File getResourceFile(String pResource) throws IOException {
//         return getResourceFromBase(TEST_RESOURCE_BASE_PATH, pResource);
//     }
// 
//     /**
//      * Locates a main resource file in the class path.
//      */
//     public static File getMainResourceFile(String pResource) throws IOException {
//         return getResourceFromBase(RESOURCE_BASE_PATH, pResource);
//     }
// 
//     /**
//      * Try to to load the given file from baseDir, in case of errors try to add module names to fix behaviour from within IntelliJ.
//      */
//     private static File getResourceFromBase(File baseDir, String pResource) throws IOException {
//         File f = new File(baseDir, pResource);
//         if (!f.isFile()) {
//             throw new FileNotFoundException("Unable to locate resource file: " + pResource);
//         }
//         return f;
//     }
// 
//     /**
//      * Locates a set of resource files in the class path.
//      * In case of errors try to add module names to fix behaviour from within IntelliJ.
//      */
//     public static File[] getResourceFiles(String pResource) throws IOException {
//         File f = new File(TEST_RESOURCE_BASE_PATH, pResource);
//         if (!f.isDirectory()) {
//             throw new FileNotFoundException("Unable to locate resource directory: " + pResource);
//         }
// 
//         return f.listFiles(new FileFilter() {
//             public boolean accept(File pathname) {
//                 return pathname.isFile();
//             }
//         });
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns an {@link InputStream}.
//      */
//     public static InputStream getResourceStream(String pResource) throws IOException {
//         return new FileInputStream(getResourceFile(pResource));
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns a {@link Reader}.
//      */
//     public static Reader getResourceReader(String pResource) throws IOException {
//         return new InputStreamReader(getResourceStream(pResource), StandardCharsets.UTF_8);
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns a {@link BufferedReader}.
//      */
//     public static BufferedReader getBufferedResourceReader(String pResource) throws IOException {
//         return new BufferedReader(getResourceReader(pResource));
//     }
// 
//     /**
//      * Locates a resource file in the class path and returns a {@link BufferedReader}.
//      */
//     public static BufferedReader getBufferedReader(File file) throws IOException {
//         return new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
//     }
// 
//     /**
//      * Locates the name of a directory, which contains the given
//      * resource file.
//      */
//     public static String getResourceDirectory(String pResource) throws IOException {
//         final File resource = getResourceFile(pResource);
//         final File dir = resource.getParentFile();
//         return DocumentImplUtils.toName(dir);
//     }
// }


// Path: apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenseAppender.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.apache.commons.io.IOUtils;
import org.apache.rat.test.utils.Resources;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

        final String firstLine = "package API::TestAPI;";
        final String secondLine = ""; 
        final String thirdLine = "#" + FIRST_LICENSE_LINE;

        commonTestTemplate(filename, new FileCreator() {
                    public void createFile(Writer writer)
                            throws IOException {
                        writer.write(firstLine + "\n");
                        writer.write("print \"Hello world\"\n");
                    }
                },
                checkLines(firstLine, secondLine, thirdLine));
    }    

    @Test
    public void addLicenseToTclWithoutHashBang()
            throws IOException {
        String filename = "tmp.tcl";
        String firstLine = "#" + FIRST_LICENSE_LINE;

        commonTestTemplate(filename, new FileCreator() {
                    public void createFile(Writer writer)
                            throws IOException {
                        writer.write("puts \"Hello world\"\n");
                    }
                },
                checkLines(firstLine, null));
    }

    @Test
    public void addLicenseToTclWithHashBang() throws IOException {