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


Java GreenMailUtil.sendAttachmentEmail方法代码示例

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


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

示例1: testPopAttachments

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopAttachments() throws Exception{
	File folder = Files.createTempDir();
	
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "attachments",
			EmailReader.PARAM_FOLDER, folder.getPath());

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
	assertEquals(1, folder.list().length);
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	FileUtils.deleteDirectory(folder);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:41,代码来源:EmailReaderTest.java

示例2: testImapAttachments

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testImapAttachments() throws Exception{
	File folder = Files.createTempDir();
	
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "imap",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getImap().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getImap().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "attachments",
			EmailReader.PARAM_FOLDER, folder.getPath());

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
	assertEquals(1, folder.list().length);
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	FileUtils.deleteDirectory(folder);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:41,代码来源:EmailReaderTest.java

示例3: testLargeMessageTextAndAttachment

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testLargeMessageTextAndAttachment() throws MessagingException, IOException {
    String to = "[email protected]";
    GreenMailUtil.sendAttachmentEmail(to, "[email protected]", "Subject", createLargeString(),
            createLargeByteArray(), "application/blubb", "file", "descr",
            greenMail.getSmtp().getServerSetup());
    greenMail.waitForIncomingEmail(5000, 1);

    retrieveAndCheck(greenMail.getPop3(), to);
    retrieveAndCheck(greenMail.getImap(), to);
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:12,代码来源:LargeMessageTest.java

示例4: testSmtpServerReceiveMultipart

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testSmtpServerReceiveMultipart() throws Exception {
    assertEquals(0, greenMail.getReceivedMessages().length);

    String subject = GreenMailUtil.random();
    String body = GreenMailUtil.random();
    GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject, body, new byte[]{0, 1, 2}, "image/gif", "testimage_filename", "testimage_description", ServerSetupTest.SMTP);
    greenMail.waitForIncomingEmail(1500, 1);
    Message[] emails = greenMail.getReceivedMessages();
    assertEquals(1, emails.length);
    assertEquals(subject, emails[0].getSubject());

    Object o = emails[0].getContent();
    assertTrue(o instanceof MimeMultipart);
    MimeMultipart mp = (MimeMultipart) o;
    assertEquals(2, mp.getCount());
    BodyPart bp;
    bp = mp.getBodyPart(0);
    assertEquals(body, GreenMailUtil.getBody(bp).trim());

    bp = mp.getBodyPart(1);
    assertEquals("AAEC", GreenMailUtil.getBody(bp).trim());

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    GreenMailUtil.copyStream(bp.getInputStream(), bout);
    byte[] gif = bout.toByteArray();
    for (int i = 0; i < gif.length; i++) {
        assertEquals(i, gif[i]);
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:31,代码来源:SmtpServerTest.java

示例5: testRetriveMultipart

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testRetriveMultipart() throws Exception {
    assertNotNull(greenMail.getImap());

    String subject = GreenMailUtil.random();
    String body = GreenMailUtil.random();
    String to = "[email protected]";
    GreenMailUtil.sendAttachmentEmail(to, "[email protected]", subject, body, new byte[]{0, 1, 2}, "image/gif", "testimage_filename", "testimage_description", ServerSetupTest.SMTP);
    greenMail.waitForIncomingEmail(5000, 1);

    try (Retriever retriever = new Retriever(greenMail.getImap())) {
        Message[] messages = retriever.getMessages(to);

        Object o = messages[0].getContent();
        assertTrue(o instanceof MimeMultipart);
        MimeMultipart mp = (MimeMultipart) o;
        assertEquals(2, mp.getCount());
        BodyPart bp;
        bp = mp.getBodyPart(0);
        assertEquals(body, GreenMailUtil.getBody(bp).trim());

        bp = mp.getBodyPart(1);
        assertEquals("AAEC", GreenMailUtil.getBody(bp).trim());

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        GreenMailUtil.copyStream(bp.getInputStream(), bout);
        byte[] gif = bout.toByteArray();
        for (int i = 0; i < gif.length; i++) {
            assertEquals(i, gif[i]);
        }
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:33,代码来源:ImapServerTest.java

示例6: testRetrieveMultipart

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testRetrieveMultipart() throws Exception {
    assertNotNull(greenMail.getPop3());

    String subject = GreenMailUtil.random();
    String body = GreenMailUtil.random();
    String to = "[email protected]";
    GreenMailUtil.sendAttachmentEmail(to, "[email protected]", subject, body, new byte[]{0, 1, 2}, "image/gif", "testimage_filename", "testimage_description", ServerSetupTest.SMTP);
    greenMail.waitForIncomingEmail(5000, 1);

    try (Retriever retriever = new Retriever(greenMail.getPop3())) {
        Message[] messages = retriever.getMessages(to);

        Object o = messages[0].getContent();
        assertTrue(o instanceof MimeMultipart);
        MimeMultipart mp = (MimeMultipart) o;
        assertEquals(2, mp.getCount());
        BodyPart bp;
        bp = mp.getBodyPart(0);
        assertEquals(body, GreenMailUtil.getBody(bp).trim());

        bp = mp.getBodyPart(1);
        assertEquals("AAEC", GreenMailUtil.getBody(bp).trim());

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        GreenMailUtil.copyStream(bp.getInputStream(), bout);
        byte[] gif = bout.toByteArray();
        for (int i = 0; i < gif.length; i++) {
            assertEquals(i, gif[i]);
        }
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:33,代码来源:Pop3ServerTest.java

示例7: testPopContent

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopContent() throws Exception{
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "content");

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body1));
	
	jCas.reset();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body2));
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:42,代码来源:EmailReaderTest.java

示例8: testPopDeleteMessages

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopDeleteMessages() throws Exception{
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "content",
			EmailReader.PARAM_DELETE_EMAIL, true);

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body1));
	
	jCas.reset();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body2));
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	//Check that there are no messages on the server
	bcr = (BaleenCollectionReader) CollectionReaderFactory.createReader(EmailReader.class,
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password");
	
	bcr.initialize();
	assertFalse(bcr.doHasNext());
	bcr.close();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:56,代码来源:EmailReaderTest.java

示例9: testPopDeleteAttachments

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopDeleteAttachments() throws Exception{
	File folder = Files.createTempDir();
	
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "attachments",
			EmailReader.PARAM_FOLDER, folder.getPath(),
			EmailReader.PARAM_DELETE_ATTACHMENT, true);

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
	assertEquals(0, folder.list().length);
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	FileUtils.deleteDirectory(folder);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:42,代码来源:EmailReaderTest.java

示例10: testImapContent

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testImapContent() throws Exception{
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "imap",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getImap().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getImap().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "content");

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body1));
	
	jCas.reset();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body2));
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:42,代码来源:EmailReaderTest.java

示例11: testImapDeleteMessages

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testImapDeleteMessages() throws Exception{
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "imap",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getImap().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getImap().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "content",
			EmailReader.PARAM_DELETE_EMAIL, true);

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body1));
	
	jCas.reset();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body2));
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	//Check that there are no messages on the server
	bcr = (BaleenCollectionReader) CollectionReaderFactory.createReader(EmailReader.class,
			EmailReader.PARAM_PROTOCOL, "imap",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getImap().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getImap().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password");
	
	bcr.initialize();
	assertFalse(bcr.doHasNext());
	bcr.close();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:56,代码来源:EmailReaderTest.java

示例12: testImapDeleteAttachments

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testImapDeleteAttachments() throws Exception{
	File folder = Files.createTempDir();
	
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "imap",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getImap().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getImap().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "attachments",
			EmailReader.PARAM_FOLDER, folder.getPath(),
			EmailReader.PARAM_DELETE_ATTACHMENT, true);

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
	assertEquals(0, folder.list().length);
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	FileUtils.deleteDirectory(folder);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:42,代码来源:EmailReaderTest.java

示例13: testGetEmptyBodyAndHeader

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testGetEmptyBodyAndHeader() throws Exception {
    GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
    try {
        greenMail.start();

        String subject = GreenMailUtil.random();
        String body = ""; // Provokes https://github.com/greenmail-mail-test/greenmail/issues/151
        String to = "[email protected]";
        final byte[] gifAttachment = {0, 1, 2};
        GreenMailUtil.sendAttachmentEmail(to, "[email protected]", subject, body, gifAttachment,
                "image/gif", "testimage_filename", "testimage_description",
                greenMail.getSmtp().getServerSetup());
        greenMail.waitForIncomingEmail(5000, 1);

        try (Retriever retriever = new Retriever(greenMail.getImap())) {
            MimeMultipart mp = (MimeMultipart) retriever.getMessages(to)[0].getContent();
            BodyPart bp;
            bp = mp.getBodyPart(0);
            assertEquals(body, GreenMailUtil.getBody(bp).trim());
            assertEquals(
                    "Content-Type: text/plain; charset=us-ascii\r\n" +
                    "Content-Transfer-Encoding: 7bit",
                    GreenMailUtil.getHeaders(bp).trim());

            bp = mp.getBodyPart(1);
            assertEquals("AAEC", GreenMailUtil.getBody(bp).trim());
            assertEquals(
                    "Content-Type: image/gif; name=testimage_filename\r\n" +
                    "Content-Transfer-Encoding: base64\r\n" +
                    "Content-Disposition: attachment; filename=testimage_filename\r\n" +
                    "Content-Description: testimage_description",
                    GreenMailUtil.getHeaders(bp).trim());

            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            GreenMailUtil.copyStream(bp.getInputStream(), bout);
            assertArrayEquals(gifAttachment, bout.toByteArray());
        }
    } finally {
        greenMail.stop();
    }
}
 
开发者ID:greenmail-mail-test,项目名称:greenmail,代码行数:43,代码来源:GreenMailUtilTest.java

示例14: testPopBoth

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopBoth() throws Exception{
	File folder = Files.createTempDir();
	
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "both",
			EmailReader.PARAM_FOLDER, folder.getPath());

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body1));
	
	jCas.reset();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body2));
	
	jCas.reset();

	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
	assertEquals(1, folder.list().length);
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	FileUtils.deleteDirectory(folder);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:55,代码来源:EmailReaderTest.java

示例15: testPopBadProcessConfig

import com.icegreen.greenmail.util.GreenMailUtil; //导入方法依赖的package包/类
@Test
public void testPopBadProcessConfig() throws Exception{
	File folder = Files.createTempDir();
	
	String subject1 = GreenMailUtil.random();
	String body1 = GreenMailUtil.random();
	
	GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", subject1, body1);
	
	String subject2 = GreenMailUtil.random();
	String body2 = GreenMailUtil.random();
	
	GreenMailUtil.sendAttachmentEmail("[email protected]", "[email protected]", subject2, body2, IOUtils.toByteArray(getClass().getResourceAsStream("lineReader.txt")), "text/plain", "lineReader.txt", "Test File", ServerSetupTest.SMTP);
			
	BaleenCollectionReader bcr = getCollectionReader(
			EmailReader.PARAM_PROTOCOL, "pop3",
			EmailReader.PARAM_WAIT, 5,
			EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
			EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
			EmailReader.PARAM_USER, "[email protected]",
			EmailReader.PARAM_PASS, "password",
			EmailReader.PARAM_PROCESS, "NotARealProcess",
			EmailReader.PARAM_FOLDER, folder.getPath());

	bcr.initialize();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body1));
	
	jCas.reset();
	
	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(body2));
	
	jCas.reset();

	assertTrue(bcr.doHasNext());
	bcr.getNext(jCas);
	
	assertTrue(jCas.getDocumentText().startsWith(FIRST_LINE));
	assertEquals(1, folder.list().length);
	
	jCas.reset();
	
	assertFalse(bcr.doHasNext());
	
	bcr.close();
	
	FileUtils.deleteDirectory(folder);
}
 
开发者ID:dstl,项目名称:baleen,代码行数:55,代码来源:EmailReaderTest.java


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