1 package org.apache.maven.doxia.module.rtf;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.doxia.sink.Sink;
23 import org.apache.maven.doxia.sink.AbstractSinkTestCase;
24 import org.apache.maven.doxia.sink.SinkTestDocument;
25 import org.apache.maven.doxia.parser.Parser;
26 import org.apache.maven.doxia.module.apt.AptParser;
27 import org.codehaus.plexus.util.IOUtil;
28
29 import java.io.File;
30 import java.io.FileOutputStream;
31 import java.io.OutputStream;
32 import java.io.Reader;
33 import java.io.InputStream;
34 import java.io.InputStreamReader;
35
36
37
38
39
40 public class RtfSinkTest
41 extends AbstractSinkTestCase
42 {
43
44 protected String outputExtension()
45 {
46 return "rtf";
47 }
48
49
50 protected Parser createParser()
51 {
52 return new AptParser();
53 }
54
55
56 protected Sink createSink()
57 throws Exception
58 {
59 File outputFile = new File( getBasedirFile(), "target/output/test.rtf" );
60 outputFile.getParentFile().mkdirs();
61 return new RtfSink( new FileOutputStream( outputFile ) );
62 }
63
64
65 protected Reader getTestReader()
66 throws Exception
67 {
68 InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "test.apt" );
69
70 InputStreamReader reader = new InputStreamReader( is );
71
72 return reader;
73 }
74
75 public void testDocument()
76 throws Exception
77 {
78 File outputFile = new File( getBasedirFile(), "target/test-output/sink/testDocument.rtf" );
79 outputFile.getParentFile().mkdirs();
80 OutputStream out = new FileOutputStream( outputFile );
81
82 Sink sink = new RtfSink( out );
83 try
84 {
85 SinkTestDocument.generate( sink );
86 }
87 finally
88 {
89 sink.close();
90 IOUtil.close( out );
91 }
92 }
93 }