1 package org.jahia.urls; 2 3 import junit.framework.*; 4 import java.net.*; 5 import javax.servlet.http.*; 6 import java.io.UnsupportedEncodingException ; 7 8 public class TestURI extends TestCase { 9 private URI uRI = null; 10 private final String uriTest1 = "http://login:password@host/path1/path2/filename?name1=value2&name2=value2#fragment"; 11 private final String uriTest2 = "http://login:password@host/path1_éàéà/path2_äöü/file name.txt.txtàéàéà?name1_éàéà=value2_éàéàé&name2_öüöüö=value2_öüöüöü#fragment_éèéèéè!"; 12 13 protected void setUp() throws Exception { 14 super.setUp(); 15 16 uRI = new URI(); 17 } 18 19 protected void tearDown() throws Exception { 20 uRI = null; 21 super.tearDown(); 22 } 23 24 public void testURI() { 25 uRI = new URI(); 26 27 } 28 29 public void testURI1() { 30 String uri = null; 31 uRI = new URI(uriTest1); 32 String expectedReturn = uriTest1; 33 String actualReturn = uRI.toString(); 34 assertEquals("return value", expectedReturn, actualReturn); 35 uRI = new URI(uriTest2); 36 expectedReturn = uriTest2; 37 try { 38 System.out.println(uriTest2); 39 System.out.println("becomes with .toString(\"UTF-8\")"); 40 System.out.println(uRI.toString("UTF-8")); 41 actualReturn = URICodec.decode(uRI.toString("UTF-8"), "UTF-8"); 42 assertEquals("return value", expectedReturn, actualReturn); 43 } catch (UnsupportedEncodingException uee) { 44 uee.printStackTrace(); 45 } 46 try { 47 System.out.println(uriTest2); 48 System.out.println("becomes with .toString(\"ISO-8859-1\")"); 49 System.out.println(uRI.toString("ISO-8859-1")); 50 actualReturn = URICodec.decode(uRI.toString("ISO-8859-1"), "ISO-8859-1"); 51 assertEquals("return value", expectedReturn, actualReturn); 52 } catch (UnsupportedEncodingException uee) { 53 uee.printStackTrace(); 54 } 55 uri = null; 56 uRI = new URI(uri); 57 } 58 59 public void testGetAuthority() { 60 String expectedReturn = null; 61 String actualReturn = uRI.getAuthority(); 62 assertEquals("return value", expectedReturn, actualReturn); 63 64 } 65 66 public void testGetFragmentString() { 67 String expectedReturn = null; 68 String actualReturn = uRI.getFragmentString(); 69 assertEquals("return value", expectedReturn, actualReturn); 70 71 } 72 73 public void testGetHostName() { 74 String expectedReturn = null; 75 String actualReturn = uRI.getHostName(); 76 assertEquals("return value", expectedReturn, actualReturn); 77 78 } 79 80 public void testGetPath() { 81 String expectedReturn = null; 82 String actualReturn = uRI.getPath(); 83 assertEquals("return value", expectedReturn, actualReturn); 84 85 } 86 87 public void testGetPort() { 88 int expectedReturn = -1; 89 int actualReturn = uRI.getPort(); 90 assertEquals("return value", expectedReturn, actualReturn); 91 92 } 93 94 public void testGetQueryString() { 95 String expectedReturn = null; 96 String actualReturn = uRI.getQueryString(); 97 assertEquals("return value", expectedReturn, actualReturn); 98 99 } 100 101 public void testGetScheme() { 102 String expectedReturn = null; 103 String actualReturn = uRI.getScheme(); 104 assertEquals("return value", expectedReturn, actualReturn); 105 106 } 107 108 public void testGetUserInfo() { 109 String expectedReturn = null; 110 String actualReturn = uRI.getUserInfo(); 111 assertEquals("return value", expectedReturn, actualReturn); 112 113 } 114 115 public void testIsURIStartingAtPath() { 116 boolean expectedReturn = false; 117 boolean actualReturn = uRI.isURIStartingAtPath(); 118 assertEquals("return value", expectedReturn, actualReturn); 119 120 } 121 122 public void testSetAuthority() { 123 String authority = null; 124 uRI.setAuthority(authority); 125 126 } 127 128 public void testSetFragmentString() { 129 String fragmentString = null; 130 uRI.setFragmentString(fragmentString); 131 132 } 133 134 public void testSetHostName() { 135 String hostName = null; 136 uRI.setHostName(hostName); 137 138 } 139 140 public void testSetPath() { 141 String path = null; 142 uRI.setPath(path); 143 144 } 145 146 public void testSetPort() { 147 int port = 0; 148 uRI.setPort(port); 149 150 } 151 152 public void testSetQueryString() { 153 String queryString = null; 154 uRI.setQueryString(queryString); 155 156 } 157 158 public void testSetScheme() { 159 String scheme = null; 160 uRI.setScheme(scheme); 161 162 } 163 164 public void testSetURI() { 165 String uri = null; 166 uRI.setURI(uri); 167 168 } 169 170 public void testSetURI1() { 171 URL javaURL = null; 172 uRI.setURI(javaURL); 173 174 } 175 176 public void testSetURIStartingAtPath() { 177 boolean uriStartingAtPath = false; 178 uRI.setURIStartingAtPath(uriStartingAtPath); 179 180 } 181 182 public void testSetUserInfo() { 183 String userInfo = null; 184 uRI.setUserInfo(userInfo); 185 186 } 187 188 public void testToString() { 189 String expectedReturn = null; 190 String actualReturn = uRI.toString(); 191 assertEquals("return value", expectedReturn, actualReturn); 192 193 } 194 195 public void testToString1() { 196 HttpServletResponse response = null; 197 String expectedReturn = null; 198 String actualReturn = uRI.toString(response); 199 assertEquals("return value", expectedReturn, actualReturn); 200 201 } 202 203 public void testToString2() { 204 HttpServletResponse response = null; 205 String encoding = null; 206 String expectedReturn = null; 207 String actualReturn = uRI.toString(response, encoding); 208 assertEquals("return value", expectedReturn, actualReturn); 209 210 } 211 212 public void testToString3() { 213 String encoding = null; 214 String expectedReturn = null; 215 String actualReturn = uRI.toString(encoding); 216 assertEquals("return value", expectedReturn, actualReturn); 217 218 } 219 220 } 221 | Popular Tags |