File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
sentry-async-profiler/src/test/java/io/sentry/asyncprofiler/provider Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ package io.sentry.asyncprofiler.provider
2+
3+ import io.sentry.ILogger
4+ import io.sentry.ISentryExecutorService
5+ import io.sentry.NoOpContinuousProfiler
6+ import io.sentry.asyncprofiler.profiling.JavaContinuousProfiler
7+ import one.profiler.AsyncProfiler
8+ import org.mockito.Mockito.mock
9+ import org.mockito.Mockito.mockStatic
10+ import kotlin.test.Test
11+ import kotlin.test.assertSame
12+ import kotlin.test.assertTrue
13+
14+
15+ class AsyncProfilerContinuousProfilerProviderTest {
16+
17+ @Test
18+ fun `provider returns JavaAsyncProfiler if AsyncProfiler can be loaded` () {
19+ val profiler = AsyncProfilerContinuousProfilerProvider ().getContinuousProfiler(
20+ mock(ILogger ::class .java),
21+ " " ,
22+ 10 ,
23+ mock(ISentryExecutorService ::class .java)
24+ )
25+
26+ assertTrue(profiler is JavaContinuousProfiler )
27+ }
28+
29+ @Test
30+ fun `provider return NoopProfiler if AsyncProfiler cannot be loaded` () {
31+ mockStatic(AsyncProfiler ::class .java).use {
32+ it.`when `<Any > { AsyncProfiler .getInstance() }.thenReturn(null )
33+
34+ val profiler = AsyncProfilerContinuousProfilerProvider ().getContinuousProfiler(
35+ mock(ILogger ::class .java),
36+ " " ,
37+ 10 ,
38+ mock(ISentryExecutorService ::class .java)
39+ )
40+
41+ assertSame(NoOpContinuousProfiler .getInstance(), profiler)
42+ }
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments