X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=test%2Fnet%2Fjaekl%2Fcfb%2FCFBTest.java;h=1e70fb28ae81dd11b3d5da7eefe9d2a0cdfa2969;hp=6d446676e0e32d1243830f7c537fc1f44a0fc673;hb=7ef6c36cd147216c5354082b11aa33cf6b5c6f49;hpb=59715b74a1ef7cb3fcdb48544b6f4f2cf8208805 diff --git a/test/net/jaekl/cfb/CFBTest.java b/test/net/jaekl/cfb/CFBTest.java index 6d44667..1e70fb2 100644 --- a/test/net/jaekl/cfb/CFBTest.java +++ b/test/net/jaekl/cfb/CFBTest.java @@ -1,6 +1,7 @@ package net.jaekl.cfb; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -107,6 +108,53 @@ public class CFBTest { m_cfb = new CFBMock(Locale.getDefault(), m_driver); } + @Test + public void testParseArgs_noParams() throws IOException + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = {}; + + boolean result = m_cfb.parseArgs(pw, args); + pw.close(); + sw.close(); + + assertFalse(result); + assertEquals("[must.specify.fbp.file]\n[invoke.with.help.for.help]\n", sw.toString()); + } + + @Test + public void testParseArgs_dropTables() throws IOException + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = { "--drop-tables" }; + + boolean result = m_cfb.parseArgs(pw, args); + pw.close(); + sw.close(); + + assertTrue(result); + assertEquals("", sw.toString()); + } + + @Test + public void testParseArgs_invalidParam() throws IOException + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + String[] args = {"--xyzzyaoeuidhtnsl"}; + + boolean result = m_cfb.parseArgs(pw, args); + pw.close(); + sw.close(); + String actual = sw.toString(); + + assertFalse(result); + assertTrue(actual.contains("usage")); + assertTrue(actual.contains("--help")); + } + @Test public void testStoreAndReport_noPrior() throws IOException, SQLException, SAXException, TypeMismatchException {