@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<String>();
    preDefinedTexts.add("12345");
    preDefinedTexts.add("abcde");
    accountCaptchaService.setPreDefinedTexts(preDefinedTexts);

    accountService = (AccountService) ctx.getBean("accountService");

    greenMail = new GreenMail(ServerSetup.SMTP);
    greenMail.setUser("*****@*****.**", "123456");
    greenMail.start();

    File persistDataFile = new File("target/test-classes/persist-data.xml");
    if (persistDataFile.exists()) {
      persistDataFile.delete();
    }
  }
示例#2
0
  @Override
  public void setUp() throws Exception {
    ServerSocket socket = new ServerSocket(0);
    this.emailServerPort = socket.getLocalPort();
    socket.close();

    // ServerSetup smtp = new ServerSetup( 1234, null, ServerSetup.PROTOCOL_SMTP );
    ServerSetup smtp = new ServerSetup(this.emailServerPort, null, ServerSetup.PROTOCOL_SMTP);

    server = new GreenMail(smtp);
    server.setUser("*****@*****.**", "smtp-username", "smtp-password");
    server.start();

    this.lookup(SecuritySystem.class).start();
  }
示例#3
0
 @Before
 public void setUp() {
   beforeTest = new Date();
   greenMail.start();
   mailbox = "*****@*****.**";
   password = "******";
   greenMail.setUser(mailbox, password);
   udr =
       new UserDataRequest(
           new Credentials(User.Factory.create().createUser(mailbox, mailbox, null), password),
           null,
           null,
           null);
   testUtils =
       new ImapTestUtils(
           mailboxService, privateMailboxService, udr, mailbox, beforeTest, collectionPathHelper);
 }
示例#4
0
  public StubMailServer() {

    greenmail = new GreenMail(new ServerSetup[] {IMAP_SERVER_SETUP, SMTP_SERVER_SETUP});
    GreenMailUser user =
        greenmail.setUser(
            UserForImap.TEST_USER.emailAddress,
            UserForImap.TEST_USER.loginUsername,
            UserForImap.TEST_USER.password);

    for (String mailbox : new String[] {"Drafts", "Spam"}) {
      Log.d(K9.LOG_TAG, "creating mailbox " + mailbox);
      try {
        greenmail.getManagers().getImapHostManager().createMailbox(user, mailbox);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    greenmail.start();
  }
 @Override
 public void afterPropertiesSet() throws Exception {
   greenMail = new GreenMail(new ServerSetup(port, null, ServerSetup.PROTOCOL_SMTP));
   greenMail.setUser(account, password);
   greenMail.start();
 }