Search in sources :

Example 1 with URLWrapper

use of com.google.firebase.perf.util.URLWrapper in project firebase-android-sdk by firebase.

the class FirebasePerfUrlConnectionTest method testGetContentError.

@Test
public void testGetContentError() throws IOException {
    URLWrapper wrapper = mock(URLWrapper.class);
    when(wrapper.toString()).thenReturn("www.google.com");
    when(wrapper.openConnection()).thenThrow(IOException.class);
    try {
        FirebasePerfUrlConnection.getContent(wrapper, transportManager, timer);
        fail("expected IOException");
    } catch (IOException e) {
        verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
        NetworkRequestMetric metric = networkArgumentCaptor.getValue();
        verifyNetworkRequestMetric(metric);
    }
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) IOException(java.io.IOException) URLWrapper(com.google.firebase.perf.util.URLWrapper) Test(org.junit.Test)

Example 2 with URLWrapper

use of com.google.firebase.perf.util.URLWrapper in project firebase-android-sdk by firebase.

the class FirebasePerfUrlConnectionTest method testOpenStreamHttpConnectionError.

@Test
public void testOpenStreamHttpConnectionError() throws IOException {
    URLWrapper wrapper = mock(URLWrapper.class);
    when(wrapper.toString()).thenReturn("www.google.com");
    when(wrapper.openConnection()).thenThrow(IOException.class);
    try {
        FirebasePerfUrlConnection.openStream(wrapper, transportManager, timer);
        fail("expected IOException");
    } catch (IOException e) {
        verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
        NetworkRequestMetric metric = networkArgumentCaptor.getValue();
        verifyNetworkRequestMetric(metric);
    }
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) IOException(java.io.IOException) URLWrapper(com.google.firebase.perf.util.URLWrapper) Test(org.junit.Test)

Example 3 with URLWrapper

use of com.google.firebase.perf.util.URLWrapper in project firebase-android-sdk by firebase.

the class FirebasePerfUrlConnectionTest method testGetContentClasses.

@Test
public void testGetContentClasses() throws IOException {
    @SuppressWarnings("rawtypes") Class[] classes = { TransportManager.class };
    URLWrapper wrapper = mock(URLWrapper.class);
    when(wrapper.toString()).thenReturn("www.google.com");
    when(wrapper.openConnection()).thenThrow(IOException.class);
    try {
        FirebasePerfUrlConnection.getContent(wrapper, classes, transportManager, timer);
        fail("expected IOException");
    } catch (IOException e) {
        verify(transportManager).log(networkArgumentCaptor.capture(), ArgumentMatchers.any(ApplicationProcessState.class));
        NetworkRequestMetric metric = networkArgumentCaptor.getValue();
        verifyNetworkRequestMetric(metric);
    }
}
Also used : NetworkRequestMetric(com.google.firebase.perf.v1.NetworkRequestMetric) IOException(java.io.IOException) URLWrapper(com.google.firebase.perf.util.URLWrapper) Test(org.junit.Test)

Aggregations

URLWrapper (com.google.firebase.perf.util.URLWrapper)3 NetworkRequestMetric (com.google.firebase.perf.v1.NetworkRequestMetric)3 IOException (java.io.IOException)3 Test (org.junit.Test)3