1 15 package org.apache.tapestry.engine; 16 17 import java.util.HashMap ; 18 import java.util.Map ; 19 20 import org.apache.tapestry.IPage; 21 import org.apache.tapestry.IRequestCycle; 22 import org.apache.tapestry.Tapestry; 23 import org.apache.tapestry.services.LinkFactory; 24 import org.apache.tapestry.services.ServiceConstants; 25 import org.easymock.MockControl; 26 27 33 public class TestResetService extends ServiceTestCase 34 { 35 private IRequestCycle newRequestCycle(IPage page) 36 { 37 MockControl control = newControl(IRequestCycle.class); 38 IRequestCycle cycle = (IRequestCycle) control.getMock(); 39 40 cycle.getPage(); 41 control.setReturnValue(page); 42 43 return cycle; 44 } 45 46 public void testGetLink() 47 { 48 IPage page = newPage("TargetPage"); 49 IRequestCycle cycle = newRequestCycle(page); 50 51 Map parameters = new HashMap (); 52 parameters.put(ServiceConstants.SERVICE, Tapestry.RESET_SERVICE); 53 parameters.put(ServiceConstants.PAGE, "TargetPage"); 54 55 ILink link = newLink(); 56 LinkFactory lf = newLinkFactory(cycle, parameters, true, link); 57 58 replayControls(); 59 60 ResetService s = new ResetService(); 61 s.setLinkFactory(lf); 62 63 assertSame(link, s.getLink(cycle, null)); 64 65 verifyControls(); 66 } 67 68 public void testGetLinkNonNullParameter() 69 { 70 ResetService s = new ResetService(); 71 72 try 73 { 74 s.getLink(null, "NonNullValue"); 75 unreachable(); 76 } 77 catch (IllegalArgumentException ex) 78 { 79 assertEquals(EngineMessages.serviceNoParameter(s), ex.getMessage()); 80 } 81 } 82 83 } | Popular Tags |