grails-2.0

Grails 2.0 integration test pollution?

醉酒当歌 提交于 2019-12-01 06:51:36
So i have a small integration test that houses 5 tests in total. Running that test exclusively results in all tests passed. However running my entire test suite results in 4 test failures of the 5. I've just recently upgraded to grails-2.0 from 1.3.7 and i switched from hsqldb to h2. Has anyone any pointers in which direction i should be looking in order to fix this (test-pollution) problem? Domain model Integration test: class SeriesIntegrationTests extends GrailsUnitTestCase { Series series Episode episode protected void setUp() { super.setUp() series = new Series(ttdbId: 2348); episode =

Asserting on a list of items in Spock

旧时模样 提交于 2019-12-01 06:06:42
Using Spock 0.7 with Grails 2.04. Trying to set up a testing environment. I need some help in regards to testing a list of objects. I have a list of location objects. I want to test a date on each of those objects. I am iterating over but not sure how to make the test fail if the dates are not equal. Is there a good way to test objects in a list? I have listed below my then block of code. then: weatherList != null weatherList.empty != null weatherList.size() == 3 weatherList.each { Calendar today = Calendar.getInstance(); today.clearTime() if(it.forecastDate != today) { return false } } Peter

Grails 2.2.0 Support in Eclipse

时光总嘲笑我的痴心妄想 提交于 2019-11-30 21:02:53
I am trying to create a grails 2.2.0 project using eclipse-jee-juno. It gives me an error Groovy compiler level expected by the project does not match workspace compiler level. Project compiler level is: 1.8.X Workspace compiler level is 1.7.X Go to Project properties -> Groovy compiler to set the Groovy compiler level for this project. Background : I have installed grails 2.2.0 and I am able to create and run a sample project/controller by using the command line (not eclipse) Grails 2.x need groovy 1.8+ to work. In eclipse, right click your project, select 'properties' from menu and go to

Grails Testing with Spock - Which Mocking Framework Select?

这一生的挚爱 提交于 2019-11-30 19:11:47
I have more general question. Which framework or implementation I should use for mocking in Grails 2.x when using Spock? I know tons of mocking style: leverage Groovy metaClass, Grails mockFor(), Groovy Mock(), Groovy closure style, etc. Each of them has its own advantages and disadvantages. But what I don't understand is that some mocking style works in certain occasions which I cannot determine (i.e. mockFor() works for certain implementation and not for the others). Currently I have two similar implementation of service method mocking. This one works: @TestFor(MyController) @Mock([MyDevice]

Grails 2.x createCriteria 'or' doesn't work for nested associations

ぃ、小莉子 提交于 2019-11-30 14:49:00
It seems that in Grails 2.x, if you have a domain class association, and you try to run a createCriteria using or on that relation + another query, the or will ignore the other query and just use the results of the nested association. I realize this may be a little confusing, so here is an example: class Passenger { Long id Boolean isDriving } class Car { Long id Passenger passenger Boolean isMoving static constraints = { passenger nullable: true } } and a test: class CarIntegrationTests { @Test void testCar() { Passenger passenger1 = new Passenger(isDriving: true) passenger1.save() Car car1 =

“Error loading plugin manager: TomcatGrailsPlugin” on Grails 2.3 Database Migration

99封情书 提交于 2019-11-30 06:29:05
问题 I use Grails 2.3 and the Grails database migration plugin (1.3.6). When I do grails dbm-update I get the following error. How can I solve this error? Error Error loading plugin manager: TomcatGrailsPlugin (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.) java.lang.ClassNotFoundException: TomcatGrailsPlugin at _GrailsBootstrap_groovy$_run_closure2.doCall(_GrailsBootstrap_groovy:40) at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133) at org.codehaus

Grails Testing with Spock - Which Mocking Framework Select?

橙三吉。 提交于 2019-11-30 04:30:12
问题 I have more general question. Which framework or implementation I should use for mocking in Grails 2.x when using Spock? I know tons of mocking style: leverage Groovy metaClass, Grails mockFor(), Groovy Mock(), Groovy closure style, etc. Each of them has its own advantages and disadvantages. But what I don't understand is that some mocking style works in certain occasions which I cannot determine (i.e. mockFor() works for certain implementation and not for the others). Currently I have two

Grails saves datetime as UTC time, but reads it as local server time?

时间秒杀一切 提交于 2019-11-29 23:57:33
I have the following line in my Grails application to set the default timezone to UTC: TimeZone.setDefault(TimeZone.getTimeZone("UTC")) I have an Audit entity with a dateCreated field: class Audit { Date dateCreated String message } Then I create and save an instance of it: def audit = new Audit(message: "Testing audit message") This will save it to my database correctly as UTC time. However, when I try to read it back: audit = Audit.get(1) The timestamp is read back as local time instead. So if my timezone is +1 UTC and the current local time is 12:34:56 BST , what will be saved to the

Grails 2.x createCriteria 'or' doesn't work for nested associations

你。 提交于 2019-11-29 21:07:52
问题 It seems that in Grails 2.x, if you have a domain class association, and you try to run a createCriteria using or on that relation + another query, the or will ignore the other query and just use the results of the nested association. I realize this may be a little confusing, so here is an example: class Passenger { Long id Boolean isDriving } class Car { Long id Passenger passenger Boolean isMoving static constraints = { passenger nullable: true } } and a test: class CarIntegrationTests {

Implement a REST API in a Grails app

浪子不回头ぞ 提交于 2019-11-29 18:57:43
I was wondering what would be the best approach to make a Grails app offer a RESTful API (some CRUD actions mainly) that can be used by a web service, e.g. when you want to build a corresponding iOS app to your browser-based app or anything else. I thought of building a separate part in my Grails application that takes calls from www.mywebapp.com/api/someAction so that I can reuse the Service layer. How would I do the URL mapping then? Only having one big ApiController does not sound very groovy. Or is there any better approach I did not know of? This approach must support something like OAuth