View Javadoc

1   /*
2    * $Id: TestWrappingLookupCommand.java 421119 2006-07-12 04:49:11Z wsmoak $
3    *
4    * Copyright 2003,2004 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts.chain.commands.generic;
19  
20  import junit.framework.TestCase;
21  
22  import org.apache.commons.chain.Context;
23  import org.apache.commons.chain.impl.ContextBase;
24  import org.apache.commons.chain.web.servlet.ServletWebContext;
25  import org.apache.struts.chain.contexts.ServletActionContext;
26  
27  /* JUnitTest case for class: org.apache.struts.chain.commands.generic.WrappingLookupCommand */
28  public class TestWrappingLookupCommand extends TestCase {
29      public TestWrappingLookupCommand(String _name) {
30          super(_name);
31      }
32  
33      /* setUp method for test case */
34      protected void setUp() {
35      }
36  
37      /* tearDown method for test case */
38      protected void tearDown() {
39      }
40  
41      public void testSame() throws Exception {
42          WrappingLookupCommand command = new WrappingLookupCommand();
43          Context testContext = new ContextBase();
44  
45          Context wrapped = command.getContext(testContext);
46  
47          assertNotNull(wrapped);
48          assertSame(testContext, wrapped);
49      }
50  
51      public void testWrapContextSubclass()
52          throws Exception {
53          WrappingLookupCommand command = new WrappingLookupCommand();
54  
55          command.setWrapperClassName(ServletActionContext.class.getName());
56  
57          Context testContext = new ServletWebContext();
58  
59          Context wrapped = command.getContext(testContext);
60  
61          assertNotNull(wrapped);
62          assertTrue(wrapped instanceof ServletActionContext);
63      }
64  
65      /* Executes the test case */
66      public static void main(String[] argv) {
67          String[] testCaseList = { TestWrappingLookupCommand.class.getName() };
68  
69          junit.textui.TestRunner.main(testCaseList);
70      }
71  }