KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > bean > TestResourceTag


1 /*
2  * $Id: TestResourceTag.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.struts.taglib.bean;
19
20 import java.io.IOException JavaDoc;
21
22 import javax.servlet.ServletException JavaDoc;
23
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.cactus.WebResponse;
28 import org.apache.struts.taglib.TaglibTestBase;
29
30 /**
31  * Suite of unit tests for the
32  * <code>org.apache.struts.taglib.bean.ResourceTag</code> class.
33  *
34  */

35 public class TestResourceTag extends TaglibTestBase {
36     
37     /**
38      * Defines the testcase name for JUnit.
39      *
40      * @param theName the testcase's name.
41      */

42     public TestResourceTag(String JavaDoc theName) {
43         super(theName);
44     }
45
46     /**
47      * Start the tests.
48      *
49      * @param theArgs the arguments. Not used
50      */

51     public static void main(String JavaDoc[] theArgs) {
52         junit.awtui.TestRunner.main(new String JavaDoc[] {TestResourceTag.class.getName()});
53     }
54
55     /**
56      * @return a test suite (<code>TestSuite</code>) that includes all methods
57      * starting with "test"
58      */

59     public static Test suite() {
60         // All methods starting with "test" will be executed in the test suite.
61
return new TestSuite(TestResourceTag.class);
62     }
63     
64     
65     private void formatAndTest(String JavaDoc compare, String JavaDoc output) {
66         //fix for introduced carriage return / line feeds
67
output = replace(output,"\r","");
68         output = replace(output,"\n","");
69         output = output.trim();
70         //System.out.println("Testing [" + compare + "] == [" + output + "]");
71
assertEquals(compare, output);
72     }
73
74     public void testResourceTag() throws IOException JavaDoc, ServletException JavaDoc{
75         request.setAttribute("runTest", "testResourceTag");
76         pageContext.forward("/test/org/apache/struts/taglib/bean/TestResourceTag.jsp");
77     }
78     public void endResourceTag(WebResponse response){
79         formatAndTest("Test Value", response.getText());
80     }
81
82     public void testResourceTagInput() throws IOException JavaDoc, ServletException JavaDoc{
83         request.setAttribute("runTest", "testResourceTagInput");
84         pageContext.forward("/test/org/apache/struts/taglib/bean/TestResourceTag.jsp");
85     }
86     public void endResourceTagInput(WebResponse response){
87         formatAndTest("Test Value", response.getText());
88     }
89
90
91 }
92
Popular Tags