1   /*
2    * Copyright 2004-2008 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.uruma.binding.value;
17  
18  import junit.framework.TestCase;
19  
20  import org.seasar.framework.beans.PropertyDesc;
21  import org.seasar.uruma.component.UIComponent;
22  
23  /**
24   * {@link ValueBinderFactory} のためのテストクラスです。<br />
25   * 
26   * @author y-komori
27   */
28  public class ValueBinderFactoryTest extends TestCase {
29      /**
30       * {@link ValueBinderFactory#addValueBinder(ValueBinder)} メソッドのテストです。<br />
31       */
32      public void testAddValueBinder() {
33          assertNull("1", ValueBinderFactory.getValueBinder(TestWidget.class));
34  
35          TestValueBinder binder = new TestValueBinder();
36          ValueBinderFactory.addValueBinder(binder);
37  
38          assertEquals("2", binder, ValueBinderFactory
39                  .getValueBinder(TestWidget.class));
40  
41      }
42  
43      class TestWidget {
44      }
45  
46      class TestValueBinder implements ValueBinder {
47          public void exportSelection(final Object widget, final Object formObj,
48                  final PropertyDesc propDesc, final UIComponent uiComp) {
49              // Do nothing.
50          }
51  
52          public void exportValue(final Object widget, final Object formObj,
53                  final PropertyDesc propDesc, final UIComponent uiComp) {
54              // Do nothing.
55          }
56  
57          public Class<?> getWidgetType() {
58              return TestWidget.class;
59          }
60  
61          public void importSelection(final Object widget, final Object formObj,
62                  final PropertyDesc propDesc, final UIComponent uiComp) {
63              // Do nothing.
64          }
65  
66          public void importValue(final Object widget, final Object formObj,
67                  final PropertyDesc propDesc, final UIComponent uiComp) {
68              // Do nothing.
69          }
70      }
71  }