01: // StrutsTestCase - a JUnit extension for testing Struts actions
02: // within the context of the ActionServlet.
03: // Copyright (C) 2002 Deryl Seale
04: //
05: // This library is free software; you can redistribute it and/or
06: // modify it under the terms of the Apache Software License as
07: // published by the Apache Software Foundation; either version 1.1
08: // of the License, or (at your option) any later version.
09: //
10: // This library is distributed in the hope that it will be useful,
11: // but WITHOUT ANY WARRANTY; without even the implied warranty of
12: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: // Apache Software Foundation Licens for more details.
14: //
15: // You may view the full text here: http://www.apache.org/LICENSE.txt
16:
17: package servletunit.struts.tests;
18:
19: import servletunit.struts.MockStrutsTestCase;
20:
21: import java.io.File;
22:
23: /**
24: * A Junit test of the MockStrutsTestCase
25: * @author Sean Pritchard
26: */
27:
28: public class TestMockStrutsTestCase extends MockStrutsTestCase {
29:
30: public TestMockStrutsTestCase(String testCase) {
31: super (testCase);
32: }
33:
34: public void setUp() throws Exception {
35: super .setUp();
36: setServletConfigFile("/WEB-INF/web.xml");
37: }
38:
39: public void testSetInitParameter() throws Exception {
40: setInitParameter("testName", "testValue");
41: assertEquals("testValue", getActionServlet().getInitParameter(
42: "testName"));
43: }
44:
45: public void testSetContextDirectory() {
46: File file = new File(System.getProperty("basedir"));
47: setContextDirectory(file);
48: assertEquals(new File(file, "test.html").getAbsolutePath(),
49: getRequest().getRealPath("/test.html"));
50: }
51:
52: public void testGetRealPathNotSet() {
53: assertNull(getRequest().getRealPath("/test.html"));
54: }
55:
56: }
|