org.subethamail.wiser.Wiser Java Examples
The following examples show how to use
org.subethamail.wiser.Wiser.
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 flowable-engine with Apache License 2.0 | 6 votes |
@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 #2
Source File: TimeoutTest.java From subethasmtp with Apache License 2.0 | 6 votes |
/** */ @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 #3
Source File: MessageContentTest.java From subethasmtp with Apache License 2.0 | 6 votes |
/** */ @Override protected void setUp() throws Exception { super.setUp(); Properties props = new Properties(); props.setProperty("mail.smtp.host", "localhost"); props.setProperty("mail.smtp.port", Integer.toString(PORT)); this.session = Session.getInstance(props); this.wiser = new Wiser(); this.wiser.setPort(PORT); this.wiser.start(); }
Example #4
Source File: EmailTestCase.java From flowable-engine with Apache License 2.0 | 6 votes |
@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 #5
Source File: EmailSendTaskTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@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 #6
Source File: EmailServiceTaskTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@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 #7
Source File: ContentEngineConfiguratorTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@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 #8
Source File: EmailSendTaskTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@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: MailerTest.java From rice with Educational Community License v2.0 | 6 votes |
/** * 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 #10
Source File: EmailTestCase.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@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 #11
Source File: EmailSendTaskTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@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 #12
Source File: EmailTestCase.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@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 #13
Source File: EmailSendTaskTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@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 #14
Source File: AbstractEmailTest.java From commons-email with Apache License 2.0 | 6 votes |
/** * Validate the message was sent properly * @param mailServer reference to the fake mail server * @param strSubject expected subject * @param strMessage the expected message as a string * @param fromAdd expected from address * @param toAdd list of expected to addresses * @param ccAdd list of expected cc addresses * @param bccAdd list of expected bcc addresses * @param boolSaveToFile true will output to file, false doesnt * @throws IOException Exception */ protected void validateSend( final Wiser mailServer, final String strSubject, final String strMessage, final InternetAddress fromAdd, final List<InternetAddress> toAdd, final List<InternetAddress> ccAdd, final List<InternetAddress> bccAdd, final boolean boolSaveToFile) throws IOException { // test other properties final WiserMessage emailMessage = this.validateSend( mailServer, strSubject, fromAdd, toAdd, ccAdd, bccAdd, true); // test message content assertThat("didn't find expected message content in message body", getMessageBody(emailMessage), containsString(strMessage)); }
Example #15
Source File: EmailTestCase.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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 #16
Source File: AbstractEmailTest.java From commons-email with Apache License 2.0 | 5 votes |
/** * Initializes the stub mail server. Fails if the server cannot be proven * to have started. If the server is already started, this method returns * without changing the state of the server. */ public void getMailServer() { if (this.fakeMailServer == null || isMailServerStopped(fakeMailServer)) { mailServerPort++; this.fakeMailServer = new Wiser(); this.fakeMailServer.setPort(getMailServerPort()); this.fakeMailServer.start(); assertFalse("fake mail server didn't start", isMailServerStopped(fakeMailServer)); final Date dtStartWait = new Date(); while (isMailServerStopped(fakeMailServer)) { // test for connected if (this.fakeMailServer != null && !isMailServerStopped(fakeMailServer)) { break; } // test for timeout if (dtStartWait.getTime() + EmailConfiguration.TIME_OUT <= new Date().getTime()) { fail("Mail server failed to start"); } } } }
Example #17
Source File: StartStopTest.java From subethasmtp with Apache License 2.0 | 5 votes |
/** */ 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 #18
Source File: AbstractEmailTest.java From commons-email with Apache License 2.0 | 5 votes |
/** * Validate the message was sent properly * @param mailServer reference to the fake mail server * @param strSubject expected subject * @param content the expected message content * @param fromAdd expected from address * @param toAdd list of expected to addresses * @param ccAdd list of expected cc addresses * @param bccAdd list of expected bcc addresses * @param boolSaveToFile true will output to file, false doesnt * @throws IOException Exception */ protected void validateSend( final Wiser mailServer, final String strSubject, final Multipart content, final InternetAddress fromAdd, final List<InternetAddress> toAdd, final List<InternetAddress> ccAdd, final List<InternetAddress> bccAdd, final boolean boolSaveToFile) throws IOException { // test other properties final WiserMessage emailMessage = this.validateSend( mailServer, strSubject, fromAdd, toAdd, ccAdd, bccAdd, boolSaveToFile); // test message content // get sent email content final String strSentContent = content.getContentType(); // get received email content (chop off the auto-added \n // and -- (front and end) final String emailMessageBody = getMessageBody(emailMessage); final String strMessageBody = emailMessageBody.substring(AbstractEmailTest.BODY_START_PAD, emailMessageBody.length() - AbstractEmailTest.BODY_END_PAD); assertTrue("didn't find expected content type in message body", strMessageBody.contains(strSentContent)); }
Example #19
Source File: SMTPMessageSenderTest.java From james-project with Apache License 2.0 | 5 votes |
@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 #20
Source File: TestUtils.java From digdag with Apache License 2.0 | 5 votes |
public static Wiser startMailServer(String hostname, AuthenticationHandlerFactory authenticationHandlerFactory) { Wiser server = new Wiser(); server.getServer().setAuthenticationHandlerFactory(authenticationHandlerFactory); server.setHostname(hostname); server.setPort(0); server.start(); return server; }
Example #21
Source File: WiserFailuresTest.java From subethasmtp with Apache License 2.0 | 5 votes |
/** */ @Override protected void setUp() throws Exception { super.setUp(); this.server = new Wiser(); this.server.setPort(SMTP_PORT); this.server.start(); this.socket = new Socket(HOST_NAME, SMTP_PORT); this.input = new BufferedReader(new InputStreamReader(this.socket.getInputStream())); this.output = new PrintWriter(this.socket.getOutputStream(), true); }
Example #22
Source File: BigAttachmentTest.java From subethasmtp with Apache License 2.0 | 5 votes |
/** */ @Before protected void setUp() throws Exception { this.server = new Wiser(); this.server.setPort(SMTP_PORT); this.server.start(); }
Example #23
Source File: MailerImplTest.java From quarkus with Apache License 2.0 | 5 votes |
@BeforeAll static void startWiser() { wiser = new Wiser(); wiser.setPort(0); wiser.start(); vertx = Vertx.vertx(); }
Example #24
Source File: SMTPTestWiser.java From vertx-mail-client with Apache License 2.0 | 5 votes |
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 #25
Source File: EmailServiceTaskTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); wiser = new Wiser(); wiser.setPort(5025); wiser.start(); }
Example #26
Source File: EmailServiceTaskTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); wiser = new Wiser(); wiser.setPort(5025); wiser.start(); }
Example #27
Source File: EmailServiceTaskTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); wiser = new Wiser(); wiser.setPort(5025); wiser.start(); }
Example #28
Source File: UserAccountServiceIntegrationTests.java From judgels with GNU General Public License v2.0 | 5 votes |
private static String readEmail(Wiser wiser, int index) { await() .atMost(30, TimeUnit.SECONDS) .pollInterval(1, TimeUnit.SECONDS) .until(() -> wiser.getMessages().size() > index); return new String(wiser.getMessages().get(index).getData()); }
Example #29
Source File: ApplicationAssertions.java From batchers with Apache License 2.0 | 4 votes |
public static SmtpAssertions assertThat(Wiser actual) { return new SmtpAssertions(actual); }
Example #30
Source File: WiserSmtpService.java From sling-samples with Apache License 2.0 | 4 votes |
@Activate public void activate(final WiserSmtpServiceConfiguration configuration) throws Exception { wiser = new Wiser(configuration.smtpPort()); wiser.start(); }