Package com.dumbster.smtp

Examples of com.dumbster.smtp.SimpleSmtpServer


    assertEquals(1, errors.size());
  }
 
  @SuppressWarnings("unchecked")
  public void testGo() throws Exception{
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
    try {
      action.setUsername("johnp");
      action.setPassword("poploop");
      action.setPasswordConfirm("poploop");
      action.setEmail("johnp@example.com");
      String op = action.execute();
      assertEquals(ActionSupport.SUCCESS, op);
    } finally {
      mailServer.stop();
    }
    assertTrue(mailServer.getReceivedEmailSize() == 1);
    Iterator<SmtpMessage> emailIter = mailServer.getReceivedEmail();
    SmtpMessage email = (SmtpMessage) emailIter.next();
    assertTrue(email.getHeaderValue("Subject").equals("Email Verification"));
    assertNotNull(email.getBody());
    assertTrue(email.getBody().contains("Username(johnp)"));
    assertTrue(email.getBody().contains("URL(http://foo.com/gnizr/register/verifyEmail.action?username=johnp"));
View Full Code Here


    assertEquals(1, errors.size());
  }
 
  @SuppressWarnings("unchecked")
  public void testRenewUser() throws Exception{
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
    try {
      action.setUsername("hchen1");
      String op = action.doRenewUserAccount();
      assertEquals(ActionSupport.SUCCESS, op);
    } finally {
      mailServer.stop();
    }
    assertTrue(mailServer.getReceivedEmailSize() == 1);
    Iterator<SmtpMessage> emailIter = mailServer.getReceivedEmail();
    SmtpMessage email = (SmtpMessage) emailIter.next();
    assertTrue(email.getHeaderValue("Subject").equals("Email Verification"));
    assertNotNull(email.getBody());
    assertTrue(email.getBody().contains("Username(hchen1)"));
    assertTrue(email.getBody().contains("URL(http://foo.com/gnizr/register/verifyEmail.action?username=hchen1"));
View Full Code Here

    assertEquals(AccountStatus.INACTIVE,user.getAccountStatus().intValue());
  }
 
  @SuppressWarnings("unchecked")
  public void testRenewUser2() throws Exception{
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
    try {
      action.setUsername("gnizr");
      String op = action.doRenewUserAccount();
      assertEquals(ActionSupport.INPUT, op);
    } finally {
      mailServer.stop();
    }
    assertTrue(mailServer.getReceivedEmailSize() == 0);
   
    User user = userManager.getUser("gnizr");
    assertEquals(AccountStatus.ACTIVE,user.getAccountStatus().intValue());
  }
View Full Code Here

    assertEquals(AccountStatus.ACTIVE,user.getAccountStatus().intValue());
  }
 
  @SuppressWarnings("unchecked")
  public void testRenewUser3() throws Exception{
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
    try {
      action.setUsername("poopppp");
      String op = action.doRenewUserAccount();
      assertEquals(ActionSupport.INPUT, op);
    } finally {
      mailServer.stop();
    }
    assertTrue(mailServer.getReceivedEmailSize() == 0);
  }
View Full Code Here

  }
 
 
  @SuppressWarnings("unchecked")
  public void testGoApprovalEnabled() throws Exception{
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
    try {
      action.getGnizrConfiguration().setRegistrationPolicy("approval");
      action.setUsername("johnp");
      action.setPassword("poploop");
      action.setPasswordConfirm("poploop");
      action.setEmail("johnp@example.com");
      String op = action.execute();
      assertEquals(ActionSupport.SUCCESS, op);
    } finally {
      mailServer.stop();
    }
    assertTrue(mailServer.getReceivedEmailSize() == 2);
    Iterator<SmtpMessage> emailIter = mailServer.getReceivedEmail();
    SmtpMessage email = (SmtpMessage) emailIter.next();
    assertTrue(email.getHeaderValue("Subject").equals("Account Registration Pending"));
    assertNotNull(email.getBody());
    assertTrue(email.getBody().contains("NotifyEmail"));
    assertTrue(email.getBody().contains("Username(johnp)"));
View Full Code Here

    assertEquals(0, errors.size());
  }

  @SuppressWarnings("unchecked")
  public void testGo() throws Exception {
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
    try {
      action.setUsername("hchen1");
      String op = action.execute();
      assertEquals(ActionSupport.SUCCESS, op);
    } finally {
      mailServer.stop();
    }
    assertTrue(mailServer.getReceivedEmailSize() == 1);
    Iterator<SmtpMessage> emailIter = mailServer.getReceivedEmail();
    SmtpMessage email = (SmtpMessage) emailIter.next();
    assertTrue(email.getHeaderValue("Subject").equals("Reset Password"));
    assertNotNull(email.getBody());
    assertTrue(email.getBody().contains("Follow this URL to reset your password"));
  }
View Full Code Here

        .getResourceAsStream("/TestApproveUserAccount-input.xml"));
  }
 
  @SuppressWarnings("unchecked")
  public void testDoApproveActivationRequestion() throws Exception{
    SimpleSmtpServer mailServer = SimpleSmtpServer.start();
   
    User user = userManager.getUser(username);
    assertEquals(AccountStatus.INACTIVE,user.getAccountStatus().intValue());
    try{
      action.setUsername(username);
      action.setToken(token);
   
      String op = action.doApproveActivationRequest();
      assertEquals(ActionSupport.SUCCESS,op);
    }finally{
      mailServer.stop();
    }
   
    user = userManager.getUser(username);
    assertEquals(AccountStatus.ACTIVE,user.getAccountStatus().intValue());   
    assertFalse(tokenManager.isValidResetToken(token, user));
   
    assertTrue(mailServer.getReceivedEmailSize() == 1);
    Iterator<SmtpMessage> emailIter = mailServer.getReceivedEmail();
    SmtpMessage email = (SmtpMessage) emailIter.next();
    assertTrue(email.getHeaderValue("Subject").equals("Welcome"));
    assertNotNull(email.getBody());
    assertTrue(email.getBody().contains("WelcomeEmail"));
    assertTrue(email.getBody().contains("Username(hchen1)"));
View Full Code Here

    @Before
    public void startMailServer()
    {
        // starting it this way as we don't want to wait for a open socket
        mailServer = new SimpleSmtpServer(2525);
        Thread t = new Thread(mailServer);
        t.start();

    }
View Full Code Here

    @Before
    public void startMailServer() throws IOException
    {
        // starting it this way as we don't want to wait for a open socket
        mailServer = new SimpleSmtpServer(2525);
        Thread t = new Thread(mailServer);
        t.start();
        flushMailQueue(product.getProductInstance());
        mailServer.stop();

        // starting it this way as we don't want to wait for a open socket
        mailServer = new SimpleSmtpServer(2525);
        t = new Thread(mailServer);
        t.start();
    }
View Full Code Here

                        mockDj,
                        mockStation.getUrl() + "confirm?key="
                                + mockDj.getEmailConfirmation())).andReturn(
                mockEmailResponse);

        SimpleSmtpServer smtp = SimpleSmtpServer.start(mockStation
                .getSmtpServerPort());
        replay(mockEmailRenderer);
        jizzEmailServices.confirmEmailAddress(mockDj);
        smtp.stop();
        verify(mockEmailRenderer);

        assertEquals(1, smtp.getReceivedEmailSize());
        SmtpMessage msg = (SmtpMessage) smtp.getReceivedEmail().next();

        logger.debug("Confirmation email: {}", msg.getBody());
    }
View Full Code Here

TOP

Related Classes of com.dumbster.smtp.SimpleSmtpServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.