Created
March 21, 2018 10:15
-
-
Save pavelaizen/cafc2c8c0afd7b2574fde70c3fef2f90 to your computer and use it in GitHub Desktop.
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
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