Skip to content
Snippets Groups Projects
Commit 32c48cbc authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

switched from readConfig to Files.readLines

parent 07c14928
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,9 @@ import org.junit.Test; ...@@ -13,6 +13,9 @@ import org.junit.Test;
import teetime.util.classpath.ClassForNameResolver; import teetime.util.classpath.ClassForNameResolver;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
public class PipeFactoryLoaderTest { public class PipeFactoryLoaderTest {
@Test @Test
...@@ -37,8 +40,8 @@ public class PipeFactoryLoaderTest { ...@@ -37,8 +40,8 @@ public class PipeFactoryLoaderTest {
files.add(pipeConfig.toURI().toURL()); files.add(pipeConfig.toURI().toURL());
List<IPipeFactory> pipeFactories = PipeFactoryLoader.mergeFiles(files); List<IPipeFactory> pipeFactories = PipeFactoryLoader.mergeFiles(files);
ArrayList<String> contents = readConf(pipeConfig); List<String> contents = Files.readLines(pipeConfig, Charsets.UTF_8);
contents.addAll(readConf(testConfig)); contents.addAll(Files.readLines(testConfig, Charsets.UTF_8));
// Check if all read factories are contained in one of the files // Check if all read factories are contained in one of the files
for (IPipeFactory iPipeFactory : pipeFactories) { for (IPipeFactory iPipeFactory : pipeFactories) {
...@@ -50,13 +53,13 @@ public class PipeFactoryLoaderTest { ...@@ -50,13 +53,13 @@ public class PipeFactoryLoaderTest {
ClassForNameResolver<IPipeFactory> classResolver = new ClassForNameResolver<IPipeFactory>(IPipeFactory.class); ClassForNameResolver<IPipeFactory> classResolver = new ClassForNameResolver<IPipeFactory>(IPipeFactory.class);
// Look for the "normal" pipes // Look for the "normal" pipes
for (String className : readConf(pipeConfig)) { for (String className : Files.readLines(pipeConfig, Charsets.UTF_8)) {
IPipeFactory pipeFactory = classResolver.classForName(className).newInstance(); IPipeFactory pipeFactory = classResolver.classForName(className).newInstance();
IPipeFactory returnedFactory = pipeRegistry.getPipeFactory(pipeFactory.getThreadCommunication(), pipeFactory.getOrdering(), pipeFactory.isGrowable()); IPipeFactory returnedFactory = pipeRegistry.getPipeFactory(pipeFactory.getThreadCommunication(), pipeFactory.getOrdering(), pipeFactory.isGrowable());
Assert.assertEquals(pipeFactory.getClass().getCanonicalName(), returnedFactory.getClass().getCanonicalName()); Assert.assertEquals(pipeFactory.getClass().getCanonicalName(), returnedFactory.getClass().getCanonicalName());
} }
// Second "and a half" part // Second "and a half" part
for (String className : readConf(testConfig)) { for (String className : Files.readLines(testConfig, Charsets.UTF_8)) {
IPipeFactory pipeFactory = classResolver.classForName(className).newInstance(); IPipeFactory pipeFactory = classResolver.classForName(className).newInstance();
// Still old factory // Still old factory
IPipeFactory returnedFactory = pipeRegistry.getPipeFactory(pipeFactory.getThreadCommunication(), pipeFactory.getOrdering(), pipeFactory.isGrowable()); IPipeFactory returnedFactory = pipeRegistry.getPipeFactory(pipeFactory.getThreadCommunication(), pipeFactory.getOrdering(), pipeFactory.isGrowable());
...@@ -81,14 +84,4 @@ public class PipeFactoryLoaderTest { ...@@ -81,14 +84,4 @@ public class PipeFactoryLoaderTest {
return lines; return lines;
} }
private ArrayList<String> readConf(final File fileName) throws IOException {
BufferedReader fileReader = new BufferedReader(new FileReader(fileName));
ArrayList<String> list = new ArrayList<String>();
String line;
while ((line = fileReader.readLine()) != null) {
list.add(line);
}
fileReader.close();
return list;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment