KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > servletunit > struts > tests > TestNoRequestPathInfo


1 // StrutsTestCase - a JUnit extension for testing Struts actions
2
// within the context of the ActionServlet.
3
// Copyright (C) 2002 Deryl Seale
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the Apache Software License as
7
// published by the Apache Software Foundation; either version 1.1
8
// of the License, or (at your option) any later version.
9
//
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
package servletunit.struts.tests;
17
18 import servletunit.struts.MockStrutsTestCase;
19 import java.io.File JavaDoc;
20 /**
21  *
22  * <p>Title: TestNoRequestPathInfo</p>
23  * <p>Description: Confirms correct behavior if
24  * actionPerfoem() is called prior to calling
25  * setRequestPathInfo().</p>
26  * <p>Copyright: Copyright (c) 2003</p>
27  * @author Sean Pritchard
28  * @version 1.0
29  */

30 public class TestNoRequestPathInfo extends MockStrutsTestCase {
31
32     public TestNoRequestPathInfo() {
33     }
34
35     public void setUp() throws Exception JavaDoc {
36         super.setUp();
37         this.setContextDirectory(new File JavaDoc(System.getProperty("basedir") + "/src/examples"));
38         setConfigFile("/WEB-INF/struts-config-test.xml");
39     }
40
41     /**
42      * this test assumes that web.xml and struts-config.xml
43      * can be found. If these files are found,
44      * but no request path is set prior to calling
45      * actionPerform(), we expect an IllegalStateException
46      */

47     public void testNoRequestPathInfo(){
48         try{
49             actionPerform();
50             fail("IllegalStateException expected");
51         }catch(IllegalStateException JavaDoc e){
52             //expected
53
}
54     }
55 }
Popular Tags