-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed concurrency bug that could be triggered via the React Native pl…
…ugin
- Loading branch information
Showing
6 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
bugsnag-android-core/src/androidTest/java/com/bugsnag/android/DataCollectorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.bugsnag.android | ||
|
||
import android.content.Context | ||
import android.content.res.Configuration | ||
import android.content.res.Resources | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Mockito | ||
import org.mockito.junit.MockitoJUnitRunner | ||
import java.io.File | ||
import kotlin.concurrent.thread | ||
|
||
@RunWith(MockitoJUnitRunner::class) | ||
class DataCollectorTest { | ||
|
||
@Test | ||
fun testConcurretAccess() { | ||
val res = Mockito.mock(Resources::class.java) | ||
Mockito.`when`(res.configuration).thenReturn(Configuration()) | ||
|
||
val collector = DeviceDataCollector( | ||
Mockito.mock(Connectivity::class.java), | ||
Mockito.mock(Context::class.java), | ||
res, | ||
"fakeDevice", | ||
Mockito.mock(DeviceBuildInfo::class.java), | ||
File("/tmp/javatest"), | ||
Mockito.mock(RootDetector::class.java), | ||
Mockito.mock(BackgroundTaskService::class.java), | ||
Mockito.mock(Logger::class.java) | ||
) | ||
|
||
repeat(10) { index -> | ||
collector.addRuntimeVersionInfo("key" + index, "value" + index) | ||
} | ||
|
||
val count = 500 | ||
|
||
thread { | ||
repeat(count) { index -> | ||
collector.addRuntimeVersionInfo("key" + index, "value" + index) | ||
} | ||
} | ||
|
||
repeat(count) { | ||
collector.generateDevice() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters