本文整理汇总了Java中com.dumbster.smtp.SimpleSmtpServer.stop方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleSmtpServer.stop方法的具体用法?Java SimpleSmtpServer.stop怎么用?Java SimpleSmtpServer.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dumbster.smtp.SimpleSmtpServer
的用法示例。
在下文中一共展示了SimpleSmtpServer.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
}
示例7: 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();
}
}
示例8: 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();
}
}
示例9: 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);
}
示例10: notifyAssign3
import com.dumbster.smtp.SimpleSmtpServer; //导入方法依赖的package包/类
@Test
public void notifyAssign3() {
log.debug("start notifyAssign3()");
Controllable c = createControllable(ExecutionStatus.POSTPONED);
MethodResource res = new MethodResource(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.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"));
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
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 (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: notifyAssign3WithRemarks
import com.dumbster.smtp.SimpleSmtpServer; //导入方法依赖的package包/类
@Test
public void notifyAssign3WithRemarks() {
log.debug("start notifyAssign3WithRemarks()");
Controllable c = createControllable(ExecutionStatus.POSTPONED);
EjbResource res = new EjbResource(new TEntity(), null, null);
res.setMethod("executePay");
c.setResource(res);
c.setCreateRemark("Hase");
c.setFirstApprovalRemark("Igel");
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"));
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
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 (executePay)\n"
+ "initiated by: userId on Fri Sep 20 16:13:22 CEST 2013\n"
+ "creation remark: Hase\n"
+ "first released by: firstApprovalUserId on Sun Sep 22 16:13:22 CEST 2013\n"
+ "remark: Igel\n\n\n" + "thanks for your attention\n"
+ "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例12: notifyFirstAssign
import com.dumbster.smtp.SimpleSmtpServer; //导入方法依赖的package包/类
@Test
public void notifyFirstAssign() {
log.debug("start notifyFirstAssign()");
Controllable c = createControllable(ExecutionStatus.FIRST_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.FIRST_POSTPONED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: FIRST_POSTPONED", email.getHeaderValue("Subject"));
Iterator<String> it = email.getHeaderNames();
while (it.hasNext()) {
String key = it.next();
log.debug(key + " = " + email.getHeaderValue(key));
}
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
log.debug(email.getBody());
String exp = "Hello approvalUser,\n\n"
+ "A business case under 6-eyes dual control has been assigned to you for a first 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"
+ "thanks for your attention\n" + "Cibet (http://www.logitags.com/cibet)";
Assert.assertEquals(exp, email.getBody());
} finally {
server.stop();
}
}
示例13: notifyFirstAssign2
import com.dumbster.smtp.SimpleSmtpServer; //导入方法依赖的package包/类
@Test
public void notifyFirstAssign2() {
log.debug("start notifyFirstAssign2()");
Controllable c = createControllable(ExecutionStatus.FIRST_POSTPONED);
MethodResource res = new MethodResource(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_POSTPONED, c);
server.stop();
Assert.assertTrue(server.getReceivedEmailSize() == 1);
Iterator<SmtpMessage> emailIter = server.getReceivedEmail();
SmtpMessage email = emailIter.next();
Assert.assertEquals("Cibet Notification: FIRST_POSTPONED", email.getHeaderValue("Subject"));
Iterator<String> it = email.getHeaderNames();
while (it.hasNext()) {
String key = it.next();
log.debug(key + " = " + email.getHeaderValue(key));
}
Assert.assertEquals("[email protected]", email.getHeaderValue("From"));
Assert.assertEquals("[email protected]", email.getHeaderValue("To"));
log.debug(email.getBody());
String exp = "Hello approvalUser,\n\n"
+ "A business case under 6-eyes dual control has been assigned to you for a first 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 (executePay)\n"
+ "initiated by: userId on Fri Sep 20 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();
}
}
示例14: notifyRejected2
import com.dumbster.smtp.SimpleSmtpServer; //导入方法依赖的package包/类
@Test
public void notifyRejected2() {
log.debug("start notifyRejected2()");
Controllable c = createControllable(ExecutionStatus.REJECTED);
MethodResource res = new MethodResource(new TEntity(), null, null);
res.setMethod("executePay");
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.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 (executePay)\n"
+ "initiated by: userId on Fri Sep 20 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();
}
}
示例15: notifyReleased2
import com.dumbster.smtp.SimpleSmtpServer; //导入方法依赖的package包/类
@Test
public void notifyReleased2() {
log.debug("start notifyReleased2()");
Controllable c = createControllable(ExecutionStatus.EXECUTED);
EjbResource res = new EjbResource(new TEntity(), null, null);
res.setMethod("executePay");
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.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 (executePay)\n"
+ "initiated by: userId on Fri Sep 20 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();
}
}