1   package org.apache.turbine.util;
2   
3   /*
4    * Copyright 2001-2005 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.parser.ParserUtils;
28  
29  /***
30   * Testing of the DynamicURI class
31   *
32   * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
33   * @version $Id: DynamicURITest.java 264148 2005-08-29 14:21:04Z henning $
34   */
35  public class DynamicURITest extends BaseTestCase
36  {
37      private DynamicURI duri;
38  
39      /***
40       * Constructor for test.
41       *
42       * @param testName name of the test being executed
43       */
44      public DynamicURITest(String testName)
45              throws Exception
46      {
47          super(testName);
48  
49          // Setup configuration
50          ServiceManager serviceManager = TurbineServices.getInstance();
51          serviceManager.setApplicationRoot(".");
52          Configuration cfg = new BaseConfiguration();
53          cfg.setProperty(ParserUtils.URL_CASE_FOLDING_KEY,
54                  ParserUtils.URL_CASE_FOLDING_LOWER_VALUE );
55          serviceManager.setConfiguration(cfg);
56  
57      }
58  
59      /***
60       * Performs any initialization that must happen before each test is run.
61       */
62      protected void setUp()
63      {
64          ServerData sd = new ServerData("www.testserver.com", 80, "http",
65                  "/servlet/turbine", "/context");
66          duri = new DynamicURI(sd);
67      }
68  
69      /***
70       * Clean up after each test is run.
71       */
72      protected void tearDown()
73      {
74          duri = null;
75      }
76  
77      /***
78       * Factory method for creating a TestSuite for this class.
79       *
80       * @return the test suite
81       */
82      public static TestSuite suite()
83      {
84          TestSuite suite = new TestSuite(DynamicURITest.class);
85          return suite;
86      }
87  
88      public void testAddRemove()
89      {
90          duri.addPathInfo("test","x").removePathInfo("test");
91          duri.addQueryData("test2","x").removeQueryData("test2");
92      }
93  
94  }