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 junitx.framework.ArrayAssert;
19  
20  /**
21   * {@link OmissionArgumentsFilter} のためのテストクラスです。<br />
22   * 
23   * @author y-komori
24   */
25  public class OmissionArgumentsFilterTest extends
26          AbstractArgumentFilterTest<OmissionArgumentsFilter> {
27      /**
28       * {@link OmissionArgumentsFilter#filter(Object[])} メソッドのテストです。<br />
29       */
30      public void testFilter1() throws Exception {
31          OmissionArgumentsFilter filter = createFilter("targetMethod1");
32          // 引数が同数の場合
33          assertNull("1", filter.filter(null));
34  
35          // 引数が多い場合
36          ArrayAssert.assertEquals("2", new Object[] {}, filter
37                  .filter(new Object[] { "test" }));
38      }
39  
40      /**
41       * {@link OmissionArgumentsFilter#filter(Object[])} メソッドのテストです。<br />
42       */
43      public void testFilter2() throws Exception {
44          OmissionArgumentsFilter filter = createFilter("targetMethod2",
45                  Object.class);
46  
47          // 引数が同数の場合
48          Object[] args = new Object[] { "test1" };
49          ArrayAssert.assertEquals("1", args, filter.filter(args));
50  
51          // 引数が多いの場合
52          ArrayAssert.assertEquals("2", args, filter.filter(new Object[] {
53                  "test1", "test2" }));
54      }
55  
56      /**
57       * {@link OmissionArgumentsFilter#filter(Object[])} メソッドのテストです。<br />
58       */
59      public void testFilter3() throws Exception {
60          OmissionArgumentsFilter filter = createFilter("targetMethod3",
61                  Object.class, Object.class);
62  
63          // 引数が同数の場合
64          Object[] args = new Object[] { "test1", "test2" };
65          ArrayAssert.assertEquals("1", args, filter.filter(args));
66  
67          // 引数が多いの場合
68          ArrayAssert.assertEquals("2", args, filter.filter(new Object[] {
69                  "test1", "test2", "test3" }));
70      }
71  
72      /**
73       * テスト対象メソッドです。
74       */
75      public void targetMethod1() {
76  
77      }
78  
79      /**
80       * テスト対象メソッドです。
81       */
82      public void targetMethod2(final Object arg1) {
83  
84      }
85  
86      /**
87       * テスト対象メソッドです。
88       */
89      public void targetMethod3(final Object arg1, final Object arg2) {
90  
91      }
92  
93      /*
94       * @see org.seasar.uruma.binding.method.impl.AbstractArgumentFilterTest#getFilterType()
95       */
96      @Override
97      protected Class<OmissionArgumentsFilter> getFilterType() {
98          return OmissionArgumentsFilter.class;
99      }
100 }