Skip to content
Snippets Groups Projects
Commit b023e8da authored by ribeaudc's avatar ribeaudc
Browse files

Make a better Unit test of DefaultReaderParser

SVN: 208
parent df763c11
No related branches found
No related tags found
No related merge requests found
...@@ -16,36 +16,38 @@ ...@@ -16,36 +16,38 @@
package ch.systemsx.cisd.common.parser; package ch.systemsx.cisd.common.parser;
import static org.testng.AssertJUnit.assertEquals;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.util.List; import java.util.List;
import static org.testng.AssertJUnit.*; import org.apache.commons.io.IOUtils;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import ch.systemsx.cisd.common.logging.LogInitializer;
/** /**
* Test cases for corresponding {@link DefaultReaderParser} class. * Test cases for corresponding {@link DefaultReaderParser} class.
* *
* @author Christian Ribeaud * @author Christian Ribeaud
*/ */
public final class DefaultReaderParserTest public final class DefaultReaderParserTest
{ {
private final String text = "1.line:\t1\t2\t3\n2.line\t4\t5\t6\n3.line\t7\t8\t9"; private final String text =
"\n# This is a comment\n" + "firstName\tlastName\taddress\tcity\n"
@BeforeSuite + "Christian\tRibeaud\tKapfrain 2/2\tEfringen-Kirchen\n"
public final void init() + "Marcel\tOdiet\tRue des Pervenches 46\t2800 Delmont\n";
{
LogInitializer.init();
}
@Test @Test
public final void testParseWithoutFactory() public final void testParseWithoutFactory() throws IOException
{ {
IReaderParser<String[]> parser = new DefaultReaderParser<String[]>(); IReaderParser<String[]> parser = new DefaultReaderParser<String[]>();
parser.setObjectFactory(IParserObjectFactory.DO_NOTHING_OBJECT_FACTORY); parser.setObjectFactory(IParserObjectFactory.DO_NOTHING_OBJECT_FACTORY);
List<String[]> result = parser.parse(new StringReader(text)); Reader reader = new StringReader(text);
assertEquals(result.get(0)[0], "1.line:"); List<String[]> result = parser.parse(reader);
assertEquals(result.get(0)[0], "firstName");
assertEquals(result.get(1)[1], "Ribeaud");
assertEquals(result.get(2)[2], "Rue des Pervenches 46");
IOUtils.closeQuietly(reader);
} }
} }
\ No newline at end of file
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