1 15 package org.apache.tapestry.engine; 16 17 import java.util.HashMap ; 18 import java.util.Map ; 19 20 import org.apache.hivemind.test.HiveMindTestCase; 21 22 27 public class TestServiceEncoding extends HiveMindTestCase 28 { 29 public void testSetServletPath() 30 { 31 ServiceEncodingImpl se = new ServiceEncodingImpl("/bar"); 32 33 assertEquals("/bar", se.getServletPath()); 34 assertEquals(false, se.isModified()); 35 36 se.setServletPath("/foo"); 37 38 assertEquals("/foo", se.getServletPath()); 39 assertEquals(true, se.isModified()); 40 } 41 42 public void testCreateWithExistingMap() 43 { 44 Map parameters = new HashMap (); 45 46 ServiceEncodingImpl se = new ServiceEncodingImpl("/foo", parameters); 47 48 se.setParameterValue("foo", "bar"); 49 50 assertEquals("bar", parameters.get("foo")); 51 } 52 53 public void testGetParameterValue() 54 { 55 ServiceEncodingImpl se = new ServiceEncodingImpl("/foo"); 56 57 se.setParameterValue("foo", "bar"); 58 59 assertEquals(true, se.isModified()); 60 61 assertEquals("bar", se.getParameterValue("foo")); 62 63 se.setParameterValues("flintstone", new String [] 64 { "fred", "wilma", "dino" }); 65 66 assertEquals("fred", se.getParameterValue("flintstone")); 67 68 assertNull(se.getParameterValue("unknown")); 69 } 70 71 public void testGetParameterValues() 72 { 73 ServiceEncodingImpl se = new ServiceEncodingImpl("/foo"); 74 se.setParameterValues("flintstone", new String [] 75 { "fred", "wilma", "dino" }); 76 77 assertListsEqual(new String [] 78 { "fred", "wilma", "dino" }, se.getParameterValues("flintstone")); 79 80 assertEquals(true, se.isModified()); 81 82 se.setParameterValue("foo", "bar"); 83 84 assertListsEqual(new String [] 85 { "bar" }, se.getParameterValues("foo")); 86 87 assertNull(se.getParameterValue("unknown")); 88 } 89 90 public void testResetModified() 91 { 92 ServiceEncodingImpl se = new ServiceEncodingImpl("/bar"); 93 94 assertEquals(false, se.isModified()); 95 96 se.setServletPath("/foo"); 97 98 assertEquals(true, se.isModified()); 99 100 se.resetModified(); 101 102 assertEquals(false, se.isModified()); 103 } 104 105 public void testGetParameterNames() 106 { 107 ServiceEncodingImpl se = new ServiceEncodingImpl("/foo"); 108 109 se.setParameterValue("foo", "bar"); 110 se.setParameterValue("alpha", "beta"); 111 112 assertListsEqual(new String [] 113 { "alpha", "foo" }, se.getParameterNames()); 114 } 115 } | Popular Tags |