Skip to content

Commit 35221c1

Browse files
committed
Polish
1 parent de7eeb5 commit 35221c1

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ static BeanTypeRegistry get(ListableBeanFactory beanFactory) {
9696
BeanDefinition bd = new RootBeanDefinition(BeanTypeRegistry.class);
9797
bd.getConstructorArgumentValues().addIndexedArgumentValue(0, beanFactory);
9898
listableBeanFactory.registerBeanDefinition(BEAN_NAME, bd);
99-
10099
}
101100
return listableBeanFactory.getBean(BEAN_NAME, BeanTypeRegistry.class);
102101
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationServletIntegrationTests.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void close() {
6969

7070
@Test
7171
public void defaultConfiguration() {
72-
registerAndRefreshContext();
72+
load();
7373
assertThat(this.context.getBean(FreeMarkerViewResolver.class)).isNotNull();
7474
assertThat(this.context.getBean(FreeMarkerConfigurer.class)).isNotNull();
7575
assertThat(this.context.getBean(FreeMarkerConfig.class)).isNotNull();
@@ -79,7 +79,7 @@ public void defaultConfiguration() {
7979

8080
@Test
8181
public void defaultViewResolution() throws Exception {
82-
registerAndRefreshContext();
82+
load();
8383
MockHttpServletResponse response = render("home");
8484
String result = response.getContentAsString();
8585
assertThat(result).contains("home");
@@ -88,7 +88,7 @@ public void defaultViewResolution() throws Exception {
8888

8989
@Test
9090
public void customContentType() throws Exception {
91-
registerAndRefreshContext("spring.freemarker.contentType:application/json");
91+
load("spring.freemarker.contentType:application/json");
9292
MockHttpServletResponse response = render("home");
9393
String result = response.getContentAsString();
9494
assertThat(result).contains("home");
@@ -97,23 +97,23 @@ public void customContentType() throws Exception {
9797

9898
@Test
9999
public void customPrefix() throws Exception {
100-
registerAndRefreshContext("spring.freemarker.prefix:prefix/");
100+
load("spring.freemarker.prefix:prefix/");
101101
MockHttpServletResponse response = render("prefixed");
102102
String result = response.getContentAsString();
103103
assertThat(result).contains("prefixed");
104104
}
105105

106106
@Test
107107
public void customSuffix() throws Exception {
108-
registerAndRefreshContext("spring.freemarker.suffix:.freemarker");
108+
load("spring.freemarker.suffix:.freemarker");
109109
MockHttpServletResponse response = render("suffixed");
110110
String result = response.getContentAsString();
111111
assertThat(result).contains("suffixed");
112112
}
113113

114114
@Test
115115
public void customTemplateLoaderPath() throws Exception {
116-
registerAndRefreshContext(
116+
load(
117117
"spring.freemarker.templateLoaderPath:classpath:/custom-templates/");
118118
MockHttpServletResponse response = render("custom");
119119
String result = response.getContentAsString();
@@ -122,14 +122,14 @@ public void customTemplateLoaderPath() throws Exception {
122122

123123
@Test
124124
public void disableCache() {
125-
registerAndRefreshContext("spring.freemarker.cache:false");
125+
load("spring.freemarker.cache:false");
126126
assertThat(this.context.getBean(FreeMarkerViewResolver.class).getCacheLimit())
127127
.isEqualTo(0);
128128
}
129129

130130
@Test
131131
public void allowSessionOverride() {
132-
registerAndRefreshContext("spring.freemarker.allow-session-override:true");
132+
load("spring.freemarker.allow-session-override:true");
133133
AbstractTemplateViewResolver viewResolver = this.context
134134
.getBean(FreeMarkerViewResolver.class);
135135
assertThat(ReflectionTestUtils.getField(viewResolver, "allowSessionOverride"))
@@ -139,14 +139,14 @@ public void allowSessionOverride() {
139139
@SuppressWarnings("deprecation")
140140
@Test
141141
public void customFreeMarkerSettings() {
142-
registerAndRefreshContext("spring.freemarker.settings.boolean_format:yup,nope");
142+
load("spring.freemarker.settings.boolean_format:yup,nope");
143143
assertThat(this.context.getBean(FreeMarkerConfigurer.class).getConfiguration()
144144
.getSetting("boolean_format")).isEqualTo("yup,nope");
145145
}
146146

147147
@Test
148148
public void renderTemplate() throws Exception {
149-
registerAndRefreshContext();
149+
load();
150150
FreeMarkerConfigurer freemarker = this.context
151151
.getBean(FreeMarkerConfigurer.class);
152152
StringWriter writer = new StringWriter();
@@ -156,13 +156,13 @@ public void renderTemplate() throws Exception {
156156

157157
@Test
158158
public void registerResourceHandlingFilterDisabledByDefault() {
159-
registerAndRefreshContext();
159+
load();
160160
assertThat(this.context.getBeansOfType(FilterRegistrationBean.class)).isEmpty();
161161
}
162162

163163
@Test
164164
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() {
165-
registerAndRefreshContext("spring.resources.chain.enabled:true");
165+
load("spring.resources.chain.enabled:true");
166166
FilterRegistrationBean<?> registration = this.context
167167
.getBean(FilterRegistrationBean.class);
168168
assertThat(registration.getFilter())
@@ -175,7 +175,7 @@ public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() {
175175
@SuppressWarnings("rawtypes")
176176
public void registerResourceHandlingFilterWithOtherRegistrationBean() {
177177
// gh-14897
178-
registerAndRefreshContext(FilterRegistrationConfiguration.class,
178+
load(FilterRegistrationConfiguration.class,
179179
"spring.resources.chain.enabled:true");
180180
Map<String, FilterRegistrationBean> beans = this.context
181181
.getBeansOfType(FilterRegistrationBean.class);
@@ -187,11 +187,11 @@ public void registerResourceHandlingFilterWithOtherRegistrationBean() {
187187
EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));
188188
}
189189

190-
private void registerAndRefreshContext(String... env) {
191-
registerAndRefreshContext(BaseConfiguration.class, env);
190+
private void load(String... env) {
191+
load(BaseConfiguration.class, env);
192192
}
193193

194-
private void registerAndRefreshContext(Class<?> config, String... env) {
194+
private void load(Class<?> config, String... env) {
195195
this.context = new AnnotationConfigWebApplicationContext();
196196
this.context.setServletContext(new MockServletContext());
197197
TestPropertyValues.of(env).applyTo(this.context);

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,6 @@ public void cachingCanBeDisabled() {
262262
private void load(Class<?> config, String... envVariables) {
263263
this.context = new AnnotationConfigWebApplicationContext();
264264
TestPropertyValues.of(envVariables).applyTo(this.context);
265-
if (config != null) {
266-
this.context.register(config);
267-
}
268265
this.context.register(config);
269266
this.context.refresh();
270267
}

0 commit comments

Comments
 (0)