diff --git a/.classpath b/.classpath index 9022062d8dfa64335dc564f900678538dac21bd5..abce7149466c4bdeeedaa5ff1de5103a25f09f4a 100644 --- a/.classpath +++ b/.classpath @@ -24,7 +24,7 @@ </attributes> </classpathentry> <classpathentry including="**/*.java" kind="src" path="src/main/resources"/> - <classpathentry including="**/*.java" kind="src" path="src/test/resources"/> + <classpathentry kind="src" path="src/test/resources"/> <classpathentry kind="src" path="conf"/> <classpathentry kind="output" path="target/classes"/> </classpath> diff --git a/src/test/java/teetime/framework/FileSearcherTest.java b/src/test/java/teetime/framework/FileSearcherTest.java new file mode 100644 index 0000000000000000000000000000000000000000..74c4b073bc0cadc6cbcd662266282165d6e80662 --- /dev/null +++ b/src/test/java/teetime/framework/FileSearcherTest.java @@ -0,0 +1,47 @@ +package teetime.framework; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; + +public class FileSearcherTest { + + @Test + public void fileInClasspath() throws IOException { + List<URL> list = FileSearcher.loadResources("data/input.txt"); + Assert.assertEquals(false, list.isEmpty()); + } + + @Test + public void multipleFiles() throws IOException { + List<URL> list = FileSearcher.loadResources("LICENSE.txt"); + Assert.assertEquals(true, list.size() > 1); + } + + @Test + public void missingFile() throws IOException { + List<URL> list = FileSearcher.loadResources("filethatdoesnotexistinanyproject.nope"); + Assert.assertEquals(true, list.isEmpty()); + } + + @Test + public void emptyConfig() throws IOException { + // List<IPipeFactory> list = PipeFactoryLoader.mergeConfigFiles(); + } + + private int countLines(final File fileName) throws IOException { + BufferedReader r = new BufferedReader(new FileReader(fileName)); + int lines = 0; + while (r.readLine() != null) { + lines++; + } + r.close(); + return lines; + } +}