當前位置: 首頁>>代碼示例>>Java>>正文


Java GreenMail.setUser方法代碼示例

本文整理匯總了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();
}
 
開發者ID:gitblit,項目名稱:fathom,代碼行數:17,代碼來源:MailerTest.java

示例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));

}
 
開發者ID:ohtuprojekti,項目名稱:OKKoPa,代碼行數:25,代碼來源:IMAPfolderTest.java

示例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));
}
 
開發者ID:ohtuprojekti,項目名稱:OKKoPa,代碼行數:19,代碼來源:IMAPserverTest.java

示例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");
}
 
開發者ID:ohtuprojekti,項目名稱:OKKoPa,代碼行數:24,代碼來源:IMAPmessageTest.java

示例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;
}
 
開發者ID:tapack,項目名稱:satisfy,代碼行數:8,代碼來源:FakeEmailServerRunnerImpl.java

示例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();
}
 
開發者ID:theparanoidtimes,項目名稱:tabellarium,代碼行數:9,代碼來源:ImapMailboxFolderTaskExecutorTest.java

示例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();
    }
}
 
開發者ID:junwei-wang,項目名稱:com.hotfixs.books,代碼行數:30,代碼來源:AccountServiceTest.java

示例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()));
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:16,代碼來源:TestEmailNotifier.java

示例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();
}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:8,代碼來源:TestEmailSender.java

示例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();
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:22,代碼來源:ExampleReceiveNoRuleTest.java

示例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;
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:25,代碼來源:ConcurrentCloseIT.java

示例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;
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:31,代碼來源:GreenMailBean.java

示例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());
}
 
開發者ID:Cognifide,項目名稱:bobcat,代碼行數:14,代碼來源:MailServer.java

示例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!");
}
 
開發者ID:wso2,項目名稱:product-ei,代碼行數:10,代碼來源:GreenMailServer.java

示例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();
    }
}
 
開發者ID:greenmail-mail-test,項目名稱:greenmail,代碼行數:36,代碼來源:GreenMailUtilTest.java


注:本文中的com.icegreen.greenmail.util.GreenMail.setUser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。