本文整理匯總了Java中com.icegreen.greenmail.util.GreenMail.setUser方法的典型用法代碼示例。如果您正苦於以下問題:Java GreenMail.setUser方法的具體用法?Java GreenMail.setUser怎麽用?Java GreenMail.setUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.icegreen.greenmail.util.GreenMail
的用法示例。
在下文中一共展示了GreenMail.setUser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
String username = settings.getString(Mailer.Setting.mail_username, null);
String password = settings.getString(Mailer.Setting.mail_password, null);
int port = settings.getInteger(Mailer.Setting.mail_port, 0);
String systemAddress = settings.getString(Mailer.Setting.mail_systemAddress, null);
// start the test smtp server
server = new GreenMail(new ServerSetup(port, null, ServerSetup.PROTOCOL_SMTP));
server.setUser(systemAddress, username, password);
server.start();
// start the mailer service
mailer.start();
}
示例2: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Before
public void setUp() throws MessagingException, UserException, InterruptedException {
ServerSetup sS = new ServerSetup(4008, "localhost", ServerSetup.PROTOCOL_IMAPS);
greenMail = new GreenMail(sS);
greenMail.start();
user = greenMail.setUser("[email protected]", "okkopa", "soooosecret");
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setSubject("subject2576Hf");
message.setText("viesti");
user.deliver(message);
Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
server = new IMAPserver("localhost", "okkopa", "soooosecret", 4008);
server.login();
IMAPfolder = new IMAPfolder(server, "inbox");
assertTrue(greenMail.waitForIncomingEmail(5000, 1));
}
示例3: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
ServerSetup sS = new ServerSetup(4008, "localhost", ServerSetup.PROTOCOL_IMAPS);
greenMail = new GreenMail(sS);
greenMail.start();
user = greenMail.setUser("[email protected]", "okkopa", "soooosecret");
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setSubject("subject2576Hf");
message.setText("viesti");
user.deliver(message);
Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
assertTrue(greenMail.waitForIncomingEmail(5000, 1));
}
示例4: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Before
public void setUp() throws MessagingException, UserException, InterruptedException {
Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
ServerSetup sS = new ServerSetup(4008, "localhost", ServerSetup.PROTOCOL_IMAPS);
greenMail = new GreenMail(sS);
greenMail.start();
user = greenMail.setUser("[email protected]", "okkopa", "soooosecret");
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setSubject("subject2576Hf");
message.setText("viesti");
user.deliver(message);
assertTrue(greenMail.waitForIncomingEmail(5000, 1));
server = new IMAPserver("localhost", "okkopa", "soooosecret", 4008);
server.login();
IMAPfolder = new IMAPfolder(server, "inbox");
}
示例5: startGreenMailServers
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
private GreenMail startGreenMailServers() {
ServerSetup[] serverSetups = getServerSetups();
GreenMail greenMail = new GreenMail(serverSetups);
greenMail.setUser(PropertyAccessor.getTestMailBoxLogin(), PropertyAccessor.getTestMailBoxPass());
greenMail.start();
return greenMail;
}
示例6: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
ServerSetup serverSetup = new ServerSetup(30993, "localhost", "imap");
greenMail = new GreenMail(serverSetup);
GreenMailUser user = greenMail.setUser("[email protected]", "[email protected]", "password");
inbox = greenMail.getManagers().getImapHostManager().getInbox(user);
greenMail.start();
}
示例7: prepare
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Before
public void prepare()
throws Exception {
String[] springConfigFiles = {
"account-email.xml",
"account-persist.xml",
"account-captcha.xml",
"account-service.xml"};
ApplicationContext ctx = new ClassPathXmlApplicationContext(springConfigFiles);
AccountCaptchaService accountCaptchaService = (AccountCaptchaService) ctx.getBean("accountCaptchaService");
List<String> preDefinedTexts = new ArrayList<>();
preDefinedTexts.add("12345");
preDefinedTexts.add("abcde");
accountCaptchaService.setPreDefinedTexts(preDefinedTexts);
accountService = (AccountService) ctx.getBean("accountService");
greenMail = new GreenMail(new ServerSetup(8008, null, "smtp"));
greenMail.setUser("[email protected]", "password");
greenMail.start();
File persistDataFile = new File("target/test-classes/persist-data.xml");
if (persistDataFile.exists()) {
persistDataFile.delete();
}
}
示例8: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
ServerSetup serverSetup = new ServerSetup(getFreePort(), "localhost", "smtp");
server = new GreenMail(serverSetup);
server.setUser("[email protected]", "user", "password");
server.start();
Configuration conf = new Configuration();
conf.set("mail.smtp.host", "localhost");
conf.set("mail.smtp.port", Integer.toString(server.getSmtp().getPort()));
emailSender = new EmailSender(conf);
runtimeInfo = new StandaloneRuntimeInfo(RuntimeModule.SDC_PROPERTY_PREFIX, new MetricRegistry(),
Arrays.asList(TestEmailNotifier.class.getClassLoader()));
}
示例9: setUp
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
ServerSetup serverSetup = new ServerSetup(getFreePort(), "localhost", "smtp");
server = new GreenMail(serverSetup);
server.setUser("[email protected]", "user", "password");
server.start();
}
示例10: testReceive
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Test
public void testReceive() throws MessagingException, IOException {
//Start all email servers using non-default ports.
GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
try {
greenMail.start();
//Use random content to avoid potential residual lingering problems
final String subject = GreenMailUtil.random();
final String body = GreenMailUtil.random();
MimeMessage message = createMimeMessage(subject, body, greenMail); // Construct message
GreenMailUser user = greenMail.setUser("[email protected]", "waelc", "soooosecret");
user.deliver(message);
assertEquals(1, greenMail.getReceivedMessages().length);
// --- Place your retrieve code here
} finally {
greenMail.stop();
}
}
示例11: testThis
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
private void testThis() throws InterruptedException {
exc = null;
final GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP);
greenMail.setUser("[email protected]","[email protected]");
greenMail.start();
final Thread sendThread = new Thread() {
public void run() {
try {
sendMail("[email protected]", "[email protected]", "abc", "def", ServerSetupTest.SMTP);
} catch (final Throwable e) {
exc = new RuntimeException(e);
}
}
};
sendThread.start();
greenMail.waitForIncomingEmail(3000, 1);
final MimeMessage[] emails = greenMail.getReceivedMessages();
assertEquals(1, emails.length);
greenMail.stop();
sendThread.join(10000);
if (exc != null) {
throw exc;
}
}
示例12: afterPropertiesSet
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
/**
* Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied
* BeanFactoryAware and ApplicationContextAware). <p>This method allows the bean instance to
* perform initialization only possible when all bean properties have been set and to throw an
* exception in the event of misconfiguration.
*
* @throws Exception in the event of misconfiguration (such as failure to set an essential
* property) or if initialization fails.
*/
@Override
public void afterPropertiesSet() throws Exception {
greenMail = new GreenMail(createServerSetup());
if (null != users) {
for (String user : users) {
int posColon = user.indexOf(':');
int posAt = user.indexOf('@');
String login = user.substring(0, posColon);
String pwd = user.substring(posColon + 1, posAt);
String domain = user.substring(posAt + 1);
if (log.isDebugEnabled()) {
log.debug("Adding user " + login + ':' + pwd + '@' + domain);
}
greenMail.setUser(login + '@' + domain, login, pwd);
}
}
if (autostart) {
greenMail.start();
started = true;
}
}
示例13: start
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
public void start() {
Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
// from javadoc
// smtp 3025
// smtps 3465
// pop3 3110
// pop3s 3995
// imap 3143
// imaps 3993
mailServer = new GreenMail();
mailServer.start();
mailServer.setUser(address, config.getUsername(), config.getPassword());
}
示例14: startServer
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
/**
* Start the server and add the user.
*/
public void startServer() {
greenMail = new GreenMail();
greenMail.start();
primaryUser = greenMail.setUser(USER_EMAIL, USER_LOGIN, USER_PW);
log.info("GreenMail Server started and user added!");
}
示例15: testSendTextEmailTest
import com.icegreen.greenmail.util.GreenMail; //導入方法依賴的package包/類
@Test
public void testSendTextEmailTest() throws Exception {
GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP);
try {
greenMail.setUser("[email protected]", "pwd");
greenMail.start();
GreenMailUtil.sendTextEmail("\"Foo, Bar\" <[email protected]>", "\"Bar, Foo\" <[email protected]>",
"Test subject", "Test message", ServerSetupTest.SMTP);
greenMail.waitForIncomingEmail(1);
Store store = greenMail.getImap().createStore();
store.connect("[email protected]", "pwd");
try {
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message[] msgs = folder.getMessages();
assertTrue(null != msgs && msgs.length == 1);
Message m = msgs[0];
assertEquals("Test subject", m.getSubject());
Address a[] = m.getRecipients(Message.RecipientType.TO);
assertTrue(null != a && a.length == 1
&& a[0].toString().equals("\"Foo, Bar\" <[email protected]>"));
a = m.getFrom();
assertTrue(null != a && a.length == 1
&& a[0].toString().equals("\"Bar, Foo\" <[email protected]>"));
assertTrue(m.getContentType().toLowerCase()
.startsWith("text/plain"));
assertEquals("Test message", m.getContent());
} finally {
store.close();
}
} finally {
greenMail.stop();
}
}