Java Code Examples for org.subethamail.wiser.Wiser#setPort()

The following examples show how to use org.subethamail.wiser.Wiser#setPort() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmailTestCase.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  int port = processEngineConfiguration.getMailServerPort();

  boolean serverUpAndRunning = false;
  while (!serverUpAndRunning) {
    wiser = new Wiser();
    wiser.setPort(port);

    try {
      LOG.info("Starting Wiser mail server on port: " + port);
      wiser.start();
      serverUpAndRunning = true;
      LOG.info("Wiser mail server listening on port: " + port);
    } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
      if (e.getMessage().toLowerCase().contains("BindException")) {
        Thread.sleep(250L);
      }
    }
  }
}
 
Example 2
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  boolean serverUpAndRunning = false;
  while (!serverUpAndRunning) {
    wiser = new Wiser();
    wiser.setPort(5025);

    try {
      wiser.start();
      serverUpAndRunning = true;
    } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
      if (e.getMessage().toLowerCase().contains("BindException")) {
        Thread.sleep(250L);
      }
    }
  }
}
 
Example 3
Source File: EmailTestCase.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  boolean serverUpAndRunning = false;
  while (!serverUpAndRunning) {
    wiser = new Wiser();
    wiser.setPort(5025);

    try {
      wiser.start();
      serverUpAndRunning = true;
    } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
      if (e.getMessage().toLowerCase().contains("bindexception")) {
        Thread.sleep(250L);
      }
    }
  }
}
 
Example 4
Source File: TimeoutTest.java    From subethasmtp with Apache License 2.0 6 votes vote down vote up
/** */
@Test
public void testTimeout() throws Exception {
	Wiser wiser = new Wiser();
	wiser.setPort(PORT);
	wiser.getServer().setConnectionTimeout(1000);
	wiser.start();

	SMTPClient client = new SMTPClient("localhost", PORT);
	client.sendReceive("HELO foo");
	Thread.sleep(2000);
	try {
		client.sendReceive("HELO bar");
		fail();
	} catch (SocketException e) {
		// expected
	} finally {
		wiser.stop();
	}
}
 
Example 5
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  
  boolean serverUpAndRunning = false;
  while (!serverUpAndRunning) {
    wiser = new Wiser();
    wiser.setPort(5025);
    
    try {
      wiser.start();
      serverUpAndRunning = true;
    } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
      if (e.getMessage().toLowerCase().contains("BindException")) {
        Thread.sleep(250L);
      }
    }
  }
}
 
Example 6
Source File: EmailTestCase.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  
  boolean serverUpAndRunning = false;
  while (!serverUpAndRunning) {
    wiser = new Wiser();
    wiser.setPort(5025);
    
    try {
      wiser.start();
      serverUpAndRunning = true;
    } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
      if (e.getMessage().toLowerCase().contains("bindexception")) {
        Thread.sleep(250L);
      }
    }
  }
}
 
Example 7
Source File: MailerTest.java    From rice with Educational Community License v2.0 6 votes vote down vote up
/**
 * Test that a Mailer can be retrieved via the KEWServiceLocator and can be used 
 * to send an e-mail message to the SMTP server.
 */
@Test
public void testSendMessage() {
	// Initialize SMTP server
	Wiser smtpServer = new Wiser();
	smtpServer.setPort(55000);
	smtpServer.start();
	
	// Test that a Mailer can be retrieved via the KEWServiceLocator
	Mailer mailer = null;
	mailer = CoreApiServiceLocator.getMailer();
	assertNotNull(mailer);
	
	// Test that an e-mail message gets sent to the SMTP server
	mailer.sendEmail(new EmailFrom(sender), new EmailTo(recipient), new EmailSubject(subject), new EmailBody(messageBody), false);
	Assert.assertEquals(1, smtpServer.getMessages().size());

       // Shutdown the SMTP server
       smtpServer.stop();        
}
 
Example 8
Source File: EmailSendTaskTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();

    boolean serverUpAndRunning = false;
    while (!serverUpAndRunning) {
        wiser = new Wiser();
        wiser.setPort(5025);

        try {
            wiser.start();
            serverUpAndRunning = true;
        } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
            if (e.getMessage().toLowerCase().contains("BindException")) {
                Thread.sleep(250L);
            }
        }
    }
}
 
Example 9
Source File: EmailTestCase.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();

    boolean serverUpAndRunning = false;
    while (!serverUpAndRunning) {
        wiser = new Wiser();
        wiser.setPort(5025);

        try {
            wiser.start();
            serverUpAndRunning = true;
        } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
            if (e.getMessage().toLowerCase().contains("bindexception")) {
                Thread.sleep(250L);
            }
        }
    }
}
 
Example 10
Source File: ContentEngineConfiguratorTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setup() throws Exception{
    if (processEngine == null) {
        processEngine = ProcessEngineConfiguration
            .createProcessEngineConfigurationFromResource("flowable.cfg.xml")
            .buildProcessEngine();
        contentEngineConfiguration = (ContentEngineConfiguration) processEngine.getProcessEngineConfiguration()
            .getEngineConfigurations().get(EngineConfigurationConstants.KEY_CONTENT_ENGINE_CONFIG);
        contentService = contentEngineConfiguration.getContentService();
    }

    wiser = new Wiser();
    wiser.setPort(5025);
    try {
        wiser.start();
    } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
        if (e.getMessage().toLowerCase().contains("bindexception")) {
            Thread.sleep(250L);
        }
    }
}
 
Example 11
Source File: EmailServiceTaskTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@BeforeEach
protected void setUp() throws Exception {
    boolean serverUpAndRunning = false;
    while (!serverUpAndRunning) {
        wiser = new Wiser();
        wiser.setPort(5025);

        try {
            wiser.start();
            serverUpAndRunning = true;
        } catch (RuntimeException e) { // Fix for slow port-closing CI Servers
            if (e.getMessage().toLowerCase().contains("bindexception")) {
                Thread.sleep(250L);
            }
        }
    }
}
 
Example 12
Source File: EmailSendTaskTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@BeforeEach
protected void setUp() throws Exception {
    boolean serverUpAndRunning = false;
    while (!serverUpAndRunning) {
        wiser = new Wiser();
        wiser.setPort(5025);

        try {
            wiser.start();
            serverUpAndRunning = true;
        } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
            if (e.getMessage().toLowerCase().contains("bindexception")) {
                Thread.sleep(250L);
            }
        }
    }
}
 
Example 13
Source File: EmailTestCase.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@BeforeEach
protected void setUp() throws Exception {

    initialForceTo = processEngineConfiguration.getMailServerForceTo();
    Map<String, MailServerInfo> mailServers = processEngineConfiguration.getMailServers();
    initialMailServers = mailServers == null ? null : new HashMap<>(mailServers);
    boolean serverUpAndRunning = false;
    while (!serverUpAndRunning) {
        wiser = new Wiser();
        wiser.setPort(5025);

        try {
            wiser.start();
            serverUpAndRunning = true;
        } catch (RuntimeException e) { // Fix for slow port-closing Jenkins
            if (e.getMessage().toLowerCase().contains("bindexception")) {
                Thread.sleep(250L);
            }
        }
    }
}
 
Example 14
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  wiser = new Wiser();
  wiser.setPort(5025);
  wiser.start();
}
 
Example 15
Source File: StartStopTest.java    From subethasmtp with Apache License 2.0 5 votes vote down vote up
/** */
private void startStop(boolean pause) throws Exception
{
	Wiser wiser = new Wiser();
	wiser.setPort(PORT);

	wiser.start();

	if (pause)
		Thread.sleep(1000);

	wiser.stop();

	this.counter++;
}
 
Example 16
Source File: SMTPTestWiser.java    From vertx-mail-client with Apache License 2.0 5 votes vote down vote up
protected void startSMTP(String factory) {
  wiser = new Wiser();

  wiser.setPort(1587);
  wiser.getServer().setAuthenticationHandlerFactory(new AuthenticationHandlerFactory() {
    /*
     * AUTH PLAIN handler which returns success on any string
     */
    @Override
    public List<String> getAuthenticationMechanisms() {
      return Arrays.asList("PLAIN");
    }

    @Override
    public AuthenticationHandler create() {
      return new AuthenticationHandler() {

        @Override
        public String auth(final String clientInput) throws RejectException {
          log.info(clientInput);
          return null;
        }

        @Override
        public Object getIdentity() {
          return "username";
        }
      };
    }
  });

  Security.setProperty("ssl.SocketFactory.provider", factory);
  wiser.getServer().setEnableTLS(true);

  wiser.start();
}
 
Example 17
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();
  wiser = new Wiser();
  wiser.setPort(5025);
  wiser.start();
}
 
Example 18
Source File: MailerImplTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BeforeAll
static void startWiser() {
    wiser = new Wiser();
    wiser.setPort(0);
    wiser.start();

    vertx = Vertx.vertx();
}
 
Example 19
Source File: MailClosedConnectionTest.java    From vertx-mail-client with Apache License 2.0 4 votes vote down vote up
@Before
public void startSMTP() {
  wiser = new Wiser();
  wiser.setPort(1587);
  wiser.start();
}
 
Example 20
Source File: EmailServiceTest.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@BeforeClass
public static void setUpEmailService() throws Exception {
	log.info("Setting up test case...");
	final ServerConfigurationService config = context.mock(ServerConfigurationService.class);

	emailService = new BasicEmailService();
	emailService.setServerConfigurationService(config);

	emailService.setSmtp(HOST);
	emailService.setSmtpPort(Integer.toString(PORT));
	emailService.setMaxRecipients("100");
	emailService.setOneMessagePerConnection(false);
	emailService.setAllowTransport(ALLOW_TRANSPORT);

	context.checking(new Expectations() {
		{
			allowing(config).getServerName();
			will(returnValue("localhost"));

			String connTimeoutKey = emailService.propName(BasicEmailService.MAIL_CONNECTIONTIMEOUT_T);
			allowing(config).getString(connTimeoutKey, null);
			will(returnValue(null));

			String timeoutKey = emailService.propName(BasicEmailService.MAIL_TIMEOUT_T);
			allowing(config).getString(timeoutKey, null);
			will(returnValue(null));

			allowing(config).getString(BasicEmailService.MAIL_SENDFROMSAKAI, "true");
			will(returnValue("true"));

			allowing(config).getString(BasicEmailService.MAIL_SENDFROMSAKAI_EXCEPTIONS, null);
			will(returnValue(null));

			allowing(config).getString(BasicEmailService.MAIL_SENDFROMSAKAI_FROMTEXT, "{}");
			will(returnValue("{}"));

			allowing(config).getInt(BasicEmailService.MAIL_SENDFROMSAKAI_MAXSIZE, 25000000);
			will(returnValue(25000000));

		}
	});

	log.debug("Initing EmailService...");
	emailService.init();
	log.debug("EmailService inited.");

	if (ALLOW_TRANSPORT) {
		log.debug("Starting internal mail server...");
		wiser = new Wiser();
		wiser.setPort(PORT);
		wiser.start();
		log.debug("Internal mail server started.");
	}
}