26
26
import groovy .text .TemplateEngine ;
27
27
import groovy .text .markup .MarkupTemplateEngine ;
28
28
import groovy .text .markup .TemplateConfiguration ;
29
- import groovy .text .markup .TemplateResolver ;
30
29
import org .hamcrest .Matchers ;
31
30
import org .junit .Assert ;
32
31
import org .junit .Before ;
@@ -51,15 +50,12 @@ public class GroovyMarkupConfigurerTests {
51
50
52
51
private GroovyMarkupConfigurer configurer ;
53
52
54
- private TemplateResolver resolver ;
55
53
56
54
@ Before
57
55
public void setup () throws Exception {
58
56
this .applicationContext = new StaticApplicationContext ();
59
57
this .configurer = new GroovyMarkupConfigurer ();
60
58
this .configurer .setResourceLoaderPath (RESOURCE_LOADER_PATH );
61
- this .resolver = this .configurer .createTemplateResolver ();
62
- this .resolver .configure (this .getClass ().getClassLoader (), null );
63
59
}
64
60
65
61
@ Test
@@ -136,38 +132,38 @@ public TestTemplateEngine() {
136
132
137
133
@ Test
138
134
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" );
140
136
Assert .assertNotNull (url );
141
137
}
142
138
143
139
@ Test
144
140
public void resolveI18nFullLocale () throws Exception {
145
141
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" );
147
143
Assert .assertNotNull (url );
148
144
Assert .assertThat (url .getPath (), Matchers .containsString ("i18n_de_DE.tpl" ));
149
145
}
150
146
151
147
@ Test
152
148
public void resolveI18nPartialLocale () throws Exception {
153
149
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" );
155
151
Assert .assertNotNull (url );
156
152
Assert .assertThat (url .getPath (), Matchers .containsString ("i18n_fr.tpl" ));
157
153
}
158
154
159
155
@ Test
160
156
public void resolveI18nDefaultLocale () throws Exception {
161
157
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" );
163
159
Assert .assertNotNull (url );
164
160
Assert .assertThat (url .getPath (), Matchers .containsString ("i18n.tpl" ));
165
161
}
166
162
167
163
@ Test (expected = IOException .class )
168
164
public void failMissingTemplate () throws Exception {
169
165
LocaleContextHolder .setLocale (Locale .US );
170
- this .resolver .resolveTemplate (TEMPLATE_PREFIX + "missing.tpl" );
166
+ this .configurer .resolveTemplate (getClass (). getClassLoader (), TEMPLATE_PREFIX + "missing.tpl" );
171
167
Assert .fail ();
172
168
}
173
169
}
0 commit comments