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


Java Wiser.setHostname方法代码示例

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


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

示例1: create

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@BeforeClass
public void create() throws Exception {
  wiser = new Wiser();
  wiser.setHostname("localhost");
  wiser.setPort(25000);
  queryService = LensServices.get().getService(QueryExecutionService.NAME);
  Map<String, String> sessionconf = new HashMap<>();
  sessionconf.put("test.session.key", "svalue");
  sessionconf.put(LensConfConstants.QUERY_MAIL_NOTIFY, "true");
  sessionconf.put(LensConfConstants.QUERY_RESULT_EMAIL_CC, "[email protected],[email protected],[email protected]");
  lensSessionId = queryService.openSession("[email protected]", "bar", sessionconf); // @localhost should be removed
  // automatically
  createTable(TEST_TABLE);
  loadData(TEST_TABLE, TestResourceFile.TEST_DATA2_FILE.getValue());
  wiser.start();
}
 
开发者ID:apache,项目名称:lens,代码行数:17,代码来源:TestQueryEndEmailNotifier.java

示例2: testTextMailMessageSendFailed

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test(expected = SendFailedException.class)
public void testTextMailMessageSendFailed() {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
    String messageId = "[email protected]";

    // Port is one off so this should fail
    Wiser wiser = new Wiser(mailConfig.getServerPort() + 1);
    wiser.setHostname(mailConfig.getServerHost());

    try {
        wiser.start();

        new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(replyToAddress).to(toAddress).subject(subject).bodyText(textBody).importance(
                MessagePriority.HIGH).messageId(messageId).send();
    }
    finally {
        stop(wiser);
    }
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:22,代码来源:MailMessageTest.java

示例3: testTextMailMessageInvalidAddress

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test(expected = InvalidAddressException.class)
public void testTextMailMessageInvalidAddress() throws SendFailedException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();

    String messageId = "[email protected]";

    // Port is one off so this should fail
    Wiser wiser = new Wiser(mailConfig.getServerPort() + 1);
    wiser.setHostname(mailConfig.getServerHost());

    try {
        wiser.start();

        new MailMessageImpl(mailConfig).from("seam [email protected]", fromName).replyTo(replyToAddress).to(toAddress, toName).subject(subject).bodyText(textBody)
                .importance(MessagePriority.HIGH).messageId(messageId).send();
    }
    finally {
        stop(wiser);
    }
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:23,代码来源:MailMessageTest.java

示例4: testVelocityTextMailMessageSendFailed

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test(expected = SendFailedException.class)
public void testVelocityTextMailMessageSendFailed() throws UnsupportedEncodingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();
    String uuid = java.util.UUID.randomUUID().toString();
    String subject = "Text Message from $version Mail - " + uuid;
    String version = "Seam 3";

    // Port is two off so this should fail
    Wiser wiser = new Wiser(mailConfig.getServerPort() + 2);
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        new MailMessageImpl(mailConfig).from(fromAddress).replyTo(replyToAddress).to(toAddress).subject(new VelocityTemplate(subject)).bodyText(
                new VelocityTemplate(Resources.newInputStreamSupplier(Resources.getResource("template.text.velocity")).getInput())).put("version", version).importance(MessagePriority.HIGH).send();
    }
    finally {
        stop(wiser);
    }
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:21,代码来源:VelocityMailMessageTest.java

示例5: testFreeMarkerTextMailMessageSendFailed

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test(expected = SendFailedException.class)
public void testFreeMarkerTextMailMessageSendFailed() throws IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String uuid = java.util.UUID.randomUUID().toString();
    String subject = "Text Message from $version Mail - " + uuid;
    Person person = new Person(toName, toAddress);
    String version = "Seam 3";

    // Port is two off so this should fail
    Wiser wiser = new Wiser(mailConfig.getServerPort() + 2);
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        person.setName(toName);
        person.setEmail(toAddress);

        new MailMessageImpl(mailConfig).from(fromAddress).replyTo(replyToAddress).to(toAddress).subject(new FreeMarkerTemplate(subject)).bodyText(
                new FreeMarkerTemplate(Resources.newInputStreamSupplier(Resources.getResource("template.text.freemarker")).getInput())).put("person", person).put("version", version).importance(
                MessagePriority.HIGH).send();
    }
    finally {
        stop(wiser);
    }
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:27,代码来源:FreeMarkerMailMessageTest.java

示例6:

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Bean(initMethod = "start", destroyMethod = "stop")
/*    */ Wiser wiser() {
	/* 49 */ Wiser answer = new Wiser();
	/* 50 */ answer.setPort(this.mailEasyConfig.getSmtpPort());
	/* 51 */ answer.setHostname(this.mailEasyConfig.getSmtpHost());
	/* 52 */ return answer;
	/*    */ }
 
开发者ID:quirinobrizi,项目名称:maileasy,代码行数:8,代码来源:Application.java

示例7: setupClass

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@BeforeClass
public static void setupClass() throws IOException {
    Properties p = new Properties();
    try {
        p.load(AbstractTestCase.class.getResourceAsStream("/mail.properties"));
        wiser = new Wiser();
        wiser.setHostname(p.getProperty("mail.host"));
        wiser.setPort(Integer.valueOf(p.getProperty("mail.port")));

        wiser.start();
    } catch (IOException e) {
        throw e;
    }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:15,代码来源:AbstractTestCase.java

示例8: startMailServer

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
public static Wiser startMailServer(String hostname, AuthenticationHandlerFactory authenticationHandlerFactory)
{
    Wiser server = new Wiser();
    server.getServer().setAuthenticationHandlerFactory(authenticationHandlerFactory);
    server.setHostname(hostname);
    server.setPort(0);
    server.start();
    return server;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:10,代码来源:TestUtils.java

示例9: testSMTPSessionAuthentication

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testSMTPSessionAuthentication() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();
    Person person = new Person(toName, toAddress);
    String subject = "HTML+Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();

    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    wiser.getServer().setAuthenticationHandlerFactory(new EasyAuthenticationHandlerFactory(new SMTPAuthenticator("test", "test12!")));
    try {
        wiser.start();

        new MailMessageImpl(mailConfig).from(fromAddress).to(person.getEmail()).subject(subject).put("version", "Seam 3").bodyHtmlTextAlt(
                new VelocityTemplate(Resources.newInputStreamSupplier(Resources.getResource("template.html.velocity")).getInput()),
                new VelocityTemplate(Resources.newInputStreamSupplier(Resources.getResource("template.text.velocity")).getInput())).importance(MessagePriority.LOW).deliveryReceipt(fromAddress)
                .readReceipt("seam.test").addAttachment("template.html.velocity", "text/html", ContentDisposition.ATTACHMENT,
                        Resources.newInputStreamSupplier(Resources.getResource("template.html.velocity")).getInput()).addAttachment(
                        new URLAttachment("http://design.jboss.org/seam/logo/final/seam_mail_85px.png", "seamLogo.png", ContentDisposition.INLINE)).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:32,代码来源:VelocityMailMessageTest.java

示例10: testTextMailMessage

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testTextMailMessage() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
    String messageId = "[email protected]";

    EmailMessage e;

    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        e =
                new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(replyToAddress).to(MailTestUtil.getAddressHeader(toName, toAddress)).subject(
                        subject).bodyText(textBody).importance(MessagePriority.HIGH).messageId(messageId).envelopeFrom(ENVELOPE_FROM_ADDRESS).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals(MailTestUtil.getAddressHeader(fromName, fromAddress), mess.getHeader("From", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(replyToAddress), mess.getHeader("Reply-To", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(toName, toAddress), mess.getHeader("To", null));
    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    Assert.assertEquals(MessagePriority.HIGH.getPriority(), mess.getHeader("Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getX_priority(), mess.getHeader("X-Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getImportance(), mess.getHeader("Importance", null));
    Assert.assertTrue(mess.getHeader("Content-Type", null).startsWith("multipart/mixed"));
    Assert.assertEquals(messageId, MailUtility.headerStripper(mess.getHeader("Message-ID", null)));

    MimeMultipart mixed = (MimeMultipart) mess.getContent();
    BodyPart text = mixed.getBodyPart(0);

    Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
    Assert.assertEquals(1, mixed.getCount());

    Assert.assertTrue("Incorrect Charset: " + e.getCharset(), text.getContentType().startsWith("text/plain; charset=" + e.getCharset()));
    Assert.assertEquals(textBody, MailTestUtil.getStringContent(text));
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:48,代码来源:MailMessageTest.java

示例11: testTextMailMessageSpecialCharacters

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testTextMailMessageSpecialCharacters() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "Sometimes subjects have speical characters like ü - " + java.util.UUID.randomUUID().toString();
    String specialTextBody = "This is a Text Body with a special character - ü";

    EmailMessage e;

    String messageId = "[email protected]";

    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        e =
                new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(replyToAddress).to(MailTestUtil.getAddressHeader(toName, toAddress)).subject(
                        subject).bodyText(specialTextBody).importance(MessagePriority.HIGH).messageId(messageId).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals("Subject has been modified", subject, MimeUtility.decodeText(MimeUtility.unfold(mess.getHeader("Subject", null))));

    MimeMultipart mixed = (MimeMultipart) mess.getContent();
    BodyPart text = mixed.getBodyPart(0);

    Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
    Assert.assertEquals(1, mixed.getCount());

    Assert.assertTrue("Incorrect Charset: " + e.getCharset(), text.getContentType().startsWith("text/plain; charset=" + e.getCharset()));
    Assert.assertEquals(specialTextBody, MimeUtility.decodeText(MailTestUtil.getStringContent(text)));
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:42,代码来源:MailMessageTest.java

示例12: testHTMLMailMessage

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testHTMLMailMessage() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "HTML Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
    Person person = new Person(toName, toAddress);

    EmailMessage e;

    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();
        e =
                new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(MailTestUtil.getAddressHeader(replyToName, replyToAddress)).to(person).subject(
                        subject).bodyHtml(htmlBody).importance(MessagePriority.HIGH).addAttachment(
                        new URLAttachment("http://design.jboss.org/seam/logo/final/seam_mail_85px.png", "seamLogo.png", ContentDisposition.INLINE)).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals(MailTestUtil.getAddressHeader(fromName, fromAddress), mess.getHeader("From", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(replyToName, replyToAddress), mess.getHeader("Reply-To", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(toName, toAddress), mess.getHeader("To", null));
    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    Assert.assertEquals(MessagePriority.HIGH.getPriority(), mess.getHeader("Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getX_priority(), mess.getHeader("X-Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getImportance(), mess.getHeader("Importance", null));
    Assert.assertEquals(e.getMessageId(), MailUtility.headerStripper(mess.getHeader("Message-ID", null)));
    Assert.assertTrue(mess.getHeader("Content-Type", null).startsWith("multipart/mixed"));

    MimeMultipart mixed = (MimeMultipart) mess.getContent();
    MimeMultipart related = (MimeMultipart) mixed.getBodyPart(0).getContent();
    BodyPart html = related.getBodyPart(0);
    BodyPart attachment1 = related.getBodyPart(1);

    Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
    Assert.assertEquals(1, mixed.getCount());

    Assert.assertTrue(related.getContentType().startsWith("multipart/related"));
    Assert.assertEquals(2, related.getCount());

    Assert.assertTrue(html.getContentType().startsWith("text/html"));
    Assert.assertEquals(htmlBody, MailTestUtil.getStringContent(html));

    Assert.assertTrue(attachment1.getContentType().startsWith("image/png;"));
    Assert.assertEquals("seamLogo.png", attachment1.getFileName());
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:56,代码来源:MailMessageTest.java

示例13: testHTMLTextAltMailMessage

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testHTMLTextAltMailMessage() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();
    String subject = "HTML+Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
    Person person = new Person(toName, toAddress);
    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).to(person).subject(subject).bodyHtmlTextAlt(htmlBody, textBody).importance(MessagePriority.LOW)
                .deliveryReceipt(fromAddress).readReceipt("seam.test").addAttachment("template.text.velocity", "text/plain", ContentDisposition.ATTACHMENT,
                        Resources.newInputStreamSupplier(Resources.getResource("template.text.velocity")).getInput()).addAttachment(
                        new URLAttachment("http://design.jboss.org/seam/logo/final/seam_mail_85px.png", "seamLogo.png", ContentDisposition.INLINE)).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals(MailTestUtil.getAddressHeader(fromName, fromAddress), mess.getHeader("From", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(toName, toAddress), mess.getHeader("To", null));
    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    Assert.assertEquals(MessagePriority.LOW.getPriority(), mess.getHeader("Priority", null));
    Assert.assertEquals(MessagePriority.LOW.getX_priority(), mess.getHeader("X-Priority", null));
    Assert.assertEquals(MessagePriority.LOW.getImportance(), mess.getHeader("Importance", null));
    Assert.assertTrue(mess.getHeader("Content-Type", null).startsWith("multipart/mixed"));

    MimeMultipart mixed = (MimeMultipart) mess.getContent();
    MimeMultipart related = (MimeMultipart) mixed.getBodyPart(0).getContent();
    MimeMultipart alternative = (MimeMultipart) related.getBodyPart(0).getContent();
    BodyPart attachment = mixed.getBodyPart(1);
    BodyPart inlineAttachment = related.getBodyPart(1);

    BodyPart textAlt = alternative.getBodyPart(0);
    BodyPart html = alternative.getBodyPart(1);

    Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
    Assert.assertEquals(2, mixed.getCount());

    Assert.assertTrue(related.getContentType().startsWith("multipart/related"));
    Assert.assertEquals(2, related.getCount());

    Assert.assertTrue(html.getContentType().startsWith("text/html"));
    Assert.assertEquals(htmlBody, MailTestUtil.getStringContent(html));

    Assert.assertTrue(textAlt.getContentType().startsWith("text/plain"));
    Assert.assertEquals(textBody, MailTestUtil.getStringContent(textAlt));

    Assert.assertTrue(attachment.getContentType().startsWith("text/plain"));
    Assert.assertEquals("template.text.velocity", attachment.getFileName());

    Assert.assertTrue(inlineAttachment.getContentType().startsWith("image/png;"));
    Assert.assertEquals("seamLogo.png", inlineAttachment.getFileName());
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:61,代码来源:MailMessageTest.java

示例14: testTextMailMessageLongFields

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testTextMailMessageLongFields() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "Sometimes it is important to have a really long subject even if nobody is going to read it - " + java.util.UUID.randomUUID().toString();

    String longFromName = "FromSometimesPeopleHaveNamesWhichAreALotLongerThanYouEverExpectedSomeoneToHaveSoItisGoodToTestUpTo100CharactersOrSo YouKnow?";
    String longFromAddress = "sometimesPeopleHaveNamesWhichAreALotLongerThanYo[email protected]jboss.org";
    String longToName = "ToSometimesPeopleHaveNamesWhichAreALotLongerThanYouEverExpectedSomeoneToHaveSoItisGoodToTestUpTo100CharactersOrSo YouKnow?";
    String longToAddress = "toSometimesPeopleHaveNamesWhichAreALotLongerThanYouEverExpec[email protected]seam-mail.test";
    String longCcName = "CCSometimesPeopleHaveNamesWhichAreALotLongerThanYouEverExpectedSomeoneToHaveSoItisGoodToTestUpTo100CharactersOrSo YouKnow? Hatty";
    String longCcAddress = "cCSometimesPeopleHaveNamesWhichAreALotLongerThanYouEverE[email protected]jboss.org";

    EmailMessage e;

    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        e =
                new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(longFromName, longFromAddress)).to(MailTestUtil.getAddressHeader(longToName, longToAddress)).cc(
                        MailTestUtil.getAddressHeader(longCcName, longCcAddress)).subject(subject).bodyText(textBody).importance(MessagePriority.HIGH).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 2 got " + wiser.getMessages().size(), wiser.getMessages().size() == 2);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals(MailTestUtil.getAddressHeader(longFromName, longFromAddress), mess.getHeader("From", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(longToName, longToAddress), mess.getHeader("To", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(longCcName, longCcAddress), mess.getHeader("CC", null));
    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    Assert.assertEquals(MessagePriority.HIGH.getPriority(), mess.getHeader("Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getX_priority(), mess.getHeader("X-Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getImportance(), mess.getHeader("Importance", null));
    Assert.assertTrue(mess.getHeader("Content-Type", null).startsWith("multipart/mixed"));

    MimeMultipart mixed = (MimeMultipart) mess.getContent();
    BodyPart text = mixed.getBodyPart(0);

    Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
    Assert.assertEquals(1, mixed.getCount());

    Assert.assertTrue("Incorrect Charset: " + e.getCharset(), text.getContentType().startsWith("text/plain; charset=" + e.getCharset()));
    Assert.assertEquals(textBody, MailTestUtil.getStringContent(text));
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:53,代码来源:MailMessageTest.java

示例15: testTextMailMessageUsingPerson

import org.subethamail.wiser.Wiser; //导入方法依赖的package包/类
@Test
public void testTextMailMessageUsingPerson() throws MessagingException, IOException {
    SessionConfig mailConfig = TestMailConfigs.standardConfig();

    String subject = "Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
    Person person = new Person(toName, toAddress);
    String messageId = "[email protected]";

    EmailMessage e;

    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.setHostname(mailConfig.getServerHost());
    try {
        wiser.start();

        e =
                new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(replyToAddress).to(person).subject(subject).bodyText(textBody).importance(
                        MessagePriority.HIGH).messageId(messageId).send();
    }
    finally {
        stop(wiser);
    }

    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);

    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();

    Assert.assertEquals(MailTestUtil.getAddressHeader(fromName, fromAddress), mess.getHeader("From", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(replyToAddress), mess.getHeader("Reply-To", null));
    Assert.assertEquals(MailTestUtil.getAddressHeader(toName, toAddress), mess.getHeader("To", null));
    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    Assert.assertEquals(MessagePriority.HIGH.getPriority(), mess.getHeader("Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getX_priority(), mess.getHeader("X-Priority", null));
    Assert.assertEquals(MessagePriority.HIGH.getImportance(), mess.getHeader("Importance", null));
    Assert.assertTrue(mess.getHeader("Content-Type", null).startsWith("multipart/mixed"));
    Assert.assertEquals(messageId, MailUtility.headerStripper(mess.getHeader("Message-ID", null)));

    MimeMultipart mixed = (MimeMultipart) mess.getContent();
    BodyPart text = mixed.getBodyPart(0);

    Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
    Assert.assertEquals(1, mixed.getCount());

    Assert.assertTrue("Incorrect Charset: " + e.getCharset(), text.getContentType().startsWith("text/plain; charset=" + e.getCharset()));
    Assert.assertEquals(textBody, MailTestUtil.getStringContent(text));
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
 
开发者ID:codylerum,项目名称:simple-email,代码行数:49,代码来源:MailMessageTest.java


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