Java Code Examples for org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean#setPreferFileSystemAccess()

The following examples show how to use org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean#setPreferFileSystemAccess() . 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: ApplicationConfig.java    From ambari-logsearch with Apache License 2.0 5 votes vote down vote up
@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 2
Source File: InterfaceTestApplication.java    From interface-test with Apache License 2.0 5 votes vote down vote up
@Bean
public FreeMarkerConfigurationFactoryBean freeMarkerConfiguration() {
    FreeMarkerConfigurationFactoryBean freeMarkerFactoryBean = new FreeMarkerConfigurationFactoryBean();
    freeMarkerFactoryBean.setTemplateLoaderPaths("classpath:/templates");
    freeMarkerFactoryBean.setPreferFileSystemAccess(true);
    freeMarkerFactoryBean.setDefaultEncoding("UTF-8");
    return freeMarkerFactoryBean;
}
 
Example 3
Source File: HeatTemplateBuilderTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 4
Source File: CloudFormationTemplateBuilderDBTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: CloudFormationTemplateBuilderTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 6
Source File: TestConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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: AwsNetworkCfTemplateProviderTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: AzureNetworkTemplateBuilderTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: AzureTemplateBuilderTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: UserDataBuilderTest.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@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);
}