use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class InstrHttpURLConnectionTest method testDisconnect.
@Test
public void testDisconnect() throws IOException {
HttpURLConnection urlConnection = mockHttpUrlConnection();
new InstrHttpURLConnection(urlConnection, timer, networkMetricBuilder).disconnect();
verify(urlConnection).disconnect();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
assertEquals(2000, metric.getTimeToResponseCompletedUs());
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class InstrHttpURLConnectionTest method testGetContentIOException.
@SuppressWarnings("TestExceptionChecker")
@Test(expected = IOException.class)
public void testGetContentIOException() throws IOException {
HttpURLConnection urlConnection = mockHttpUrlConnection();
when(urlConnection.getDoOutput()).thenReturn(true);
when(urlConnection.getContent()).thenThrow(new IOException());
new InstrHttpURLConnection(urlConnection, timer, networkMetricBuilder).getContent();
verify(urlConnection).getContent();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
assertEquals(1000, metric.getClientStartTimeUs());
assertEquals(HttpMethod.POST, metric.getHttpMethod());
assertEquals(urlConnection.getResponseCode(), metric.getHttpResponseCode());
assertEquals(urlConnection.getContentLength(), null);
assertEquals(urlConnection.getContentType(), null);
assertEquals(2000, metric.getTimeToResponseCompletedUs());
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class InstrHttpsURLConnectionTest method testDisconnect.
@Test
public void testDisconnect() throws IOException {
HttpsURLConnection urlConnection = mockHttpsUrlConnection();
new InstrHttpsURLConnection(urlConnection, timer, networkMetricBuilder).disconnect();
verify(urlConnection).disconnect();
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
assertThat(metric.getTimeToResponseCompletedUs()).isEqualTo(2000);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class InstrURLConnectionBaseTest method testGetResponseMessageThrowsIOException.
@Test
public void testGetResponseMessageThrowsIOException() throws IOException {
HttpURLConnection urlConnection = mockHttpUrlConnection();
doThrow(IOException.class).when(urlConnection).getResponseMessage();
assertThrows(IOException.class, () -> new InstrURLConnectionBase(urlConnection, timer, networkMetricBuilder).getResponseMessage());
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
assertThat(metric.getTimeToResponseCompletedUs()).isEqualTo(2000);
}
use of com.google.firebase.perf.v1.NetworkRequestMetric in project firebase-android-sdk by firebase.
the class InstrURLConnectionBaseTest method testGetInputStreamThrowsIOException.
@Test
public void testGetInputStreamThrowsIOException() throws IOException {
HttpURLConnection urlConnection = mockHttpUrlConnection();
doThrow(IOException.class).when(urlConnection).getInputStream();
assertThrows(IOException.class, () -> new InstrURLConnectionBase(urlConnection, timer, networkMetricBuilder).getInputStream());
verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
NetworkRequestMetric metric = networkArgumentCaptor.getValue();
assertThat(metric.getTimeToResponseCompletedUs()).isEqualTo(2000);
}
Aggregations