use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class TemplateEngineTest method testTemplateResolverConfiguration04.
@Test
public void testTemplateResolverConfiguration04() {
final TemplateEngine templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(new ClassLoaderTemplateResolver());
templateEngine.setTemplateResolver(new FileTemplateResolver());
templateEngine.initialize();
final List<ITemplateResolver> templateResolvers = new ArrayList<ITemplateResolver>(templateEngine.getTemplateResolvers());
Assert.assertEquals(1, templateResolvers.size());
Assert.assertEquals("org.thymeleaf.templateresolver.FileTemplateResolver", templateResolvers.get(0).getName());
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class TemplateEngineTest method testDefaultTemplateResolver02.
@Test
public void testDefaultTemplateResolver02() {
final TemplateEngine templateEngine = new SpringTemplateEngine();
final Context context = new Context();
context.setLocale(Locale.ENGLISH);
context.setVariable("one", "this value");
final ClassLoaderTemplateResolver classLoaderTemplateResolver = new ClassLoaderTemplateResolver();
classLoaderTemplateResolver.setCheckExistence(true);
templateEngine.addTemplateResolver(classLoaderTemplateResolver);
final DefaultTemplateResolver defaultTemplateResolver = new DefaultTemplateResolver();
defaultTemplateResolver.setTemplate("<p>something</p>");
templateEngine.addTemplateResolver(defaultTemplateResolver);
templateEngine.initialize();
final List<ITemplateResolver> templateResolvers = new ArrayList<ITemplateResolver>(templateEngine.getTemplateResolvers());
Assert.assertEquals(2, templateResolvers.size());
Assert.assertEquals("org.thymeleaf.templateresolver.ClassLoaderTemplateResolver", templateResolvers.get(0).getName());
Assert.assertEquals("org.thymeleaf.templateresolver.DefaultTemplateResolver", templateResolvers.get(1).getName());
Assert.assertEquals("<p>something</p>", templateEngine.process("nonexisting", context));
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class TemplateEngineTest method testTemplateResolverConfiguration09.
@Test
public void testTemplateResolverConfiguration09() {
final TemplateEngine templateEngine = new TemplateEngine();
final Set<ITemplateResolver> resolvers = new LinkedHashSet<ITemplateResolver>();
resolvers.add(new ClassLoaderTemplateResolver());
resolvers.add(new FileTemplateResolver());
templateEngine.setTemplateResolvers(resolvers);
templateEngine.initialize();
final List<ITemplateResolver> templateResolvers = new ArrayList<ITemplateResolver>(templateEngine.getTemplateResolvers());
Assert.assertEquals(2, templateResolvers.size());
Assert.assertEquals("org.thymeleaf.templateresolver.ClassLoaderTemplateResolver", templateResolvers.get(0).getName());
Assert.assertEquals("org.thymeleaf.templateresolver.FileTemplateResolver", templateResolvers.get(1).getName());
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class TemplateEngineTest method testTemplateResolverConfiguration08.
@Test
public void testTemplateResolverConfiguration08() {
final TemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(new ClassLoaderTemplateResolver());
templateEngine.addTemplateResolver(new FileTemplateResolver());
templateEngine.initialize();
final List<ITemplateResolver> templateResolvers = new ArrayList<ITemplateResolver>(templateEngine.getTemplateResolvers());
Assert.assertEquals(2, templateResolvers.size());
Assert.assertEquals("org.thymeleaf.templateresolver.ClassLoaderTemplateResolver", templateResolvers.get(0).getName());
Assert.assertEquals("org.thymeleaf.templateresolver.FileTemplateResolver", templateResolvers.get(1).getName());
}
use of org.thymeleaf.templateresolver.ClassLoaderTemplateResolver in project thymeleaf-tests by thymeleaf.
the class TemplateEngineTest method testTemplateResolverConfiguration06.
@Test
public void testTemplateResolverConfiguration06() {
final TemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(new ClassLoaderTemplateResolver());
templateEngine.addTemplateResolver(new FileTemplateResolver());
templateEngine.initialize();
final List<ITemplateResolver> templateResolvers = new ArrayList<ITemplateResolver>(templateEngine.getTemplateResolvers());
Assert.assertEquals(2, templateResolvers.size());
Assert.assertEquals("org.thymeleaf.templateresolver.ClassLoaderTemplateResolver", templateResolvers.get(0).getName());
Assert.assertEquals("org.thymeleaf.templateresolver.FileTemplateResolver", templateResolvers.get(1).getName());
}
Aggregations