1
votes

I'm trying to test a PUT in a functional test in Play Framework 1.2.3.

I gone through the API of FunctionalTest and found these methods:

public static Response PUT(Object url, String contenttype, String body)

public static Response PUT(Request request, Object url, String contenttype, String body) {

My question is: How do you build the body value, to simulate an HTML Form submission?

Thnaks

1
What kind of request are you exactly trying to emulate? - Tommi
I'm trying to emulate a html form submission. For example: <html> #{form @update()} <input value="${user.name}"/> #{/form} </html> - Joao Pereira
Why are you using PUT then? HTML forms support only GET and POST. - Tommi
Ok, I get it. Is there any way with play framework to emulate PUT and DELET out-of the box? For example, I recall that in RoR we use a form parameter to tell which http method to use and RoR do the correct routing for us. Is anything similar in Play Framework? - Joao Pereira

1 Answers

1
votes

Never tried myself with a put but you can create a convenience method that initalize correctly a request for put and then use "request.params.put(key, value)" on it. Here is an example of put request initialization

public Request newPutRequest(String url) {
    Request request = newRequest();
    request.url = url;
    request.path = request.url;
    request.method = "PUT";
    return request;
}