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