Hi Matt,

Move 
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
from the constructor to the setUp() method...
and open a bug (at least the doc on the web site should be updated).

Regards,

Julien





----- Message d'origine ----
De : Matt Raible <[EMAIL PROTECTED]>
À : jwebunit-users@lists.sourceforge.net
Envoyé le : Mardi, 28 Octobre 2008, 9h25mn 15s
Objet : [JWebUnit-users] Upgrading from 1.2 to 2.0

I'm trying to upgrade from an older version of jWebUnit to the latest
and greatest that uses HtmlUnit. However, I keep getting the following
error in my test output (from Maven).

Tests run: 5, Failures: 5, Errors: 0, Skipped: 0, Time elapsed: 0.054
sec <<< FAILURE!
warning(junit.framework.TestSuite$1)  Time elapsed: 0.006 sec  <<< FAILURE!
junit.framework.AssertionFailedError: Exception in constructor:
testWelcomePage (java.lang.NullPointerException
    at 
net.sourceforge.jwebunit.junit.WebTestCase.setTestingEngineKey(WebTestCase.java:2032)
    at org.appfuse.web.UserWebTest.<init>(UserWebTest.java:15)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at junit.framework.TestSuite.createTest(TestSuite.java:65)
    at junit.framework.TestSuite.addTestMethod(TestSuite.java:283)
    at junit.framework.TestSuite.<init>(TestSuite.java:146)
    at 
org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:69)

The relevant code in my class is as follows:

import net.sourceforge.jwebunit.junit.WebTestCase;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;


import java.util.ResourceBundle;

public class UserWebTest extends WebTestCase {
    private ResourceBundle messages;

    public UserWebTest(String name) {
        super(name);
        setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
        getTestContext().setBaseUrl("http://localhost:25888";);
        getTestContext().setResourceBundleName("messages");
        messages = ResourceBundle.getBundle("messages");
        //getTestContext().setLocale(Locale.GERMAN);
        //getTestContext().getWebClient().setHeaderField("Accept-Language",
"de");
    }

    public void testWelcomePage() {
        beginAt("/");
        assertTitleKeyMatches("index.title");
    }

The error seems to be occurring at the following line:

        setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);

If I remove this line, the error is:

junit.framework.AssertionFailedError: Exception in constructor:
testWelcomePage (java.lang.NullPointerException
    at 
net.sourceforge.jwebunit.junit.WebTestCase.getTestContext(WebTestCase.java:106)
    at org.appfuse.web.UserWebTest.<init>(UserWebTest.java:15)

I'm using Java 5 and Maven 2.0.9 on OS X.

Thanks,

Matt

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users



      

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to