You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stackoverflow with the tag 'powermock'. (Make sure you include a short code snippet to demonstrate the problem and if you have an exception then make sure include stack trace.)
In order to help us to clarify issue can you answer the following question:
What steps will reproduce the problem?
-Hi i try to mock use simplecache exoplayer but i get this error but still can run the code:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.powermock.reflect.internal.WhiteboxImpl (file:/Users/mohdhafiz/.gradle/caches/transforms-2/files-2.1/b881769387f8f0472cf9cb77d1671e6e/jetified-powermock-reflect-2.0.9.jar) to method java.io.File.readObject(java.io.ObjectInputStream)
WARNING: Please consider reporting this to the maintainers of org.powermock.reflect.internal.WhiteboxImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.NullPointerException
at com.google.android.exoplayer2.upstream.cache.CachedContentIndex$DatabaseStorage.load(CachedContentIndex.java:822)
at com.google.android.exoplayer2.upstream.cache.CachedContentIndex.initialize(CachedContentIndex.java:207)
at com.google.android.exoplayer2.upstream.cache.SimpleCache.initialize(SimpleCache.java:582)
at com.google.android.exoplayer2.upstream.cache.SimpleCache.access$000(SimpleCache.java:49)
at com.google.android.exoplayer2.upstream.cache.SimpleCache$1.run(SimpleCache.java:268)
What is the expected output?
no error display
What do you see instead?
run unit test as usual
What version of the product are you using?
-testImplementation "org.powermock:powermock-module-junit4:2.0.9"
-testImplementation "org.powermock:powermock-api-mockito2:2.0.9"
Sample code as below :
`@RunWith(PowerMockRunner::class)
@PrepareForTest(VideoCache::class, SimpleCache::class)
class VideoCacheTest {
private lateinit var simpleCache: SimpleCache
private val videoCache = PowerMockito.mockStatic(VideoCache::class.java)
private val context = PowerMockito.mock(Context::class.java)
@Before
fun setup(){
simpleCache = VideoCache.getInstance(context)
//PowerMockito.`when`(VideoCache.getInstance(context)).thenReturn(simpleCache)
}
@Test
fun testGetInstanceVideoCache() {
assertEquals("",simpleCache, VideoCache.getInstance(context))
}
}`
`object VideoCache {
private var downloadCache: SimpleCache? = null
private var downloadContentDirectory:File? = null
private var databaseProvider:StandaloneDatabaseProvider? = null
private const val dirName: String = "Sample"
Hey there and thank you for using PowerMock
Please read the following tips before filing an issue:
Is this something you can debug and fix?
Can you see anything in the logs? Can you debug why this happens? Send a pull request! Bug fixes and documentation fixes are very welcome.
Is this question about PowerMock usage?
The better way to ask question:
None of the above, want to create a GitHub issue
Issues should always have a Short, Self Contained, Correct (Compilable), Example (same as any question on stackoverflow.com)
In order to help us to clarify issue can you answer the following question:
What steps will reproduce the problem?
-Hi i try to mock use simplecache exoplayer but i get this error but still can run the code:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.powermock.reflect.internal.WhiteboxImpl (file:/Users/mohdhafiz/.gradle/caches/transforms-2/files-2.1/b881769387f8f0472cf9cb77d1671e6e/jetified-powermock-reflect-2.0.9.jar) to method java.io.File.readObject(java.io.ObjectInputStream)
WARNING: Please consider reporting this to the maintainers of org.powermock.reflect.internal.WhiteboxImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.NullPointerException
at com.google.android.exoplayer2.upstream.cache.CachedContentIndex$DatabaseStorage.load(CachedContentIndex.java:822)
at com.google.android.exoplayer2.upstream.cache.CachedContentIndex.initialize(CachedContentIndex.java:207)
at com.google.android.exoplayer2.upstream.cache.SimpleCache.initialize(SimpleCache.java:582)
at com.google.android.exoplayer2.upstream.cache.SimpleCache.access$000(SimpleCache.java:49)
at com.google.android.exoplayer2.upstream.cache.SimpleCache$1.run(SimpleCache.java:268)
What is the expected output?
What do you see instead?
What version of the product are you using?
-testImplementation "org.powermock:powermock-module-junit4:2.0.9"
-testImplementation "org.powermock:powermock-api-mockito2:2.0.9"
Sample code as below :
`@RunWith(PowerMockRunner::class)
@PrepareForTest(VideoCache::class, SimpleCache::class)
class VideoCacheTest {
private lateinit var simpleCache: SimpleCache
private val videoCache = PowerMockito.mockStatic(VideoCache::class.java)
private val context = PowerMockito.mock(Context::class.java)
}`
`object VideoCache {
private var downloadCache: SimpleCache? = null
private var downloadContentDirectory:File? = null
private var databaseProvider:StandaloneDatabaseProvider? = null
private const val dirName: String = "Sample"
}`
The text was updated successfully, but these errors were encountered: