### Question:
HttpClientImpl implements OktaHttpClient { @Override public void cancel() { if (mUrlConnection != null) { mUrlConnection.disconnect(); } }  @Override InputStream connect(@NonNull Uri uri, @NonNull ConnectionParameters params); @Override void cleanUp(); @Override void cancel(); @Override Map<String, List<String>> getHeaderFields(); @Override String getHeader(String header); @Override int getResponseCode(); @Override int getContentLength(); @Override String getResponseMessage(); @VisibleForTesting HttpURLConnection getUrlConnection();  }### Answer:
@Test public void cancel() throws AuthorizationException { mEndPoint.enqueueUserInfoSuccess(5); final CountDownLatch latch = new CountDownLatch(1); final JSONObject[] result = new JSONObject[1]; final AuthorizationException[] exception = new AuthorizationException[1]; Thread t = new Thread(() -> { try { result[0] = mRequest.executeRequest(mHttpClient); } catch (AuthorizationException e) { exception[0] = e; } }); t.start(); mHttpClient.cancel(); if (exception[0] != null) { String errorMessage = exception[0].getMessage(); assertTrue("Canceled".equals(errorMessage) || "stream is closed".equals(errorMessage)); } else { assertNull(result[0]); } }