Hi,

I'm trying to figure out how to include jwebunit as a maven dependency in my 
project. I followed instructions from the website but I didn't manage to get 
it work.

I checked the url that points to maven repository[1], and indeed, there is no 
net/sourceforge/jwebunit directory (or maven groupId).

[1] http://jwebunit.sourceforge.net/m2-repo

I also checked the maven snapshot repository[2]. This repository contains some 
dated versions of jar files but I don't see any -SNAPSHOT versions.

As the integration of jwebunit with maven wasn't working, I tried to check out 
the svn trunk and compile the project myself... I was surprise to see that 
the version of jwebunit in the pom was 2.0-SNAPSHOT whereas the lastest final 
release is 1.2 (if we consider 1.3-rc1 as not being a final release)... but 
ok, I compiled and deployed the project to a local repository and I managed 
to get maven dependency to work.

But now, when I'm executing a test via eclipse, I get an error (check it out 
at the end of this mail). This is a single test which is retreiving a 
login/password page, filling in the textfields and submitting the form.
This exception occurs when calling the submit method.

The form looks like:

<form action="/kweb/" method="post">
<fieldset id="loginbox">
  <label  for="username">Username:</label><input type="text" 
name="os_username" id="username" /><br />
  <label  for="password">Password:</label><input type="password" 
name="os_password" id="password" /><br />
   <div class="textfieldModifier">
 <input type="checkbox" name="os_cookie" value="true" id="persistent_login"/>
 <label  for="persistent_login" class="label">Remember me on this 
computer</label><br/>
   </div>
   <div class="form-buttons">
     <input type="reset" value="Clear Fields"/>
     <input type="submit" value="Login"/>
   </div>
   <p id="forgotpassword">
     Forgot your password ? Click <a 
href="/kweb/lostpassword/form.action">here</a>.
   </p>
</fieldset>
</form

And the code for my test is the following:

    public void testLoginWithExistingUserShouldBeSuccessful() {
        assertLinkPresentWithText("Log in");
        clickLinkWithText("Log in");
        assertFormPresent();
        assertFormElementPresent("os_username");
        assertTextPresent("Username:");
        assertFormElementEmpty("os_username");
        assertFormElementPresent("os_password");
        assertTextPresent("Password:");
        assertFormElementEmpty("os_password");
        assertResetButtonPresent();
        assertSubmitButtonPresent();
        setTextField("os_username", "fburlet");
        setTextField("os_password", "fburlet");
        checkCheckbox("os_cookie");
        submit(); <= here it fails with the stacktrace at the bottom of this 
mail.
        assertElementPresent("user-welcome");
        assertTextPresent("Logged in as");
    }


I have two problems to solve (or maybe only one because they are perhaps 
dependent). First, how do I get maven dependencies working if I want to use 
your deployed versions.
Second, what's going wrong with my test ? :o)

Thanks for your patience and your reading :o)

Regards,

Fred.

----
The stacktrace:

com.gargoylesoftware.htmlunit.ObjectInstantiationException: Exception when 
calling constructor [public 
com.gargoylesoftware.htmlunit.html.HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlPage,java.util.Map)]
        at 
com.gargoylesoftware.htmlunit.html.DefaultElementFactory.createElement(DefaultElementFactory.java:113)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.startElement(HTMLParser.java:358)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown 
Source)
        at org.cyberneko.html.filters.DefaultFilter.startElement(Unknown Source)
        at org.cyberneko.html.filters.NamespaceBinder.startElement(Unknown 
Source)
        at org.cyberneko.html.HTMLTagBalancer.callStartElement(Unknown Source)
        at org.cyberneko.html.HTMLTagBalancer.startElement(Unknown Source)
        at 
org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(Unknown 
Source)
        at org.cyberneko.html.HTMLScanner$ContentScanner.scan(Unknown Source)
        at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
        at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
        at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:311)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:426)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:344)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
        at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:217)
        at 
com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(HtmlSubmitInput.java:78)
        at 
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:120)
        at 
net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.submit(HtmlUnitDialog.java:959)
        at net.sourceforge.jwebunit.WebTester.submit(WebTester.java:1719)
        at net.sourceforge.jwebunit.WebTestCase.submit(WebTestCase.java:674)
        at 
com.kiala.kweb.TestLogin.testLoginWithExistingUserShouldBeSuccessful(TestLogin.java:40)
        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:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at net.sourceforge.jwebunit.WebTestCase.runBare(WebTestCase.java:50)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Enclosed exception: java.lang.VerifyError: (class: 
com/gargoylesoftware/htmlunit/javascript/host/EventHandler, method: get 
signature: 
(Ljava/lang/String;Lorg/mozilla/javascript/Scriptable;)Ljava/lang/Object;) 
Illegal use of nonvirtual function call
        at 
com.gargoylesoftware.htmlunit.html.HtmlElement.setEventHandler(HtmlElement.java:241)
        at 
com.gargoylesoftware.htmlunit.html.HtmlElement.attributesToEventHandlers(HtmlElement.java:650)
        at 
com.gargoylesoftware.htmlunit.html.HtmlElement.<init>(HtmlElement.java:98)
        at 
com.gargoylesoftware.htmlunit.html.StyledElement.<init>(StyledElement.java:62)
        at 
com.gargoylesoftware.htmlunit.html.ClickableElement.<init>(ClickableElement.java:73)
        at 
com.gargoylesoftware.htmlunit.html.FocusableElement.<init>(FocusableElement.java:58)
        at 
com.gargoylesoftware.htmlunit.html.HtmlAnchor.<init>(HtmlAnchor.java:70)
        at sun.reflect.GeneratedConstructorAccessor4.newInstance(Unknown Source)
        at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at 
com.gargoylesoftware.htmlunit.html.DefaultElementFactory.createElement(DefaultElementFactory.java:101)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.startElement(HTMLParser.java:358)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown 
Source)
        at org.cyberneko.html.filters.DefaultFilter.startElement(Unknown Source)
        at org.cyberneko.html.filters.NamespaceBinder.startElement(Unknown 
Source)
        at org.cyberneko.html.HTMLTagBalancer.callStartElement(Unknown Source)
        at org.cyberneko.html.HTMLTagBalancer.startElement(Unknown Source)
        at 
org.cyberneko.html.HTMLScanner$ContentScanner.scanStartElement(Unknown 
Source)
        at org.cyberneko.html.HTMLScanner$ContentScanner.scan(Unknown Source)
        at org.cyberneko.html.HTMLScanner.scanDocument(Unknown Source)
        at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
        at org.cyberneko.html.HTMLConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:311)
        at 
com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:226)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:112)
        at 
com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:85)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:426)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:344)
        at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:371)
        at com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:217)
        at 
com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(HtmlSubmitInput.java:78)
        at 
com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:120)
        at 
net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog.submit(HtmlUnitDialog.java:959)
        at net.sourceforge.jwebunit.WebTester.submit(WebTester.java:1719)
        at net.sourceforge.jwebunit.WebTestCase.submit(WebTestCase.java:674)
        at 
com.kiala.kweb.TestLogin.testLoginWithExistingUserShouldBeSuccessful(TestLogin.java:40)
        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:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at net.sourceforge.jwebunit.WebTestCase.runBare(WebTestCase.java:50)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to