refactor MailUtilTest to not use TestEngine, WikiContext, or initialize logs
@@ -25,12 +25,8 @@ import java.util.Properties;
import javax.mail.MessagingException;
import javax.net.ssl.SSLHandshakeException;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.wiki.TestEngine;
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiPage;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
/**
@@ -43,9 +39,7 @@ import org.junit.jupiter.api.Test;
*/
public class MailUtilTest
{
- Properties m_props = TestEngine.getTestProperties();
-
- WikiContext m_context;
+ static Properties m_props = new Properties();
static final String PAGE_NAME = "TestPage";
@@ -57,12 +51,9 @@ public class MailUtilTest
static final String TEST_RECEIVER = "someone@somewhere.org";
static final String TEST_SENDER = "homer.simpson@burns.com";
- @BeforeEach
- public void setUp() throws Exception {
- PropertyConfigurator.configure(m_props);
- TestEngine testEngine = new TestEngine( m_props );
- m_context = new WikiContext( testEngine,
- new WikiPage( testEngine, PAGE_NAME ) );
+ @BeforeAll
+ public static void setUp() throws Exception {
+ m_props = PropertyReader.getCombinedProperties( PropertyReader.CUSTOM_JSPWIKI_CONFIG );
}
/**
@@ -72,13 +63,12 @@ public class MailUtilTest
@Test
public void testProperties()
{
- Properties props = m_context.getEngine().getWikiProperties();
- Assertions.assertEquals( "127.0.0.1", props.getProperty( MailUtil.PROP_MAIL_HOST ) );
- Assertions.assertEquals( "25", props.getProperty( MailUtil.PROP_MAIL_PORT ) );
- Assertions.assertEquals( "JSPWiki <JSPWiki@localhost>", props.getProperty( MailUtil.PROP_MAIL_SENDER ) );
- Assertions.assertNull( props.getProperty( MailUtil.PROP_MAIL_ACCOUNT ) );
- Assertions.assertNull( props.getProperty( MailUtil.PROP_MAIL_PASSWORD ) );
- Assertions.assertNull( props.getProperty( MailUtil.PROP_MAIL_JNDI_NAME ) );
+ Assertions.assertEquals( "127.0.0.1", m_props.getProperty( MailUtil.PROP_MAIL_HOST ) );
+ Assertions.assertEquals( "25", m_props.getProperty( MailUtil.PROP_MAIL_PORT ) );
+ Assertions.assertEquals( "JSPWiki <JSPWiki@localhost>", m_props.getProperty( MailUtil.PROP_MAIL_SENDER ) );
+ Assertions.assertNull( m_props.getProperty( MailUtil.PROP_MAIL_ACCOUNT ) );
+ Assertions.assertNull( m_props.getProperty( MailUtil.PROP_MAIL_PASSWORD ) );
+ Assertions.assertNull( m_props.getProperty( MailUtil.PROP_MAIL_JNDI_NAME ) );
}
/**
@@ -97,10 +87,7 @@ public class MailUtilTest
try
{
- MailUtil.sendMessage(m_context.getEngine().getWikiProperties(),
- user,
- "Mail test",
- "This is a test mail generated by MailUtilTest.");
+ MailUtil.sendMessage( m_props, user, "Mail test", "This is a test mail generated by MailUtilTest." );
}
catch( MessagingException e )
{
