### Question:
ServerConfigUpgrader extends Task { void parseMailConfig(Properties existingConfig) { FileInputStream mailConfigInputStream = null; File mailServiceConfig = new File(upgradeDir + "/conf/templates/jboss-service-events.xml"); try { mailConfigInputStream = new FileInputStream(mailServiceConfig); } catch (FileNotFoundException e) { return; } log("Parsing jboss mail service configuration=" + mailServiceConfig.getAbsolutePath()); try { parseMailConfig(mailConfigInputStream, existingConfig); } finally { if (mailConfigInputStream != null) { try { mailConfigInputStream.close(); } catch (IOException e) { } } } }  @Override void execute(); void setExisting(String existingConfigFile); void setNew(String newConfigFile); void setUpgradeDir(String upgradeDir);  }### Answer:
@Test public void testParseDefaultMailConfig() { ServerConfigUpgrader upgrader = new ServerConfigUpgrader(); InputStream input = ServerConfigUpgrader.class.getClassLoader().getResourceAsStream( "default-mail-config.xml"); Properties serverConfig = new Properties(); Properties expectedConfig = new Properties(); expectedConfig.put("mail.user", "EAM Application"); expectedConfig.put("mail.password", "password"); upgrader.parseMailConfig(input, serverConfig); assertEquals(expectedConfig, serverConfig); }
@Test public void testParseMailConfigWithTLSAuth() { ServerConfigUpgrader upgrader = new ServerConfigUpgrader(); InputStream input = ServerConfigUpgrader.class.getClassLoader().getResourceAsStream( "auth-tls-mail-config.xml"); Properties serverConfig = new Properties(); Properties expectedConfig = new Properties(); expectedConfig.put("mail.user", "jen"); expectedConfig.put("mail.password", "password"); expectedConfig.put("mail.smtp.auth", "true"); expectedConfig.put("mail.smtp.port", "587"); expectedConfig.put("mail.smtp.starttls.enable", "true"); expectedConfig.put("mail.smtp.socketFactory.port", "465"); expectedConfig.put("mail.smtp.socketFactory.fallback", "false"); expectedConfig.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); upgrader.parseMailConfig(input, serverConfig); assertEquals(expectedConfig, serverConfig); }