unit testing - Grails PUT request with XML -
I have put a request I'm trying to unit test to create a user object. Unit Test: controller action: Paramaps map is empty for some reasons if the administrator's action is executed. I have a very similar unit test for POST requests and it works fine.
void testPUTXMLResponse () {def mockUser = new user (user name "Fred", password: Userkencrypt ( "Letmein"), FirstName "Fred", LastName "Flintstone", MiddleName: "T", phone: "555-555-5555", email: 'fred@fred.com', activationDate: new date (), logonFailureCount: 0) mockDomain ( user, [mockUser]) def mockUserXML = mockUser XML mockRequest.method = 'put' mockRequest.contentType = 'text / xml' mockRequest.format = 'xml' as mockRequest.content = mockUserXML.toString (). getBytes () controller.create () def updatedUser = XML.parse (mockResponse.contentAsString) stressed updatedUser.id == 1}
def = {println If request.xml def user = new user (params.user) (! user.hasErrors () & amp; & amp; user.save ()) {println user.id withFormat {html {/ * (Presenting the scene: "show", [user: user]) * XML} submission to user as XML} Jason (r) as JSON}}} {} format with println user.errors {Html} / {render (see: "create", [User: user]) * /} XML {user as XML. JSON}}}} as an error
Comments
Post a Comment