### Question:
DefaultMailSenderConfiguration implements MailSenderConfiguration { @Override public Properties getAdditionalProperties() { Properties properties; String extraPropertiesAsString = this.currentWikiMailConfigSource.getProperty(PROPERTIES_PROPERTY, String.class); if (extraPropertiesAsString == null && !isMainWiki()) { extraPropertiesAsString = this.mainWikiMailConfigSource.getProperty(PROPERTIES_PROPERTY, String.class); } if (extraPropertiesAsString == null) { properties = this.xwikiPropertiesSource.getProperty(PREFIX + PROPERTIES_PROPERTY, Properties.class); } else { InputStream is = new ByteArrayInputStream(extraPropertiesAsString.getBytes()); properties = new Properties(); try { properties.load(is); } catch (Exception e) { this.logger.warn("Error while parsing mail properties [{}]. Root cause [{}]. Ignoring configuration...", extraPropertiesAsString, ExceptionUtils.getRootCauseMessage(e)); } } return properties; }  @Override String getHost(); @Override int getPort(); @Override String getUsername(); @Override String getPassword(); @Override List<String> getBCCAddresses(); @Override String getFromAddress(); @Override Properties getAdditionalProperties(); @Override Properties getAllProperties(); @Override boolean usesAuthentication(); @Override String getScriptServicePermissionCheckerHint(); @Override long getSendWaitTime(); @Override int getPrepareQueueCapacity(); @Override int getSendQueueCapacity(); static final String JAVAMAIL_TRANSPORT_PROTOCOL; static final String JAVAMAIL_SMTP_HOST; static final String JAVAMAIL_SMTP_PORT; static final String JAVAMAIL_SMTP_USERNAME; static final String JAVAMAIL_SMTP_AUTH; }### Answer:
@Test public void getAdditionalPropertiesFromMailConfigDocumentInMainWiki() { when(this.mailConfigDocumentSource.getProperty("properties", String.class)).thenReturn( "key1=value1\nkey2=value2"); Properties returnedProperties = this.configuration.getAdditionalProperties(); assertEquals("value1", returnedProperties.getProperty("key1")); assertEquals("value2", returnedProperties.getProperty("key2")); }
@Test public void getAdditionalPropertiesFromXWikiProperties() { Properties properties = new Properties(); properties.setProperty("key1", "value1"); properties.setProperty("key2", "value2"); when(this.xwikiPropertiesSource.getProperty("mail.sender.properties", Properties.class)).thenReturn(properties); Properties returnedProperties = this.configuration.getAdditionalProperties(); assertEquals("value1", returnedProperties.getProperty("key1")); assertEquals("value2", returnedProperties.getProperty("key2")); }
@Test public void getAdditionalPropertiesWhenErrorInFormat() { when(this.mailConfigDocumentSource.getProperty("properties", String.class)).thenReturn("\\uinvalid"); assertTrue(this.configuration.getAdditionalProperties().isEmpty()); assertEquals(1, logCapture.size()); assertEquals("Error while parsing mail properties [\\uinvalid]. Root cause [IllegalArgumentException: " + "Malformed \\uxxxx encoding.]. Ignoring configuration...", logCapture.getMessage(0)); }