我已經構建了一個 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"); }}
查看完整描述
