我已經(jīng)構(gòu)建了一個 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; }}現(xiàn)在我正嘗試從主類調(diào)用 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"); }}
1 回答

慕虎7371278
TA貢獻(xiàn)1802條經(jīng)驗 獲得超4個贊
JVM 正在尋找javax/servlet/http/HttpServletRequest
類,而您還沒有將它加載到類路徑中。請記住,ESAPI 是一個基于 Web 的庫,如果您克隆實際的 esapi-java-legacy 項目并在那里進(jìn)行單元測試,您可能會更輕松地進(jìn)行測試。
添加回答
舉報
0/150
提交
取消