Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import org.assertj.core.api.Assertions.assertThat
  2. import org.junit.jupiter.api.Test
  3. import org.junit.jupiter.api.BeforeEach
  4. import org.junit.jupiter.api.AfterEach
  5.  
  6. import io.mockk.clearMocks
  7. import io.mockk.every
  8. import io.mockk.mockk
  9. import io.mockk.verify
  10.  
  11. import kotlinx.coroutines.delay
  12. import kotlinx.coroutines.launch
  13. import kotlinx.coroutines.runBlocking
  14.  
  15.  
  16. /**
  17. * Unit Test - AgentConnection
  18. */
  19. class AgentConnectionUnitTest {
  20. // unit under test
  21. lateinit var connectHandler: OurConnectHandler
  22.  
  23. // mocks
  24. val stompServer: StompServer = mockk(relaxed = true)
  25.  
  26. // dependencies
  27. val testPool = newFixedThreadPoolContext( 4, "testPool")
  28.  
  29. //________________________________________________________________________________
  30. // setUp/TearDown
  31. //________________________________________________________________________________
  32. @BeforeEach
  33. fun `before each`() {
  34. clearMocks(stompServer, writingFrameHandler, socket, authAsyncTemplate)
  35. every { stompServer.options().supportedVersions } returns listOf("1.2")
  36. }
  37.  
  38. @AfterEach
  39. fun `after each`() {
  40.  
  41. }
  42.  
  43. //________________________________________________________________________________
  44. // Tests
  45. //________________________________________________________________________________
  46. @Test
  47. fun `should disconnect if credentials are missing`() {
  48. runBlocking(testPool) {
  49. assertThat(result).isFalse()
  50.  
  51. }
  52. verify(exactly = 1) { socket.close()}
  53. }
  54.  
  55.  
  56. } // EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement