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 package fr.ifremer.isisfish.datastore;
27
28 import java.io.StringWriter;
29 import java.io.Writer;
30 import java.util.Date;
31 import java.util.HashMap;
32 import java.util.Map;
33
34 import org.junit.Assert;
35 import org.junit.Before;
36 import org.junit.Test;
37
38 import fr.ifremer.isisfish.AbstractIsisFishTest;
39 import fr.ifremer.isisfish.IsisFish;
40 import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
41 import freemarker.template.Configuration;
42 import freemarker.template.Template;
43
44
45
46
47
48
49
50
51
52
53
54
55 public class ExportStorageTest extends AbstractIsisFishTest {
56
57 protected Configuration freemarkerConfiguration;
58
59 @Before
60 public void setUp() throws Exception {
61 freemarkerConfiguration = getFreemarkerConfiguration();
62 }
63
64 @Test
65 public void testNewExportWithCompilation() throws Exception {
66
67 String fileName = "TestExport1";
68
69 ExportStorage exportStorage = ExportStorage.createExport(fileName, Location.COMMUNITY);
70
71
72 Template template = freemarkerConfiguration
73 .getTemplate(ExportStorage.EXPORT_TEMPLATE);
74
75
76 Map<String, Object> root = new HashMap<String, Object>();
77
78 root.put("category", "");
79 root.put("name", fileName);
80 root.put("date", new Date());
81 root.put("author", IsisFish.config.getUserName());
82 root.put("email", IsisFish.config.getUserMail());
83
84
85 Writer out = new StringWriter();
86 template.process(root, out);
87 out.flush();
88 exportStorage.setContent(out.toString());
89
90
91 int compileResult = exportStorage.compile(false, null);
92 Assert.assertEquals(0, compileResult);
93 }
94
95 }