### Question:
BaseRequest implements HttpRequest<T, U> { @Override public void cancelRequest() { mCanceled = true; close(); } BaseRequest(); @Override void cancelRequest(); @Override synchronized void close(); @NonNull @Override String toString(); @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
    public ConnectionParameters mConnParams; }### Answer:
@Test public void cancelRequest() throws Exception { mExpectedEx.expect(IOException.class); mExpectedEx.expectMessage("Canceled"); mEndPoint.enqueueReturnSuccessEmptyBody(1); mRequest.mUri = Uri.parse(mEndPoint.getUrl()); mRequest.mConnParams = new ConnectionParameters.ParameterBuilder() .setRequestMethod(ConnectionParameters.RequestMethod.GET) .create(); AtomicReference<Exception> exception = new AtomicReference<>(); Thread t = new Thread(() -> { try { mRequest.openConnection(mHttpClient); } catch (Exception e) { exception.set(e); } }); t.start(); mRequest.cancelRequest(); t.join(); if (exception.get() != null) { throw exception.get(); } }