KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > net > QueryStringTest


1 package org.sapia.ubik.net;
2
3 import junit.framework.TestCase;
4
5
6 /**
7  * @author Yanick Duchesne
8  * <dl>
9  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
10  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
11  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
12  * </dl>
13  */

14 public class QueryStringTest extends TestCase {
15   /**
16    * Constructor for QueryStringTest.
17    */

18   public QueryStringTest(String JavaDoc name) {
19     super(name);
20   }
21
22   public void testParse() throws Exception JavaDoc {
23     String JavaDoc s = "/some/path?name1=value1&name2=value2";
24     QueryString qs = QueryString.parse(s);
25     super.assertEquals("/some/path", qs.getPath());
26     super.assertEquals("value1", qs.getParameter("name1"));
27     super.assertEquals("value2", qs.getParameter("name2"));
28   }
29
30   public void testToString() throws Exception JavaDoc {
31     String JavaDoc s = "/some/path?name1=value1&name2=value2";
32     QueryString qs = QueryString.parse(s);
33     qs = QueryString.parse(qs.toString());
34     super.assertEquals("/some/path", qs.getPath());
35     super.assertEquals("value1", qs.getParameter("name1"));
36     super.assertEquals("value2", qs.getParameter("name2"));
37   }
38
39   public void testInstantiate() throws Exception JavaDoc {
40     QueryString qs = new QueryString("/some/path");
41     qs.addParameter("name1", "value1");
42     qs.addParameter("name2", "value2");
43     super.assertEquals("/some/path", qs.getPath());
44     super.assertEquals("value1", qs.getParameter("name1"));
45     super.assertEquals("value2", qs.getParameter("name2"));
46   }
47 }
48
Popular Tags