@Test public void testCreate() { Properties properties = new Properties(); properties.setProperty("greenmail.setup.all", ""); final PropertiesBasedServerSetupBuilder setupBuilder = new PropertiesBasedServerSetupBuilder(); ServerSetup[] setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(ServerSetup.ALL); properties.clear(); properties.setProperty("greenmail.setup.imap", ""); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(new ServerSetup[]{ServerSetup.IMAP}); properties.clear(); properties.setProperty("greenmail.setup.test.all", ""); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(ServerSetupTest.ALL); properties.clear(); properties.setProperty("greenmail.setup.test.smtp", ""); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(new ServerSetup[]{ServerSetupTest.SMTP}); properties.clear(); properties.setProperty("greenmail.setup.test.smtp", ""); properties.setProperty(PropertiesBasedServerSetupBuilder.GREENMAIL_VERBOSE, ""); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(new ServerSetup[]{ServerSetupTest.SMTP}); assertThat(setups[0].isVerbose()).isTrue(); properties.clear(); properties.setProperty("greenmail.setup.test.smtp", ""); properties.setProperty("greenmail.hostname", "0.0.0.0"); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(new ServerSetup[]{ServerSetupTest.SMTP.createCopy("0.0.0.0")}); assertThat(setups[0].isVerbose()).isFalse(); for (ServerSetup setup : ServerSetupTest.ALL) { properties.clear(); properties.setProperty("greenmail." + setup.getProtocol() + ".hostname", "127.0.0.1"); properties.setProperty("greenmail." + setup.getProtocol() + ".port", Integer.toString(setup.getPort())); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(new ServerSetup[]{setup}); } properties.clear(); properties.setProperty("greenmail.smtp.hostname", "127.0.0.1"); properties.setProperty("greenmail.smtp.port", "3025"); properties.setProperty("greenmail.imap.hostname", "127.0.0.1"); properties.setProperty("greenmail.imap.port", "3143"); setups = setupBuilder.build(properties); assertThat(setups).isEqualTo(ServerSetupTest.SMTP_IMAP); }
public ServerSetup[] build(Properties properties) { List<ServerSetup> serverSetups = new ArrayList<>(); String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress()); long serverStartupTimeout = Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1")); addDefaultSetups(hostname, properties, serverSetups); addTestSetups(hostname, properties, serverSetups); for (String protocol : ServerSetup.PROTOCOLS) { addSetup(hostname, protocol, properties, serverSetups); } for (ServerSetup setup : serverSetups) { if (properties.containsKey(GREENMAIL_VERBOSE)) { setup.setVerbose(true); } if (serverStartupTimeout >= 0L) { setup.setServerStartupTimeout(serverStartupTimeout); } } return serverSetups.toArray(new ServerSetup[serverSetups.size()]); }
PropertiesBasedServerSetupBuilder { public ServerSetup[] build(Properties properties) { List<ServerSetup> serverSetups = new ArrayList<>(); String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress()); long serverStartupTimeout = Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1")); addDefaultSetups(hostname, properties, serverSetups); addTestSetups(hostname, properties, serverSetups); for (String protocol : ServerSetup.PROTOCOLS) { addSetup(hostname, protocol, properties, serverSetups); } for (ServerSetup setup : serverSetups) { if (properties.containsKey(GREENMAIL_VERBOSE)) { setup.setVerbose(true); } if (serverStartupTimeout >= 0L) { setup.setServerStartupTimeout(serverStartupTimeout); } } return serverSetups.toArray(new ServerSetup[serverSetups.size()]); } }
PropertiesBasedServerSetupBuilder { public ServerSetup[] build(Properties properties) { List<ServerSetup> serverSetups = new ArrayList<>(); String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress()); long serverStartupTimeout = Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1")); addDefaultSetups(hostname, properties, serverSetups); addTestSetups(hostname, properties, serverSetups); for (String protocol : ServerSetup.PROTOCOLS) { addSetup(hostname, protocol, properties, serverSetups); } for (ServerSetup setup : serverSetups) { if (properties.containsKey(GREENMAIL_VERBOSE)) { setup.setVerbose(true); } if (serverStartupTimeout >= 0L) { setup.setServerStartupTimeout(serverStartupTimeout); } } return serverSetups.toArray(new ServerSetup[serverSetups.size()]); }  }
PropertiesBasedServerSetupBuilder { public ServerSetup[] build(Properties properties) { List<ServerSetup> serverSetups = new ArrayList<>(); String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress()); long serverStartupTimeout = Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1")); addDefaultSetups(hostname, properties, serverSetups); addTestSetups(hostname, properties, serverSetups); for (String protocol : ServerSetup.PROTOCOLS) { addSetup(hostname, protocol, properties, serverSetups); } for (ServerSetup setup : serverSetups) { if (properties.containsKey(GREENMAIL_VERBOSE)) { setup.setVerbose(true); } if (serverStartupTimeout >= 0L) { setup.setServerStartupTimeout(serverStartupTimeout); } } return serverSetups.toArray(new ServerSetup[serverSetups.size()]); }  ServerSetup[] build(Properties properties); }
PropertiesBasedServerSetupBuilder { public ServerSetup[] build(Properties properties) { List<ServerSetup> serverSetups = new ArrayList<>(); String hostname = properties.getProperty("greenmail.hostname", ServerSetup.getLocalHostAddress()); long serverStartupTimeout = Long.parseLong(properties.getProperty("greenmail.startup.timeout", "-1")); addDefaultSetups(hostname, properties, serverSetups); addTestSetups(hostname, properties, serverSetups); for (String protocol : ServerSetup.PROTOCOLS) { addSetup(hostname, protocol, properties, serverSetups); } for (ServerSetup setup : serverSetups) { if (properties.containsKey(GREENMAIL_VERBOSE)) { setup.setVerbose(true); } if (serverStartupTimeout >= 0L) { setup.setServerStartupTimeout(serverStartupTimeout); } } return serverSetups.toArray(new ServerSetup[serverSetups.size()]); }  ServerSetup[] build(Properties properties); static final String GREENMAIL_VERBOSE; }