我正在尝试学习 HTTPUnit 并阅读了http://httpunit.sourceforge.net/doc/cookbook.html上提到的食谱
但是当我尝试这个非常简单的代码时
package httpUnit.test;
import java.io.IOException;
import org.xml.sax.SAXException;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebLink;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
/*** Hello world!**/
public class App{
public static void main( String[] args ) throws IOException, SAXException {
System.out.println( "Trying HTPUnit library");
WebConversation wc = new WebConversation();
WebRequest req = new GetMethodWebRequest("http://localhost:8080/proof/demo.html");
WebResponse resp = wc.getResponse(req);
/* WebLink[ ] link = resp.getLinks();
for (int i=0; i<link.length; i++) {
System.out.println(link[i].getText());
}
System.out.println(link.length);
*/
}
};
我收到以下错误:
TypeError: undefined is not a function. (httpunit; line 15)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:597)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:557)
Error continues.....
和
Exception in thread "main" com.meterware.httpunit.ScriptException: Script '/*!
* jQuery JavaScript Library v1.6
* http://jquery.com/
有人可以弄清楚可能是什么问题。我无法理解。我已经从http://mvnrepository.com/artifact/httpunit/httpunit/1.6.1创建了具有 maven 依赖项的 maven 项目
我在tomcat的证明文件夹中托管了demo.html,它在浏览器中打开得很好。