本文整理汇总了Java中com.dumbster.smtp.SimpleSmtpServer类的典型用法代码示例。如果您正苦于以下问题:Java SimpleSmtpServer类的具体用法?Java SimpleSmtpServer怎么用?Java SimpleSmtpServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleSmtpServer类属于com.dumbster.smtp包,在下文中一共展示了SimpleSmtpServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@org.junit.Before
public void setUp() throws Exception {
String in = IOUtils.toString(getClass().getResourceAsStream("/test-mail-action-state.yml"));
YamlModelAccessor<ActionState> yaml = new YamlModelAccessor<>();
mailState = yaml.convertEntry(in);
server = SimpleSmtpServer.start(2525);
SMTPUtilImpl smtp = new SMTPUtilImpl();
smtp.setMailhost("localhost");
smtp.setMailport(2525);
action = new SendMailAction();
action.setConfig(config);
action.setSmtpUtil(smtp);
action.setConfig(config);
List<MailReceiver> receiverList = new ArrayList<>();
when(mailRec.getEmail()).thenReturn("[email protected]");
receiverList.add(mailRec);
when(config.readMailReveiverForMailinglist(anyString())).thenReturn(receiverList);
}
示例2: assertMail
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
public static void assertMail(
SimpleSmtpServer server,
String from,
String to,
String replyTo,
String subject,
String mimeType,
String body,
String attachmentContentID,
String attachmentFileName) {
assertEquals(server.getReceivedEmails().size(), 1);
SmtpMessage email = server.getReceivedEmails().iterator().next();
assertEquals(email.getHeaderValue("Subject"), subject);
assertEquals(email.getHeaderValue("From"), from);
assertEquals(email.getHeaderValue("Reply-To"), replyTo);
assertEquals(email.getHeaderValue("To"), to);
assertTrue(email.getBody().contains("Content-Type: " + mimeType));
assertTrue(email.getBody().contains(body));
if (attachmentFileName != null && attachmentContentID != null) {
assertTrue(email.getBody().contains("filename=" + attachmentFileName));
assertTrue(email.getBody().contains("Content-ID: <" + attachmentContentID + ">"));
}
}
示例3: setup
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@BeforeMethod
public void setup(ITestContext context) throws IOException {
server = SimpleSmtpServer.start(SimpleSmtpServer.AUTO_SMTP_PORT);
Map<String, String> mailConfiguration =
ImmutableMap.of(
"mail.smtp.host",
"localhost",
"mail.smtp.port",
server.getPort() + "",
"mail.transport.protocol",
"smtp",
" mail.smtp.auth",
"false");
mailSender = new MailSender(new MailSessionProvider(mailConfiguration));
}
示例4: restoreMailConfiguration
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
/**
* Restore mail configuration.
*
* @param createTestApplicationSession
* the create test application session
* @param dumbster
* the dumbster
*/
protected final void restoreMailConfiguration(final CreateApplicationSessionRequest createTestApplicationSession,final SimpleSmtpServer dumbster) {
final ApplicationConfiguration sendEmail = applicationConfigurationService.checkValueOrLoadDefault(
"Email configuration send emails", "Send email", ConfigurationGroup.EXTERNAL_SERVICES,
EmailServiceImpl.class.getSimpleName(), "Send email", "Responsible for sending email",
"application.email.send.email", "false");
final ApplicationConfiguration smtpPort = applicationConfigurationService.checkValueOrLoadDefault(
"Email configuration smtp port", "Smtp port", ConfigurationGroup.EXTERNAL_SERVICES,
EmailServiceImpl.class.getSimpleName(), "Smtp port", "Responsible for sending email",
"application.email.smtp.port", "587");
updateApplicationConfiguration(createTestApplicationSession, sendEmail, "false");
updateApplicationConfiguration(createTestApplicationSession, smtpPort,"587");
dumbster.stop();
}
示例5: send
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void send() {
LostPasswordSpammer spammer = new LostPasswordSpammer(config);
User user = new User();
user.setEmail("[email protected]");
user.setActivationKey("123");
spammer.prepare(user, "lost subject");
SimpleSmtpServer server = null;
try {
server = SimpleSmtpServer.start(config.getInt(ConfigKeys.MAIL_SMTP_PORT));
spammer.dispatchMessages();
}
finally {
if (server != null) {
server.stop();
}
}
Assert.assertEquals(1, server.getReceivedEmailSize());
SmtpMessage message = (SmtpMessage)server.getReceivedEmail().next();
Assert.assertTrue(message.getBody().indexOf("http://localhost/user/recoverPassword/123.page") > -1);
}
示例6: getValidFakeConfig
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
private JavaMailSender getValidFakeConfig() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("localhost");
mailSender.setPort(SimpleSmtpServer.DEFAULT_SMTP_PORT);
Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.debug", "true");
return mailSender;
}
示例7: notifyAssign
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void notifyAssign() {
log.debug("start notifyAssign()");
Controllable c = createControllable(ExecutionStatus.POSTPONED);
JpaResource res = new JpaResource(new TEntity());
c.setResource(res);
EmailNotificationProvider prov = new EmailNotificationProvider();
prov.setFrom("[email protected]");
prov.setSmtpHost("localhost");
prov.setSmtpPort("8854");
SimpleSmtpServer server = SimpleSmtpServer.start(8854);
try {
prov.notify(ExecutionStatus.POSTPONED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: POSTPONED", email.getHeaderValue("Subject"));
log.debug(email.getBody());
String exp = "Hello approvalUser,\n\n"
+ "A business case under dual control has been assigned to you for final approval. You may release or reject the case. Please visit the dialogue for releasing/rejecting.\n"
+ "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
+ "control event: DELETE\n"
+ "controlled target: com.cibethelper.entities.TEntity \n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n"
+ "first released by: firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n\n\n"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例8: notifyAssign2
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void notifyAssign2() {
log.debug("start notifyAssign2()");
Controllable c = createControllable(ExecutionStatus.POSTPONED);
JpaResource res = new JpaResource(new TEntity());
c.setResource(res);
c.setFirstApprovalUser(null);
c.setFirstApprovalAddress(null);
c.setFirstApprovalDate(null);
EmailNotificationProvider prov = new EmailNotificationProvider();
prov.setFrom("[email protected]");
prov.setSmtpHost("localhost");
prov.setSmtpPort("8854");
SimpleSmtpServer server = SimpleSmtpServer.start(8854);
try {
prov.notify(ExecutionStatus.POSTPONED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: POSTPONED", email.getHeaderValue("Subject"));
log.debug(email.getBody());
String exp = "Hello approvalUser,\n\n"
+ "A business case under dual control has been assigned to you for final approval. You may release or reject the case. Please visit the dialogue for releasing/rejecting.\n"
+ "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
+ "control event: DELETE\n"
+ "controlled target: com.cibethelper.entities.TEntity \n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n\n\n\n"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例9: notifyFirstReleased
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void notifyFirstReleased() {
log.debug("start notifyFirstReleased()");
Controllable c = createControllable(ExecutionStatus.FIRST_RELEASED);
JpaResource res = new JpaResource(new TEntity());
c.setResource(res);
EmailNotificationProvider prov = new EmailNotificationProvider();
prov.setFrom("[email protected]");
prov.setSmtpHost("localhost");
prov.setSmtpPort("8854");
SimpleSmtpServer server = SimpleSmtpServer.start(8854);
try {
prov.notify(ExecutionStatus.FIRST_RELEASED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: FIRST_RELEASED", email.getHeaderValue("Subject"));
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
log.debug(email.getBody());
String exp = "Hello userId,\n\n"
+ "A business case under 6-eyes dual control has been released by the first approval user.\n"
+ "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
+ "control event: DELETE\n"
+ "controlled target: com.cibethelper.entities.TEntity \n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n"
+ "first released by: firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n\n\n"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例10: notifyFirstReleased2
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void notifyFirstReleased2() {
log.debug("start notifyFirstReleased2()");
Controllable c = createControllable(ExecutionStatus.FIRST_RELEASED);
EjbResource res = new EjbResource(new TEntity(), null, null);
res.setMethod("executePay");
c.setResource(res);
EmailNotificationProvider prov = new EmailNotificationProvider();
prov.setFrom("[email protected]");
prov.setSmtpHost("localhost");
prov.setSmtpPort("8854");
SimpleSmtpServer server = SimpleSmtpServer.start(8854);
try {
prov.notify(ExecutionStatus.FIRST_RELEASED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: FIRST_RELEASED", email.getHeaderValue("Subject"));
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
log.debug(email.getBody());
String exp = "Hello userId,\n\n"
+ "A business case under 6-eyes dual control has been released by the first approval user.\n"
+ "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
+ "control event: DELETE\n"
+ "controlled target: com.cibethelper.entities.TEntity (executePay)\n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n"
+ "first released by: firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n\n\n"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例11: notifyRejected
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void notifyRejected() {
log.debug("start notifyRejected()");
Controllable c = createControllable(ExecutionStatus.REJECTED);
JpaResource res = new JpaResource(new TEntity());
c.setResource(res);
EmailNotificationProvider prov = new EmailNotificationProvider();
prov.setFrom("[email protected]");
prov.setSmtpHost("localhost");
prov.setSmtpPort("8854");
SimpleSmtpServer server = SimpleSmtpServer.start(8854);
try {
prov.notify(ExecutionStatus.REJECTED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: REJECTED", email.getHeaderValue("Subject"));
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
log.debug(email.getBody());
String exp = "Hello userId,\n\n" + "A business case under dual control has been rejected.\n"
+ "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
+ "control event: DELETE\n"
+ "controlled target: com.cibethelper.entities.TEntity \n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n"
+ "first released by: firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n"
+ "rejected by: approvalUser on Wed Sep 25 16:13:22 CEST 2013\n\n\n"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例12: notifyReleased
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void notifyReleased() {
log.debug("start notifyReleased()");
Controllable c = createControllable(ExecutionStatus.EXECUTED);
JpaResource res = new JpaResource(new TEntity());
c.setResource(res);
EmailNotificationProvider prov = new EmailNotificationProvider();
prov.setFrom("[email protected]");
prov.setSmtpHost("localhost");
prov.setSmtpPort("8854");
SimpleSmtpServer server = SimpleSmtpServer.start(8854);
try {
prov.notify(ExecutionStatus.EXECUTED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: EXECUTED", email.getHeaderValue("Subject"));
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
log.debug(email.getBody());
String exp = "Hello userId,\n\n" + "A business case under dual control has been finally released.\n"
+ "The dual controlled business case is registered under id: 123 (case id: test-caseid)\n\n"
+ "control event: DELETE\n"
+ "controlled target: com.cibethelper.entities.TEntity \n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n"
+ "first released by: firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n"
+ "released by: approvalUser on Wed Sep 25 16:13:22 CEST 2013\n\n\n"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例13: send
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Test
public void send() {
when(repository.getTotalPosts(notNull(Topic.class))).thenReturn(10);
TopicReplySpammer spammer = new TopicReplySpammer(config);
List<User> users = new ArrayList<User>();
User u1 = new User(); u1.setEmail("[email protected]");
User u2 = new User(); u2.setEmail("[email protected]");
users.add(u1); users.add(u2);
Topic topic = new Topic(repository); topic.setId(1); topic.setSubject("subject x");
topic.setLastPost(new Post()); topic.getLastPost().setId(123);
spammer.prepare(topic, users);
SimpleSmtpServer server = null;
try {
server = SimpleSmtpServer.start(config.getInt(ConfigKeys.MAIL_SMTP_PORT));
spammer.dispatchMessages();
}
finally {
if (server != null) {
server.stop();
}
}
Assert.assertEquals(2, server.getReceivedEmailSize());
SmtpMessage message = (SmtpMessage)server.getReceivedEmail().next();
Assert.assertTrue(message.getBody().indexOf("subject x") > -1);
Assert.assertTrue(message.getBody().indexOf("http://localhost/topics/list/1.page#123") > -1);
Assert.assertTrue(message.getBody().indexOf("http://localhost/topics/unwatch/1.page") > -1);
}
示例14: setup
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@Before
public void setup() {
smtpServer = SimpleSmtpServer.start(TEST_SMTP_PORT);
emailService = new SpitterEmailServiceImpl();
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setPort(1025);
emailService.mailSender = mailSender;
}
示例15: startManager
import com.dumbster.smtp.SimpleSmtpServer; //导入依赖的package包/类
@BeforeClass
public static void startManager() throws ConfigurationException {
Registry.start();
try {
smtpPort = 9700 + new Random().nextInt(99);
httpPort = 9600 + new Random().nextInt(99);
System.setProperty(Property.DEFAULT_JUDDI_EMAIL_PREFIX + "mail.smtp.host", "localhost");
System.setProperty(Property.DEFAULT_JUDDI_EMAIL_PREFIX + "mail.smtp.port", String.valueOf(smtpPort));
System.setProperty(Property.DEFAULT_JUDDI_EMAIL_PREFIX + "mail.smtp.from", "[email protected]");
mailServer = SimpleSmtpServer.start(smtpPort);
//bring up the TCK HTTP SubscriptionListener
httpEndpoint = "http://localhost:" + httpPort + "/tcksubscriptionlistener";
System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
logger.debug("Getting auth tokens..");
api010.saveJoePublisher();
api010.saveMaryPublisher();
UDDISecurityPortType security = new UDDISecurityImpl();
authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
Assert.assertNotNull(authInfoJoe);
authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
Assert.assertNotNull(authInfoMary);
} catch (Exception e) {
logger.error(e.getMessage(), e);
Assert.fail(e.getMessage());
}
}