1 15 package org.apache.tapestry.engine.encoders; 16 17 import org.apache.hivemind.test.HiveMindTestCase; 18 import org.apache.tapestry.engine.ServiceEncoding; 19 import org.apache.tapestry.services.ServiceConstants; 20 import org.easymock.MockControl; 21 22 28 public class TestServiceExtensionEncoder extends HiveMindTestCase 29 { 30 public void testEncode() 31 { 32 MockControl c = newControl(ServiceEncoding.class); 33 ServiceEncoding sec = (ServiceEncoding) c.getMock(); 34 35 sec.getParameterValue(ServiceConstants.SERVICE); 36 c.setReturnValue("heavy"); 37 38 sec.setServletPath("/heavy.svc"); 39 sec.setParameterValue(ServiceConstants.SERVICE, null); 40 41 replayControls(); 42 43 ServiceExtensionEncoder e = new ServiceExtensionEncoder(); 44 e.setExtension("svc"); 45 46 e.encode(sec); 47 48 verifyControls(); 49 } 50 51 public void testDecodeWrongExtension() 52 { 53 MockControl c = newControl(ServiceEncoding.class); 54 ServiceEncoding sec = (ServiceEncoding) c.getMock(); 55 56 sec.getServletPath(); 57 c.setReturnValue("/foo/bar/baz.direct"); 58 59 replayControls(); 60 61 ServiceExtensionEncoder e = new ServiceExtensionEncoder(); 62 e.setExtension("svc"); 63 64 e.decode(sec); 65 66 verifyControls(); 67 } 68 69 public void testDecode() 70 { 71 MockControl c = newControl(ServiceEncoding.class); 72 ServiceEncoding sec = (ServiceEncoding) c.getMock(); 73 74 sec.getServletPath(); 75 c.setReturnValue("/hitter.svc"); 76 77 sec.setParameterValue(ServiceConstants.SERVICE, "hitter"); 78 79 replayControls(); 80 81 ServiceExtensionEncoder e = new ServiceExtensionEncoder(); 82 e.setExtension("svc"); 83 84 e.decode(sec); 85 86 verifyControls(); 87 } 88 } | Popular Tags |