org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean Java Examples
The following examples show how to use
org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FreeMarkerConfigurerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.afterPropertiesSet(); Configuration cfg = fcfb.getObject(); assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader); }
Example #2
Source File: UserDataBuilderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException, TemplateException { FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); Configuration configuration = factoryBean.getObject(); underTest.setFreemarkerConfiguration(configuration); UserDataBuilderParams params = new UserDataBuilderParams(); params.setCustomData("date >> /tmp/time.txt"); ReflectionTestUtils.setField(underTest, "userDataBuilderParams", params); }
Example #3
Source File: AzureTemplateBuilderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { initMocks(this); FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); Configuration configuration = factoryBean.getObject(); ReflectionTestUtils.setField(azureTemplateBuilder, "freemarkerConfiguration", configuration); ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplatePath", templatePath); ReflectionTestUtils.setField(azureTemplateBuilder, "armTemplateParametersPath", "templates/parameters.ftl"); Map<InstanceGroupType, String> userData = ImmutableMap.of( InstanceGroupType.CORE, CORE_CUSTOM_DATA, InstanceGroupType.GATEWAY, GATEWAY_CUSTOM_DATA ); groups = new ArrayList<>(); stackName = "testStack"; name = "master"; List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1), new Volume("/hadoop/fs2", "HDD", 1)); InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L, "cb-centos66-amb200-2015-05-25"); Map<String, Object> params = new HashMap<>(); params.put(CloudInstance.SUBNET_ID, "existingSubnet"); InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak"); instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication, params); List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[]{new PortDefinition("22", "22"), new PortDefinition("443", "443")}, "tcp")); security = new Security(rules, emptyList()); image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()); cloudContext = new CloudContext(7899L, "thisisaverylongazureresourcenamewhichneedstobeshortened", "dummy1", "test", Location.location(Region.region("EU"), new AvailabilityZone("availabilityZone")), USER_ID, WORKSPACE_ID); azureCredentialView = new AzureCredentialView(cloudCredential()); azureStorageView = new AzureStorageView(azureCredentialView, cloudContext, azureStorage, null); azureSubnetStrategy = AzureSubnetStrategy.getAzureSubnetStrategy(FILL, Collections.singletonList("existingSubnet"), ImmutableMap.of("existingSubnet", 100L)); reset(azureUtils); }
Example #4
Source File: AzureNetworkTemplateBuilderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Before public void before() throws IOException, TemplateException { FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); ReflectionTestUtils.setField(underTest, "freemarkerConfiguration", factoryBean.getObject()); ReflectionTestUtils.setField(underTest, "armTemplatePath", "templates/arm-network.ftl"); }
Example #5
Source File: AwsNetworkCfTemplateProviderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@BeforeEach public void before() throws IOException, TemplateException { FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); ReflectionTestUtils.setField(underTest, "freemarkerConfiguration", factoryBean.getObject()); ReflectionTestUtils.setField(underTest, "cloudFormationNetworkTemplatePath", TEMPLATE_PATH); ReflectionTestUtils.setField(underTest, "gatewayServices", List.of("gateway1", "gateway2")); ReflectionTestUtils.setField(underTest, "interfaceServices", List.of("interface1", "interface2")); }
Example #6
Source File: TestConfig.java From cloudbreak with Apache License 2.0 | 5 votes |
@Bean public freemarker.template.Configuration configurationProvider() throws IOException, TemplateException { FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); return factoryBean.getObject(); }
Example #7
Source File: CloudFormationTemplateBuilderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() throws Exception { FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); Configuration configuration = factoryBean.getObject(); ReflectionTestUtils.setField(cloudFormationTemplateBuilder, "freemarkerConfiguration", configuration); when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod(); awsCloudFormationTemplate = configuration.getTemplate(LATEST_AWS_CLOUD_FORMATION_TEMPLATE_PATH, "UTF-8").toString(); authenticatedContext = authenticatedContext(); existingSubnetCidr = "testSubnet"; InstanceTemplate instanceTemplate = createDefaultInstanceTemplate(); instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak"); instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication); Security security = getDefaultCloudStackSecurity(); Map<InstanceGroupType, String> userData = ImmutableMap.of( InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY" ); image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>()); List<Group> groups = List.of(createDefaultGroup("master", InstanceGroupType.CORE, ROOT_VOLUME_SIZE, security, Optional.empty()), createDefaultGroup("gateway", InstanceGroupType.GATEWAY, ROOT_VOLUME_SIZE, security, Optional.empty())); cloudStack = createDefaultCloudStack(groups, getDefaultCloudStackParameters(), getDefaultCloudStackTags()); }
Example #8
Source File: CloudFormationTemplateBuilderDBTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@BeforeEach void setUp() throws Exception { initMocks(this); factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); ReflectionTestUtils.setField(cloudFormationTemplateBuilder, "freemarkerConfiguration", factoryBean.getObject()); when(freeMarkerTemplateUtils.processTemplateIntoString(any(), any())).thenCallRealMethod(); }
Example #9
Source File: HeatTemplateBuilderTest.java From cloudbreak with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException, TemplateException { initMocks(this); FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/"); factoryBean.afterPropertiesSet(); Configuration configuration = factoryBean.getObject(); ReflectionTestUtils.setField(heatTemplateBuilder, "freemarkerConfiguration", configuration); ReflectionTestUtils.setField(heatTemplateBuilder, "openStackHeatTemplatePath", templatePath); stackName = "testStack"; groups = new ArrayList<>(1); String name = "master"; List<Volume> volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1), new Volume("/hadoop/fs2", "HDD", 1)); InstanceTemplate instanceTemplate = new InstanceTemplate("m1.medium", name, 0L, volumes, InstanceStatus.CREATE_REQUESTED, new HashMap<>(), 0L, "cb-centos66-amb200-2015-05-25"); InstanceAuthentication instanceAuthentication = new InstanceAuthentication("sshkey", "", "cloudbreak"); CloudInstance instance = new CloudInstance("SOME_ID", instanceTemplate, instanceAuthentication); List<SecurityRule> rules = singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[]{new PortDefinition("22", "22"), new PortDefinition("443", "443")}, "tcp")); Security security = new Security(rules, emptyList()); groups.add(new Group(name, InstanceGroupType.CORE, singletonList(instance), security, null, instanceAuthentication, instanceAuthentication.getLoginUserName(), instanceAuthentication.getPublicKey(), 50, Optional.empty())); Map<InstanceGroupType, String> userData = ImmutableMap.of( InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY" ); image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "url", "default", null, new HashMap<>()); }
Example #10
Source File: FreeMarkerConfigurerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("rawtypes") public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertThat(fcfb.getObject(), instanceOf(Configuration.class)); Configuration fc = fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }
Example #11
Source File: FreeMarkerConfigurerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.afterPropertiesSet(); Configuration cfg = fcfb.getObject(); assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader); }
Example #12
Source File: FreeMarkerConfigurerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test(expected = IOException.class) public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); fcfb.afterPropertiesSet(); }
Example #13
Source File: InterfaceTestApplication.java From interface-test with Apache License 2.0 | 5 votes |
@Bean public FreeMarkerConfigurationFactoryBean freeMarkerConfiguration() { FreeMarkerConfigurationFactoryBean freeMarkerFactoryBean = new FreeMarkerConfigurationFactoryBean(); freeMarkerFactoryBean.setTemplateLoaderPaths("classpath:/templates"); freeMarkerFactoryBean.setPreferFileSystemAccess(true); freeMarkerFactoryBean.setDefaultEncoding("UTF-8"); return freeMarkerFactoryBean; }
Example #14
Source File: EmailConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean public FreeMarkerConfigurationFactoryBean freeMarkerConfig() { Properties props = new Properties(); props.setProperty("number_format","0.##"); props.setProperty("locale","en-US"); FreeMarkerConfigurationFactoryBean factory = new FreeMarkerConfigurationFactoryBean(); factory.setFreemarkerSettings(props); factory.setTemplateLoaderPath("classpath:/email-templates/"); return factory; }
Example #15
Source File: ApplicationConfig.java From ambari-logsearch with Apache License 2.0 | 5 votes |
@Bean public freemarker.template.Configuration freemarkerConfiguration() throws IOException, TemplateException { FreeMarkerConfigurationFactoryBean factoryBean = new FreeMarkerConfigurationFactoryBean(); factoryBean.setPreferFileSystemAccess(false); factoryBean.setTemplateLoaderPath("classpath:/templates"); factoryBean.afterPropertiesSet(); return factoryBean.getObject(); }
Example #16
Source File: FreeMarkerConfigurerTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("rawtypes") public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertThat(fcfb.getObject(), instanceOf(Configuration.class)); Configuration fc = fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }
Example #17
Source File: FreeMarkerConfigurerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void freeMarkerConfigurationFactoryBeanWithResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); fcfb.afterPropertiesSet(); Configuration cfg = fcfb.getObject(); assertTrue(cfg.getTemplateLoader() instanceof SpringTemplateLoader); }
Example #18
Source File: FreeMarkerConfigurerTests.java From java-technology-stack with MIT License | 5 votes |
@Test(expected = IOException.class) public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); fcfb.afterPropertiesSet(); }
Example #19
Source File: FreeMarkerConfigurerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("rawtypes") public void freeMarkerConfigurationFactoryBeanWithNonFileResourceLoaderPath() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setTemplateLoaderPath("file:/mydir"); Properties settings = new Properties(); settings.setProperty("localized_lookup", "false"); fcfb.setFreemarkerSettings(settings); fcfb.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if (!("file:/mydir".equals(location) || "file:/mydir/test".equals(location))) { throw new IllegalArgumentException(location); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); fcfb.afterPropertiesSet(); assertThat(fcfb.getObject(), instanceOf(Configuration.class)); Configuration fc = fcfb.getObject(); Template ft = fc.getTemplate("test"); assertEquals("test", FreeMarkerTemplateUtils.processTemplateIntoString(ft, new HashMap())); }
Example #20
Source File: FreeMarkerConfigurerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test(expected = IOException.class) public void freeMarkerConfigurationFactoryBeanWithConfigLocation() throws Exception { FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean(); fcfb.setConfigLocation(new FileSystemResource("myprops.properties")); Properties props = new Properties(); props.setProperty("myprop", "/mydir"); fcfb.setFreemarkerSettings(props); fcfb.afterPropertiesSet(); }
Example #21
Source File: OghamFreemarkerConfiguration.java From ogham with Apache License 2.0 | 4 votes |
@Bean @Qualifier("email") @ConditionalOnMissingBean(name = "emailFreemarkerConfiguration") public freemarker.template.Configuration emailFreemarkerConfiguration(FreeMarkerConfigurationFactoryBean factory) throws IOException, TemplateException { return factory.createConfiguration(); }
Example #22
Source File: OghamFreemarkerConfiguration.java From ogham with Apache License 2.0 | 4 votes |
@Bean @Qualifier("sms") @ConditionalOnMissingBean(name = "smsFreemarkerConfiguration") public freemarker.template.Configuration smsFreemarkerConfiguration(FreeMarkerConfigurationFactoryBean factory) throws IOException, TemplateException { return factory.createConfiguration(); }
Example #23
Source File: MavenArtifactNotifierCoreNotificationConfig.java From artifact-listener with Apache License 2.0 | 4 votes |
@Bean public FreeMarkerConfigurationFactoryBean freemarkerMailConfiguration() { FreeMarkerConfigurationFactoryBean configuration = new FreeMarkerConfigurationFactoryBean(); configuration.setTemplateLoaderPath("classpath:notification"); return configuration; }