Groovy on Grails Blog

Specifying request attribute in service integration tests

Today I ran into some problems when wanting to add request dependant tests to my integration test suite. The controller tests in grails are already mocked with MockHttpServletRequestMockHttpServletResponse, and MockHttpSession , but what about services??

 

In my case I wanted the  RequestContextHolder.getRequestAttributes()

to contain a 'request' so I could get the servername from that inside my session scoped service. 

 

So what I did was: 

def request = new MockHttpServletRequest();        request.setServerName("test2.localhost")        RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request))

 

Artisteer plugin on grails repo

Artisteer plugin updated and can be downloaded at 

http://www.grails.org/plugin/artisteerplugin

 

(that is also the page for latest doc and info regarding this plugin)

 

New version of Grails Artisteer plugin released

The Grails artisteer plugin repository has been updated. The plugin is located at: 

 

https://github.com/webinventions/artisteergrailsplugin

 

The plugin zip is also up to date, although it still has 0.1 as version number.

 

New features: 

 

Ability to create layout templates based on a script instead of uploading to a controller

just type: 

grails generate-artisteer-gsp-template [path\andname of file.zip]

 

And you will get the template in the layouts directory. It will have the same name as the filename without the '.zip' and  always be 'version 0' when running from the script. When uploading with controller the version number will be the same as the template id that is stored in the database. 

 

So now you can choose if you just want to generate some templates with this script or upload templates while application is running. 

 

You can also customize footers/headers and menues for the template in the artisteer files that are generated when you start your application. 

Last Updated (Friday, 25 March 2011 14:22)

 

Grails cleanouts issues and how to resolve them

Sometimes your grails applications comes to a state where they don't refresh as they should. Just now I ran into an issue where adding new domain objects /controllers wouldnt make any difference when starting the application. 

 

To clean out grails applications: 

  • Remove the %users_home%/.grails/* directories (not the .grails itself though) 
  • do a 'grails clean' 
  • If this doesn't help, try removing the grails.xml file in the WEB-INF directory which lists resources. I had an issue with this and it was probably not writeable or so, but removing the file solved my problems and I could see my newly generated controllers /domains

 

 

Grails performance vs php framework..

Check this article out! It shows php symphony vs Grails.. (please switch to Grails)

http://cutiecode.maniacmansion.it/post/2378498792/grails-vs-symfony-2-0-benchmark

 

Smile

Last Updated (Sunday, 16 January 2011 20:46)

 
More Articles...
Svenska (Sverige)English (United Kingdom)