Great, thanks.

Julien HENRY wrote:
> Hi Rusty,
> 
> Just call getAllHeaders after beginAt as beginAt is basically the 
> browser initialization method.
> 
> Regards,
> 
> Julien
> 
> ------------------------------------------------------------------------
> *De :* Rusty Wright <rusty.wri...@gmail.com>
> *À :* jwebunit-users@lists.sourceforge.net
> *Envoyé le :* Dimanche, 23 Août 2009, 4h55mn 26s
> *Objet :* [JWebUnit-users] simple test throws NPE
> 
> I must not be doing something right, but the documentation on the
> jwebunit page isn't helping me.  Can someone tell me what I'm missing?
> 
> public class WebTest extends WebTestCase {
>   private final Log log = LogFactory.getLog(getClass());
> 
>   @Override
>   public void setUp() throws Exception {
>     super.setUp();
> 
>     setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
> 
>     getTestContext().setBaseUrl("http://www.google.com/";);
>   }
> 
>   /**
>     */
>   public void testIndex() {
>     dumpHeaders(getAllHeaders());
> 
>     beginAt("/");
> 
>     assertTitleEquals("title goes here");
> 
>     assertTextPresent("something needs to go here");
>   }
> 
>   private void dumpHeaders(final Map<String, String> headers) {
>     for (final String key : headers.keySet()) {
>       this.log.debug(key + ": " + headers.get(key));
>     }
>   }
> }
> 
> Here are the version numbers of the jars:
> 
> C:\users\rusty\workspaces\spring_samples\sample001>mvn dependency:tree
> [INFO] Scanning for projects...
> [INFO] Searching repository for plugin with prefix: 'dependency'.
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Building spring sample 001
> [INFO]    task-segment: [dependency:tree]
> [INFO]
> ------------------------------------------------------------------------
> [INFO] [dependency:tree {execution: default-cli}]
> [INFO] com.object-effects:sample001:war:1.0-SNAPSHOT
> [INFO] +- org.springframework:spring-webmvc:jar:2.5.6:compile
> [INFO] |  +- commons-logging:commons-logging:jar:1.1.1:compile
> [INFO] |  +- org.springframework:spring-beans:jar:2.5.6:compile
> [INFO] |  +- org.springframework:spring-context:jar:2.5.6:compile
> [INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
> [INFO] |  +- org.springframework:spring-context-support:jar:2.5.6:compile
> [INFO] |  +- org.springframework:spring-core:jar:2.5.6:compile
> [INFO] |  \- org.springframework:spring-web:jar:2.5.6:compile
> [INFO] +- javax.servlet:jstl:jar:1.1.2:compile
> [INFO] +- log4j:log4j:jar:1.2.15:compile
> [INFO] |  \- javax.mail:mail:jar:1.4:compile
> [INFO] |    \- javax.activation:activation:jar:1.1:compile
> [INFO] +- net.sourceforge.jwebunit:jwebunit-core:jar:2.2:test
> [INFO] |  +- regexp:regexp:jar:1.3:test
> [INFO] |  \- javax.servlet:servlet-api:jar:2.4:test
> [INFO] +- junit:junit:jar:4.7:test
> [INFO] \- net.sourceforge.jwebunit:jwebunit-htmlunit-plugin:jar:2.2:test
> [INFO]    +- net.sourceforge.htmlunit:htmlunit:jar:2.5:test
> [INFO]    |  +- xalan:xalan:jar:2.7.1:test
> [INFO]    |  |  \- xalan:serializer:jar:2.7.1:test
> [INFO]    |  |    \- xml-apis:xml-apis:jar:1.3.04:test
> [INFO]    |  +- commons-collections:commons-collections:jar:3.2.1:test
> [INFO]    |  +- commons-lang:commons-lang:jar:2.4:test
> [INFO]    |  +- commons-httpclient:commons-httpclient:jar:3.1:test
> [INFO]    |  +- commons-codec:commons-codec:jar:1.3:test
> [INFO]    |  +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.5:test
> [INFO]    |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.12:test
> [INFO]    |  |  \- xerces:xercesImpl:jar:2.8.1:test
> [INFO]    |  +- net.sourceforge.cssparser:cssparser:jar:0.9.5:test
> [INFO]    |  |  \- org.w3c.css:sac:jar:1.3:test
> [INFO]    |  \- commons-io:commons-io:jar:1.4:test
> [INFO]    +- org.slf4j:slf4j-api:jar:1.5.0:test
> [INFO]    \- org.slf4j:slf4j-log4j12:jar:1.5.0:test
> 
> Here's the stack trace:
> 
> -------------------------------------------------------------------------------
> Test set: com.objecteffects.web.integration.WebTest
> -------------------------------------------------------------------------------
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.078
> sec <<< FAILURE!
> testIndexLogin(com.objecteffects.web.integration.WebTest)  Time elapsed:
> 0.047 sec  <<< ERROR!
> java.lang.NullPointerException
>     at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.getWebResponse(HtmlUnitTestingEngineImpl.java:2273)
>     at
> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.getAllHeaders(HtmlUnitTestingEngineImpl.java:2302)
>     at
> net.sourceforge.jwebunit.junit.WebTester.getAllHeaders(WebTester.java:360)
>     at
> net.sourceforge.jwebunit.junit.WebTestCase.getAllHeaders(WebTestCase.java:291)
>     at
> com.objecteffects.web.integration.WebTest.testIndexLogin(WebTest.java:33)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at junit.framework.TestCase.runTest(TestCase.java:168)
>     at junit.framework.TestCase.runBare(TestCase.java:134)
>     at 
> net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java:79)
>     at junit.framework.TestResult$1.protect(TestResult.java:110)
>     at junit.framework.TestResult.runProtected(TestResult.java:128)
>     at junit.framework.TestResult.run(TestResult.java:113)
>     at junit.framework.TestCase.run(TestCase.java:124)
>     at junit.framework.TestSuite.runTest(TestSuite.java:232)
>     at junit.framework.TestSuite.run(TestSuite.java:227)
>     at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>     at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>     at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
>     at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
>     at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
>     at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
> 
> 
> Thanks
> 
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and 
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> JWebUnit-users mailing list
> JWebUnit-users@lists.sourceforge.net 
> <mailto:JWebUnit-users@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> JWebUnit-users mailing list
> JWebUnit-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to