Skip to content

Commit

Permalink
The default request method for mock requests should be GET
Browse files Browse the repository at this point in the history
Related to commit 4e6359d
  • Loading branch information
Jeff Scott Brown committed Apr 30, 2014
1 parent befe5c5 commit 35408d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Expand Up @@ -281,7 +281,7 @@ class ControllerUnitTestMixin extends GrailsUnitTestMixin {
ServletsGrailsPluginSupport.enhanceServletApi()
ConvertersPluginSupport.enhanceApplication(grailsApplication,applicationContext)

request = new GrailsMockHttpServletRequest(requestMimeTypesApi: new TestRequestMimeTypesApi(grailsApplication: grailsApplication, applicationContext: applicationContext), method: 'GET')
request = new GrailsMockHttpServletRequest(requestMimeTypesApi: new TestRequestMimeTypesApi(grailsApplication: grailsApplication, applicationContext: applicationContext))
response = new GrailsMockHttpServletResponse(responseMimeTypesApi: new TestResponseMimeTypesApi(grailsApplication: grailsApplication, applicationContext: applicationContext))
webRequest = GrailsWebUtil.bindMockWebRequest(applicationContext, request, response)
request = (GrailsMockHttpServletRequest)webRequest.getCurrentRequest()
Expand Down
Expand Up @@ -44,6 +44,7 @@ class GrailsMockHttpServletRequestTests extends GroovyTestCase {
void testGetXML() {
// Set up the test data.
def request = new GrailsMockHttpServletRequest()
request.method = 'POST'
request.contentType = "application/xml; charset=UTF-8"
request.content = TEST_XML_CONTENT.getBytes("UTF-8")

Expand All @@ -53,6 +54,7 @@ class GrailsMockHttpServletRequestTests extends GroovyTestCase {

void testGetXMLMultipleCalls() {
def request = new GrailsMockHttpServletRequest()
request.method = 'POST'
request.contentType = "application/xml; charset=UTF-8"
request.content = TEST_XML_CONTENT.getBytes("UTF-8")

Expand All @@ -68,6 +70,7 @@ class GrailsMockHttpServletRequestTests extends GroovyTestCase {

void testGetXMLNoContent() {
def request = new GrailsMockHttpServletRequest()
request.method = 'POST'
shouldFail {
request.XML
}
Expand All @@ -80,6 +83,7 @@ First line
Second line
"""
def request = new GrailsMockHttpServletRequest()
request.method = 'POST'
request.contentType = "text/plain; charset=UTF-8"
request.content = content.getBytes("UTF-8")

Expand Down
Expand Up @@ -66,6 +66,11 @@ class GrailsMockHttpServletRequest extends MockHttpServletRequest implements Mul
private cachedXml
DispatcherType dispatcherType
AsyncContext asyncContext


GrailsMockHttpServletRequest() {
method = 'GET'
}

/**
* Sets the request format to use
Expand Down

0 comments on commit 35408d7

Please sign in to comment.