01: package org.strecks.form.controller;
02:
03: import static org.easymock.classextension.EasyMock.createStrictMock;
04: import static org.easymock.classextension.EasyMock.replay;
05: import static org.easymock.classextension.EasyMock.verify;
06:
07: import java.util.HashMap;
08: import java.util.Map;
09:
10: import org.strecks.bind.handler.BindHandler;
11: import org.strecks.bind.internal.BindConvertInfo;
12: import org.strecks.converter.Converter;
13: import org.strecks.converter.handler.DefaultConversionHandler;
14: import org.strecks.form.impl.SimpleStrutsForm;
15: import org.testng.annotations.BeforeMethod;
16: import org.testng.annotations.Test;
17:
18: /**
19: * @author Phil Zoio
20: */
21: public class TestDelegatingFormBinding {
22:
23: private BindHandler bindHandler;
24:
25: private SimpleStrutsForm simpleForm;
26:
27: private DelegatingForm form;
28:
29: @BeforeMethod
30: public void setUp() {
31:
32: simpleForm = new SimpleStrutsForm();
33: bindHandler = createStrictMock(BindHandler.class);
34: Map<String, BindHandler> map = new HashMap<String, BindHandler>();
35: map.put("prop", bindHandler);
36:
37: BindConvertInfo bci = new BindConvertInfo(map,
38: new HashMap<String, Converter>(),
39: new DefaultConversionHandler());
40:
41: form = new DelegatingForm(simpleForm);
42: form.setBindConvertInfo(bci);
43:
44: }
45:
46: @Test
47: public void testBindInwards() {
48:
49: bindHandler.bindInwards(simpleForm, null, null);
50: replay(bindHandler);
51: form.bindInwards(null);
52: verify(bindHandler);
53:
54: }
55:
56: @Test
57: public void testBindOutwards() {
58:
59: bindHandler.bindOutwards(simpleForm, null);
60: replay(bindHandler);
61: form.bindOutwards(null);
62: verify(bindHandler);
63:
64: }
65:
66: @Test(expectedExceptions=IllegalArgumentException.class)
67: public void testNullBciOut() {
68:
69: form.setBindConvertInfo(null);
70: form.bindOutwards(null);
71:
72: }
73:
74: @Test(expectedExceptions=IllegalArgumentException.class)
75: public void testNullBciIn() {
76:
77: form.setBindConvertInfo(null);
78: form.bindInwards(null);
79:
80: }
81:
82: }
|