use of com.microsoft.appcenter.crashes.ingestion.models.Exception in project mobile-center-sdk-android by Microsoft.
the class WrapperSdkExceptionManagerTest method saveWrapperSdkCrashFailsWithIOException.
@Test
public void saveWrapperSdkCrashFailsWithIOException() throws IOException, JSONException {
doThrow(new IOException()).when(StorageHelper.InternalStorage.class);
StorageHelper.InternalStorage.write(any(File.class), anyString());
LogSerializer logSerializer = Mockito.mock(LogSerializer.class);
when(logSerializer.serializeLog(any(ManagedErrorLog.class))).thenReturn("mock");
Crashes.getInstance().setLogSerializer(logSerializer);
WrapperSdkExceptionManager.saveWrapperException(Thread.currentThread(), null, new Exception(), new byte[] { 'd' });
verifyStatic();
AppCenterLog.error(anyString(), anyString(), argThat(new ArgumentMatcher<Throwable>() {
@Override
public boolean matches(Object argument) {
return argument instanceof IOException;
}
}));
/* Second call is ignored. */
WrapperSdkExceptionManager.saveWrapperException(Thread.currentThread(), null, new Exception(), new byte[] { 'e' });
/* No more error. */
verifyStatic();
AppCenterLog.error(anyString(), anyString(), argThat(new ArgumentMatcher<Throwable>() {
@Override
public boolean matches(Object argument) {
return argument instanceof IOException;
}
}));
}
use of com.microsoft.appcenter.crashes.ingestion.models.Exception in project mobile-center-sdk-android by Microsoft.
the class WrapperSdkExceptionManagerTest method saveWrapperSdkCrashFailsToCreateThrowablePlaceholder.
@Test
public void saveWrapperSdkCrashFailsToCreateThrowablePlaceholder() throws java.lang.Exception {
LogSerializer logSerializer = Mockito.mock(LogSerializer.class);
when(logSerializer.serializeLog(any(ManagedErrorLog.class))).thenReturn("mock");
Crashes.getInstance().setLogSerializer(logSerializer);
File throwableFile = mock(File.class);
whenNew(File.class).withParameterTypes(String.class, String.class).withArguments(anyString(), argThat(new ArgumentMatcher<String>() {
@Override
public boolean matches(Object argument) {
return String.valueOf(argument).endsWith(ErrorLogHelper.THROWABLE_FILE_EXTENSION);
}
})).thenReturn(throwableFile);
when(throwableFile.createNewFile()).thenReturn(false);
byte[] data = new byte[] { 'd' };
WrapperSdkExceptionManager.saveWrapperException(Thread.currentThread(), null, new Exception(), data);
verifyStatic();
AppCenterLog.error(anyString(), anyString(), argThat(new ArgumentMatcher<Throwable>() {
@Override
public boolean matches(Object argument) {
return argument instanceof IOException;
}
}));
/* Second call is ignored. */
data = new byte[] { 'e' };
WrapperSdkExceptionManager.saveWrapperException(Thread.currentThread(), null, new Exception(), data);
/* No more error. */
verifyStatic();
AppCenterLog.error(anyString(), anyString(), argThat(new ArgumentMatcher<Throwable>() {
@Override
public boolean matches(Object argument) {
return argument instanceof IOException;
}
}));
}
Aggregations