1   /*
2    * Copyright 2004-2009 the Seasar Foundation and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.cubby.internal.controller.impl;
17  
18  import static org.easymock.EasyMock.createNiceMock;
19  import static org.easymock.EasyMock.replay;
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertFalse;
22  import static org.junit.Assert.assertNotNull;
23  import static org.junit.Assert.assertNull;
24  import static org.junit.Assert.assertSame;
25  import static org.junit.Assert.assertTrue;
26  
27  import java.io.ByteArrayInputStream;
28  import java.io.ByteArrayOutputStream;
29  import java.io.File;
30  import java.io.IOException;
31  import java.io.InputStream;
32  import java.io.OutputStream;
33  import java.io.UnsupportedEncodingException;
34  import java.lang.reflect.Method;
35  import java.math.BigDecimal;
36  import java.math.BigInteger;
37  import java.sql.Time;
38  import java.sql.Timestamp;
39  import java.text.SimpleDateFormat;
40  import java.util.Calendar;
41  import java.util.Collections;
42  import java.util.Date;
43  import java.util.HashMap;
44  import java.util.Iterator;
45  import java.util.List;
46  import java.util.Map;
47  import java.util.Set;
48  
49  import javax.servlet.http.HttpServletRequest;
50  import javax.servlet.http.HttpServletResponse;
51  
52  import org.apache.commons.fileupload.FileItem;
53  import org.junit.After;
54  import org.junit.Before;
55  import org.junit.Test;
56  import org.seasar.cubby.action.Action;
57  import org.seasar.cubby.action.ActionContext;
58  import org.seasar.cubby.action.ActionErrors;
59  import org.seasar.cubby.action.ActionResult;
60  import org.seasar.cubby.action.Form;
61  import org.seasar.cubby.action.RequestParameter;
62  import org.seasar.cubby.action.RequestParameterBindingType;
63  import org.seasar.cubby.controller.FormatPattern;
64  import org.seasar.cubby.controller.MessagesBehaviour;
65  import org.seasar.cubby.controller.impl.DefaultFormatPattern;
66  import org.seasar.cubby.controller.impl.DefaultMessagesBehaviour;
67  import org.seasar.cubby.converter.ConversionHelper;
68  import org.seasar.cubby.converter.Converter;
69  import org.seasar.cubby.internal.action.impl.ActionErrorsImpl;
70  import org.seasar.cubby.internal.controller.RequestParameterBinder;
71  import org.seasar.cubby.internal.controller.ThreadContext;
72  import org.seasar.cubby.internal.controller.ThreadContext.Command;
73  import org.seasar.cubby.mock.MockActionContext;
74  import org.seasar.cubby.mock.MockContainerProvider;
75  import org.seasar.cubby.mock.MockConverterProvider;
76  import org.seasar.cubby.plugin.PluginRegistry;
77  import org.seasar.cubby.plugins.BinderPlugin;
78  import org.seasar.cubby.spi.BeanDescProvider;
79  import org.seasar.cubby.spi.ContainerProvider;
80  import org.seasar.cubby.spi.ConverterProvider;
81  import org.seasar.cubby.spi.beans.impl.DefaultBeanDescProvider;
82  import org.seasar.cubby.spi.container.Container;
83  import org.seasar.cubby.spi.container.LookupException;
84  
85  /**
86   * 
87   * @author baba
88   */
89  public class RequestParameterBinderImplTest {
90  
91  	private final PluginRegistry pluginRegistry = PluginRegistry.getInstance();
92  
93  	private RequestParameterBinder requestParameterBinder;
94  
95  	@Before
96  	public void setup() {
97  		final BinderPlugin binderPlugin = new BinderPlugin();
98  		final FormatPattern formatPattern = new DefaultFormatPattern();
99  		final MessagesBehaviour messagesBehaviour = new DefaultMessagesBehaviour();
100 		binderPlugin.bind(ContainerProvider.class).toInstance(
101 				new MockContainerProvider(new Container() {
102 
103 					public <T> T lookup(Class<T> type) {
104 						if (FormatPattern.class.equals(type)) {
105 							return type.cast(formatPattern);
106 						}
107 						if (MessagesBehaviour.class.equals(type)) {
108 							return type.cast(messagesBehaviour);
109 						}
110 						throw new LookupException(type.getName());
111 					}
112 				}));
113 		binderPlugin.bind(ConverterProvider.class).toInstance(
114 				new MockConverterProvider(new BraceConverter()));
115 		binderPlugin.bind(BeanDescProvider.class).toInstance(
116 				new DefaultBeanDescProvider());
117 
118 		pluginRegistry.register(binderPlugin);
119 
120 		requestParameterBinder = new RequestParameterBinderImpl();
121 	}
122 
123 	@After
124 	public void teardown() {
125 		pluginRegistry.clear();
126 	}
127 
128 	@Test
129 	public void mapToBeanNullSource() {
130 		FormDto dto = new FormDto();
131 		ActionContext actionContext = new MockActionContext(null,
132 				MockAction.class, actionMethod(MockAction.class, "all"));
133 		ActionErrors errors = new ActionErrorsImpl();
134 		requestParameterBinder.bind(null, dto, actionContext, errors);
135 		assertTrue(errors.isEmpty());
136 	}
137 
138 	@Test
139 	public void mapToBean() {
140 		Map<String, Object[]> map = new HashMap<String, Object[]>();
141 		map.put("date", new Object[] { "2006-01-01" });
142 
143 		FormDto dto = new FormDto();
144 
145 		ActionContext actionContext = new MockActionContext(null,
146 				MockAction.class, actionMethod(MockAction.class, "all"));
147 		ActionErrors errors = new ActionErrorsImpl();
148 		requestParameterBinder.bind(map, dto, actionContext, errors);
149 		Calendar cal = Calendar.getInstance();
150 		cal.set(2006, 0, 1);
151 		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
152 		assertEquals(format.format(cal.getTime()), format.format(dto.getDate()));
153 		assertTrue(errors.isEmpty());
154 	}
155 
156 	@Test
157 	public void mapToBean_OneValue() {
158 		Map<String, Object[]> map = new HashMap<String, Object[]>();
159 		map.put("num1", new Object[] { "1" });
160 		map.put("num2", new Object[] { "2" });
161 		map.put("num3", new Object[] { "def" });
162 
163 		FormDto dto = new FormDto();
164 
165 		ActionContext actionContext = new MockActionContext(null,
166 				MockAction.class, actionMethod(MockAction.class, "all"));
167 		ActionErrors errors = new ActionErrorsImpl();
168 		requestParameterBinder.bind(map, dto, actionContext, errors);
169 		assertNotNull(dto.getNum1());
170 		assertEquals(Integer.valueOf(1), dto.getNum1());
171 		assertNotNull(dto.getNum2());
172 		assertEquals(1, dto.getNum2().length);
173 		assertEquals(Integer.valueOf(2), dto.getNum2()[0]);
174 		assertNotNull(dto.getNum3());
175 		assertEquals(1, dto.getNum3().size());
176 		assertEquals("def", dto.getNum3().get(0));
177 		assertTrue(errors.isEmpty());
178 	}
179 
180 	@Test
181 	public void mapToBean_MultiValue() {
182 		Map<String, Object[]> map = new HashMap<String, Object[]>();
183 		map.put("num2", new Object[] { "1", "2" });
184 		map.put("num3", new Object[] { "abc", "def" });
185 
186 		FormDto dto = new FormDto();
187 
188 		ActionContext actionContext = new MockActionContext(null,
189 				MockAction.class, actionMethod(MockAction.class, "all"));
190 		ActionErrors errors = new ActionErrorsImpl();
191 		requestParameterBinder.bind(map, dto, actionContext, errors);
192 		assertNotNull(dto.getNum2());
193 		assertEquals(2, dto.getNum2().length);
194 		assertEquals(Integer.valueOf(1), dto.getNum2()[0]);
195 		assertEquals(Integer.valueOf(2), dto.getNum2()[1]);
196 		assertNotNull(dto.getNum3());
197 		assertEquals(2, dto.getNum3().size());
198 		assertEquals("abc", dto.getNum3().get(0));
199 		assertEquals("def", dto.getNum3().get(1));
200 		assertTrue(errors.isEmpty());
201 	}
202 
203 	@Test
204 	public void mapToBean_MultiValueIncludesEmptyValue() {
205 		Map<String, Object[]> map = new HashMap<String, Object[]>();
206 		map.put("num2", new String[] { "1", "", "2" });
207 
208 		FormDto dto = new FormDto();
209 
210 		ActionContext actionContext = new MockActionContext(null,
211 				MockAction.class, actionMethod(MockAction.class, "all"));
212 		ActionErrors errors = new ActionErrorsImpl();
213 		requestParameterBinder.bind(map, dto, actionContext, errors);
214 		assertEquals(3, dto.getNum2().length);
215 		assertEquals(Integer.valueOf(1), dto.getNum2()[0]);
216 		assertEquals(null, dto.getNum2()[1]);
217 		assertEquals(Integer.valueOf(2), dto.getNum2()[2]);
218 		assertTrue(errors.isEmpty());
219 	}
220 
221 	@Test
222 	public void mapToBean_MultiValueIncludesNullValue() {
223 		Map<String, Object[]> map = new HashMap<String, Object[]>();
224 		map.put("num3", new String[] { "zzz", null, "xxx" });
225 
226 		FormDto dto = new FormDto();
227 
228 		ActionContext actionContext = new MockActionContext(null,
229 				MockAction.class, actionMethod(MockAction.class, "all"));
230 		ActionErrors errors = new ActionErrorsImpl();
231 		requestParameterBinder.bind(map, dto, actionContext, errors);
232 		assertEquals(3, dto.getNum3().size());
233 		assertEquals("zzz", dto.getNum3().get(0));
234 		assertNull(dto.getNum3().get(1));
235 		assertEquals("xxx", dto.getNum3().get(2));
236 		assertTrue(errors.isEmpty());
237 	}
238 
239 	@Test
240 	public void mapToBean_annotated() {
241 		Map<String, Object[]> map = new HashMap<String, Object[]>();
242 		map.put("normal", new Object[] { "abcd" });
243 		map.put("specifiedName", new Object[] { "efgh" });
244 		map.put("foo", new Object[] { "ijkl" });
245 		map.put("specifiedConverter", new Object[] { "mnop" });
246 		map.put("specifiedNameAndConverter", new Object[] { "qrst" });
247 		map.put("bar", new Object[] { "uvwx" });
248 
249 		AnnotatedDto dto = new AnnotatedDto();
250 
251 		ActionContext actionContext = new MockActionContext(null,
252 				MockAction.class, actionMethod(MockAction.class, "all"));
253 		ActionErrors errors = new ActionErrorsImpl();
254 		requestParameterBinder.bind(map, dto, actionContext, errors);
255 		assertEquals("abcd", dto.getNormal());
256 		assertEquals("ijkl", dto.getSpecifiedName());
257 		assertEquals("{mnop}", dto.getSpecifiedConverter());
258 		assertEquals("{uvwx}", dto.getSpecifiedNameAndConverter());
259 		assertTrue(errors.isEmpty());
260 	}
261 
262 	@Test
263 	public void converters() {
264 		Map<String, Object[]> map = new HashMap<String, Object[]>();
265 		map.put("decimal", new Object[] { "12.3" });
266 		map.put("decimals", new Object[] { "45.6", "78.9" });
267 		map.put("bigint", new Object[] { "9876" });
268 		map.put("bigints", new Object[] { "5432", "10" });
269 		map.put("bool1", new Object[] { "true" });
270 		map.put("bools1", new Object[] { "true", "false" });
271 		map.put("bool2", new Object[] { "false" });
272 		map.put("bools2", new Object[] { "false", "true", "false" });
273 		map.put("byte1", new Object[] { "12" });
274 		map.put("bytes1", new Object[] { "34", "56" });
275 		map.put("byte2", new Object[] { "98" });
276 		map.put("bytes2", new Object[] { "76", "54" });
277 		map.put("char1", new Object[] { "a" });
278 		map.put("chars1", new Object[] { "b", "c" });
279 		map.put("char2", new Object[] { "d" });
280 		map.put("chars2", new Object[] { "e", "f" });
281 		map.put("date", new Object[] { "2008-7-28" });
282 		map.put("dates", new Object[] { "2008-8-14", "2008-10-30" });
283 		map.put("double1", new Object[] { "1.2" });
284 		map.put("doubles1", new Object[] { "3.4", "5.6" });
285 		map.put("double2", new Object[] { "9.8" });
286 		map.put("doubles2", new Object[] { "7.6", "5.4" });
287 		map.put("en", new Object[] { "VALUE1" });
288 		map.put("ens", new Object[] { "VALUE2", "VALUE3" });
289 		map.put("float1", new Object[] { "1.2" });
290 		map.put("floats1", new Object[] { "3.4", "5.6" });
291 		map.put("float2", new Object[] { "9.8" });
292 		map.put("floats2", new Object[] { "7.6", "5.4" });
293 		map.put("int1", new Object[] { "12" });
294 		map.put("ints1", new Object[] { "34", "56" });
295 		map.put("int2", new Object[] { "98" });
296 		map.put("ints2", new Object[] { "76", "54" });
297 		map.put("long1", new Object[] { "12" });
298 		map.put("longs1", new Object[] { "34", "56" });
299 		map.put("long2", new Object[] { "98" });
300 		map.put("longs2", new Object[] { "76", "54" });
301 		map.put("short1", new Object[] { "12" });
302 		map.put("shorts1", new Object[] { "34", "56" });
303 		map.put("short2", new Object[] { "98" });
304 		map.put("shorts2", new Object[] { "76", "54" });
305 		map.put("sqldate", new Object[] { "2008-7-28" });
306 		map.put("sqldates", new Object[] { "2008-8-14", "2008-10-30" });
307 		map.put("sqltime", new Object[] { "12:34:56" });
308 		map.put("sqltimes", new Object[] { "13:45:24", "23:44:00" });
309 		map.put("sqltimestamp", new Object[] { "2008-7-28 12:34:56" });
310 		map.put("sqltimestamps", new Object[] { "2008-8-14 13:45:24",
311 				"2008-10-30 23:44:00" });
312 
313 		ConvertersDto dto = new ConvertersDto();
314 
315 		ActionContext actionContext = new MockActionContext(null,
316 				MockAction.class, actionMethod(MockAction.class, "all"));
317 		ActionErrors errors = new ActionErrorsImpl();
318 		requestParameterBinder.bind(map, dto, actionContext, errors);
319 
320 		assertNotNull(dto.getDecimal());
321 		assertTrue(new BigDecimal("12.3").compareTo(dto.getDecimal()) == 0);
322 
323 		assertNotNull(dto.getDecimals());
324 		assertEquals(2, dto.getDecimals().length);
325 		assertTrue(new BigDecimal("45.6").compareTo(dto.getDecimals()[0]) == 0);
326 		assertTrue(new BigDecimal("78.9").compareTo(dto.getDecimals()[1]) == 0);
327 
328 		assertNotNull(dto.getBigint());
329 		assertTrue(new BigInteger("9876").compareTo(dto.getBigint()) == 0);
330 
331 		assertNotNull(dto.getBigints());
332 		assertEquals(2, dto.getBigints().length);
333 		assertTrue(new BigInteger("5432").compareTo(dto.getBigints()[0]) == 0);
334 		assertTrue(new BigInteger("10").compareTo(dto.getBigints()[1]) == 0);
335 
336 		assertNotNull(dto.getBool1());
337 		assertTrue(dto.getBool1());
338 
339 		assertNotNull(dto.getBools1());
340 		assertEquals(2, dto.getBools1().length);
341 		assertTrue(dto.getBools1()[0]);
342 		assertFalse(dto.getBools1()[1]);
343 
344 		assertFalse(dto.isBool2());
345 
346 		assertNotNull(dto.getBools2());
347 		assertEquals(3, dto.getBools2().length);
348 		assertFalse(dto.getBools2()[0]);
349 		assertTrue(dto.getBools2()[1]);
350 		assertFalse(dto.getBools2()[2]);
351 
352 		assertNotNull(dto.getByte1());
353 		assertEquals(new Byte((byte) 12), dto.getByte1());
354 
355 		assertNotNull(dto.getBytes1());
356 		assertEquals(2, dto.getBytes1().length);
357 		assertEquals(new Byte((byte) 34), dto.getBytes1()[0]);
358 		assertEquals(new Byte((byte) 56), dto.getBytes1()[1]);
359 
360 		assertEquals((byte) 98, dto.getByte2());
361 
362 		assertNotNull(dto.getBytes2());
363 		assertEquals(2, dto.getBytes2().length);
364 		assertEquals((byte) 76, dto.getBytes2()[0]);
365 		assertEquals((byte) 54, dto.getBytes2()[1]);
366 
367 		assertNotNull(dto.getChar1());
368 		assertEquals(new Character('a'), dto.getChar1());
369 
370 		assertNotNull(dto.getChars1());
371 		assertEquals(2, dto.getChars1().length);
372 		assertEquals(new Character('b'), dto.getChars1()[0]);
373 		assertEquals(new Character('c'), dto.getChars1()[1]);
374 
375 		assertNotNull(dto.getChar2());
376 		assertEquals('d', dto.getChar2());
377 
378 		assertNotNull(dto.getChars2());
379 		assertEquals(2, dto.getChars2().length);
380 		assertEquals('e', dto.getChars2()[0]);
381 		assertEquals('f', dto.getChars2()[1]);
382 
383 		assertNotNull(dto.getDate());
384 		assertEquals(new Date(fromDateToMillis(2008, 7, 28)), dto.getDate());
385 
386 		assertNotNull(dto.getDates());
387 		assertEquals(2, dto.getDates().length);
388 		assertEquals(new Date(fromDateToMillis(2008, 8, 14)), dto.getDates()[0]);
389 		assertEquals(new Date(fromDateToMillis(2008, 10, 30)),
390 				dto.getDates()[1]);
391 
392 		assertNotNull(dto.getDouble1());
393 		assertEquals(new Double(1.2d), dto.getDouble1());
394 
395 		assertNotNull(dto.getDoubles1());
396 		assertEquals(2, dto.getDoubles1().length);
397 		assertEquals(new Double(3.4d), dto.getDoubles1()[0]);
398 		assertEquals(new Double(5.6d), dto.getDoubles1()[1]);
399 
400 		assertEquals(9.8d, dto.getDouble2(), 0.0d);
401 
402 		assertNotNull(dto.getDoubles2());
403 		assertEquals(2, dto.getDoubles2().length);
404 		assertEquals(7.6d, dto.getDoubles2()[0], 0.0d);
405 		assertEquals(5.4d, dto.getDoubles2()[1], 0.0d);
406 
407 		assertNotNull(dto.getEn());
408 		assertSame(ExEnum.VALUE1, dto.getEn());
409 
410 		assertNotNull(dto.getEns());
411 		assertEquals(2, dto.getEns().length);
412 		assertSame(ExEnum.VALUE2, dto.getEns()[0]);
413 		assertSame(ExEnum.VALUE3, dto.getEns()[1]);
414 
415 		assertNotNull(dto.getFloat1());
416 		assertEquals(new Float(1.2f), dto.getFloat1());
417 
418 		assertNotNull(dto.getFloats1());
419 		assertEquals(2, dto.getFloats1().length);
420 		assertEquals(new Float(3.4f), dto.getFloats1()[0]);
421 		assertEquals(new Float(5.6f), dto.getFloats1()[1]);
422 
423 		assertEquals(9.8f, dto.getFloat2(), 0.0f);
424 
425 		assertNotNull(dto.getFloats2());
426 		assertEquals(2, dto.getFloats2().length);
427 		assertEquals(7.6f, dto.getFloats2()[0], 0.0f);
428 		assertEquals(5.4f, dto.getFloats2()[1], 0.0f);
429 
430 		assertNotNull(dto.getInt1());
431 		assertEquals(new Integer(12), dto.getInt1());
432 
433 		assertNotNull(dto.getInts1());
434 		assertEquals(2, dto.getInts1().length);
435 		assertEquals(new Integer(34), dto.getInts1()[0]);
436 		assertEquals(new Integer(56), dto.getInts1()[1]);
437 
438 		assertEquals(98, dto.getInt2());
439 
440 		assertNotNull(dto.getInts2());
441 		assertEquals(2, dto.getInts2().length);
442 		assertEquals(76, dto.getInts2()[0]);
443 		assertEquals(54, dto.getInts2()[1]);
444 
445 		assertNotNull(dto.getLong1());
446 		assertEquals(new Long(12l), dto.getLong1());
447 
448 		assertNotNull(dto.getLongs1());
449 		assertEquals(2, dto.getLongs1().length);
450 		assertEquals(new Long(34l), dto.getLongs1()[0]);
451 		assertEquals(new Long(56l), dto.getLongs1()[1]);
452 
453 		assertEquals(98l, dto.getLong2());
454 
455 		assertNotNull(dto.getLongs2());
456 		assertEquals(2, dto.getLongs2().length);
457 		assertEquals(76l, dto.getLongs2()[0]);
458 		assertEquals(54l, dto.getLongs2()[1]);
459 
460 		assertNotNull(dto.getShort1());
461 		assertEquals(new Short((short) 12), dto.getShort1());
462 
463 		assertNotNull(dto.getShorts1());
464 		assertEquals(2, dto.getShorts1().length);
465 		assertEquals(new Short((short) 34), dto.getShorts1()[0]);
466 		assertEquals(new Short((short) 56), dto.getShorts1()[1]);
467 
468 		assertEquals((short) 98, dto.getShort2());
469 
470 		assertNotNull(dto.getShorts2());
471 		assertEquals(2, dto.getShorts2().length);
472 		assertEquals((short) 76, dto.getShorts2()[0]);
473 		assertEquals((short) 54, dto.getShorts2()[1]);
474 
475 		assertNotNull(dto.getSqldate());
476 		assertEquals(new java.sql.Date(fromDateToMillis(2008, 7, 28)), dto
477 				.getSqldate());
478 
479 		assertNotNull(dto.getSqldates());
480 		assertEquals(2, dto.getSqldates().length);
481 		assertEquals(new java.sql.Date(fromDateToMillis(2008, 8, 14)), dto
482 				.getSqldates()[0]);
483 		assertEquals(new java.sql.Date(fromDateToMillis(2008, 10, 30)), dto
484 				.getSqldates()[1]);
485 
486 		assertNotNull(dto.getSqltime());
487 		assertEquals(new Time(fromTimeToMillis(12, 34, 56)), dto.getSqltime());
488 
489 		assertNotNull(dto.getSqltimes());
490 		assertEquals(2, dto.getSqltimes().length);
491 		assertEquals(new Time(fromTimeToMillis(13, 45, 24)),
492 				dto.getSqltimes()[0]);
493 		assertEquals(new Time(fromTimeToMillis(23, 44, 00)),
494 				dto.getSqltimes()[1]);
495 
496 		assertNotNull(dto.getSqltimestamp());
497 		assertEquals(new Timestamp(fromTimestampToMillis(2008, 7, 28, 12, 34,
498 				56)), dto.getSqltimestamp());
499 
500 		assertNotNull(dto.getSqltimestamps());
501 		assertEquals(2, dto.getSqltimestamps().length);
502 		assertEquals(new Timestamp(fromTimestampToMillis(2008, 8, 14, 13, 45,
503 				24)), dto.getSqltimestamps()[0]);
504 		assertEquals(new Timestamp(fromTimestampToMillis(2008, 10, 30, 23, 44,
505 				00)), dto.getSqltimestamps()[1]);
506 
507 		assertTrue(errors.isEmpty());
508 
509 		System.out.println(dto);
510 	}
511 
512 	@Test
513 	public void convertersWithError() throws Exception {
514 		HttpServletRequest request = createNiceMock(HttpServletRequest.class);
515 		HttpServletResponse response = createNiceMock(HttpServletResponse.class);
516 		replay(request, response);
517 
518 		final Map<String, Object[]> map = new HashMap<String, Object[]>();
519 		map.put("decimal", new Object[] { "a" });
520 		map.put("decimals", new Object[] { "45.6", "b" });
521 		map.put("bigint", new Object[] { "c" });
522 		map.put("bigints", new Object[] { "d", "10" });
523 		map.put("byte1", new Object[] { "12a" });
524 		map.put("bytes1", new Object[] { "3324234456789", "56" });
525 		map.put("byte2", new Object[] { "98o" });
526 		map.put("bytes2", new Object[] { "76p", "54" });
527 		map.put("date", new Object[] { "2009-2-29" });
528 		map.put("dates", new Object[] { "2008-8-14", "2008/10/30" });
529 		map.put("double1", new Object[] { "1.2a" });
530 		map.put("doubles1", new Object[] { "3.4", "5.6b" });
531 		map.put("double2", new Object[] { "9.8c" });
532 		map.put("doubles2", new Object[] { "7.6d", "5.4" });
533 		map.put("en", new Object[] { "VALUE4" });
534 		map.put("ens", new Object[] { "VALUE2", "VALUE5" });
535 		map.put("float1", new Object[] { "1.2a" });
536 		map.put("floats1", new Object[] { "3.4b", "5.6" });
537 		map.put("float2", new Object[] { "9.8c" });
538 		map.put("floats2", new Object[] { "7.6d", "5.4" });
539 		map.put("int1", new Object[] { "12.1" });
540 		map.put("ints1", new Object[] { "34f", "56" });
541 		map.put("int2", new Object[] { "98g" });
542 		map.put("ints2", new Object[] { "76", "54h" });
543 		map.put("long1", new Object[] { "12i" });
544 		map.put("longs1", new Object[] { "34j", "56" });
545 		map.put("long2", new Object[] { "98k" });
546 		map.put("longs2", new Object[] { "76l", "54" });
547 		map.put("short1", new Object[] { "12m" });
548 		map.put("shorts1", new Object[] { "34n", "56" });
549 		map.put("short2", new Object[] { "98o" });
550 		map.put("shorts2", new Object[] { "76p", "54" });
551 		map.put("sqldate", new Object[] { "2008-7-280" });
552 		map.put("sqldates", new Object[] { "2008-8-14-", "2008-10-30" });
553 		map.put("sqltime", new Object[] { "25:34:56" });
554 		map.put("sqltimes", new Object[] { "13:45:99", "23:44:00" });
555 		map.put("sqltimestamp", new Object[] { "2008-7-28-12:34:56" });
556 		map.put("sqltimestamps", new Object[] { "2008-8-32 13:45:24",
557 				"2008-10-30 23:44:00" });
558 
559 		final ConvertersDto dto = new ConvertersDto();
560 
561 		final ActionContext actionContext = new MockActionContext(null,
562 				MockAction.class, actionMethod(MockAction.class, "all"));
563 		final ActionErrors errors = new ActionErrorsImpl();
564 		// requestParameterBinder.bind(map, dto, actionContext, errors);
565 
566 		ThreadContext.runInContext(request, response, new Command() {
567 
568 			public void execute(HttpServletRequest request,
569 					HttpServletResponse response) throws Exception {
570 				requestParameterBinder.bind(map, dto, actionContext, errors);
571 			}
572 
573 		});
574 
575 		assertFalse(errors.isEmpty());
576 
577 		System.out.println(errors.getFields().get("decimals"));
578 		assertFalse(errors.getFields().get("decimals").isEmpty());
579 		System.out.println(errors.getIndexedFields().get("decimals").get(0));
580 		assertTrue(errors.getIndexedFields().get("decimals").get(0).isEmpty());
581 		System.out.println(errors.getIndexedFields().get("decimals").get(1));
582 		assertFalse(errors.getIndexedFields().get("decimals").get(1).isEmpty());
583 
584 		System.out.println(errors.getFields().get("bigint"));
585 		assertFalse(errors.getFields().get("bigint").isEmpty());
586 		System.out.println(errors.getIndexedFields().get("bigints").get(0));
587 		assertFalse(errors.getIndexedFields().get("bigints").get(0).isEmpty());
588 		System.out.println(errors.getIndexedFields().get("bigints").get(1));
589 		assertTrue(errors.getIndexedFields().get("bigints").get(1).isEmpty());
590 
591 		System.out.println(errors.getFields().get("byte1"));
592 		assertFalse(errors.getFields().get("byte1").isEmpty());
593 		System.out.println(errors.getIndexedFields().get("bytes1").get(0));
594 		assertFalse(errors.getIndexedFields().get("bytes1").get(0).isEmpty());
595 		System.out.println(errors.getIndexedFields().get("bytes1").get(1));
596 		assertTrue(errors.getIndexedFields().get("bytes1").get(1).isEmpty());
597 
598 		System.out.println(errors.getFields().get("byte2"));
599 		assertFalse(errors.getFields().get("byte2").isEmpty());
600 		System.out.println(errors.getIndexedFields().get("bytes2").get(0));
601 		assertFalse(errors.getIndexedFields().get("bytes2").get(0).isEmpty());
602 		System.out.println(errors.getIndexedFields().get("bytes2").get(1));
603 		assertTrue(errors.getIndexedFields().get("bytes2").get(1).isEmpty());
604 
605 		System.out.println(errors.getFields().get("double1"));
606 		assertFalse(errors.getFields().get("double1").isEmpty());
607 		System.out.println(errors.getIndexedFields().get("doubles1").get(0));
608 		assertTrue(errors.getIndexedFields().get("doubles1").get(0).isEmpty());
609 		System.out.println(errors.getIndexedFields().get("doubles1").get(1));
610 		assertFalse(errors.getIndexedFields().get("doubles1").get(1).isEmpty());
611 
612 		System.out.println(errors.getFields().get("double2"));
613 		assertFalse(errors.getFields().get("double2").isEmpty());
614 		System.out.println(errors.getIndexedFields().get("doubles2").get(0));
615 		assertFalse(errors.getIndexedFields().get("doubles2").get(0).isEmpty());
616 		System.out.println(errors.getIndexedFields().get("doubles2").get(1));
617 		assertTrue(errors.getIndexedFields().get("doubles2").get(1).isEmpty());
618 
619 		System.out.println(errors.getFields().get("float1"));
620 		assertFalse(errors.getFields().get("float1").isEmpty());
621 		System.out.println(errors.getIndexedFields().get("floats1").get(0));
622 		assertFalse(errors.getIndexedFields().get("floats1").get(0).isEmpty());
623 		System.out.println(errors.getIndexedFields().get("floats1").get(1));
624 		assertTrue(errors.getIndexedFields().get("floats1").get(1).isEmpty());
625 
626 		System.out.println(errors.getFields().get("float2"));
627 		assertFalse(errors.getFields().get("float2").isEmpty());
628 		System.out.println(errors.getIndexedFields().get("floats2").get(0));
629 		assertFalse(errors.getIndexedFields().get("floats2").get(0).isEmpty());
630 		System.out.println(errors.getIndexedFields().get("floats2").get(1));
631 		assertTrue(errors.getIndexedFields().get("floats2").get(1).isEmpty());
632 
633 		System.out.println(errors.getFields().get("int1"));
634 		assertFalse(errors.getFields().get("int1").isEmpty());
635 		System.out.println(errors.getIndexedFields().get("ints1").get(0));
636 		assertFalse(errors.getIndexedFields().get("ints1").get(0).isEmpty());
637 		System.out.println(errors.getIndexedFields().get("ints1").get(1));
638 		assertTrue(errors.getIndexedFields().get("ints1").get(1).isEmpty());
639 
640 		System.out.println(errors.getFields().get("int2"));
641 		assertFalse(errors.getFields().get("int2").isEmpty());
642 		System.out.println(errors.getIndexedFields().get("ints2").get(0));
643 		assertTrue(errors.getIndexedFields().get("ints2").get(0).isEmpty());
644 		System.out.println(errors.getIndexedFields().get("ints2").get(1));
645 		assertFalse(errors.getIndexedFields().get("ints2").get(1).isEmpty());
646 
647 		System.out.println(errors.getFields().get("long1"));
648 		assertFalse(errors.getFields().get("long1").isEmpty());
649 		System.out.println(errors.getIndexedFields().get("longs1").get(0));
650 		assertFalse(errors.getIndexedFields().get("longs1").get(0).isEmpty());
651 		System.out.println(errors.getIndexedFields().get("longs1").get(1));
652 		assertTrue(errors.getIndexedFields().get("longs1").get(1).isEmpty());
653 
654 		System.out.println(errors.getFields().get("long2"));
655 		assertFalse(errors.getFields().get("long2").isEmpty());
656 		System.out.println(errors.getIndexedFields().get("longs2").get(0));
657 		assertFalse(errors.getIndexedFields().get("longs2").get(0).isEmpty());
658 		System.out.println(errors.getIndexedFields().get("longs2").get(1));
659 		assertTrue(errors.getIndexedFields().get("longs2").get(1).isEmpty());
660 
661 		System.out.println(errors.getFields().get("short1"));
662 		assertFalse(errors.getFields().get("short1").isEmpty());
663 		System.out.println(errors.getIndexedFields().get("shorts1").get(0));
664 		assertFalse(errors.getIndexedFields().get("shorts1").get(0).isEmpty());
665 		System.out.println(errors.getIndexedFields().get("shorts1").get(1));
666 		assertTrue(errors.getIndexedFields().get("shorts1").get(1).isEmpty());
667 
668 		System.out.println(errors.getFields().get("short2"));
669 		assertFalse(errors.getFields().get("short2").isEmpty());
670 		System.out.println(errors.getIndexedFields().get("shorts2").get(0));
671 		assertFalse(errors.getIndexedFields().get("shorts2").get(0).isEmpty());
672 		System.out.println(errors.getIndexedFields().get("shorts2").get(1));
673 		assertTrue(errors.getIndexedFields().get("shorts2").get(1).isEmpty());
674 
675 		System.out.println(errors.getFields().get("date"));
676 		assertFalse(errors.getFields().get("date").isEmpty());
677 		System.out.println(errors.getIndexedFields().get("dates").get(0));
678 		assertTrue(errors.getIndexedFields().get("dates").get(0).isEmpty());
679 		System.out.println(errors.getIndexedFields().get("dates").get(1));
680 		assertFalse(errors.getIndexedFields().get("dates").get(1).isEmpty());
681 
682 		System.out.println(errors.getFields().get("sqldate"));
683 		assertFalse(errors.getFields().get("sqldate").isEmpty());
684 		System.out.println(errors.getIndexedFields().get("sqldates").get(0));
685 		assertFalse(errors.getIndexedFields().get("sqldates").get(0).isEmpty());
686 		System.out.println(errors.getIndexedFields().get("sqldates").get(1));
687 		assertTrue(errors.getIndexedFields().get("sqldates").get(1).isEmpty());
688 
689 		System.out.println(errors.getFields().get("sqltime"));
690 		assertFalse(errors.getFields().get("sqltime").isEmpty());
691 		System.out.println(errors.getIndexedFields().get("sqltimes").get(0));
692 		assertFalse(errors.getIndexedFields().get("sqltimes").get(0).isEmpty());
693 		System.out.println(errors.getIndexedFields().get("sqltimes").get(1));
694 		assertTrue(errors.getIndexedFields().get("sqltimes").get(1).isEmpty());
695 
696 		System.out.println(errors.getFields().get("sqltimestamp"));
697 		assertFalse(errors.getFields().get("sqltimestamp").isEmpty());
698 		System.out.println(errors.getIndexedFields().get("sqltimestamps")
699 				.get(0));
700 		assertFalse(errors.getIndexedFields().get("sqltimestamps").get(0)
701 				.isEmpty());
702 		System.out.println(errors.getIndexedFields().get("sqltimestamps")
703 				.get(1));
704 		assertTrue(errors.getIndexedFields().get("sqltimestamps").get(1)
705 				.isEmpty());
706 
707 		System.out.println(errors.getFields().get("en"));
708 		assertFalse(errors.getFields().get("en").isEmpty());
709 		System.out.println(errors.getIndexedFields().get("ens").get(0));
710 		assertTrue(errors.getIndexedFields().get("ens").get(0).isEmpty());
711 		System.out.println(errors.getIndexedFields().get("ens").get(1));
712 		assertFalse(errors.getIndexedFields().get("ens").get(1).isEmpty());
713 
714 	}
715 
716 	@Test
717 	public void convertFileItem() throws Exception {
718 		HttpServletRequest request = createNiceMock(HttpServletRequest.class);
719 		HttpServletResponse response = createNiceMock(HttpServletResponse.class);
720 		replay(request, response);
721 
722 		final Map<String, Object[]> map = new HashMap<String, Object[]>();
723 		map.put("file", new FileItem[] { new MockFileItem("123") });
724 		map.put("bytefile", new FileItem[] { new MockFileItem("456") });
725 		map.put("bytefiles", new FileItem[] { new MockFileItem("abc"),
726 				new MockFileItem("def") });
727 		map.put("bytefilelist", new FileItem[] { new MockFileItem("GHI"),
728 				new MockFileItem("JKL") });
729 		map.put("input", new FileItem[] { new MockFileItem("QQ") });
730 
731 		final FileItemDto dto = new FileItemDto();
732 
733 		final ActionContext actionContext = new MockActionContext(null,
734 				MockAction.class, actionMethod(MockAction.class, "all"));
735 		final ActionErrors errors = new ActionErrorsImpl();
736 		ThreadContext.runInContext(request, response, new Command() {
737 
738 			public void execute(HttpServletRequest request,
739 					HttpServletResponse response) throws Exception {
740 				requestParameterBinder.bind(map, dto, actionContext, errors);
741 			}
742 
743 		});
744 
745 		String encoding = "UTF-8";
746 		assertNotNull(dto.getFile());
747 		assertEquals("123", new String(dto.getFile().get(), encoding));
748 		assertNotNull(dto.getBytefile());
749 		assertEquals("456", new String(dto.getBytefile(), encoding));
750 		assertNotNull(dto.getBytefiles());
751 		assertEquals(2, dto.getBytefiles().length);
752 		assertEquals("abc", new String(dto.getBytefiles()[0], encoding));
753 		assertEquals("def", new String(dto.getBytefiles()[1], encoding));
754 		assertNotNull(dto.getBytefilelist());
755 		assertEquals(2, dto.getBytefilelist().size());
756 		Iterator<byte[]> it = dto.getBytefilelist().iterator();
757 		assertEquals("GHI", new String(it.next(), encoding));
758 		assertEquals("JKL", new String(it.next(), encoding));
759 		assertNotNull(dto.getInput());
760 		assertEquals("QQ", new String(getBytes(dto.getInput()), encoding));
761 		assertTrue(errors.isEmpty());
762 	}
763 
764 	public void testBindTypeNoAnnotated() {
765 		Map<String, Object[]> map = new HashMap<String, Object[]>();
766 		map.put("hasRequestParameter", new Object[] { "abc" });
767 		map.put("noRequestParameter", new Object[] { "def" });
768 		FormDto2 dto = new FormDto2();
769 		ActionContext actionContext = new MockActionContext(null,
770 				MockAction.class, actionMethod(MockAction.class, "noAnnotated"));
771 		ActionErrors errors = new ActionErrorsImpl();
772 		requestParameterBinder.bind(map, dto, actionContext, errors);
773 		assertNotNull(dto.getHasRequestParameter());
774 		assertEquals("abc", dto.getHasRequestParameter());
775 		assertNull(dto.getNoRequestParameter());
776 		assertTrue(errors.isEmpty());
777 	}
778 
779 	public void testBindTypeNoBindingType() {
780 		Map<String, Object[]> map = new HashMap<String, Object[]>();
781 		map.put("hasRequestParameter", new Object[] { "abc" });
782 		map.put("noRequestParameter", new Object[] { "def" });
783 		FormDto2 dto = new FormDto2();
784 		ActionContext actionContext = new MockActionContext(null,
785 				MockAction.class, actionMethod(MockAction.class,
786 						"noBindingType"));
787 		ActionErrors errors = new ActionErrorsImpl();
788 		requestParameterBinder.bind(map, dto, actionContext, errors);
789 		assertNotNull(dto.getHasRequestParameter());
790 		assertEquals("abc", dto.getHasRequestParameter());
791 		assertNotNull(dto.getNoRequestParameter());
792 		assertEquals("def", dto.getNoRequestParameter());
793 		assertTrue(errors.isEmpty());
794 	}
795 
796 	public void testBindTypeAllProperties() {
797 		Map<String, Object[]> map = new HashMap<String, Object[]>();
798 		map.put("hasRequestParameter", new Object[] { "abc" });
799 		map.put("noRequestParameter", new Object[] { "def" });
800 		FormDto2 dto = new FormDto2();
801 		ActionContext actionContext = new MockActionContext(null,
802 				MockAction.class, actionMethod(MockAction.class, "all"));
803 		ActionErrors errors = new ActionErrorsImpl();
804 		requestParameterBinder.bind(map, dto, actionContext, errors);
805 		assertNotNull(dto.getHasRequestParameter());
806 		assertEquals("abc", dto.getHasRequestParameter());
807 		assertNotNull(dto.getNoRequestParameter());
808 		assertEquals("def", dto.getNoRequestParameter());
809 		assertTrue(errors.isEmpty());
810 	}
811 
812 	public void testBindTypeOnlySpecifiedProperties() {
813 		Map<String, Object[]> map = new HashMap<String, Object[]>();
814 		map.put("hasRequestParameter", new Object[] { "abc" });
815 		map.put("noRequestParameter", new Object[] { "def" });
816 		FormDto2 dto = new FormDto2();
817 		ActionContext actionContext = new MockActionContext(null,
818 				MockAction.class, actionMethod(MockAction.class, "specified"));
819 		ActionErrors errors = new ActionErrorsImpl();
820 		requestParameterBinder.bind(map, dto, actionContext, errors);
821 		assertNotNull(dto.getHasRequestParameter());
822 		assertEquals("abc", dto.getHasRequestParameter());
823 		assertNull(dto.getNoRequestParameter());
824 		assertTrue(errors.isEmpty());
825 	}
826 
827 	public void testBindTypeNoAnnotatedOnClass() {
828 		Map<String, Object[]> map = new HashMap<String, Object[]>();
829 		map.put("hasRequestParameter", new Object[] { "abc" });
830 		map.put("noRequestParameter", new Object[] { "def" });
831 		FormDto2 dto = new FormDto2();
832 		ActionContext actionContext = new MockActionContext(null,
833 				MockAction2.class, actionMethod(MockAction2.class,
834 						"noAnnotated"));
835 		ActionErrors errors = new ActionErrorsImpl();
836 		requestParameterBinder.bind(map, dto, actionContext, errors);
837 		assertNotNull(dto.getHasRequestParameter());
838 		assertEquals("abc", dto.getHasRequestParameter());
839 		assertNotNull(dto.getNoRequestParameter());
840 		assertEquals("def", dto.getNoRequestParameter());
841 		assertTrue(errors.isEmpty());
842 	}
843 
844 	public void testBindTypeOnlySpecifiedPropertiesOnClass() {
845 		Map<String, Object[]> map = new HashMap<String, Object[]>();
846 		map.put("hasRequestParameter", new Object[] { "abc" });
847 		map.put("noRequestParameter", new Object[] { "def" });
848 		FormDto2 dto = new FormDto2();
849 		ActionContext actionContext = new MockActionContext(null,
850 				MockAction2.class, actionMethod(MockAction2.class, "specified"));
851 		ActionErrors errors = new ActionErrorsImpl();
852 		requestParameterBinder.bind(map, dto, actionContext, errors);
853 		assertNotNull(dto.getHasRequestParameter());
854 		assertEquals("abc", dto.getHasRequestParameter());
855 		assertNull(dto.getNoRequestParameter());
856 		assertTrue(errors.isEmpty());
857 	}
858 
859 	private Method actionMethod(Class<? extends Action> actionClass,
860 			String methodName) {
861 		try {
862 			return actionClass.getMethod(methodName);
863 		} catch (NoSuchMethodException ex) {
864 			throw new RuntimeException();
865 		}
866 	}
867 
868 	private class MockAction extends Action {
869 		@Form(bindingType = RequestParameterBindingType.ALL_PROPERTIES)
870 		public ActionResult all() {
871 			return null;
872 		}
873 
874 		@Form(bindingType = RequestParameterBindingType.ONLY_SPECIFIED_PROPERTIES)
875 		public ActionResult specified() {
876 			return null;
877 		}
878 
879 		@Form
880 		public ActionResult noBindingType() {
881 			return null;
882 		}
883 
884 		public ActionResult noAnnotated() {
885 			return null;
886 		}
887 	}
888 
889 	@Form(bindingType = RequestParameterBindingType.ALL_PROPERTIES)
890 	private class MockAction2 extends Action {
891 		@Form(bindingType = RequestParameterBindingType.ONLY_SPECIFIED_PROPERTIES)
892 		public ActionResult specified() {
893 			return null;
894 		}
895 
896 		public ActionResult noAnnotated() {
897 			return null;
898 		}
899 	}
900 
901 	public static class FormDto2 {
902 		private String hasRequestParameter;
903 
904 		public String getHasRequestParameter() {
905 			return hasRequestParameter;
906 		}
907 
908 		@RequestParameter
909 		public void setHasRequestParameter(String hasRequestParameter) {
910 			this.hasRequestParameter = hasRequestParameter;
911 		}
912 
913 		private String noRequestParameter;
914 
915 		public String getNoRequestParameter() {
916 			return noRequestParameter;
917 		}
918 
919 		public void setNoRequestParameter(String noRequestParameter) {
920 			this.noRequestParameter = noRequestParameter;
921 		}
922 	}
923 
924 	public static class FormDto {
925 		private Date date;
926 		private Integer num1;
927 		private Integer[] num2;
928 		private List<String> num3;
929 
930 		public Date getDate() {
931 			return date;
932 		}
933 
934 		public void setDate(Date date) {
935 			this.date = date;
936 		}
937 
938 		public Integer getNum1() {
939 			return num1;
940 		}
941 
942 		public void setNum1(Integer num1) {
943 			this.num1 = num1;
944 		}
945 
946 		public Integer[] getNum2() {
947 			return num2;
948 		}
949 
950 		public void setNum2(Integer[] num2) {
951 			this.num2 = num2;
952 		}
953 
954 		public List<String> getNum3() {
955 			return num3;
956 		}
957 
958 		public void setNum3(List<String> num3) {
959 			this.num3 = num3;
960 		}
961 	}
962 
963 	public static class ConvertersDto {
964 		private BigDecimal decimal;
965 		private BigDecimal[] decimals;
966 		private BigInteger bigint;
967 		private BigInteger[] bigints;
968 		private Boolean bool1;
969 		private Boolean[] bools1;
970 		private boolean bool2;
971 		private boolean[] bools2;
972 		private Byte byte1;
973 		private Byte[] bytes1;
974 		private byte byte2;
975 		private byte[] bytes2;
976 		private Character char1;
977 		private Character[] chars1;
978 		private char char2;
979 		private char[] chars2;
980 		private Date date;
981 		private Date[] dates;
982 		private Double double1;
983 		private Double[] doubles1;
984 		private double double2;
985 		private double[] doubles2;
986 		private ExEnum en;
987 		private ExEnum[] ens;
988 		private Float float1;
989 		private Float[] floats1;
990 		private float float2;
991 		private float[] floats2;
992 		private Integer int1;
993 		private Integer[] ints1;
994 		private int int2;
995 		private int[] ints2;
996 		private Long long1;
997 		private Long[] longs1;
998 		private long long2;
999 		private long[] longs2;
1000 		private Short short1;
1001 		private Short[] shorts1;
1002 		private short short2;
1003 		private short[] shorts2;
1004 		private java.sql.Date sqldate;
1005 		private java.sql.Date[] sqldates;
1006 		private Time sqltime;
1007 		private Time[] sqltimes;
1008 		private Timestamp sqltimestamp;
1009 		private Timestamp[] sqltimestamps;
1010 
1011 		public BigDecimal getDecimal() {
1012 			return decimal;
1013 		}
1014 
1015 		public void setDecimal(BigDecimal decimal) {
1016 			this.decimal = decimal;
1017 		}
1018 
1019 		public BigDecimal[] getDecimals() {
1020 			return decimals;
1021 		}
1022 
1023 		public void setDecimals(BigDecimal[] decimals) {
1024 			this.decimals = decimals;
1025 		}
1026 
1027 		public BigInteger getBigint() {
1028 			return bigint;
1029 		}
1030 
1031 		public void setBigint(BigInteger bigint) {
1032 			this.bigint = bigint;
1033 		}
1034 
1035 		public BigInteger[] getBigints() {
1036 			return bigints;
1037 		}
1038 
1039 		public void setBigints(BigInteger[] bigints) {
1040 			this.bigints = bigints;
1041 		}
1042 
1043 		public Boolean getBool1() {
1044 			return bool1;
1045 		}
1046 
1047 		public void setBool1(Boolean bool1) {
1048 			this.bool1 = bool1;
1049 		}
1050 
1051 		public Boolean[] getBools1() {
1052 			return bools1;
1053 		}
1054 
1055 		public void setBools1(Boolean[] bools1) {
1056 			this.bools1 = bools1;
1057 		}
1058 
1059 		public boolean isBool2() {
1060 			return bool2;
1061 		}
1062 
1063 		public void setBool2(boolean bool2) {
1064 			this.bool2 = bool2;
1065 		}
1066 
1067 		public boolean[] getBools2() {
1068 			return bools2;
1069 		}
1070 
1071 		public void setBools2(boolean[] bools2) {
1072 			this.bools2 = bools2;
1073 		}
1074 
1075 		public Byte getByte1() {
1076 			return byte1;
1077 		}
1078 
1079 		public void setByte1(Byte byte1) {
1080 			this.byte1 = byte1;
1081 		}
1082 
1083 		public Byte[] getBytes1() {
1084 			return bytes1;
1085 		}
1086 
1087 		public void setBytes1(Byte[] bytes1) {
1088 			this.bytes1 = bytes1;
1089 		}
1090 
1091 		public byte getByte2() {
1092 			return byte2;
1093 		}
1094 
1095 		public void setByte2(byte byte2) {
1096 			this.byte2 = byte2;
1097 		}
1098 
1099 		public byte[] getBytes2() {
1100 			return bytes2;
1101 		}
1102 
1103 		public void setBytes2(byte[] bytes2) {
1104 			this.bytes2 = bytes2;
1105 		}
1106 
1107 		public Character getChar1() {
1108 			return char1;
1109 		}
1110 
1111 		public void setChar1(Character char1) {
1112 			this.char1 = char1;
1113 		}
1114 
1115 		public Character[] getChars1() {
1116 			return chars1;
1117 		}
1118 
1119 		public void setChars1(Character[] chars1) {
1120 			this.chars1 = chars1;
1121 		}
1122 
1123 		public char getChar2() {
1124 			return char2;
1125 		}
1126 
1127 		public void setChar2(char char2) {
1128 			this.char2 = char2;
1129 		}
1130 
1131 		public char[] getChars2() {
1132 			return chars2;
1133 		}
1134 
1135 		public void setChars2(char[] chars2) {
1136 			this.chars2 = chars2;
1137 		}
1138 
1139 		public Date getDate() {
1140 			return date;
1141 		}
1142 
1143 		public void setDate(Date date) {
1144 			this.date = date;
1145 		}
1146 
1147 		public Date[] getDates() {
1148 			return dates;
1149 		}
1150 
1151 		public void setDates(Date[] dates) {
1152 			this.dates = dates;
1153 		}
1154 
1155 		public Double getDouble1() {
1156 			return double1;
1157 		}
1158 
1159 		public void setDouble1(Double double1) {
1160 			this.double1 = double1;
1161 		}
1162 
1163 		public Double[] getDoubles1() {
1164 			return doubles1;
1165 		}
1166 
1167 		public void setDoubles1(Double[] doubles1) {
1168 			this.doubles1 = doubles1;
1169 		}
1170 
1171 		public double getDouble2() {
1172 			return double2;
1173 		}
1174 
1175 		public void setDouble2(double double2) {
1176 			this.double2 = double2;
1177 		}
1178 
1179 		public double[] getDoubles2() {
1180 			return doubles2;
1181 		}
1182 
1183 		public void setDoubles2(double[] doubles2) {
1184 			this.doubles2 = doubles2;
1185 		}
1186 
1187 		public ExEnum getEn() {
1188 			return en;
1189 		}
1190 
1191 		public void setEn(ExEnum en) {
1192 			this.en = en;
1193 		}
1194 
1195 		public ExEnum[] getEns() {
1196 			return ens;
1197 		}
1198 
1199 		public void setEns(ExEnum[] ens) {
1200 			this.ens = ens;
1201 		}
1202 
1203 		public Float getFloat1() {
1204 			return float1;
1205 		}
1206 
1207 		public void setFloat1(Float float1) {
1208 			this.float1 = float1;
1209 		}
1210 
1211 		public Float[] getFloats1() {
1212 			return floats1;
1213 		}
1214 
1215 		public void setFloats1(Float[] floats1) {
1216 			this.floats1 = floats1;
1217 		}
1218 
1219 		public float getFloat2() {
1220 			return float2;
1221 		}
1222 
1223 		public void setFloat2(float float2) {
1224 			this.float2 = float2;
1225 		}
1226 
1227 		public float[] getFloats2() {
1228 			return floats2;
1229 		}
1230 
1231 		public void setFloats2(float[] floats2) {
1232 			this.floats2 = floats2;
1233 		}
1234 
1235 		public Integer getInt1() {
1236 			return int1;
1237 		}
1238 
1239 		public void setInt1(Integer int1) {
1240 			this.int1 = int1;
1241 		}
1242 
1243 		public Integer[] getInts1() {
1244 			return ints1;
1245 		}
1246 
1247 		public void setInts1(Integer[] ints1) {
1248 			this.ints1 = ints1;
1249 		}
1250 
1251 		public int getInt2() {
1252 			return int2;
1253 		}
1254 
1255 		public void setInt2(int int2) {
1256 			this.int2 = int2;
1257 		}
1258 
1259 		public int[] getInts2() {
1260 			return ints2;
1261 		}
1262 
1263 		public void setInts2(int[] ints2) {
1264 			this.ints2 = ints2;
1265 		}
1266 
1267 		public Long getLong1() {
1268 			return long1;
1269 		}
1270 
1271 		public void setLong1(Long long1) {
1272 			this.long1 = long1;
1273 		}
1274 
1275 		public Long[] getLongs1() {
1276 			return longs1;
1277 		}
1278 
1279 		public void setLongs1(Long[] longs1) {
1280 			this.longs1 = longs1;
1281 		}
1282 
1283 		public long getLong2() {
1284 			return long2;
1285 		}
1286 
1287 		public void setLong2(long long2) {
1288 			this.long2 = long2;
1289 		}
1290 
1291 		public long[] getLongs2() {
1292 			return longs2;
1293 		}
1294 
1295 		public void setLongs2(long[] longs2) {
1296 			this.longs2 = longs2;
1297 		}
1298 
1299 		public Short getShort1() {
1300 			return short1;
1301 		}
1302 
1303 		public void setShort1(Short short1) {
1304 			this.short1 = short1;
1305 		}
1306 
1307 		public Short[] getShorts1() {
1308 			return shorts1;
1309 		}
1310 
1311 		public void setShorts1(Short[] shorts1) {
1312 			this.shorts1 = shorts1;
1313 		}
1314 
1315 		public short getShort2() {
1316 			return short2;
1317 		}
1318 
1319 		public void setShort2(short short2) {
1320 			this.short2 = short2;
1321 		}
1322 
1323 		public short[] getShorts2() {
1324 			return shorts2;
1325 		}
1326 
1327 		public void setShorts2(short[] shorts2) {
1328 			this.shorts2 = shorts2;
1329 		}
1330 
1331 		public java.sql.Date getSqldate() {
1332 			return sqldate;
1333 		}
1334 
1335 		public void setSqldate(java.sql.Date sqldate) {
1336 			this.sqldate = sqldate;
1337 		}
1338 
1339 		public java.sql.Date[] getSqldates() {
1340 			return sqldates;
1341 		}
1342 
1343 		public void setSqldates(java.sql.Date[] sqldates) {
1344 			this.sqldates = sqldates;
1345 		}
1346 
1347 		public Time getSqltime() {
1348 			return sqltime;
1349 		}
1350 
1351 		public void setSqltime(Time sqltime) {
1352 			this.sqltime = sqltime;
1353 		}
1354 
1355 		public Time[] getSqltimes() {
1356 			return sqltimes;
1357 		}
1358 
1359 		public void setSqltimes(Time[] sqltimes) {
1360 			this.sqltimes = sqltimes;
1361 		}
1362 
1363 		public Timestamp getSqltimestamp() {
1364 			return sqltimestamp;
1365 		}
1366 
1367 		public void setSqltimestamp(Timestamp sqltimestamp) {
1368 			this.sqltimestamp = sqltimestamp;
1369 		}
1370 
1371 		public Timestamp[] getSqltimestamps() {
1372 			return sqltimestamps;
1373 		}
1374 
1375 		public void setSqltimestamps(Timestamp[] sqltimestamps) {
1376 			this.sqltimestamps = sqltimestamps;
1377 		}
1378 	}
1379 
1380 	public enum ExEnum {
1381 		VALUE1, VALUE2, VALUE3;
1382 	}
1383 
1384 	public static class FileItemDto {
1385 		private FileItem file;
1386 		private byte[] bytefile;
1387 		private byte[][] bytefiles;
1388 		private Set<byte[]> bytefilelist;
1389 		private InputStream input;
1390 
1391 		public FileItem getFile() {
1392 			return file;
1393 		}
1394 
1395 		public void setFile(FileItem file) {
1396 			this.file = file;
1397 		}
1398 
1399 		public byte[] getBytefile() {
1400 			return bytefile;
1401 		}
1402 
1403 		public void setBytefile(byte[] bytefile) {
1404 			this.bytefile = bytefile;
1405 		}
1406 
1407 		public byte[][] getBytefiles() {
1408 			return bytefiles;
1409 		}
1410 
1411 		public void setBytefiles(byte[][] bytefiles) {
1412 			this.bytefiles = bytefiles;
1413 		}
1414 
1415 		public Set<byte[]> getBytefilelist() {
1416 			return bytefilelist;
1417 		}
1418 
1419 		public void setBytefilelist(Set<byte[]> bytefilelist) {
1420 			this.bytefilelist = bytefilelist;
1421 		}
1422 
1423 		public InputStream getInput() {
1424 			return input;
1425 		}
1426 
1427 		public void setInput(InputStream input) {
1428 			this.input = input;
1429 		}
1430 	}
1431 
1432 	private static class MockFileItem implements FileItem {
1433 
1434 		private static final long serialVersionUID = 1L;
1435 
1436 		private String name;
1437 
1438 		public MockFileItem(String name) {
1439 			this.name = name;
1440 		}
1441 
1442 		public void delete() {
1443 		}
1444 
1445 		public byte[] get() {
1446 			try {
1447 				return name.getBytes("UTF-8");
1448 			} catch (UnsupportedEncodingException e) {
1449 				throw new RuntimeException();
1450 			}
1451 		}
1452 
1453 		public String getContentType() {
1454 			return null;
1455 		}
1456 
1457 		public String getFieldName() {
1458 			return null;
1459 		}
1460 
1461 		public InputStream getInputStream() throws IOException {
1462 			return new ByteArrayInputStream(get());
1463 		}
1464 
1465 		public String getName() {
1466 			return this.name;
1467 		}
1468 
1469 		public OutputStream getOutputStream() throws IOException {
1470 			return null;
1471 		}
1472 
1473 		public long getSize() {
1474 			return 0;
1475 		}
1476 
1477 		public String getString() {
1478 			return null;
1479 		}
1480 
1481 		public String getString(String encoding)
1482 				throws UnsupportedEncodingException {
1483 			return null;
1484 		}
1485 
1486 		public boolean isFormField() {
1487 			return false;
1488 		}
1489 
1490 		public boolean isInMemory() {
1491 			return false;
1492 		}
1493 
1494 		public void setFieldName(String name) {
1495 		}
1496 
1497 		public void setFormField(boolean state) {
1498 		}
1499 
1500 		public void write(File file) throws Exception {
1501 		}
1502 	}
1503 
1504 	private static final Map<Integer, Integer> MONTHS;
1505 	static {
1506 		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
1507 		map.put(1, Calendar.JANUARY);
1508 		map.put(2, Calendar.FEBRUARY);
1509 		map.put(3, Calendar.MARCH);
1510 		map.put(4, Calendar.APRIL);
1511 		map.put(5, Calendar.MAY);
1512 		map.put(6, Calendar.JUNE);
1513 		map.put(7, Calendar.JULY);
1514 		map.put(8, Calendar.AUGUST);
1515 		map.put(9, Calendar.SEPTEMBER);
1516 		map.put(10, Calendar.OCTOBER);
1517 		map.put(11, Calendar.NOVEMBER);
1518 		map.put(12, Calendar.DECEMBER);
1519 		MONTHS = Collections.unmodifiableMap(map);
1520 	}
1521 
1522 	private static long fromDateToMillis(int year, int month, int date) {
1523 		Calendar c = Calendar.getInstance();
1524 		c.clear();
1525 		c.set(Calendar.YEAR, year);
1526 		c.set(Calendar.MONTH, MONTHS.get(month));
1527 		c.set(Calendar.DATE, date);
1528 		return c.getTimeInMillis();
1529 	}
1530 
1531 	private static long fromTimeToMillis(int hour, int minute, int second) {
1532 		Calendar c = Calendar.getInstance();
1533 		c.clear();
1534 		c.set(Calendar.HOUR, hour);
1535 		c.set(Calendar.MINUTE, minute);
1536 		c.set(Calendar.SECOND, second);
1537 		return c.getTimeInMillis();
1538 	}
1539 
1540 	private static long fromTimestampToMillis(int year, int month, int date,
1541 			int hour, int minute, int second) {
1542 		Calendar c = Calendar.getInstance();
1543 		c.clear();
1544 		c.set(Calendar.YEAR, year);
1545 		c.set(Calendar.MONTH, MONTHS.get(month));
1546 		c.set(Calendar.DATE, date);
1547 		c.set(Calendar.HOUR, hour);
1548 		c.set(Calendar.MINUTE, minute);
1549 		c.set(Calendar.SECOND, second);
1550 		return c.getTimeInMillis();
1551 	}
1552 
1553 	private static final byte[] getBytes(InputStream is) {
1554 		byte[] bytes = null;
1555 		byte[] buf = new byte[8192];
1556 		try {
1557 			ByteArrayOutputStream baos = new ByteArrayOutputStream();
1558 			int n = 0;
1559 			while ((n = is.read(buf, 0, buf.length)) != -1) {
1560 				baos.write(buf, 0, n);
1561 			}
1562 			bytes = baos.toByteArray();
1563 		} catch (IOException e) {
1564 			throw new RuntimeException(e);
1565 		} finally {
1566 			if (is != null) {
1567 				try {
1568 					is.close();
1569 				} catch (IOException e) {
1570 				}
1571 			}
1572 		}
1573 		return bytes;
1574 	}
1575 
1576 	public interface SeparationAction {
1577 
1578 	}
1579 
1580 	public static class SeparationActionImpl implements SeparationAction {
1581 
1582 	}
1583 
1584 	public static class AnnotatedDto {
1585 
1586 		private String normal;
1587 
1588 		private String specifiedName;
1589 
1590 		private String specifiedConverter;
1591 
1592 		private String specifiedNameAndConverter;
1593 
1594 		public String getNormal() {
1595 			return normal;
1596 		}
1597 
1598 		@RequestParameter
1599 		public void setNormal(String normal) {
1600 			this.normal = normal;
1601 		}
1602 
1603 		public String getSpecifiedName() {
1604 			return specifiedName;
1605 		}
1606 
1607 		@RequestParameter(name = "foo")
1608 		public void setSpecifiedName(String specifiedName) {
1609 			this.specifiedName = specifiedName;
1610 		}
1611 
1612 		public String getSpecifiedConverter() {
1613 			return specifiedConverter;
1614 		}
1615 
1616 		@RequestParameter(converter = BraceConverter.class)
1617 		public void setSpecifiedConverter(String specifiedConverter) {
1618 			this.specifiedConverter = specifiedConverter;
1619 		}
1620 
1621 		public String getSpecifiedNameAndConverter() {
1622 			return specifiedNameAndConverter;
1623 		}
1624 
1625 		@RequestParameter(name = "bar", converter = BraceConverter.class)
1626 		public void setSpecifiedNameAndConverter(
1627 				String specifiedNameAndConverter) {
1628 			this.specifiedNameAndConverter = specifiedNameAndConverter;
1629 		}
1630 
1631 	}
1632 
1633 	public static class BraceConverter implements Converter {
1634 
1635 		public Object convertToObject(Object value, Class<?> objectType,
1636 				ConversionHelper helper) {
1637 			if (value == null) {
1638 				return null;
1639 			}
1640 			return "{" + value + "}";
1641 		}
1642 
1643 		public String convertToString(Object value, ConversionHelper helper) {
1644 			if (value == null) {
1645 				return null;
1646 			}
1647 			return value.toString().substring(1, value.toString().length() - 1);
1648 		}
1649 
1650 		public Class<?> getObjectType() {
1651 			return String.class;
1652 		}
1653 
1654 		public boolean canConvert(Class<?> parameterType, Class<?> objectType) {
1655 			return false;
1656 		}
1657 
1658 	}
1659 
1660 }