Hi Everyone,
I am trying to run a simple JWebUnit example that I have borrowed from the
documentation. The problem is that I can run the example if I run it as JUnit
test, but if I try to run it as a Java application and call the test method in
main() I get NullPointerException. I have created a completely new project in
Eclipse to make sure that nothing external is causing this problem, and have
tried this with both JWebUnit 1.4.1 and 1.4.0, and I have used only jar files
downloaded as part of JWebUnit.
-------------------------------
package test;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;
import net.sourceforge.jwebunit.junit.WebTestCase;
public class SearchExampleMain extends WebTestCase
{
public SearchExampleMain()
{
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
getTestContext().setBaseUrl("http://www.ultratechpartners.com");
getTestContext().setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
}
public void testSearch() throws Exception
{
beginAt("/");
setTextField("q", "htmlunit");
submit("btnG");
clickLinkWithText("HtmlUnit");
assertTitleEquals("htmlunit - Welcome to HtmlUnit");
assertLinkPresentWithText("Get started");
}
public static void main(String[] args)
{
SearchExampleMain se = new SearchExampleMain();
try
{
se.testSearch();
}
catch (Exception e)
{
e.printStackTrace();
}
}//End of main().
}//End of class SearchExampleMain.
-------------------------------------------------------------------------------------------
This is how I'm running it from command line (again, just to make sure Eclipse
classpath is not a problem, but I get the same when I try to run the project in
Eclipse):
-------------------------------------------------------------------------------------------
D:\java\jdk1.5.0_09\bin\javaw.exe -classpath
C:\temp\jwebunitdownloadedFile\classes;C:\temp\jwebunitdownloadedFile\lib\commons-codec-1.3.jar;C:\temp\jwebunitdownloadedFile\lib\commons-collections-3.2.jar;C:\temp\jwebunitdownloadedFile\lib\commons-httpclient-3.0.1.jar;C:\temp\jwebunitdownloadedFile\lib\commons-io-1.3.jar;C:\temp\jwebunitdownloadedFile\lib\commons-lang-2.2.jar;C:\temp\jwebunitdownloadedFile\lib\commons-logging-1.1.jar;C:\temp\jwebunitdownloadedFile\lib\dom4j-1.6.1.jar;C:\temp\jwebunitdownloadedFile\lib\htmlunit-1.11.jar;C:\temp\jwebunitdownloadedFile\lib\jaxen-1.1.jar;C:\temp\jwebunitdownloadedFile\lib\jdom-1.0.jar;C:\temp\jwebunitdownloadedFile\lib\js-1.6R5.jar;C:\temp\jwebunitdownloadedFile\lib\junit-3.8.2.jar;C:\temp\jwebunitdownloadedFile\lib\nekohtml-0.9.5.jar;C:\temp\jwebunitdownloadedFile\lib\regexp-1.3.jar;C:\temp\jwebunitdownloadedFile\lib\servlet-api-2.4.jar;C:\temp\jwebunitdownloadedFile\lib\xercesImpl-2.6.2.jar;C:\temp\jwebunitdownloadedFile\lib\xml-apis-1.3.02.jar;C:\temp\jwebunitdownloadedFile\lib\xmlParserAPIs-2.6.2.jar;C:\temp\jwebunitdownloadedFile\lib\xom-1.0.jar;C:\temp\jwebunitdownloadedFile\lib\jwebunit-htmlunit-plugin-1.4.jar;C:\temp\jwebunitdownloadedFile\lib\jwebunit-core-1.4.jar
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:3232
test.SearchExampleMain
-----------------------------------------------------------------------------------------------
Here is the output exception that I get:
Exception in thread "main" java.lang.NullPointerException
at
net.sourceforge.jwebunit.junit.WebTestCase.setTestingEngineKey(WebTestCase.java:1766)
at test.SearchExampleMain.SearchExampleMain22(SearchExampleMain.java:11)
at test.SearchExampleMain.main(SearchExampleMain.java:31)
-----------------------------------------------------------------------------------------------
I just can't get this to work, and can't find anything Googling either. I
really appreciate it if anyone has any suggestion as to what might be wrong.
The fact that I'm trying to run it as a normal application (from main method)
is not the show stopper, is it?
Thanks,
Kasra-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development