@Test public void checksRequestTimeoutFailure() throws Exception { Context mockedContext = getMockedContext(); MapboxTelemetry.applicationContext = mockedContext; OkHttpClient localOkHttpClientWithShortTimeout = new OkHttpClient.Builder() .readTimeout(100, TimeUnit.MILLISECONDS) .build(); HttpUrl localUrl = obtainBaseEndpointUrl(); TelemetryClientSettings telemetryClientSettings = new TelemetryClientSettings.Builder(mockedContext) .client(localOkHttpClientWithShortTimeout) .baseUrl(localUrl) .sslSocketFactory(clientCertificates.sslSocketFactory()) .x509TrustManager(clientCertificates.trustManager()) .hostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }) .build(); String anyUserAgent = "anyUserAgent"; TelemetryClient telemetryClient = new TelemetryClient("anyAccessToken", anyUserAgent, anyUserAgent, telemetryClientSettings, mock(Logger.class), mock(CertificateBlacklist.class), false); List<Event> theEvent = obtainAnEvent(); final CountDownLatch latch = new CountDownLatch(1); final AtomicReference<String> bodyRef = new AtomicReference<>(); final AtomicBoolean failureRef = new AtomicBoolean(); Callback aCallback = provideACallback(latch, bodyRef, failureRef); enqueueMockNoResponse(504); telemetryClient.sendEvents(theEvent, aCallback, false); latch.await(); assertTrue(failureRef.get()); }
void sendEvents(List<Event> events, Callback callback, boolean serializeNulls) { sendBatch(Collections.unmodifiableList(events), callback, serializeNulls); }
TelemetryClient { void sendEvents(List<Event> events, Callback callback, boolean serializeNulls) { sendBatch(Collections.unmodifiableList(events), callback, serializeNulls); } }
TelemetryClient { void sendEvents(List<Event> events, Callback callback, boolean serializeNulls) { sendBatch(Collections.unmodifiableList(events), callback, serializeNulls); } TelemetryClient(String accessToken, String userAgent, String reformedUserAgent, TelemetryClientSettings setting,
                  Logger logger, CertificateBlacklist certificateBlacklist, boolean isCnRegion); }
TelemetryClient { void sendEvents(List<Event> events, Callback callback, boolean serializeNulls) { sendBatch(Collections.unmodifiableList(events), callback, serializeNulls); } TelemetryClient(String accessToken, String userAgent, String reformedUserAgent, TelemetryClientSettings setting,
                  Logger logger, CertificateBlacklist certificateBlacklist, boolean isCnRegion);  }
TelemetryClient { void sendEvents(List<Event> events, Callback callback, boolean serializeNulls) { sendBatch(Collections.unmodifiableList(events), callback, serializeNulls); } TelemetryClient(String accessToken, String userAgent, String reformedUserAgent, TelemetryClientSettings setting,
                  Logger logger, CertificateBlacklist certificateBlacklist, boolean isCnRegion);   }