1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.doxia.siterenderer;
20
21 import java.io.File;
22
23 import org.codehaus.plexus.testing.PlexusTest;
24 import org.junit.jupiter.api.Test;
25
26 import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
27 import static org.junit.jupiter.api.Assertions.assertEquals;
28
29
30
31
32
33 @PlexusTest
34 public class RenderingContextTest {
35
36
37
38
39
40
41 @Test
42 public void testFilePathWithDot() throws Exception {
43 File baseDir = new File(getBasedir() + File.separatorChar + "test" + File.separatorChar + "resources");
44
45 String document = "file.with.dot.in.name.xml";
46 DocumentRenderingContext docRenderingContext =
47 new DocumentRenderingContext(baseDir, "test", document, "", "xml", false);
48 assertEquals("file.with.dot.in.name.html", docRenderingContext.getOutputPath());
49 assertEquals(".", docRenderingContext.getRelativePath());
50
51 document = "file.with.dot.in.name";
52 docRenderingContext = new DocumentRenderingContext(baseDir, document, "generator");
53 assertEquals("file.with.dot.in.name.html", docRenderingContext.getOutputPath());
54 assertEquals(".", docRenderingContext.getRelativePath());
55
56 document = "index.xml.vm";
57 docRenderingContext = new DocumentRenderingContext(baseDir, "test", document, "", "xml", false);
58 assertEquals("index.html", docRenderingContext.getOutputPath());
59 assertEquals(".", docRenderingContext.getRelativePath());
60
61 document = "download.apt.vm";
62 docRenderingContext = new DocumentRenderingContext(baseDir, "test", document, "", "apt", false);
63 assertEquals("download.html", docRenderingContext.getOutputPath());
64 assertEquals(".", docRenderingContext.getRelativePath());
65
66 document = "path/file.apt";
67 docRenderingContext = new DocumentRenderingContext(baseDir, "test", document, "", "apt", false);
68 assertEquals("path/file.html", docRenderingContext.getOutputPath());
69 assertEquals("..", docRenderingContext.getRelativePath());
70
71 document = "path/file";
72 docRenderingContext = new DocumentRenderingContext(baseDir, document, "generator");
73 assertEquals("path/file.html", docRenderingContext.getOutputPath());
74 assertEquals("..", docRenderingContext.getRelativePath());
75 }
76 }