-
Notifications
You must be signed in to change notification settings - Fork 3
/
SynchronousLatexRendererIT.java
74 lines (53 loc) · 1.88 KB
/
SynchronousLatexRendererIT.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package de.vsfexperts.latex.renderer;
import static de.vsfexperts.latex.renderer.ClasspathUtils.getContent;
import static de.vsfexperts.latex.renderer.FileMatcher.notAnEmptyFile;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import java.io.File;
import java.util.UUID;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import de.vsfexperts.latex.storage.FileSystemArchive;
import de.vsfexperts.latex.storage.LocalFileSystemStorage;
public class SynchronousLatexRendererIT {
private LocalFileSystemStorage tempStorage;
private LatexRenderer renderer;
private FileSystemArchive archive;
@Before
public void setUp() {
tempStorage = new LocalFileSystemStorage();
archive = new FileSystemArchive();
renderer = new SynchronousLatexRenderer(tempStorage, archive);
}
@After
public void tearDown() {
archive.cleanArchive();
}
@Test
public void testPdfRendering() throws Exception {
final String latexDocument = getContent("/META-INF/sample.tex");
final UUID jobId = renderer.render(latexDocument);
try {
final File pdfRenderOutput = renderer.getResult(jobId).get();
assertThat(pdfRenderOutput, is(notAnEmptyFile()));
final File archivedPdfOutput = archive.get(jobId, jobId.toString() + ".pdf").get();
assertThat(archivedPdfOutput, is(notAnEmptyFile()));
final File archivedTexDocument = archive.get(jobId, jobId.toString() + ".tex").get();
assertThat(archivedTexDocument, is(notAnEmptyFile()));
} finally {
tempStorage.delete(jobId);
}
}
@Test
public void testInvalidPdfRendering() throws Exception {
final String latexDocument = "INVALID TEX DOCUMENT";
final UUID jobId = renderer.render(latexDocument);
try {
final File baseDirectory = tempStorage.getBaseDirectory(jobId);
assertThat(baseDirectory.list().length, is(0));
} finally {
tempStorage.delete(jobId);
}
}
}