From e935b3dfb4eac10552019db7ac9ec5c8a382a1c3 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Mon, 27 Oct 2014 17:12:53 +0100 Subject: [PATCH] first version of FileSearcherTest updated buildpath to include all files in src/test/resources --- .classpath | 2 +- .../teetime/framework/FileSearcherTest.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/test/java/teetime/framework/FileSearcherTest.java diff --git a/.classpath b/.classpath index 9022062d..abce7149 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 00000000..74c4b073 --- /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; + } +} -- GitLab