org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration#org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration源码实例Demo

下面列出了org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration#org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void oghamInWebContext() throws Exception {
	context.register(WebMvcAutoConfiguration.class, OghamSpringBoot1AutoConfiguration.class);
	context.refresh();
	MessagingService messagingService = context.getBean(MessagingService.class);
	checkEmail(messagingService);
	checkSms(messagingService);
	OghamInternalAssertions.assertThat(messagingService)
		.sendGrid()
			.apiKey(equalTo("ogham"))
			.client(allOf(isA(SendGrid.class), not(isSpringBeanInstance(context, SendGrid.class))))
			.and()
		.thymeleaf()
			.all()
				.engine(isA(TemplateEngine.class))
				.and()
			.and()
		.freemarker()
			.all()
				.configuration()
					.defaultEncoding(equalTo(StandardCharsets.US_ASCII.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 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()));
}