How do I unit test a Grails service that uses a converter?
Even though you are testing a service, you can apply the @TestMixin(ControllerUnitTestMixin) annotation to your test class to get Grails to set up the JSON converter.
Even though you are testing a service, you can apply the @TestMixin(ControllerUnitTestMixin) annotation to your test class to get Grails to set up the JSON converter.
The <meta name=”layout” content=”main”> tag includes the layout in the gsp page. You can view the grails-app/views/layouts/main.gsp to view and modify the layout. You can copy main.gsp to mymain.gsp, modify it, then change layout entry in the gsp page to reference mymain.gsp instead of main.gsp and experiment with customizing your layout preserving your ability to … Read more
You can try the usual grails clean grails refresh-dependencies Also check for a newer version of your plugin. Another alternative is switch to this mongo plugin published a month ago, which is supposed to be compatible with GORM for Hibernate ‘org.grails.plugins:mongodb:6.0.0.M2’
The respond method uses content negotiation to respond with the most appropriate content type based on the requests ‘ACCEPT’ header. Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8, application/json This way the consumer of your site can choose how they wish to be returned data. This may not be the best option if you want to force a … Read more
A Simple solution to this is to refresh the gradle projects. You can do this by popping out the little gradle tab and hitting the “Refresh All Gradle Projects”
To address your confusion with the metaphor (though it has been answered in other words under your question): Groovy is to Grails as Ruby is to Ruby on Rails, but what does that mean? Grails was a web framework built on/with the Groovy programming language to do the same thing for Groovy that Rails (a … Read more
You need to split on \\|.
The preferred way to do this in groovy is: def encoded = “Hello World”.bytes.encodeBase64().toString() assert encoded == “SGVsbG8gV29ybGQ=” def decoded = new String(“SGVsbG8gV29ybGQ=”.decodeBase64()) assert decoded == “Hello World”
Possibilities of things that might be wrong with your setup: Your command order is incorrect. What works for me is: grails test-app -unit Foo (where my test class is FooTests.groovy) You aren’t explicitly importing grails.test.GrailsUnitTestCase. I had some problems with it recognizing my tests when I didn’t import this. When I was extending GroovyTestCase, things … Read more