Ah, that's good news :-)
So, upcoming release will help here. Is there a date you have in mind for the next webtest release ?

I have also voted to release an update to the webtest plug-in for grails (http://jira.codehaus.org/browse/GRAILSPLUGINS-242), so that we can get the advantage of the new included htmlunit version, as the probably many other bug fixes / improvements in webtest itself.

Thanks,
Niko


On 17.03.2008, at 09:20, Marc Guillemot wrote:

PUT, DELETE & co are supported by HtmlUnit since release 1.14. When I've
added the feature to HtmlUnit (ie before the release) I've adapted
WebTest's code to be able to use any method HtmlUnit accepts... but I
haven't tested it in WebTest since it includes HtmlUnit 1.14.

Normally you shouldn't have to hack anything for DELETE but I don't
think that you will be able to send a body currently with PUT for
instance. Any patch is welcome.

Cheers,
Marc.
--
Blog: http://mguillem.wordpress.com


Niko Schmuck wrote:
Hi Paul, and all:

Since the grails webtest plugin 0.3 seems in my installation to use an older version of htmlunit (1.11), which did not support PUT and DELETE I was going for a complete update round to the latest and greatest webtest version from subversion. After checking out the svn head, I was trying
to incoporate those two additional HTTP methods inside InvokePage
source, like:

protected Page findTarget() throws IOException, SAXException {
   if ("POST".equals(getMethod())) {
       return findTargetByPost();
   } else if ("PUT".equals(getMethod())) {
       return findTargetByPut();
   } else if ("DELETE".equals(getMethod())) {
       return findTargetByDelete();
   }
   // ... (rest unchanged)
}

And added two those two new methods:

   private Page findTargetByPut() throws IOException, SAXException {
       String url = getContext().getConfig().getUrlForPage(getUrl());
       WebRequestSettings settings = new WebRequestSettings(new
URL(url), SubmitMethod.PUT);
       final String content;
       if (getContent() != null) {
           content = getContent();
       } else {
content = FileUtil.readFileToString(getContentFile(), this);
       }
       settings.setRequestBody(content);
       return getResponse(settings);
   }

private Page findTargetByDelete() throws IOException, SAXException {
       String url = getContext().getConfig().getUrlForPage(getUrl());
       WebRequestSettings settings = new WebRequestSettings(new
URL(url), SubmitMethod.DELETE);
       return getResponse(settings);
   }

After the build was finished, I copied everything from
webtest/build/runtime/lib into
{grails-app}/plugins/webtest-0.3/test/webtest/lib, in the hope that it could work instantly :-) Unfortunately it did not completely, at least
the method='DELETE' on invoke, is now broken:

           <error
exception="com.canoo.webtest.engine.StepExecutionException"
message="Unexpected exception caught: java.lang.IllegalStateException">
               <antStack>
                   <call filename="" line="0"/>
               </antStack>
               <stacktrace><![CDATA[: Unexpected exception caught:
java.lang.IllegalStateException
       at
com.canoo.webtest.steps.StepUtil.handleException(StepUtil.java:113)
       at com.canoo.webtest.steps.Step.handleException(Step.java:378)
       at com.canoo.webtest.steps.Step.execute(Step.java:109)
       at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
       at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
       at
sun .reflect .DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:25)

       at java.lang.reflect.Method.invoke(Method.java:585)
       at
org .apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java: 105)
       at org.apache.tools.ant.Task.perform(Task.java:348)
       at
com .canoo .webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:43)

       at
com .canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java: 31)
       at com.canoo.webtest.steps.Step.execute(Step.java:101)

Did I miss something on putting the webtest plugin into a proper
condition for the update?

Thanks for your help,
Niko


Am 16.03.2008 um 10:24 schrieb Paul King:

HtmlUnit supports this capability. See here:

http://markmail.org/message/dlrgsklatlnromog

So, it should be possible to hook this into WebTest
with a little Groovy code but I haven't had time to play
with this myself to show you what the code would look like.

Paul.

Niko Schmuck wrote:
Since webtest is such an absolute fantastic tool for testing
(human-readable) web pages, I thought I also want to use it for
testing the REST services of my grails web app (although I guess it
was never intended to address this). Unfortunately it seems that the invoke step, doesn't like to use PUT and DELETE as HTTP methods? Why is there the restriction to GET and POST when invoke is executed, and are there any chances to enable the other HTTP methods in the future?
The current work around for me would be to mix in HTTP calls (with
Apache Commons HTTP Client) in my WebTest for making the tests more
complete. What I miss is, how to assign the webtest property value to
a groovy variable. Is this possible and how?
Sorry, if this has been discussed already, but I did not find any
related discussions ...
Thanks,
Niko
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest


_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest


_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to