1 /* Copyright 2004-2005 the original author or authors.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 package org
.codehaus
.groovy
.grails
.web
.servlet
;
17 import grails
.util
.GrailsWebUtil
;
18 import junit
.framework
.TestCase
;
21 * @author Graeme Rocher
24 public class GrailsFlashScopeTests
extends TestCase
{
27 public void testNextState() {
29 GrailsWebUtil
.bindMockWebRequest();
31 FlashScope fs
= new GrailsFlashScope();
32 fs
.put("test","value");
33 fs
.put("fred","flintstone");
35 assertFalse(fs
.isEmpty());
36 assertEquals("flintstone",fs
.get("fred"));
37 assertEquals(2, fs
.size());
38 assertTrue(fs
.containsKey("test"));
39 assertTrue(fs
.containsValue("value"));
40 assertFalse(fs
.containsKey("wilma"));
42 // the state immediately following this one the map should still contain the previous
46 assertFalse(fs
.isEmpty());
47 assertEquals("flintstone",fs
.get("fred"));
48 assertEquals(2, fs
.size());
49 assertTrue(fs
.containsKey("test"));
50 assertTrue(fs
.containsValue("value"));
51 assertFalse(fs
.containsKey("wilma"));
53 // the next state it should be empty
56 assertTrue(fs
.isEmpty());
57 assertEquals(0,fs
.size());