1 15 package org.apache.tapestry.util; 16 17 import java.util.HashMap ; 18 import java.util.Map ; 19 20 import org.apache.hivemind.test.HiveMindTestCase; 21 22 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 [] 46 { "flintstone" }, m.getParameterValues("fred")); 47 } 48 49 public void testGetValuesArray() 50 { 51 QueryParameterMap m = new QueryParameterMap(); 52 53 String [] values = new String [] 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 [] 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 [] 74 { "barney", "fred" }, m.getParameterNames()); 75 } 76 77 public void testExistingMap() 78 { 79 Map map = new HashMap (); 80 QueryParameterMap m = new QueryParameterMap(map); 81 82 m.setParameterValue("fred", "flintstone"); 83 84 assertEquals("flintstone", map.get("fred")); 85 } 86 } | Popular Tags |