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

The following examples show how to use org.subethamail.wiser.Wiser#start() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
Source File: SMTPMessageSenderTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@BeforeEach
void setUp() throws IOException {
    testingSMTPServer = new Wiser(RANDOM_PORT);
    testingSMTPServer.start();

    testee = new SMTPMessageSender(Domain.LOCALHOST.asString())
        .connect(LOCALHOST, Port.of(testingSMTPServer.getServer().getPort()));
}
 
Example 11
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 12
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 13
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 14
Source File: SpringBootMailIntegrationTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    final int TEST_PORT = 8025;
    wiser = new Wiser(TEST_PORT);
    wiser.start();
}
 
Example 15
Source File: WiserSmtpService.java    From sling-samples with Apache License 2.0 4 votes vote down vote up
@Activate
public void activate(final WiserSmtpServiceConfiguration configuration) throws Exception {
    wiser = new Wiser(configuration.smtpPort());
    wiser.start();
}
 
Example 16
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.");
	}
}
 
Example 17
Source File: RelayFunctionalTest.java    From mireka with Apache License 2.0 4 votes vote down vote up
private void setupWiser() {
    wiser = new Wiser(2525);
    wiser.getServer().getCommandHandler()
            .addCommand(new ObservableQuitCommand());
    wiser.start();
}
 
Example 18
Source File: EmailSteps.java    From datamill with ISC License 4 votes vote down vote up
@Before("@emailing")
public void startUpServer() {
    smtpServer = new Wiser(getSmtpPort());
    smtpServer.start();
}
 
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: ClientServerRelayTest.java    From mireka with Apache License 2.0 4 votes vote down vote up
private void setupWiser() {
    wiser = new Wiser(8026);
    wiser.start();
}