title: How to mock connection in javax.mail for Unit test?
body: <p>I need make tests for class waiting the parameter <code>javax.mail.Folder</code> and extends <code>Closeable</code>. So I need to test function <code>close()</code>.</p>
  <p>The problem is I don't know how to mock <code>javax.mail.Store</code> connection for test:</p>
  <pre><code>class CloseableFolderTest() {
      @Test
      fun testCloseableFolder() {
          val testSession = Session.getDefaultInstance(Properties())
          val testStore = testSession.getStore(&quot;pop3&quot;)
          testStore.connect() //how to mock this?
          val testFolder = testStore.defaultFolder
          testFolder.close(true)
          assertEquals(false,testFolder.isOpen)
  
      }
  }
  </code></pre>