01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.bind.internal;
16:
17: import java.util.Map;
18:
19: import org.strecks.bind.handler.BindHandler;
20: import org.strecks.bind.handler.BindSelectHandler;
21: import org.strecks.bind.handler.BindSimpleHandler;
22: import org.strecks.converter.DatePatternConverter;
23: import org.strecks.converter.SafeBeanUtilsConverter;
24: import org.strecks.converter.internal.impl.BeanWithExplicitConverters;
25: import org.testng.annotations.Test;
26:
27: /**
28: * @author Phil Zoio
29: */
30: public class TestReadBindablesWithConverter {
31:
32: @Test
33: public void testReadBindables() {
34:
35: BeanWithExplicitConverters bean = new BeanWithExplicitConverters();
36: BindAnnotationReader bindablesReader = new BindAnnotationReader();
37: BindConvertInfo bindConvertInfo = bindablesReader
38: .readBindables(bean);
39: Map<String, BindHandler> bindables = bindConvertInfo
40: .getBindMap();
41:
42: BindHandler bh1 = bindables.get("startDate");
43: assert null != bh1;
44:
45: BindSimpleHandler handler1 = (BindSimpleHandler) bh1;
46: assert handler1.getConverter() instanceof DatePatternConverter;
47: assert handler1.getConverterClass().equals(
48: DatePatternConverter.class);
49:
50: BindHandler bh2 = bindables.get("selectedStartDate");
51: assert null != bh2;
52:
53: BindSelectHandler selectHandler1 = (BindSelectHandler) bh2;
54: assert selectHandler1.getConverter() instanceof DatePatternConverter;
55: assert selectHandler1.getConverterClass().equals(
56: DatePatternConverter.class);
57:
58: BindHandler bh3 = bindables.get("startDateWithout");
59: assert null != bh3;
60:
61: BindSimpleHandler handler2 = (BindSimpleHandler) bh3;
62: assert handler2.getConverter() != null;
63: assert handler2.getConverterClass().equals(
64: SafeBeanUtilsConverter.class);
65:
66: BindHandler bh4 = bindables.get("selectedStartDateWithout");
67: assert null != bh4;
68:
69: BindSelectHandler selectHandler2 = (BindSelectHandler) bh4;
70: assert selectHandler2.getConverter() instanceof SafeBeanUtilsConverter;
71: assert selectHandler2.getConverterClass().equals(
72: SafeBeanUtilsConverter.class);
73:
74: }
75:
76: }
|