1 package org.apache.maven.doxia.docrenderer.itext;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.apache.maven.doxia.docrenderer.DocRenderer;
25 import org.codehaus.plexus.PlexusTestCase;
26 import org.codehaus.plexus.util.FileUtils;
27
28
29
30
31
32 public class DefaultPdfRendererTest
33 extends PlexusTestCase
34 {
35 private static final String OUTPUT = "target/output";
36
37 private static final String SITE = "src/test/resources/site";
38
39 private static final String DESCRIPTOR_WITHOUT_TOC = "src/test/resources/doc-without-TOC.xml";
40
41 private File outputDirectory;
42
43 private File siteDirectoryFile;
44
45 private DocRenderer docRenderer;
46
47
48 protected void setUp()
49 throws Exception
50 {
51 super.setUp();
52
53 docRenderer = (DocRenderer) lookup( DocRenderer.ROLE );
54
55 outputDirectory = getTestFile( OUTPUT );
56 outputDirectory.mkdirs();
57
58 siteDirectoryFile = getTestFile( SITE );
59
60 FileUtils.copyDirectory( new File( siteDirectoryFile, "resources/css" ), new File( outputDirectory, "css" ),
61 "*.css", ".svn" );
62 FileUtils.copyDirectory( new File( siteDirectoryFile, "resources/images" ),
63 new File( outputDirectory, "images" ), "*.png", ".svn" );
64 }
65
66
67 protected void tearDown()
68 throws Exception
69 {
70 release( docRenderer );
71 super.tearDown();
72 }
73
74
75
76
77 public void testRenderFileFile()
78 throws Exception
79 {
80 docRenderer.render( siteDirectoryFile, outputDirectory );
81
82 assertTrue( new File( outputDirectory, "faq.pdf" ).exists() );
83 assertTrue( new File( outputDirectory, "faq.pdf" ).length() > 0 );
84 assertTrue( new File( outputDirectory, "index.pdf" ).exists() );
85 assertTrue( new File( outputDirectory, "index.pdf" ).length() > 0 );
86 assertTrue( new File( outputDirectory, "overview.pdf" ).exists() );
87 assertTrue( new File( outputDirectory, "overview.pdf" ).length() > 0 );
88 assertTrue( new File( outputDirectory, "resources.pdf" ).exists() );
89 assertTrue( new File( outputDirectory, "resources.pdf" ).length() > 0 );
90
91 }
92
93
94
95
96 public void testRenderFileFileFile()
97 throws Exception
98 {
99 File descriptor = getTestFile( DESCRIPTOR_WITHOUT_TOC );
100
101 docRenderer.render( siteDirectoryFile, outputDirectory, descriptor );
102
103 assertTrue( new File( outputDirectory, "doc-with-merged.pdf" ).exists() );
104 assertTrue( new File( outputDirectory, "doc-with-merged.pdf" ).length() > 0 );
105 }
106 }