Example usage for org.springframework.ui.freemarker FreeMarkerConfigurationFactory createConfiguration

List of usage examples for org.springframework.ui.freemarker FreeMarkerConfigurationFactory createConfiguration

Introduction

In this page you can find the example usage for org.springframework.ui.freemarker FreeMarkerConfigurationFactory createConfiguration.

Prototype

public Configuration createConfiguration() throws IOException, TemplateException 

Source Link

Document

Prepare the FreeMarker Configuration and return it.

Usage

From source file:com.gnizr.web.action.user.TestRequestPasswordReset.java

protected void setUp() throws Exception {
    super.setUp();

    gnizrConfiguration = new GnizrConfiguration();
    gnizrConfiguration.setSiteContactEmail("admin@mysite.com");
    gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr");

    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();

    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();/*from  w w w  .ja v a 2  s .c om*/

    templateMessage = new SimpleMailMessage();
    templateMessage.setSubject("Reset Password");

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");

    action = new RequestPasswordReset();
    action.setUserManager(userManager);
    action.setTokenManager(tokenManager);
    action.setVerifyResetTemplate(templateMessage);
    action.setMailSender(mailSender);
    action.setFreemarkerEngine(freemarkerEngine);
    action.setGnizrConfiguration(gnizrConfiguration);
}

From source file:com.gnizr.web.action.user.TestApproveUserAccount.java

protected void setUp() throws Exception {
    super.setUp();

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");

    gnizrConfiguration = new GnizrConfiguration();
    gnizrConfiguration.setSiteContactEmail("admin@mysite.com");
    gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr");

    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();

    welcomeMessage = new SimpleMailMessage();
    welcomeMessage.setSubject("Welcome");

    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();//from   ww w .j a v a 2s.  c  o m

    action = new ApproveUserAccount();
    action.setUserManager(userManager);
    action.setTokenManager(tokenManager);
    action.setGnizrConfiguration(gnizrConfiguration);
    action.setWelcomeEmailTemplate(welcomeMessage);
    action.setFreemarkerEngine(freemarkerEngine);
    action.setMailSender(mailSender);

    username = "hchen1";
    token = tokenManager.createResetToken(new User(username));
}

From source file:com.gnizr.web.action.user.TestRegisterUser.java

protected void setUp() throws Exception {
    super.setUp();

    gnizrConfiguration = new GnizrConfiguration();
    gnizrConfiguration.setSiteContactEmail("admin@mysite.com");
    gnizrConfiguration.setWebApplicationUrl("http://foo.com/gnizr");

    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();

    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();/* w  w w . j  av  a 2 s  . c  om*/

    templateMessage = new SimpleMailMessage();
    templateMessage.setSubject("Email Verification");

    notifyMessage = new SimpleMailMessage();
    notifyMessage.setSubject("Account Registration Pending");

    approvalMessage = new SimpleMailMessage();
    approvalMessage.setSubject("Account Registration Approval");

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");

    action = new RegisterUser();
    action.setUserManager(userManager);
    action.setTokenManager(tokenManager);
    action.setVerifyEmailTemplate(templateMessage);
    action.setApprovalEmailTemplate(approvalMessage);
    action.setNotifyEmailTemplate(notifyMessage);
    action.setMailSender(mailSender);
    action.setFreemarkerEngine(freemarkerEngine);
    action.setGnizrConfiguration(gnizrConfiguration);
}

From source file:org.craftercms.commons.mail.impl.EmailFactoryImplTest.java

private Configuration createFreeMarkerConfig() throws Exception {
    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setDefaultEncoding(ENCODING);
    factory.setTemplateLoaderPath("classpath:mail/templates");

    return factory.createConfiguration();
}