URLConnectionFactory { public URLConnection openConnection(URL url) throws IOException { try { return openConnection(url, false); } catch (AuthenticationException e) { return null; } } @VisibleForTesting  URLConnectionFactory(ConnectionConfigurator connConfigurator); static URLConnectionFactory newDefaultURLConnectionFactory(
      Configuration conf); static URLConnectionFactory newOAuth2URLConnectionFactory(
      Configuration conf); URLConnection openConnection(URL url); URLConnection openConnection(URL url, boolean isSpnego); final static int DEFAULT_SOCKET_TIMEOUT; static final URLConnectionFactory DEFAULT_SYSTEM_CONNECTION_FACTORY; }
@Test public void testConnConfiguratior() throws IOException { final URL u = new URL("http: final List<HttpURLConnection> conns = Lists.newArrayList(); URLConnectionFactory fc = new URLConnectionFactory(new ConnectionConfigurator() { @Override public HttpURLConnection configure(HttpURLConnection conn) throws IOException { Assert.assertEquals(u, conn.getURL()); conns.add(conn); return conn; } }); fc.openConnection(u); Assert.assertEquals(1, conns.size()); }