1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
31 public class TestWrappingLookupCommand extends TestCase {
32 public TestWrappingLookupCommand(String _name) {
33 super(_name);
34 }
35
36
37 protected void setUp() {
38 }
39
40
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
69 public static void main(String[] argv) {
70 String[] testCaseList = { TestWrappingLookupCommand.class.getName() };
71
72 junit.textui.TestRunner.main(testCaseList);
73 }
74 }