### Question:
BasePlugin implements Plugin<Project>, ToolingRegistryProvider { @VisibleForTesting static Proxy createProxy(@NonNull Properties properties, @NonNull ILogger logger) { String host = properties.getProperty("https.proxyHost"); int port = 443; if (host != null) { String maybePort = properties.getProperty("https.proxyPort"); if (maybePort != null) { try { port = Integer.parseInt(maybePort); } catch (NumberFormatException e) { logger.lifecycle( "Invalid https.proxyPort '" + maybePort + "', using default 443"); } } } else { host = properties.getProperty("http.proxyHost"); if (host != null) { port = 80; String maybePort = properties.getProperty("http.proxyPort"); if (maybePort != null) { try { port = Integer.parseInt(maybePort); } catch (NumberFormatException e) { logger.lifecycle( "Invalid http.proxyPort '" + maybePort + "', using default 80"); } } } } if (host != null) { InetSocketAddress proxyAddr = createAddress(host, port); if (proxyAddr != null) { return new Proxy(Proxy.Type.HTTP, proxyAddr); } } return Proxy.NO_PROXY; } BasePlugin(@NonNull ToolingModelBuilderRegistry registry); @VisibleForTesting VariantManager getVariantManager(); BaseExtension getExtension(); @Override final void apply(@NonNull Project project); static void createLintClasspathConfiguration(@NonNull Project project); @NonNull @Override ToolingModelBuilderRegistry getModelBuilderRegistry(); @VisibleForTesting
    static final GradleVersion GRADLE_MIN_VERSION; }### Answer:
@Test public void createProxy() throws Exception { MockLog log = new MockLog(); Properties properties = new Properties(); InetAddress loopback = InetAddress.getByName(null); properties.setProperty("https.proxyHost", "localhost"); Proxy proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress(loopback, 443), proxy.address()); assertTrue(log.getMessages().isEmpty()); properties.setProperty("https.proxyPort", "123"); proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress(loopback, 123), proxy.address()); assertTrue(log.getMessages().isEmpty()); properties.setProperty("https.proxyPort", "bad"); proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress(loopback, 443), proxy.address()); assertTrue(log.getMessages().get(0).contains("bad")); assertTrue(log.getMessages().get(0).contains("443")); log.clear(); properties.clear(); properties.setProperty("https.proxyHost", "localhost"); properties.setProperty("http.proxyHost", "8.8.8.8"); proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress(loopback, 443), proxy.address()); properties.clear(); properties.setProperty("http.proxyHost", "8.8.8.8"); proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress("8.8.8.8", 80), proxy.address()); properties.setProperty("http.proxyPort", "123"); proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress("8.8.8.8", 123), proxy.address()); properties.setProperty("http.proxyPort", "bad"); proxy = BasePlugin.createProxy(properties, log); assertEquals(new InetSocketAddress("8.8.8.8", 80), proxy.address()); assertTrue(log.getMessages().get(0).contains("bad")); assertTrue(log.getMessages().get(0).contains("80")); log.clear(); }