当前位置: 首页>>代码示例>>Java>>正文


Java IMAPFolder.addMessages方法代码示例

本文整理汇总了Java中com.sun.mail.imap.IMAPFolder.addMessages方法的典型用法代码示例。如果您正苦于以下问题:Java IMAPFolder.addMessages方法的具体用法?Java IMAPFolder.addMessages怎么用?Java IMAPFolder.addMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.mail.imap.IMAPFolder的用法示例。


在下文中一共展示了IMAPFolder.addMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.sun.mail.imap.IMAPFolder; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {

        final Session session = Session.getInstance(getProperties());

        final MockMailbox mb = MockMailbox.get("[email protected]");
        final MailboxFolder mf = mb.getInbox();

        final MimeMessage msg = new MimeMessage((Session) null);
        msg.setSubject("Test");
        msg.setFrom("[email protected]");
        msg.setText("Some text here ...");
        msg.setRecipient(RecipientType.TO, new InternetAddress("[email protected]"));
        mf.add(msg); // 11
        mf.add(msg); // 12
        mf.add(msg); // 13
        mb.getRoot().getOrAddSubFolder("test").create().add(msg);

        final Store store = session.getStore("mock_imap");
        store.connect("[email protected]", null);
        final Folder defaultFolder = store.getDefaultFolder();
        final IMAPFolder test = (IMAPFolder) defaultFolder.getFolder("test");

        final IdleMessageCountListener mcl = new IdleMessageCountListener();
        test.addMessageCountListener(mcl);

        test.open(Folder.READ_WRITE);

        final IdleThread it = new IdleThread(test);
        it.start();

        final IdleThread it2 = new IdleThread(test);
        it2.start();

        test.addMessages(new Message[] { msg });
        test.addMessages(new Message[] { msg });
        test.addMessages(new Message[] { msg });

        // test.close(true);

        System.out.println(it.getException());
        System.out.println(mcl.getAddedCount());
        System.out.println(mcl.getRemovedCount());
        System.out.println(test.getMessageCount());
        System.out.println(it.getIdleCount());

        // System.exit(1);

    }
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:49,代码来源:Main.java

示例2: testIDLESupported

import com.sun.mail.imap.IMAPFolder; //导入方法依赖的package包/类
@Test
public void testIDLESupported() throws Exception {

    final MockMailbox mb = MockMailbox.get("[email protected]");
    final MailboxFolder mf = mb.getInbox();

    final MimeMessage msg = new MimeMessage((Session) null);
    msg.setSubject("Test");
    msg.setFrom("[email protected]");
    msg.setText("Some text here ...");
    msg.setRecipient(RecipientType.TO, new InternetAddress("[email protected]"));
    mf.add(msg); // 11
    mf.add(msg); // 12
    mf.add(msg); // 13
    mb.getRoot().getOrAddSubFolder("test").create().add(msg);

    final Store store = session.getStore("mock_imap");
    store.connect("[email protected]", null);
    final Folder defaultFolder = store.getDefaultFolder();
    final IMAPFolder test = (IMAPFolder) defaultFolder.getFolder("test");

    final IdleMessageCountListener mcl = new IdleMessageCountListener();
    test.addMessageCountListener(mcl);

    test.open(Folder.READ_WRITE);

    final IdleThread it = new IdleThread(test);
    it.start();

    test.addMessages(new Message[] { msg });
    test.addMessages(new Message[] { msg });
    test.addMessages(new Message[] { msg });

    Thread.sleep(500);

    it.interrupt();
    it.join();

    test.close(true);

    Assert.assertNull(it.getException());
    Assert.assertEquals(3, mcl.getAddedCount());
    Assert.assertEquals(0, mcl.getRemovedCount());
    Assert.assertEquals(4, test.getMessageCount());

}
 
开发者ID:salyh,项目名称:javamail-mock2,代码行数:47,代码来源:IMAPTestCase.java


注:本文中的com.sun.mail.imap.IMAPFolder.addMessages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。