KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > util > ParamEncoderTest


1 package org.displaytag.util;
2
3 import junit.framework.TestCase;
4
5
6 /**
7  * Tests for ParamEncoder.
8  * @author Fabrizio Giustina
9  * @version $Revision: 707 $ ($Author: fgiust $)
10  */

11 public class ParamEncoderTest extends TestCase
12 {
13
14     /**
15      * @see junit.framework.TestCase#getName()
16      */

17     public String JavaDoc getName()
18     {
19         return getClass().getName() + "." + super.getName();
20     }
21
22     /**
23      * Test for reported DISPL-12.
24      */

25     public void testOptionAndAnswer()
26     {
27         assertFalse("id \"option\" and \"answer\" produce the same parameter", new ParamEncoder("option")
28             .encodeParameterName("x")
29             .equals(new ParamEncoder("answer").encodeParameterName("x")));
30     }
31
32     /**
33      * Same parameter produce the same result.
34      */

35     public void testEquals()
36     {
37         assertEquals("The same parameter should produce equals key.", new ParamEncoder("equals")
38             .encodeParameterName("x"), (new ParamEncoder("equals").encodeParameterName("x")));
39     }
40
41     /**
42      * We don't wont param names to be too long.
43      */

44     public void testNotTooLong()
45     {
46         assertTrue(new ParamEncoder("averyveryveryveryveryveryverylongidvalue").encodeParameterName("x").length() < 12);
47         assertTrue(new ParamEncoder("test").encodeParameterName("x").length() < 12);
48         assertTrue(new ParamEncoder("a").encodeParameterName("x").length() < 12);
49         assertTrue(new ParamEncoder("xxxxxxxxxxxx").encodeParameterName("x").length() < 12);
50         assertTrue(new ParamEncoder("xxxxxxxxxxxxxxxxxxxxxxxxxxxx").encodeParameterName("x").length() < 12);
51     }
52 }
53
Popular Tags