From b17a03abbd1ac5dac3925c36b2d8b7a09a9cdb82 Mon Sep 17 00:00:00 2001 From: hanna Date: Fri, 27 Mar 2009 16:05:18 +0000 Subject: [PATCH] Fix argument parser test case. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@215 348d0f76-0448-11de-a6fe-93d51630548a --- .../utils/cmdLine/ArgumentParserTest.java | 46 ++++++------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/java/test/org/broadinstitute/sting/utils/cmdLine/ArgumentParserTest.java b/java/test/org/broadinstitute/sting/utils/cmdLine/ArgumentParserTest.java index c3509f5cc..d4e89bb83 100644 --- a/java/test/org/broadinstitute/sting/utils/cmdLine/ArgumentParserTest.java +++ b/java/test/org/broadinstitute/sting/utils/cmdLine/ArgumentParserTest.java @@ -64,10 +64,10 @@ public class ArgumentParserTest { // setup the parser m_parser = new ArgumentParser("Test Program", this); - m_parser.addRequiredlFlag("testBool", "B", "our test bool", "testBool"); - m_parser.addRequiredlArg("testString", "S", "our test string", "testString"); - m_parser.addRequiredlArg("testInt", "I", "our test int", "testInt"); - m_parser.addRequiredlArg("testFloat", "F", "our test float", "testFloat"); + m_parser.addOptionalFlag("testBool", "B", "our test bool", "testBool"); + m_parser.addRequiredArg("testString", "S", "our test string", "testString"); + m_parser.addRequiredArg("testInt", "I", "our test int", "testInt"); + m_parser.addRequiredArg("testFloat", "F", "our test float", "testFloat"); } @@ -93,7 +93,8 @@ public class ArgumentParserTest { try { // process the arguments - m_parser.processArgs(params); + m_parser.processArgs(params,false); + m_parser.loadArgumentsIntoObject(this); } catch (ParseException e) { fail("We received an unexpected parsing exception"); } @@ -114,7 +115,8 @@ public class ArgumentParserTest { try { // process the arguments - m_parser.processArgs(params); + m_parser.processArgs(params,false); + m_parser.loadArgumentsIntoObject(this); } catch (ParseException e) { fail("We received an unexpected parsing exception"); } @@ -132,7 +134,8 @@ public class ArgumentParserTest { try { // process the arguments - m_parser.processArgs(params); + m_parser.processArgs(params,false); + m_parser.loadArgumentsIntoObject(this); } catch (ParseException e) { fail("We received an unexpected parsing exception"); } @@ -150,7 +153,8 @@ public class ArgumentParserTest { try { // process the arguments - m_parser.processArgs(params); + m_parser.processArgs(params,false); + m_parser.loadArgumentsIntoObject(this); } catch (ParseException e) { fail("We received an unexpected parsing exception"); } @@ -166,40 +170,20 @@ public class ArgumentParserTest { public void testForUnpassedParameter() { // add a new required flag we won't send it - m_parser.addRequiredlArg("testNotTHere", "N", "our should be provided test", "testFloat"); + m_parser.addRequiredArg("testNotTHere", "N", "our should be provided test", "testFloat"); // setup the parameter list String[] params = {"-B", "-S", "String", "-I", "100", "-F", "100.0"}; try { // process the arguments - m_parser.processArgs(params); + m_parser.processArgs(params,false); fail("We should have received a missing argument exception"); } catch (ParseException e) { // do nothing but consume the exception } } - /** - * test to see that if we don't get a required flag we get an exception - */ - @Test - public void testForRequiredFlag() { - // add a new required flag we won't send it - m_parser.addRequiredlFlag("testNotTHere", "N", "our should be provided test", "testBool"); - - // setup the parameter list - String[] params = {"-B", "-S", "String", "-I", "100", "-F", "100.0"}; - - try { - // process the arguments - m_parser.processArgs(params); - fail("We should have received a missing flag exception"); - } catch (ParseException e) { - // do nothing but consume the exception - } - } - /** * test to see if we pass a bad field name we get an runtime exception */ @@ -207,7 +191,7 @@ public class ArgumentParserTest { public void testForBadArgFieldName() { try { // add a new required flag we won't send it - m_parser.addRequiredlFlag("testNotTHere", "N", "our should be provided test", "testDoesNotExist"); + m_parser.addRequiredArg("testNotTHere", "N", "our should be provided test", "testDoesNotExist"); fail("We should of recieved a runtime exception, add unavailable fields is Baaad"); } catch (RuntimeException e) { // do nothing but consume the exception