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