Skip to content

Commit 8c32392

Browse files
committed
Testing the two UnsupportedOperationException method calls
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x@741426 13f79535-47bb-0310-9956-ffa450edef68
1 parent a161832 commit 8c32392

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/test/org/apache/commons/cli/PatternOptionBuilderTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.net.URL;
2222
import java.util.Calendar;
2323
import java.util.Vector;
24+
import java.util.Date;
2425

2526
import junit.framework.TestCase;
2627

@@ -33,8 +34,8 @@ public class PatternOptionBuilderTest extends TestCase
3334
{
3435
public void testSimplePattern() throws Exception
3536
{
36-
Options options = PatternOptionBuilder.parsePattern("a:b@cde>f+n%t/");
37-
String[] args = new String[]{"-c", "-a", "foo", "-b", "java.util.Vector", "-e", "build.xml", "-f", "java.util.Calendar", "-n", "4.5", "-t", "http://commons.apache.org"};
37+
Options options = PatternOptionBuilder.parsePattern("a:b@cde>f+n%t/m*z#");
38+
String[] args = new String[] {"-c", "-a", "foo", "-b", "java.util.Vector", "-e", "build.xml", "-f", "java.util.Calendar", "-n", "4.5", "-t", "http://commons.apache.org", "-z", "Thu Jun 06 17:48:57 EDT 2002", "-m", "test*"};
3839

3940
CommandLineParser parser = new PosixParser();
4041
CommandLine line = parser.parse(options, args);
@@ -60,9 +61,21 @@ public void testSimplePattern() throws Exception
6061
assertEquals("number flag n", new Double(4.5), line.getOptionObject('n'));
6162
assertEquals("url flag t", new URL("http://commons.apache.org"), line.getOptionObject('t'));
6263

63-
/// DATES NOT SUPPORTED YET.
64-
// assertEquals("number flag t", new Date(1023400137276L), line.getOptionObject('z'));
65-
// input is: "Thu Jun 06 17:48:57 EDT 2002"
64+
// FILES NOT SUPPORTED YET
65+
try {
66+
assertEquals("files flag m", new File[0], line.getOptionObject('m'));
67+
fail("Multiple files are not supported yet, should have failed");
68+
} catch(UnsupportedOperationException uoe) {
69+
// expected
70+
}
71+
72+
// DATES NOT SUPPORTED YET
73+
try {
74+
assertEquals("number flag z", new Date(1023400137276L), line.getOptionObject('z'));
75+
fail("Date is not supported yet, should have failed");
76+
} catch(UnsupportedOperationException uoe) {
77+
// expected
78+
}
6679
}
6780

6881
public void testEmptyPattern() throws Exception

0 commit comments

Comments
 (0)