1 package org.apache.turbine; 2 3 56 57 import junit.framework.Test; 58 import junit.framework.TestCase; 59 import junit.framework.TestSuite; 60 61 68 public class DynamicURITest 69 extends TestCase 70 { 71 74 public DynamicURITest(String testName) 75 { 76 super(testName); 77 } 78 79 82 public static Test suite() 83 { 84 return new TestSuite(DynamicURITest.class); 85 } 86 87 90 public void setUp() 91 { 92 } 94 95 98 public void tearDown() 99 { 100 } 102 103 110 public void testFastEncoding() 111 { 112 char[] allchars = new char[65546]; 113 allchars[0] = 's'; 114 allchars[1] = 't'; 115 allchars[2] = 'a'; 116 allchars[3] = 'r'; 117 allchars[4] = 't'; 118 allchars[5] = ' '; 119 allchars[6] = 's'; 120 allchars[7] = 'a'; 121 allchars[8] = 'f'; 122 allchars[9] = 'e'; 123 for (int i=0; i<65536; i++) 124 { 125 allchars[i+10] = (char)i; 126 } 127 final String all = new String (allchars); 128 129 StringBuffer out = new StringBuffer (); 131 DynamicURI.writeEncoded(all, out); 132 String reference = out.toString(); 133 134 out = new StringBuffer (); 136 DynamicURI.writeFastEncoded(all, out); 137 String s = out.toString(); 138 139 assertEquals("Test of complete character set failed.", reference, s); 140 141 String in = ":colon as first char"; 143 out = new StringBuffer (); 145 DynamicURI.writeEncoded(in, out); 146 reference = out.toString(); 147 out = new StringBuffer (); 149 DynamicURI.writeFastEncoded(in, out); 150 s = out.toString(); 151 152 assertEquals("Special character as first character failed.", reference, s); 153 154 in = "colon as last char:"; 156 out = new StringBuffer (); 158 DynamicURI.writeEncoded(in, out); 159 reference = out.toString(); 160 out = new StringBuffer (); 162 DynamicURI.writeFastEncoded(in, out); 163 s = out.toString(); 164 165 assertEquals("Special character as last character failed.", reference, s); 166 167 in = "n0special_chars"; 169 out = new StringBuffer (); 171 DynamicURI.writeEncoded(in, out); 172 reference = out.toString(); 173 out = new StringBuffer (); 175 DynamicURI.writeFastEncoded(in, out); 176 s = out.toString(); 177 178 assertEquals("String with no special character failed.", reference, s); 179 } 180 } 181 | Popular Tags |