1
|
package eu.dnetlib.parthenos.virtuoso;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
|
5
|
import freemarker.cache.ClassTemplateLoader;
|
6
|
import freemarker.template.Template;
|
7
|
import freemarker.template.TemplateExceptionHandler;
|
8
|
import org.junit.Test;
|
9
|
|
10
|
import static org.junit.Assert.assertNotNull;
|
11
|
|
12
|
/**
|
13
|
* Created by Alessia Bardi on 14/03/2018.
|
14
|
*
|
15
|
* @author Alessia Bardi
|
16
|
*/
|
17
|
public class FreeMarkerTest {
|
18
|
|
19
|
@Test
|
20
|
public void testFreemarkTemplateLoading() throws IOException {
|
21
|
|
22
|
freemarker.template.Configuration config = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_27);
|
23
|
ClassTemplateLoader ctl = new ClassTemplateLoader(getClass(), "/eu/dnetlib/parthenos/sparql");
|
24
|
config.setTemplateLoader(ctl);
|
25
|
config.setDefaultEncoding("UTF-8");
|
26
|
// Sets how errors will appear.
|
27
|
// During web page *development* TemplateExceptionHandler.HTML_DEBUG_HANDLER is better.
|
28
|
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
29
|
|
30
|
// Don't log exceptions inside FreeMarker that it will thrown at you anyway:
|
31
|
config.setLogTemplateExceptions(false);
|
32
|
|
33
|
// Wrap unchecked exceptions thrown during template processing into TemplateException-s.
|
34
|
config.setWrapUncheckedExceptions(true);
|
35
|
|
36
|
|
37
|
String templateName = "E39_Actor_test.sparql";
|
38
|
Template temp = config.getTemplate(templateName);
|
39
|
assertNotNull(temp);
|
40
|
}
|
41
|
}
|