Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.assertj.core.api.Assertions.assertThat
- import org.junit.jupiter.api.Test
- import org.junit.jupiter.api.BeforeEach
- import org.junit.jupiter.api.AfterEach
- import io.mockk.clearMocks
- import io.mockk.every
- import io.mockk.mockk
- import io.mockk.verify
- import kotlinx.coroutines.delay
- import kotlinx.coroutines.launch
- import kotlinx.coroutines.runBlocking
- /**
- * Unit Test - AgentConnection
- */
- class AgentConnectionUnitTest {
- // unit under test
- lateinit var connectHandler: OurConnectHandler
- // mocks
- val stompServer: StompServer = mockk(relaxed = true)
- // dependencies
- val testPool = newFixedThreadPoolContext( 4, "testPool")
- //________________________________________________________________________________
- // setUp/TearDown
- //________________________________________________________________________________
- @BeforeEach
- fun `before each`() {
- clearMocks(stompServer, writingFrameHandler, socket, authAsyncTemplate)
- every { stompServer.options().supportedVersions } returns listOf("1.2")
- }
- @AfterEach
- fun `after each`() {
- }
- //________________________________________________________________________________
- // Tests
- //________________________________________________________________________________
- @Test
- fun `should disconnect if credentials are missing`() {
- runBlocking(testPool) {
- assertThat(result).isFalse()
- }
- verify(exactly = 1) { socket.close()}
- }
- } // EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement