1 package org.apache.turbine.util.uri;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 264148 2005-08-29 14:21:04Z henning $
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 testName)
46 throws Exception
47 {
48 super(testName);
49
50
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 }