类org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration源码实例Demo

下面列出了怎么用org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ogham   文件: SpringBeanResolutionTest.java
@Before
public void setUp() {
	contextRunner = new ApplicationContextRunner()
			.withPropertyValues(
					"mail.smtp.host="+ServerSetupTest.SMTP.getBindAddress(), 
					"mail.smtp.port="+ServerSetupTest.SMTP.getPort(),
					"ogham.sms.smpp.host=127.0.0.1",
					"ogham.sms.smpp.port="+smppServer.getPort(),
					"spring.freemarker.suffix=")
			.withConfiguration(of(TestConfig.class, ThymeleafAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot2AutoConfiguration.class));
}
 
源代码2 项目: ogham   文件: StaticMethodAccessTest.java
@Before
public void setUp() {
	contextRunner = new ApplicationContextRunner()
			.withPropertyValues(
					"mail.smtp.host="+ServerSetupTest.SMTP.getBindAddress(), 
					"mail.smtp.port="+ServerSetupTest.SMTP.getPort(),
					"ogham.sms.smpp.host=127.0.0.1",
					"ogham.sms.smpp.port="+smppServer.getPort(),
					"spring.freemarker.suffix=")
			.withConfiguration(of(FreeMarkerAutoConfiguration.class, OghamSpringBoot2AutoConfiguration.class));
}
 
@Test
public void oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration() throws Exception {
	contextRunner = contextRunner.withConfiguration(of(FreeMarkerAutoConfiguration.class, OghamSpringBoot2AutoConfiguration.class));
	contextRunner.run((context) -> {
		MessagingService messagingService = context.getBean(MessagingService.class);
		checkEmail(messagingService);
		checkSms(messagingService);
		OghamInternalAssertions.assertThat(messagingService)
			.freemarker()
				.all()
					.configuration()
						.defaultEncoding(equalTo(StandardCharsets.UTF_16BE.name()));
	});
}
 
@Test
public void oghamWithFreemarkerAutoConfigInWebContextShouldUseSpringFreemarkerConfiguration() throws Exception {
	contextRunner = contextRunner.withConfiguration(of(WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot2AutoConfiguration.class));
	contextRunner.run((context) -> {
		MessagingService messagingService = context.getBean(MessagingService.class);
		checkEmail(messagingService);
		checkSms(messagingService);
		OghamInternalAssertions.assertThat(messagingService)
			.freemarker()
				.all()
					.configuration()
						.defaultEncoding(equalTo(StandardCharsets.UTF_16BE.name()));
	});
}
 
@Test
public void oghamWithFreemarkerAutoConfigWithoutWebContextAndOghamPropertiesShouldUseSpringFreemarkerConfigurationAndOghamProperties() throws Exception {
	contextRunner = contextRunner.withConfiguration(of(FreeMarkerAutoConfiguration.class, OghamSpringBoot2AutoConfiguration.class))
			.withPropertyValues("ogham.freemarker.default-encoding="+StandardCharsets.US_ASCII.name());
	contextRunner.run((context) -> {
		MessagingService messagingService = context.getBean(MessagingService.class);
		checkEmail(messagingService);
		checkSms(messagingService);
		OghamInternalAssertions.assertThat(messagingService)
			.freemarker()
				.all()
					.configuration()
						.defaultEncoding(equalTo(StandardCharsets.US_ASCII.name()));
	});
}
 
@Test
public void oghamWithFreemarkerAutoConfigInWebContextAndOghamPropertiesShouldUseSpringFreemarkerConfigurationAndOghamProperties() throws Exception {
	contextRunner = contextRunner.withConfiguration(of(WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot2AutoConfiguration.class))
			.withPropertyValues("ogham.freemarker.default-encoding="+StandardCharsets.US_ASCII.name());
	contextRunner.run((context) -> {
		MessagingService messagingService = context.getBean(MessagingService.class);
		checkEmail(messagingService);
		checkSms(messagingService);
		OghamInternalAssertions.assertThat(messagingService)
			.freemarker()
				.all()
					.configuration()
						.defaultEncoding(equalTo(StandardCharsets.US_ASCII.name()));
	});
}
 
@Test
public void oghamWithFreemarkerAutoConfigWithoutWebContextShouldUseSpringFreemarkerConfiguration() throws Exception {
	context.register(FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	MessagingService messagingService = context.getBean(MessagingService.class);
	checkEmail(messagingService);
	checkSms(messagingService);
	OghamInternalAssertions.assertThat(messagingService)
		.freemarker()
			.all()
				.configuration()
					.defaultEncoding(equalTo(StandardCharsets.UTF_16BE.name()));
}
 
@Test
public void oghamWithFreemarkerAutoConfigInWebContextShouldUseSpringFreemarkerConfiguration() throws Exception {
	context.register(WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	MessagingService messagingService = context.getBean(MessagingService.class);
	checkEmail(messagingService);
	checkSms(messagingService);
	OghamInternalAssertions.assertThat(messagingService)
		.freemarker()
			.all()
				.configuration()
					.defaultEncoding(equalTo(StandardCharsets.UTF_16BE.name()));
}
 
@Test
public void oghamWithFreemarkerAutoConfigWithoutWebContextAndOghamPropertiesShouldUseSpringFreemarkerConfigurationAndOghamProperties() throws Exception {
	EnvironmentTestUtils.addEnvironment(context, "ogham.freemarker.default-encoding="+StandardCharsets.US_ASCII.name());
	context.register(FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	MessagingService messagingService = context.getBean(MessagingService.class);
	checkEmail(messagingService);
	checkSms(messagingService);
	OghamInternalAssertions.assertThat(messagingService)
		.freemarker()
			.all()
				.configuration()
					.defaultEncoding(equalTo(StandardCharsets.US_ASCII.name()));
}
 
@Test
public void oghamWithFreemarkerAutoConfigInWebContextAndOghamPropertiesShouldUseSpringFreemarkerConfigurationAndOghamProperties() throws Exception {
	EnvironmentTestUtils.addEnvironment(context, "ogham.freemarker.default-encoding="+StandardCharsets.US_ASCII.name());
	context.register(WebMvcAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	MessagingService messagingService = context.getBean(MessagingService.class);
	checkEmail(messagingService);
	checkSms(messagingService);
	OghamInternalAssertions.assertThat(messagingService)
		.freemarker()
			.all()
				.configuration()
					.defaultEncoding(equalTo(StandardCharsets.US_ASCII.name()));
}
 
源代码11 项目: ogham   文件: StaticMethodsAccessTest.java
@Before
public void setUp() {
	context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, 
			"mail.smtp.host="+ServerSetupTest.SMTP.getBindAddress(), 
			"mail.smtp.port="+ServerSetupTest.SMTP.getPort(),
			"ogham.sms.smpp.host=127.0.0.1",
			"ogham.sms.smpp.port="+smppServer.getPort(),
			"spring.freemarker.suffix=");
	context.register( FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	messagingService = context.getBean(MessagingService.class);
}
 
源代码12 项目: ogham   文件: SpringBeanResolutionTest.java
@Before
public void setUp() {
	context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(context, 
			"mail.smtp.host="+ServerSetupTest.SMTP.getBindAddress(), 
			"mail.smtp.port="+ServerSetupTest.SMTP.getPort(),
			"ogham.sms.smpp.host=127.0.0.1",
			"ogham.sms.smpp.port="+smppServer.getPort(),
			"spring.freemarker.suffix=");
	context.register(TestConfig.class, ThymeleafAutoConfiguration.class, FreeMarkerAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	messagingService = context.getBean(MessagingService.class);
}
 
 同包方法