/** * Stops the server. * <p> * If the server is not started, does nothing special. * </p> */ public void stopServer() { if (smtpServer.isRunning()) { LOGGER.debug("Stopping server"); smtpServer.stop(); } }
public void close() { LOGGER.debug("Closing the application and saving the configuration"); Configuration.INSTANCE.set("smtp.default.port", panel.getPortText().get().getText()); Configuration.INSTANCE.set("emails.default.dir", panel.getSaveMsgTextField().get().getText()); try { Configuration.INSTANCE.saveToUserProfile(); } catch (IOException ex) { LOGGER.error("Could not save configuration", ex); } // Check for SMTP server running and stop it if (SMTPServerHandler.INSTANCE.getSmtpServer().isRunning()) { SMTPServerHandler.INSTANCE.getSmtpServer().stop(); } mainFrame.dispose(); } }
/** * Set's the maximum number of connections this server instance will accept. * * @param maxConnections */ public void setMaxConnections(int maxConnections) { if (this.isRunning()) throw new RuntimeException("Server is already running. It isn't possible to set the maxConnections. Please stop the server first."); this.maxConnections = maxConnections; }
/** * Set's the maximum number of connections this server instance will accept. * * @param maxConnections */ public void setMaxConnections(int maxConnections) { if (this.isRunning()) throw new RuntimeException("Server is already running. It isn't possible to set the maxConnections. Please stop the server first."); this.maxConnections = maxConnections; }
/** * Check if the server is running or not. * * @return {@link Boolean} * * @see org.unitils.mail.SmtpServer#isRunning() */ @Override public Boolean isRunning() { return wiser.getServer().isRunning(); }
@Override protected void before() throws Throwable { if (!mailServer.getServer().isRunning()) { LOGGER.info("Starting mail server {} ", mailServer.hashCode()); mailServer.start(); } }
@Override protected void after() { if (mailServer.getServer().isRunning()) { LOGGER.info("Stopping mail server {} ", mailServer.hashCode()); mailServer.stop(); } }
/** * Checks if an email server is running at the address stored in the * <code>fakeMailServer</code>. * * @param fakeMailServer * The server from which the address is picked up. * @return <code>true</code> if the server claims to be running * @since 1.1 */ protected boolean isMailServerStopped(final Wiser fakeMailServer) { return !fakeMailServer.getServer().isRunning(); }
/** * @param port : the port where the server should be started on. */ public SmtpServerImpl(int port) { this.port = port; wiser = new Wiser(); wiser.setPort(port); wiser.start(); wiser.getServer().isRunning(); }