@Test public void getConnection_ProxyIsUsedWhenAvailable_ProxyTypeIsCalled() throws MalformedURLException, IOException { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.example.org", 1234)); when(this.raygunSettings.getHttpProxy()).thenReturn(proxy); HttpURLConnection connection = this.raygunConnection.getConnection("TestKey"); assertNotNull(connection); verify(this.raygunSettings, times(2)).getHttpProxy(); }
public HttpURLConnection getConnection(String apiKey) throws IOException { HttpURLConnection connection = null; URL url = new URL(raygunSettings.getApiEndPoint()); Proxy proxy = raygunSettings.getHttpProxy(); if (proxy != null) { connection = (HttpURLConnection) url.openConnection(proxy); } else { connection = (HttpURLConnection) url.openConnection(); } if (raygunSettings.getConnectTimeout() != null) { connection.setConnectTimeout(raygunSettings.getConnectTimeout()); } connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("X-ApiKey", apiKey); return connection; }
RaygunConnection { public HttpURLConnection getConnection(String apiKey) throws IOException { HttpURLConnection connection = null; URL url = new URL(raygunSettings.getApiEndPoint()); Proxy proxy = raygunSettings.getHttpProxy(); if (proxy != null) { connection = (HttpURLConnection) url.openConnection(proxy); } else { connection = (HttpURLConnection) url.openConnection(); } if (raygunSettings.getConnectTimeout() != null) { connection.setConnectTimeout(raygunSettings.getConnectTimeout()); } connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("X-ApiKey", apiKey); return connection; } }
RaygunConnection { public HttpURLConnection getConnection(String apiKey) throws IOException { HttpURLConnection connection = null; URL url = new URL(raygunSettings.getApiEndPoint()); Proxy proxy = raygunSettings.getHttpProxy(); if (proxy != null) { connection = (HttpURLConnection) url.openConnection(proxy); } else { connection = (HttpURLConnection) url.openConnection(); } if (raygunSettings.getConnectTimeout() != null) { connection.setConnectTimeout(raygunSettings.getConnectTimeout()); } connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("X-ApiKey", apiKey); return connection; } RaygunConnection(RaygunSettings raygunSettings); }
RaygunConnection { public HttpURLConnection getConnection(String apiKey) throws IOException { HttpURLConnection connection = null; URL url = new URL(raygunSettings.getApiEndPoint()); Proxy proxy = raygunSettings.getHttpProxy(); if (proxy != null) { connection = (HttpURLConnection) url.openConnection(proxy); } else { connection = (HttpURLConnection) url.openConnection(); } if (raygunSettings.getConnectTimeout() != null) { connection.setConnectTimeout(raygunSettings.getConnectTimeout()); } connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("X-ApiKey", apiKey); return connection; } RaygunConnection(RaygunSettings raygunSettings); HttpURLConnection getConnection(String apiKey); }
RaygunConnection { public HttpURLConnection getConnection(String apiKey) throws IOException { HttpURLConnection connection = null; URL url = new URL(raygunSettings.getApiEndPoint()); Proxy proxy = raygunSettings.getHttpProxy(); if (proxy != null) { connection = (HttpURLConnection) url.openConnection(proxy); } else { connection = (HttpURLConnection) url.openConnection(); } if (raygunSettings.getConnectTimeout() != null) { connection.setConnectTimeout(raygunSettings.getConnectTimeout()); } connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("X-ApiKey", apiKey); return connection; } RaygunConnection(RaygunSettings raygunSettings); HttpURLConnection getConnection(String apiKey);  }