1 15 package org.apache.tapestry.form; 16 17 import org.apache.tapestry.IActionListener; 18 import org.apache.tapestry.components.BaseComponentTestCase; 19 20 27 public class TestForm extends BaseComponentTestCase 28 { 29 private IActionListener newListener() 30 { 31 return (IActionListener) newMock(IActionListener.class); 32 } 33 34 public void testFindCancelListener() 35 { 36 IActionListener cancel = newListener(); 37 IActionListener listener = newListener(); 38 39 replayControls(); 40 41 Form form = (Form) newInstance(Form.class, new Object [] 42 { "listener", listener, "cancel", cancel }); 43 44 assertSame(cancel, form.findListener(FormConstants.SUBMIT_CANCEL)); 45 46 verifyControls(); 47 } 48 49 public void testFindCancelDefaultListener() 50 { 51 IActionListener listener = newListener(); 52 53 replayControls(); 54 55 Form form = (Form) newInstance(Form.class, "listener", listener); 56 57 assertSame(listener, form.findListener(FormConstants.SUBMIT_CANCEL)); 58 59 verifyControls(); 60 } 61 62 public void testFindRefreshListener() 63 { 64 IActionListener refresh = newListener(); 65 IActionListener listener = newListener(); 66 67 replayControls(); 68 69 Form form = (Form) newInstance(Form.class, new Object [] 70 { "listener", listener, "refresh", refresh }); 71 72 assertSame(refresh, form.findListener(FormConstants.SUBMIT_REFRESH)); 73 74 verifyControls(); 75 } 76 77 public void testFindRefreshListenerDefault() 78 { 79 IActionListener listener = newListener(); 80 81 replayControls(); 82 83 Form form = (Form) newInstance(Form.class, new Object [] 84 { "listener", listener }); 85 86 assertSame(listener, form.findListener(FormConstants.SUBMIT_REFRESH)); 87 88 verifyControls(); 89 } 90 91 public void testFindListenerNormal() 92 { 93 IActionListener cancel = newListener(); 94 IActionListener refresh = newListener(); 95 IActionListener listener = newListener(); 96 97 replayControls(); 98 99 Form form = (Form) newInstance(Form.class, new Object [] 100 { "listener", listener, "cancel", cancel, "refresh", refresh }); 101 102 assertSame(listener, form.findListener(FormConstants.SUBMIT_NORMAL)); 103 104 verifyControls(); 105 } 106 } 107 | Popular Tags |