1 32 package net.sf.retrotranslator.runtime.java.net; 33 34 import java.io.IOException ; 35 import java.net.*; 36 import java.util.List ; 37 import junit.framework.TestCase; 38 39 42 public class ProxySelector_TestCase extends TestCase { 43 44 private ProxySelector defaultSelector; 45 46 protected void setUp() throws Exception { 47 super.setUp(); 48 defaultSelector = ProxySelector.getDefault(); 49 } 50 51 protected void tearDown() throws Exception { 52 ProxySelector.setDefault(defaultSelector); 53 super.tearDown(); 54 } 55 56 public void test() throws Exception { 57 ProxySelector selector = new ProxySelector() { 58 public List <Proxy> select(URI uri) { 59 return null; 60 } 61 62 public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { 63 } 64 }; 65 ProxySelector.setDefault(selector); 66 assertSame(selector, ProxySelector.getDefault()); 67 URI uri = new URI("http://localhost"); 68 selector.select(uri); 69 selector.connectFailed(uri, null, null); 70 } 71 72 } | Popular Tags |