-
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.
Merge pull request #1679 from bugsnag/PLAT-8390-concurrency
Fixed concurrency bug that could be triggered via the React Native plugin
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 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
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
package com.bugsnag.android | ||
|
||
import android.content.Context | ||
import android.content.res.Configuration | ||
import android.content.res.Resources | ||
import org.junit.Ignore | ||
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 { | ||
|
||
@Ignore("Disabled until we're able to mock final classes or auto-open classes") | ||
@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