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.method.impl;
17  
18  import java.lang.reflect.Method;
19  
20  import org.eclipse.swt.events.SelectionEvent;
21  import org.eclipse.swt.widgets.Event;
22  import org.seasar.eclipse.common.util.AbstractShellTest;
23  
24  /**
25   * {@link TypedEventArgumentsFilter} のためのテストクラスです。<br />
26   * 
27   * @author y-komori
28   */
29  public class TypedEventArgumentsFilterTest extends AbstractShellTest {
30  
31      /**
32       * {@link TypedEventArgumentsFilterTest} を構築します。<br />
33       */
34      public TypedEventArgumentsFilterTest() {
35          super(true);
36      }
37  
38      /**
39       * {@link TypedEventArgumentsFilter#filter(Object[])} メソッドのテストです。<br />
40       */
41      public void testFilter() throws Exception {
42          TypedEventArgumentsFilter filter = cleateFilter("targetMethod1",
43                  SelectionEvent.class);
44          Event e = new Event();
45          e.widget = shell;
46          Object[] result = filter.filter(new Object[] { e });
47  
48          assertEquals("1", 1, result.length);
49          assertEquals("2", SelectionEvent.class, result[0].getClass());
50  
51      }
52  
53      private TypedEventArgumentsFilter cleateFilter(final String methodName,
54              final Class<?>... args) throws NoSuchMethodException {
55          Method method = getClass().getMethod(methodName, args);
56          return new TypedEventArgumentsFilter(method);
57      }
58  
59      /**
60       * テスト対象メソッドです。
61       */
62      public void targetMethod1(final SelectionEvent event) {
63  
64      }
65  }