1   package org.apache.turbine.util;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import junit.framework.TestSuite;
23  
24  import org.apache.commons.configuration.BaseConfiguration;
25  import org.apache.commons.configuration.Configuration;
26  
27  import org.apache.turbine.services.ServiceManager;
28  import org.apache.turbine.services.TurbineServices;
29  import org.apache.turbine.test.BaseTestCase;
30  import org.apache.turbine.util.parser.ParserUtils;
31  
32  /***
33   * Testing of the DynamicURI class
34   *
35   * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
36   * @version $Id: DynamicURITest.java 534527 2007-05-02 16:10:59Z tv $
37   */
38  public class DynamicURITest extends BaseTestCase
39  {
40      private DynamicURI duri;
41  
42      /***
43       * Constructor for test.
44       *
45       * @param testName name of the test being executed
46       */
47      public DynamicURITest(String testName)
48              throws Exception
49      {
50          super(testName);
51  
52          // Setup configuration
53          ServiceManager serviceManager = TurbineServices.getInstance();
54          serviceManager.setApplicationRoot(".");
55          Configuration cfg = new BaseConfiguration();
56          cfg.setProperty(ParserUtils.URL_CASE_FOLDING_KEY,
57                  ParserUtils.URL_CASE_FOLDING_LOWER_VALUE );
58          serviceManager.setConfiguration(cfg);
59  
60      }
61  
62      /***
63       * Performs any initialization that must happen before each test is run.
64       */
65      protected void setUp()
66      {
67          ServerData sd = new ServerData("www.testserver.com", 80, "http",
68                  "/servlet/turbine", "/context");
69          duri = new DynamicURI(sd);
70      }
71  
72      /***
73       * Clean up after each test is run.
74       */
75      protected void tearDown()
76      {
77          duri = null;
78      }
79  
80      /***
81       * Factory method for creating a TestSuite for this class.
82       *
83       * @return the test suite
84       */
85      public static TestSuite suite()
86      {
87          TestSuite suite = new TestSuite(DynamicURITest.class);
88          return suite;
89      }
90  
91      public void testAddRemove()
92      {
93          duri.addPathInfo("test","x").removePathInfo("test");
94          duri.addQueryData("test2","x").removeQueryData("test2");
95      }
96  
97  }