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