1 package com.tonbeller.wcf.utils; 2 3 import java.io.UnsupportedEncodingException ; 4 5 import junit.framework.TestCase; 6 7 public class JDK13UtilsTest extends TestCase { 8 public void testEncode() throws UnsupportedEncodingException { 9 boolean is13 = System.getProperty("java.vm.version").startsWith("1.3"); 10 11 String s1 = JDK13Utils.urlEncode("ß", "ISO-8859-1"); 12 String s2 = JDK13Utils.urlEncode("ß", "UTF-8"); 13 if (is13) 14 assertEquals(s1, s2); 15 else 16 assertNotSame(s1, s2); 17 } 18 19 20 class Ex extends RuntimeException { 21 Ex() { 22 cause = this; 23 } 24 Ex(String message) { 25 super(message); 26 cause = this; 27 } 28 Ex(String message, Throwable cause) { 29 super(message); 30 this.cause = cause; 31 } 32 Throwable cause; 33 public Throwable getCause() { 34 return cause; 35 } 36 } 37 public void testCause1() { 38 Exception c = new Ex("cause"); 39 Exception w = new Ex("wrapper", c); 40 assertEquals(c, JDK13Utils.getCause(w)); 41 } 42 43 public void testCause2() { 44 assertNull(JDK13Utils.getCause(new Ex())); 45 } 46 47 } 48 | Popular Tags |