aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/test/java/com/juick/www/ThymeleafTestsJunitRunner.java
blob: 4fd1f1f508cc5993ee16eb41df39430a82750f67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.juick.www;

import nz.net.ultraq.thymeleaf.LayoutDialect;
import org.junit.Assert;
import org.junit.Test;
import org.thymeleaf.dialect.IDialect;
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
import org.thymeleaf.spring4.dialect.SpringStandardDialect;
import org.thymeleaf.testing.templateengine.context.web.SpringWebProcessingContextBuilder;
import org.thymeleaf.testing.templateengine.engine.TestExecutor;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by aalexeev on 11/24/16.
 */
public class ThymeleafTestsJunitRunner {

    @Test
    public void runThymeleafTest() {
        final List<IDialect> dialects = new ArrayList<>();
        dialects.add(new SpringStandardDialect());
        dialects.add(new LayoutDialect());
        dialects.add(new SpringSecurityDialect());

        final SpringWebProcessingContextBuilder springPCBuilder = new SpringWebProcessingContextBuilder();

        springPCBuilder.setApplicationContextConfigLocation(null);

        final TestExecutor executor = new TestExecutor();
        executor.setProcessingContextBuilder(springPCBuilder);
        executor.setDialects(dialects);

        executor.execute("classpath:tests");

        Assert.assertTrue(executor.isAllOK());
        executor.reset();
    }
}