Skip to content

Instantly share code, notes, and snippets.

@pavelaizen
Created March 21, 2018 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavelaizen/cafc2c8c0afd7b2574fde70c3fef2f90 to your computer and use it in GitHub Desktop.
Save pavelaizen/cafc2c8c0afd7b2574fde70c3fef2f90 to your computer and use it in GitHub Desktop.
import io.mockk.*
import org.apache.logging.log4j.ThreadContext
import org.junit.Test
class Log4jExecutorTest {
class MyLog4jExecutor : Log4jExecutor() {
fun runBefore(t: Thread?, r: Runnable?) = beforeExecute(t, r)
}
@Test
fun beforeExecute() {
val executor = spyk<MyLog4jExecutor>(recordPrivateCalls = true)
val t = mockk<Thread>(relaxed = true)
val r = mockk<Runnable>(relaxed = true)
staticMockk(ThreadContext::class.java.name).use {
executor.runBefore(t,r)
verify { ThreadContext.putAll(any()) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment