@@ -5,6 +5,7 @@ import grails.plugins.rest.client.RestBuilder
55import grails.plugins.rest.client.RestResponse
66import grails.test.mixin.integration.Integration
77import grails.transaction.*
8+ import spock.lang.Ignore
89
910@Integration
1011@Rollback
@@ -31,12 +32,13 @@ class CacheSpec extends GebSpec {
3132 response. text == ' deleted all LogEntry instances'
3233 }
3334
35+ @Ignore
3436 void testCacheAndEvict () {
3537 given :
3638 RestBuilder restBuilder = new RestBuilder ()
3739 RestResponse response
38- // check that there are no log entries
39- when :
40+
41+ when : " check that there are no log entries "
4042 response = restBuilder. get(" ${ baseUrl} /test/logEntryCount" )
4143 then :
4244 response. text == ' 0'
@@ -46,9 +48,7 @@ class CacheSpec extends GebSpec {
4648 then :
4749 response. text == ' none'
4850
49- // get the index action which should trigger caching
50-
51- when :
51+ when : " get the index action which should trigger caching"
5252 response = restBuilder. get(" ${ baseUrl} /test/index" )
5353 then :
5454 response. text == ' index'
@@ -67,9 +67,7 @@ class CacheSpec extends GebSpec {
6767 long id = response. json. id
6868 long dateCreated = response. json. dateCreated
6969
70- // get the index action again, should be cached
71-
72- when :
70+ when : " get the index action again, should be cached"
7371 response = restBuilder. get(" ${ baseUrl} /test/index" )
7472 then :
7573 response. text == ' index'
@@ -87,9 +85,7 @@ class CacheSpec extends GebSpec {
8785 response. json. id == id
8886 response. json. dateCreated == dateCreated
8987
90- // evict
91-
92- when :
88+ when : " evict"
9389 response = restBuilder. get(" ${ baseUrl} /test/evict" )
9490 then :
9591 response. text == ' evict'
@@ -106,14 +102,10 @@ class CacheSpec extends GebSpec {
106102 response. json. id == id + 1
107103 response. json. dateCreated > dateCreated
108104
109- when :
110- // save the values to compare
105+ when : " save the values to compare"
111106 id++
112107 dateCreated = response. json. dateCreated
113-
114- // get the index action again, should not be cached
115-
116- and :
108+ and : " get the index action again, should not be cached"
117109 response = restBuilder. get(" ${ baseUrl} /test/index" )
118110 then :
119111 response. text == ' index'
@@ -151,9 +143,7 @@ class CacheSpec extends GebSpec {
151143 then :
152144 response. text == ' withParams baz 123'
153145
154- // try again with UrlMappings
155-
156- when :
146+ when : " try again with UrlMappings"
157147 response = restBuilder. get(" ${ baseUrl} /withParams/baz/123" )
158148 then :
159149 response. text == ' withParams baz 123'
@@ -168,233 +158,4 @@ class CacheSpec extends GebSpec {
168158 then :
169159 response. text == ' withParams baz 123'
170160 }
171-
172- void testBasicCachingService () {
173- given :
174- RestBuilder restBuilder = new RestBuilder ()
175- RestResponse response
176-
177- when :
178- response = restBuilder. get(" ${ baseUrl} /cachingService/cachingServiceInvocationCount" )
179- then :
180- response. status == 200
181- response. text. contains(' Basic Caching Service Invocation Count Is 0' )
182-
183- when :
184- response = restBuilder. get(" ${ baseUrl} /cachingService/cachingService" )
185- then :
186- response. status == 200
187- response. text. contains(" Value From Service Is 'Hello World!'" )
188-
189- when :
190- response = restBuilder. get(" ${ baseUrl} /cachingService/cachingServiceInvocationCount" )
191- then :
192- response. status == 200
193- response. text. contains(" Basic Caching Service Invocation Count Is 1" )
194-
195- when :
196- response = restBuilder. get(" ${ baseUrl} /cachingService/cachingService" )
197- then :
198- response. status == 200
199- response. text. contains(" Value From Service Is 'Hello World!'" )
200-
201- when :
202- response = restBuilder. get(" ${ baseUrl} /cachingService/cachingServiceInvocationCount" )
203- then :
204- response. status == 200
205- response. text. contains(" Basic Caching Service Invocation Count Is 1" )
206- }
207-
208-
209- void testBasicCachePutService () {
210- given :
211- RestBuilder restBuilder = new RestBuilder ()
212- RestResponse response
213-
214- when :
215- response = restBuilder. get(" ${ baseUrl} /cachingService/cacheGet?key=band" )
216- then :
217- response. status == 200
218- response. text == ' Result: null'
219-
220- when :
221- response = restBuilder. get(" ${ baseUrl} /cachingService/cachePut?key=band&value=Thin Lizzy" )
222- then :
223- response. status == 200
224- response. text == ' Result: ** Thin Lizzy **'
225-
226- when :
227- response = restBuilder. get(" ${ baseUrl} /cachingService/cacheGet?key=band" )
228- then :
229- response. status == 200
230- response. text == ' Result: ** Thin Lizzy **'
231-
232- when :
233- response = restBuilder. get(" ${ baseUrl} /cachingService/cacheGet?key=singer" )
234- then :
235- response. status == 200
236- response. text == ' Result: null'
237-
238- when :
239- response = restBuilder. get(" ${ baseUrl} /cachingService/cachePut?key=singer&value=Phil Lynott" )
240- then :
241- response. status == 200
242- response. text == ' Result: ** Phil Lynott **'
243-
244- when :
245- response = restBuilder. get(" ${ baseUrl} /cachingService/cacheGet?key=singer" )
246- then :
247- response. status == 200
248- response. text == ' Result: ** Phil Lynott **'
249-
250- when :
251- response = restBuilder. get(" ${ baseUrl} /cachingService/cachePut?key=singer&value=John Sykes" )
252- then :
253- response. status == 200
254- response. text == ' Result: ** John Sykes **'
255-
256- when :
257- response = restBuilder. get(" ${ baseUrl} /cachingService/cacheGet?key=singer" )
258- then :
259- response. status == 200
260- response. text == ' Result: ** John Sykes **'
261-
262- when :
263- response = restBuilder. get(" ${ baseUrl} /cachingService/cacheGet?key=band" )
264- then :
265- response. status == 200
266- response. text == ' Result: ** Thin Lizzy **'
267- }
268-
269- void testBlockTag () {
270- given :
271- RestBuilder restBuilder = new RestBuilder ()
272- RestResponse response
273-
274- when :
275- response = restBuilder. get(" ${ baseUrl} /taglib/blockCache?counter=5" )
276- then :
277- response. status == 200
278- response. text. contains(' First block counter 6' )
279- response. text. contains(' Second block counter 7' )
280- response. text. contains(' Third block counter 8' )
281-
282- when :
283- response = restBuilder. get(" ${ baseUrl} /taglib/blockCache?counter=42" )
284- then :
285- response. status == 200
286- response. text. contains(' First block counter 6' )
287- response. text. contains(' Second block counter 7' )
288- response. text. contains(' Third block counter 8' )
289- }
290-
291- void testClearingBlocksCache () {
292- given :
293- RestBuilder restBuilder = new RestBuilder ()
294- RestResponse response
295- when :
296- response = restBuilder. get(" ${ baseUrl} /taglib/clearBlocksCache" )
297- then :
298- response. status == 200
299- response. text. contains(' cleared blocks cache' )
300-
301- when :
302- response = restBuilder. get(" ${ baseUrl} /taglib/blockCache?counter=100" )
303- then :
304- response. status == 200
305- response. text. contains(' First block counter 101' )
306- response. text. contains(' Second block counter 102' )
307- response. text. contains(' Third block counter 103' )
308-
309- when :
310- response = restBuilder. get(" ${ baseUrl} /taglib/blockCache?counter=42" )
311- then :
312- response. status == 200
313- response. text. contains(' First block counter 101' )
314- response. text. contains(' Second block counter 102' )
315- response. text. contains(' Third block counter 103' )
316-
317- when :
318- response = restBuilder. get(" ${ baseUrl} /taglib/clearBlocksCache" )
319- then :
320- response. status == 200
321- response. text. contains(' cleared blocks cache' )
322-
323- when :
324- response = restBuilder. get(" ${ baseUrl} /taglib/blockCache?counter=50" )
325- then :
326- response. status == 200
327- response. text. contains(' First block counter 51' )
328- response. text. contains(' Second block counter 52' )
329- response. text. contains(' Third block counter 53' )
330-
331- when :
332- response = restBuilder. get(" ${ baseUrl} /taglib/blockCache?counter=150" )
333- then :
334- response. status == 200
335- response. text. contains(' First block counter 51' )
336- response. text. contains(' Second block counter 52' )
337- response. text. contains(' Third block counter 53' )
338- }
339-
340- void testRenderTag () {
341- given :
342- RestBuilder restBuilder = new RestBuilder ()
343- RestResponse response
344- when :
345- response = restBuilder. get(" ${ baseUrl} /taglib/clearTemplatesCache" )
346- then :
347- response. status == 200
348- response. text. contains(' cleared templates cache' )
349-
350- when :
351- response = restBuilder. get(" ${ baseUrl} /taglib/renderTag?counter=1" )
352- then :
353- response. status == 200
354-
355- response. text. contains(' First invocation: Counter value: 1' )
356- response. text. contains(' Second invocation: Counter value: 1' )
357- response. text. contains(' Third invocation: Counter value: 3' )
358- response. text. contains(' Fourth invocation: Counter value: 3' )
359- response. text. contains(' Fifth invocation: Counter value: 1' )
360-
361- when :
362- response = restBuilder. get(" ${ baseUrl} /taglib/renderTag?counter=5" )
363- then :
364- response. status == 200
365-
366- response. text. contains(' First invocation: Counter value: 1' )
367- response. text. contains(' Second invocation: Counter value: 1' )
368- response. text. contains(' Third invocation: Counter value: 3' )
369- response. text. contains(' Fourth invocation: Counter value: 3' )
370- response. text. contains(' Fifth invocation: Counter value: 1' )
371-
372- when :
373- response = restBuilder. get(" ${ baseUrl} /taglib/clearTemplatesCache" )
374- then :
375- response. status == 200
376- response. text. contains(' cleared templates cache' )
377-
378- when :
379- response = restBuilder. get(" ${ baseUrl} /taglib/renderTag?counter=5" )
380- then :
381- response. status == 200
382-
383- response. text. contains(' First invocation: Counter value: 5' )
384- response. text. contains(' Second invocation: Counter value: 5' )
385- response. text. contains(' Third invocation: Counter value: 7' )
386- response. text. contains(' Fourth invocation: Counter value: 7' )
387- response. text. contains(' Fifth invocation: Counter value: 5' )
388-
389- when :
390- response = restBuilder. get(" ${ baseUrl} /taglib/renderTag?counter=1" )
391- then :
392- response. status == 200
393-
394- response. text. contains(' First invocation: Counter value: 5' )
395- response. text. contains(' Second invocation: Counter value: 5' )
396- response. text. contains(' Third invocation: Counter value: 7' )
397- response. text. contains(' Fourth invocation: Counter value: 7' )
398- response. text. contains(' Fifth invocation: Counter value: 5' )
399- }
400161}
0 commit comments