Skip to content

Commit 2140648

Browse files
committed
Fix failing test
1 parent 5b02222 commit 2140648

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import groovy.text.TemplateEngine;
2727
import groovy.text.markup.MarkupTemplateEngine;
2828
import groovy.text.markup.TemplateConfiguration;
29-
import groovy.text.markup.TemplateResolver;
3029
import org.hamcrest.Matchers;
3130
import org.junit.Assert;
3231
import org.junit.Before;
@@ -51,15 +50,12 @@ public class GroovyMarkupConfigurerTests {
5150

5251
private GroovyMarkupConfigurer configurer;
5352

54-
private TemplateResolver resolver;
5553

5654
@Before
5755
public void setup() throws Exception {
5856
this.applicationContext = new StaticApplicationContext();
5957
this.configurer = new GroovyMarkupConfigurer();
6058
this.configurer.setResourceLoaderPath(RESOURCE_LOADER_PATH);
61-
this.resolver = this.configurer.createTemplateResolver();
62-
this.resolver.configure(this.getClass().getClassLoader(), null);
6359
}
6460

6561
@Test
@@ -136,38 +132,38 @@ public TestTemplateEngine() {
136132

137133
@Test
138134
public void resolveSampleTemplate() throws Exception {
139-
URL url = this.resolver.resolveTemplate(TEMPLATE_PREFIX + "test.tpl");
135+
URL url = this.configurer.resolveTemplate(getClass().getClassLoader(), TEMPLATE_PREFIX + "test.tpl");
140136
Assert.assertNotNull(url);
141137
}
142138

143139
@Test
144140
public void resolveI18nFullLocale() throws Exception {
145141
LocaleContextHolder.setLocale(Locale.GERMANY);
146-
URL url = this.resolver.resolveTemplate(TEMPLATE_PREFIX + "i18n.tpl");
142+
URL url = this.configurer.resolveTemplate(getClass().getClassLoader(), TEMPLATE_PREFIX + "i18n.tpl");
147143
Assert.assertNotNull(url);
148144
Assert.assertThat(url.getPath(), Matchers.containsString("i18n_de_DE.tpl"));
149145
}
150146

151147
@Test
152148
public void resolveI18nPartialLocale() throws Exception {
153149
LocaleContextHolder.setLocale(Locale.FRANCE);
154-
URL url = this.resolver.resolveTemplate(TEMPLATE_PREFIX + "i18n.tpl");
150+
URL url = this.configurer.resolveTemplate(getClass().getClassLoader(), TEMPLATE_PREFIX + "i18n.tpl");
155151
Assert.assertNotNull(url);
156152
Assert.assertThat(url.getPath(), Matchers.containsString("i18n_fr.tpl"));
157153
}
158154

159155
@Test
160156
public void resolveI18nDefaultLocale() throws Exception {
161157
LocaleContextHolder.setLocale(Locale.US);
162-
URL url = this.resolver.resolveTemplate(TEMPLATE_PREFIX + "i18n.tpl");
158+
URL url = this.configurer.resolveTemplate(getClass().getClassLoader(), TEMPLATE_PREFIX + "i18n.tpl");
163159
Assert.assertNotNull(url);
164160
Assert.assertThat(url.getPath(), Matchers.containsString("i18n.tpl"));
165161
}
166162

167163
@Test(expected = IOException.class)
168164
public void failMissingTemplate() throws Exception {
169165
LocaleContextHolder.setLocale(Locale.US);
170-
this.resolver.resolveTemplate(TEMPLATE_PREFIX + "missing.tpl");
166+
this.configurer.resolveTemplate(getClass().getClassLoader(), TEMPLATE_PREFIX + "missing.tpl");
171167
Assert.fail();
172168
}
173169
}

0 commit comments

Comments
 (0)