我已经构建了一个 ESAPITestValidator 类,如下所示:
public class ESAPITestValidator {
Validator instance = ESAPI.validator();
ValidationErrorList errors = new ValidationErrorList();
File parent = null;
String path = new String("");
boolean status = false;
public boolean testGetValidDirectoryPath(String inputPath,String context)
{
try
{
parent = new File(inputPath).getParentFile().getCanonicalFile();
//String parent = ESAPI.securityConfiguration().getResourceFile("ESAPI.properties").getParentFile().getCanonicalPath();
path = instance.getValidDirectoryPath(context, inputPath, parent, true, errors);
status = true;
return status;
}catch(Exception exception)
{
exception.printStackTrace();
status= false;
}
return status;
}
}
现在我正尝试从主类调用 testGetValidDirectoryPath() ,如下所示:
public class HelloWorld {
public static void main(String[] args) {
ESAPITestValidator obj = new ESAPITestValidator();
if ( obj.testGetValidDirectoryPath("C:\\Users\\1730176\\Downloads","C:\\Users") )
System.out.println("Success");
else
System.out.println("Failure");
}
}
慕虎7371278
相关分类