模拟Grails SecurityContextHolderAwareRequestWrapper集成测试

模拟Grails SecurityContextHolderAwareRequestWrapper集成测试,grails,groovy,Grails,Groovy,我正在尝试测试一个使用主干网并将JSON对象发送回服务器的应用程序 在实际控制器中,我只需执行request.JSON.update即可访问JSON值 现在我通常在测试中通过创建一个控制器然后 只需调用controller.params.name=“foo”等 现在这个对象是一个SecurityContextHolderAwareRequestWrapper,我不知道如何模拟或创建一个。以下是我的一些代码: void testProcessBatch(){ /* Set up th

我正在尝试测试一个使用主干网并将JSON对象发送回服务器的应用程序

在实际控制器中,我只需执行
request.JSON.update
即可访问JSON值

现在我通常在测试中通过创建一个控制器然后 只需调用controller.params.name=“foo”等

现在这个对象是一个
SecurityContextHolderAwareRequestWrapper
,我不知道如何模拟或创建一个。以下是我的一些代码:

  void testProcessBatch(){

    /* Set up the request here before calling the closure 'processBatch' 
    *  MockHttpServletRequest request = new MockHttpServletRequest();
    */ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));

    controller.processBatch.call()

    def result = controller.response.content
    def jsonResult = JSON.parse(controller.response.contentAsString)

    assertNotNull jsonResult.data
    assertNotNull controller.response.content
    assertEquals controller.response.status, 200 

  }

什么对象是
SecurityContextHolderAwareRequestWrapper
,这个测试的哪一部分对您不起作用?我甚至不知道如何启动和模拟这样的对象。