1 package org.apache.turbine.util.uri; 2 3 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 36 public class TurbineURITest extends BaseTestCase 37 { 38 private TurbineURI turi; 39 40 45 public TurbineURITest(String testName) 46 throws Exception 47 { 48 super(testName); 49 50 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 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 74 protected void tearDown() 75 { 76 turi = null; 77 } 78 79 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 |