예제 #1
0
  @Test
  public void testFactoryMethodForJavaMailSession() {
    DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(xbf);
    reader.loadBeanDefinitions(new ClassPathResource("factory-methods.xml", getClass()));

    MailSession session = (MailSession) xbf.getBean("javaMailSession");
    assertEquals("someuser", session.getProperty("mail.smtp.user"));
    assertEquals("somepw", session.getProperty("mail.smtp.password"));
  }
예제 #2
0
 public static MailSession getDefaultInstance(Properties props) {
   MailSession session = new MailSession();
   session.setProperties(props);
   return session;
 }