Remove use of Thymeleaf from smoke tests

Closes gh-28788
This commit is contained in:
Scott Frederick
2021-11-23 12:11:55 -06:00
parent 03e283a2e6
commit 12244a8edd
67 changed files with 237 additions and 791 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,6 @@ class RemoteUrlPropertyExtractorTests {
void validUrl() {
ApplicationContext context = doTest("http://localhost:8080");
assertThat(context.getEnvironment().getProperty("remoteUrl")).isEqualTo("http://localhost:8080");
assertThat(context.getEnvironment().getProperty("spring.thymeleaf.cache")).isNull();
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,12 +29,11 @@ import org.apache.jasper.EmbeddedServletOptions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.WebProperties;
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
@@ -55,6 +54,7 @@ import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.servlet.view.AbstractTemplateViewResolver;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -83,18 +83,11 @@ class LocalDevToolsAutoConfigurationTests {
}
}
@Test
void thymeleafCacheIsFalse() throws Exception {
this.context = getContext(() -> initializeAndRun(Config.class));
SpringResourceTemplateResolver resolver = this.context.getBean(SpringResourceTemplateResolver.class);
assertThat(resolver.isCacheable()).isFalse();
}
@Test
void defaultPropertyCanBeOverriddenFromCommandLine() throws Exception {
this.context = getContext(() -> initializeAndRun(Config.class, "--spring.thymeleaf.cache=true"));
SpringResourceTemplateResolver resolver = this.context.getBean(SpringResourceTemplateResolver.class);
assertThat(resolver.isCacheable()).isTrue();
this.context = getContext(() -> initializeAndRun(Config.class, "--spring.freemarker.cache=true"));
AbstractTemplateViewResolver resolver = this.context.getBean(AbstractTemplateViewResolver.class);
assertThat(resolver.isCache()).isTrue();
}
@Test
@@ -103,8 +96,8 @@ class LocalDevToolsAutoConfigurationTests {
System.setProperty("user.home", new File("src/test/resources/user-home").getAbsolutePath());
try {
this.context = getContext(() -> initializeAndRun(Config.class));
SpringResourceTemplateResolver resolver = this.context.getBean(SpringResourceTemplateResolver.class);
assertThat(resolver.isCacheable()).isTrue();
AbstractTemplateViewResolver resolver = this.context.getBean(AbstractTemplateViewResolver.class);
assertThat(resolver.isCache()).isTrue();
}
finally {
System.setProperty("user.home", userHome);
@@ -267,7 +260,6 @@ class LocalDevToolsAutoConfigurationTests {
private Map<String, Object> getDefaultProperties(Map<String, Object> specifiedProperties) {
Map<String, Object> properties = new HashMap<>();
properties.put("spring.thymeleaf.check-template-location", false);
properties.put("spring.devtools.livereload.port", 0);
properties.put("server.port", 0);
properties.putAll(specifiedProperties);
@@ -276,14 +268,14 @@ class LocalDevToolsAutoConfigurationTests {
@Configuration(proxyBeanMethods = false)
@Import({ ServletWebServerFactoryAutoConfiguration.class, LocalDevToolsAutoConfiguration.class,
ThymeleafAutoConfiguration.class })
FreeMarkerAutoConfiguration.class })
static class Config {
}
@Configuration(proxyBeanMethods = false)
@ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class, LocalDevToolsAutoConfiguration.class,
ThymeleafAutoConfiguration.class })
FreeMarkerAutoConfiguration.class })
static class ConfigWithMockLiveReload {
@Bean

View File

@@ -1 +1 @@
spring.thymeleaf.cache=true
spring.freemarker.cache=true