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;
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
{