commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r784813 - /commons/proper/cli/trunk/src/test/org/apache/commons/cli/bug/BugCLI148Test.java
Date Mon, 15 Jun 2009 15:34:34 GMT
Author: ebourg
Date: Mon Jun 15 15:34:34 2009
New Revision: 784813

URL: http://svn.apache.org/viewvc?rev=784813&view=rev
Log:
Minor refactoring of BugCLI148Test

Modified:
    commons/proper/cli/trunk/src/test/org/apache/commons/cli/bug/BugCLI148Test.java

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli/bug/BugCLI148Test.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli/bug/BugCLI148Test.java?rev=784813&r1=784812&r2=784813&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli/bug/BugCLI148Test.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli/bug/BugCLI148Test.java Mon Jun
15 15:34:34 2009
@@ -17,50 +17,44 @@
 
 package org.apache.commons.cli.bug;
 
+import junit.framework.TestCase;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.PosixParser;
 
-import junit.framework.TestCase;
-
 /**
  * http://issues.apache.org/jira/browse/CLI-148
  *
  * @author brianegge
  */
-public class BugCLI148Test  extends TestCase {
+public class BugCLI148Test  extends TestCase
+{    
+    private Options options;
+
+    protected void setUp() throws Exception
+    {
+        options = new Options();
+        options.addOption(OptionBuilder.hasArg().create('t'));
+        options.addOption(OptionBuilder.hasArg().create('s'));
+    }
 
     public void testWorkaround1() throws Exception
     {
-        Options options = buildCommandLineOptions();
         CommandLineParser parser = new PosixParser();
-        String[] args = new String[] {"-t-something" };
-        CommandLine commandLine;
-        commandLine = parser.parse( options, args );
-        assertEquals("-something", commandLine.getOptionValue( 't'));
+        String[] args = new String[]{ "-t-something" };
+
+        CommandLine commandLine = parser.parse(options, args);
+        assertEquals("-something", commandLine.getOptionValue('t'));
     }
 
     public void testWorkaround2() throws Exception
     {
-        Options options = buildCommandLineOptions();
         CommandLineParser parser = new PosixParser();
-        String[] args = new String[] {"-t", "\"-something\"" };
-        CommandLine commandLine;
-        commandLine = parser.parse( options, args );
-        assertEquals("-something", commandLine.getOptionValue( 't'));
-    }
+        String[] args = new String[]{ "-t", "\"-something\"" };
 
-    private Options buildCommandLineOptions()
-    {
-        Option t = OptionBuilder.withArgName( "t").hasArg().create('t');
-        Option s = OptionBuilder.withArgName( "s").hasArg().create('s');
-        Options options = new Options();
-        options.addOption( t);
-        options.addOption( s);
-        return options;
+        CommandLine commandLine = parser.parse(options, args);
+        assertEquals("-something", commandLine.getOptionValue('t'));
     }
-
 }



Mime
View raw message