KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > util > TestQueryParameterMap


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
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
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
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.
14

15 package org.apache.tapestry.util;
16
17 import java.util.HashMap JavaDoc;
18 import java.util.Map JavaDoc;
19
20 import org.apache.hivemind.test.HiveMindTestCase;
21
22 /**
23  * Tests for {@link org.apache.tapestry.util.QueryParameterMap}.
24  *
25  * @author Howard M. Lewis Ship
26  * @since 4.0
27  */

28 public class TestQueryParameterMap extends HiveMindTestCase
29 {
30     public void testUnknownKey()
31     {
32         QueryParameterMap m = new QueryParameterMap();
33
34         assertNull(m.getParameterValue("unknown"));
35         assertNull(m.getParameterValues("unknown"));
36     }
37
38     public void testGetSingleValue()
39     {
40         QueryParameterMap m = new QueryParameterMap();
41
42         m.setParameterValue("fred", "flintstone");
43
44         assertEquals("flintstone", m.getParameterValue("fred"));
45         assertListsEqual(new String JavaDoc[]
46         { "flintstone" }, m.getParameterValues("fred"));
47     }
48
49     public void testGetValuesArray()
50     {
51         QueryParameterMap m = new QueryParameterMap();
52
53         String JavaDoc[] values = new String JavaDoc[]
54         { "fred", "wilma" };
55
56         m.setParameterValues("flintstone", values);
57
58         assertListsEqual(values, m.getParameterValues("flintstone"));
59
60         m.setParameterValue("rubble", "barney");
61
62         assertListsEqual(new String JavaDoc[]
63         { "barney" }, m.getParameterValues("rubble"));
64     }
65
66     public void testGetParameterNames()
67     {
68         QueryParameterMap m = new QueryParameterMap();
69
70         m.setParameterValue("fred", "flintstone");
71         m.setParameterValue("barney", "rubble");
72
73         assertListsEqual(new String JavaDoc[]
74         { "barney", "fred" }, m.getParameterNames());
75     }
76
77     public void testExistingMap()
78     {
79         Map JavaDoc map = new HashMap JavaDoc();
80         QueryParameterMap m = new QueryParameterMap(map);
81
82         m.setParameterValue("fred", "flintstone");
83
84         assertEquals("flintstone", map.get("fred"));
85     }
86 }
Popular Tags