1   /*
2    * Copyright 2002-2004 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.springframework.richclient.command.support;
17  
18  import junit.framework.TestCase;
19  
20  public class MethodInvokingActionCommandExecutorTests extends TestCase {
21  
22      private MethodInvokingActionCommandExecutor e = new MethodInvokingActionCommandExecutor();
23  
24      private int invokeCount;
25  
26      protected void setUp() throws Exception {
27          e = new MethodInvokingActionCommandExecutor();
28          e.setTargetObject(this);
29          e.setArguments(new Object[0]);
30          e.setTargetMethod("targetMethod");
31          e.afterPropertiesSet();
32      }
33  
34      public void testExceuteInvokesMethod() {
35          e.execute();
36          assertEquals("Execute should have invoked targetMethod", 1, invokeCount);
37  
38          e.execute();
39          assertEquals("Execute should have invoked targetMethod", 2, invokeCount);
40      }
41  
42      public void targetMethod() {
43          invokeCount++;
44      }
45  }