1 15 package org.apache.tapestry.services.impl; 16 17 import org.apache.hivemind.test.HiveMindTestCase; 18 import org.apache.tapestry.IRequestCycle; 19 import org.apache.tapestry.engine.IEngineService; 20 import org.apache.tapestry.engine.ILink; 21 import org.easymock.MockControl; 22 23 29 public class TestEngineServiceOuterProxy extends HiveMindTestCase 30 { 31 public void testToString() 32 { 33 IEngineService s = new EngineServiceOuterProxy("fred"); 34 35 assertEquals("<OuterProxy for engine service 'fred'>", s.toString()); 36 } 37 38 public void testGetLink() 39 { 40 IRequestCycle cycle = newCycle(); 41 ILink link = (ILink) newMock(ILink.class); 42 43 MockControl control = newControl(IEngineService.class); 44 IEngineService delegate = (IEngineService) control.getMock(); 45 46 Object parameter = new Object (); 47 48 delegate.getLink(cycle, parameter); 49 control.setReturnValue(link); 50 51 replayControls(); 52 53 EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("xxx"); 54 proxy.installDelegate(delegate); 55 56 assertSame(link, proxy.getLink(cycle, parameter)); 57 58 verifyControls(); 59 } 60 61 private IRequestCycle newCycle() 62 { 63 return (IRequestCycle) newMock(IRequestCycle.class); 64 } 65 66 public void testGetName() 67 { 68 69 EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("Fred"); 70 71 assertEquals("Fred", proxy.getName()); 72 } 73 74 public void testService() throws Exception 75 { 76 IRequestCycle cycle = newCycle(); 77 IEngineService delegate = (IEngineService) newMock(IEngineService.class); 78 79 delegate.service(cycle); 80 81 replayControls(); 82 83 EngineServiceOuterProxy proxy = new EngineServiceOuterProxy("xxx"); 84 proxy.installDelegate(delegate); 85 86 assertSame(delegate, proxy.getDelegate()); 87 88 proxy.service(cycle); 89 90 verifyControls(); 91 } 92 } | Popular Tags |