|
1 | | -package org.fugerit.java.codesamplesfjdoc; |
| 1 | +package test.testorg.fugerit.java.codesamplesfjdoc; |
2 | 2 |
|
| 3 | +import lombok.extern.slf4j.Slf4j; |
| 4 | +import org.fugerit.java.codesamplesfjdoc.DocHelper; |
3 | 5 | import org.fugerit.java.doc.base.config.DocConfig; |
4 | 6 | import org.fugerit.java.doc.base.process.DocProcessContext; |
| 7 | +import org.junit.jupiter.api.Test; |
5 | 8 |
|
6 | 9 | import java.io.ByteArrayOutputStream; |
| 10 | +import java.io.IOException; |
7 | 11 | import java.nio.charset.StandardCharsets; |
8 | 12 | import java.util.Arrays; |
9 | 13 | import java.util.List; |
|
13 | 17 | * running this main the program will : |
14 | 18 | * - creates data to be used in document model |
15 | 19 | * - renders the 'document.ftl' template |
16 | | - * - print the result in markdown format on the stanndard output |
| 20 | + * - print the result in markdown format on the log |
17 | 21 | * |
18 | 22 | * For further documentation : |
19 | 23 | * https://github.com/fugerit-org/fj-doc |
20 | | - * |
21 | | - * NOTE: This is a 'Hello World' style example, adapt it to your scenario, especially : |
22 | | - * - remove system out and system err with your logging system |
23 | | - * - change the doc handler and the output mode (here a ByteArrayOutputStream buffer is used) |
24 | 24 | */ |
25 | | -public class DocHelperExample { |
| 25 | +@Slf4j |
| 26 | +class DocHelperTest { |
26 | 27 |
|
27 | | - public static void main(String[] args) { |
| 28 | + @Test |
| 29 | + void example() throws IOException { |
28 | 30 | try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) { |
29 | 31 | // creates the doc helper |
30 | 32 | DocHelper docHelper = new DocHelper(); |
31 | 33 | // create custom data for the fremarker template 'document.ftl' |
32 | | - List<People> listPeople = Arrays.asList( new DocHelperExample.People( "Luthien", "Tinuviel", "Queen" ), new DocHelperExample.People( "Thorin", "Oakshield", "King" ) ); |
| 34 | + List<People> listPeople = Arrays.asList( new People( "Luthien", "Tinuviel", "Queen" ), new People( "Thorin", "Oakshield", "King" ) ); |
33 | 35 | // handler id |
34 | 36 | String handlerId = DocConfig.TYPE_MD; |
35 | 37 | // output generation |
36 | 38 | docHelper.getDocProcessConfig().fullProcess( "document", DocProcessContext.newContext( "listPeople", listPeople ), handlerId, baos ); |
37 | 39 | // print the output |
38 | | - System.out.println( "html output : \n"+ new String( baos.toByteArray(), StandardCharsets.UTF_8 ) ); |
39 | | - } catch (Exception e) { |
40 | | - e.printStackTrace(); |
| 40 | + log.info( "html output : \n{}", new String( baos.toByteArray(), StandardCharsets.UTF_8 ) ); |
41 | 41 | } |
42 | 42 | } |
43 | 43 |
|
|
0 commit comments