使用Java邮件服务器进行测试 [英] Working with a Java Mail Server for Testing

查看:210
本文介绍了使用Java邮件服务器进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试从邮箱中取出邮件的应用程序,根据该邮件的内容执行一些操作,然后根据操作的结果发送一个响应邮件。

I'm in the process of testing an application that takes mail out of a mailbox, performs some action based on the content of that mail, and then sends a response mail depending on the result of the action.

我正在寻找一种方法来为此应用程序编写测试。理想情况下,我希望这些测试能够提供自己的邮件服务器,将我的测试电子邮件推送到邮件服务器上的一个文件夹,并让我的应用程序从我的测试开始的邮件服务器中删除邮件。

I'm looking for a way to write tests for this application. Ideally, I'd like for these tests to bring up their own mail server, push my test emails to a folder on this mail server, and have my application scrape the mail out of the mail server that my test started.

配置应用程序使用邮件服务器并不困难,但我不知道在哪里可以查找在Java中启动邮件服务器的编程方式。我看过JAMES,但是我无法确定如何从我的测试中启动服务器。

Configuring the application to use the mailserver is not difficult, but I do not know where to look for a programatic way of starting a mail server in Java. I've looked at JAMES, but I am unable to figure out how to start the server from within my test.

所以问题是这样的:我可以用什么一个Java的邮件服务器,我可以在Java中完全配置和启动。

So the question is this: What can I use for a mail server in Java that I can configure and start entirely within Java?

推荐答案

使用起来非常简单绿色邮件,这是设计师作为自动单元测试的邮件服务器。

There is also very simple in use GreenMail which was designer as a mail server for automatic "unit" tests.

从项目网页(可能还有一些其他工具,发送/接收功能现在):

From projects web page (probably there are some others tools with sending/receiving functionality nowadays):


GreenMail是一个开放源,直观的
和易于使用的电子邮件测试套件
服务器进行测试。支持
SMTP,POP3,IMAP与SSL套接字
支持。 GreenMail还提供了一个
JBoss GreenMail服务。 GreenMail是
的拳头,只有图书馆提供
一个测试框架,既可以接收
,也可以从Java中检索电子邮件。

GreenMail is an open source, intuitive and easy-to-use test suite of email servers for testing purposes. Supports SMTP, POP3, IMAP with SSL socket support. GreenMail also provides a JBoss GreenMail Service. GreenMail is the fist and only library that offers a test framework for both receiving and retrieving emails from Java.

这篇关于使用Java邮件服务器进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆