public class TestFileExistCmdLineOptionValidator extends TestCase {
public void testValidate() throws IOException {
// Test null option instance not allowed.
try {
new FileExistCmdLineOptionValidator().validate(null);
fail("Should have thrown IllegalArgumentException");
} catch (IllegalArgumentException ignore) { /* expect throw */
}
// Test fail case.
CmdLineOptionInstance instance = createOptionInstance(
createSimpleOption("test", false), "bogus");
assertEquals(Result.Grade.FAIL, new FileExistCmdLineOptionValidator()
.validate(instance).getGrade());
// Test pass case.
File tempFile = File.createTempFile("bogus", "bogus");
tempFile.deleteOnExit();
instance = createOptionInstance(createSimpleOption("test", false),
tempFile.getAbsolutePath());
assertEquals(Result.Grade.PASS, new FileExistCmdLineOptionValidator()
.validate(instance).getGrade());
}