Skip to content

Commit 9039cbd

Browse files
authored
Update PatternOptionBuilderTest.java
1 parent a315e18 commit 9039cbd

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.junit.Assert.fail;
2525

2626
import java.io.File;
27+
import java.io.FileInputStream;
2728
import java.net.URL;
2829
import java.util.Calendar;
2930
import java.util.Date;
@@ -159,13 +160,20 @@ public void testURLPattern() throws Exception
159160
@Test
160161
public void testExistingFilePattern() throws Exception
161162
{
162-
Options options = PatternOptionBuilder.parsePattern("f<");
163+
Options options = PatternOptionBuilder.parsePattern("f<g<");
163164
CommandLineParser parser = new PosixParser();
164-
CommandLine line = parser.parse(options, new String[] { "-f", "test.properties" });
165-
166-
assertEquals("f value", new File("test.properties"), line.getOptionObject("f"));
167-
168-
// todo test if an error is returned if the file doesn't exists (when it's implemented)
165+
CommandLine line = parser.parse(options, new String[] { "-f", "test.properties", "-g", "build.xml" });
166+
167+
assertNotNull((FileInputStream) line.getOptionObject("g"));
168+
169+
try
170+
{
171+
line.getOptionObject("f");
172+
fail("ParseException wasn't thrown");
173+
}
174+
catch (ParseException e)
175+
{
176+
}
169177
}
170178

171179
@Test

0 commit comments

Comments
 (0)