Skip to content

Commit 52b8e72

Browse files
committed
DocHelperExample converted to JUnit
1 parent f86c89a commit 52b8e72

File tree

1 file changed

+12
-12
lines changed
  • code-samples-fj-doc/src/test/java/test/testorg/fugerit/java/codesamplesfjdoc

1 file changed

+12
-12
lines changed

code-samples-fj-doc/src/main/java/org/fugerit/java/codesamplesfjdoc/DocHelperExample.java renamed to code-samples-fj-doc/src/test/java/test/testorg/fugerit/java/codesamplesfjdoc/DocHelperTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
package org.fugerit.java.codesamplesfjdoc;
1+
package test.testorg.fugerit.java.codesamplesfjdoc;
22

3+
import lombok.extern.slf4j.Slf4j;
4+
import org.fugerit.java.codesamplesfjdoc.DocHelper;
35
import org.fugerit.java.doc.base.config.DocConfig;
46
import org.fugerit.java.doc.base.process.DocProcessContext;
7+
import org.junit.jupiter.api.Test;
58

69
import java.io.ByteArrayOutputStream;
10+
import java.io.IOException;
711
import java.nio.charset.StandardCharsets;
812
import java.util.Arrays;
913
import java.util.List;
@@ -13,31 +17,27 @@
1317
* running this main the program will :
1418
* - creates data to be used in document model
1519
* - 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
1721
*
1822
* For further documentation :
1923
* 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)
2424
*/
25-
public class DocHelperExample {
25+
@Slf4j
26+
class DocHelperTest {
2627

27-
public static void main(String[] args) {
28+
@Test
29+
void example() throws IOException {
2830
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
2931
// creates the doc helper
3032
DocHelper docHelper = new DocHelper();
3133
// 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" ) );
3335
// handler id
3436
String handlerId = DocConfig.TYPE_MD;
3537
// output generation
3638
docHelper.getDocProcessConfig().fullProcess( "document", DocProcessContext.newContext( "listPeople", listPeople ), handlerId, baos );
3739
// 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 ) );
4141
}
4242
}
4343

0 commit comments

Comments
 (0)