KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > util > uri > TurbineURITest


1 package org.apache.turbine.util.uri;
2
3 /*
4  * Copyright 2001-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
19 import junit.framework.TestSuite;
20
21 import org.apache.commons.configuration.BaseConfiguration;
22 import org.apache.commons.configuration.Configuration;
23
24 import org.apache.turbine.services.ServiceManager;
25 import org.apache.turbine.services.TurbineServices;
26 import org.apache.turbine.test.BaseTestCase;
27 import org.apache.turbine.util.ServerData;
28 import org.apache.turbine.util.parser.ParserUtils;
29
30 /**
31  * Testing of the TurbineURI class
32  *
33  * @author <a HREF="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
34  * @version $Id: TurbineURITest.java,v 1.2.2.2 2004/05/20 03:33:12 seade Exp $
35  */

36 public class TurbineURITest extends BaseTestCase
37 {
38     private TurbineURI turi;
39
40     /**
41      * Constructor for test.
42      *
43      * @param testName name of the test being executed
44      */

45     public TurbineURITest(String JavaDoc testName)
46             throws Exception JavaDoc
47     {
48         super(testName);
49
50         // Setup configuration
51
ServiceManager serviceManager = TurbineServices.getInstance();
52         serviceManager.setApplicationRoot(".");
53         Configuration cfg = new BaseConfiguration();
54         cfg.setProperty(ParserUtils.URL_CASE_FOLDING_KEY,
55                 ParserUtils.URL_CASE_FOLDING_LOWER_VALUE );
56         serviceManager.setConfiguration(cfg);
57
58     }
59
60     /**
61      * Performs any initialization that must happen before each test is run.
62      */

63     protected void setUp()
64     {
65         ServerData sd = new ServerData("www.testserver.com",
66                 URIConstants.HTTP_PORT, URIConstants.HTTP,
67                 "/servlet/turbine", "/context");
68         turi = new TurbineURI(sd);
69     }
70
71     /**
72      * Clean up after each test is run.
73      */

74     protected void tearDown()
75     {
76         turi = null;
77     }
78
79     /**
80      * Factory method for creating a TestSuite for this class.
81      *
82      * @return the test suite
83      */

84     public static TestSuite suite()
85     {
86         TestSuite suite = new TestSuite(TurbineURITest.class);
87         return suite;
88     }
89
90     public void testAddRemove()
91     {
92         assertEquals("TurbineURI should not have a pathInfo", false, turi.hasPathInfo());
93         assertEquals("TurbineURI must not have a queryData", false, turi.hasQueryData());
94         turi.addPathInfo("test","x");
95         assertEquals("TurbineURI must have a pathInfo", true, turi.hasPathInfo());
96         assertEquals("TurbineURI must not have a queryData", false, turi.hasQueryData());
97         turi.removePathInfo("test");
98         assertEquals("TurbineURI must not have a pathInfo", false, turi.hasPathInfo());
99         assertEquals("TurbineURI must not have a queryData", false, turi.hasQueryData());
100
101         assertEquals("TurbineURI should not have a queryData", false, turi.hasQueryData());
102         assertEquals("TurbineURI must not have a pathInfo", false, turi.hasPathInfo());
103         turi.addQueryData("test","x");
104         assertEquals("TurbineURI must have a queryData", true, turi.hasQueryData());
105         assertEquals("TurbineURI must not have a pathInfo", false, turi.hasPathInfo());
106         turi.removeQueryData("test");
107         assertEquals("TurbineURI must not have a queryData", false, turi.hasQueryData());
108         assertEquals("TurbineURI must not have a pathInfo", false, turi.hasPathInfo());
109     }
110
111 }
112
Popular Tags