-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from fugerit-org/feature/issue_67_coverage_80
Target 70% coverage
- Loading branch information
Showing
55 changed files
with
1,101 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...r/src/test/java/test/org/fugerit/java/doc/freemarker/coverage/TestFreemarkerCoverage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package test.org.fugerit.java.doc.freemarker.coverage; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.Arrays; | ||
|
||
import org.fugerit.java.core.function.SafeFunction; | ||
import org.fugerit.java.core.function.SimpleValue; | ||
import org.fugerit.java.core.lang.helpers.ClassHelper; | ||
import org.fugerit.java.doc.base.config.DocInput; | ||
import org.fugerit.java.doc.base.config.DocOutput; | ||
import org.fugerit.java.doc.base.config.DocTypeHandler; | ||
import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandler; | ||
import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlFragmentTypeHandlerUTF8; | ||
import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandler; | ||
import org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class TestFreemarkerCoverage { | ||
|
||
private final static TestEntry[] TEST_LIST = { | ||
new TestEntry( "default_doc" , true ), | ||
new TestEntry( "default_doc_alt" , true ), | ||
new TestEntry( "default_doc_fail1" , true ) | ||
}; | ||
|
||
private final static DocTypeHandler[] HANDLERS = { FreeMarkerHtmlTypeHandler.HANDLER, | ||
FreeMarkerHtmlTypeHandlerUTF8.HANDLER, | ||
FreeMarkerHtmlFragmentTypeHandler.HANDLER, | ||
FreeMarkerHtmlFragmentTypeHandlerUTF8.HANDLER }; | ||
|
||
private boolean worker( String path, boolean result ) { | ||
SimpleValue<Boolean> res = new SimpleValue<>(false); | ||
SafeFunction.apply( () -> { | ||
for ( int k=0; k<HANDLERS.length; k++ ) { | ||
DocTypeHandler handler = HANDLERS[k]; | ||
try ( InputStreamReader reader = new InputStreamReader( ClassHelper.loadFromDefaultClassLoader(path) ); | ||
ByteArrayOutputStream buffer = new ByteArrayOutputStream() ) { | ||
handler.handle( DocInput.newInput( handler.getType() , reader ) , DocOutput.newOutput( buffer ) ); | ||
if ( result ) { | ||
res.setValue( buffer.toByteArray().length > 0 ); | ||
} else { | ||
res.setValue( buffer.toByteArray().length == 0 ); | ||
} | ||
} | ||
} | ||
} ); | ||
return res.getValue(); | ||
} | ||
|
||
@Test | ||
public void test01() { | ||
Arrays.asList( TEST_LIST ).stream().forEach( c -> { | ||
log.info( "test -> {}", c ); | ||
Assert.assertTrue( this.worker( "coverage/xml/"+c.getId()+".xml", c.isResult() ) ); | ||
} ); | ||
} | ||
|
||
} | ||
|
||
@AllArgsConstructor | ||
@ToString | ||
class TestEntry { | ||
|
||
@Getter private String id; | ||
|
||
@Getter private boolean result; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...-freemarker/src/test/java/test/org/fugerit/java/doc/freemarker/tool/TestGenerateStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package test.org.fugerit.java.doc.freemarker.tool; | ||
|
||
import java.io.InputStream; | ||
import java.io.StringWriter; | ||
import java.util.Properties; | ||
|
||
import org.fugerit.java.core.lang.helpers.ClassHelper; | ||
import org.fugerit.java.doc.freemarker.tool.GenerateStub; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import test.org.fugerit.java.BasicTest; | ||
|
||
public class TestGenerateStub extends BasicTest { | ||
|
||
@Test | ||
public void genTest001() { | ||
runTestEx( () -> { | ||
try ( InputStream is = ClassHelper.loadFromDefaultClassLoader( "generate-stub-test/doc-process-autodoc.xml" ); | ||
StringWriter writer = new StringWriter() ) { | ||
Properties props = new Properties(); | ||
GenerateStub.generate( writer, props, is ); | ||
Assert.assertNotEquals( 0 , writer.toString().length() ); | ||
} | ||
} ); | ||
} | ||
|
||
@Test | ||
public void genTest002() { | ||
runTestEx( () -> { | ||
try (StringWriter writer = new StringWriter() ) { | ||
Properties props = new Properties(); | ||
props.setProperty( GenerateStub.ARG_INPUT_FILE , "src/test/resources/generate-stub-test/doc-process-autodoc.xml" ); | ||
GenerateStub.generate( writer, props ); | ||
Assert.assertNotEquals( 0 , writer.toString().length() ); | ||
} | ||
} ); | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
fj-doc-freemarker/src/test/resources/coverage/xml/default_doc.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<doc | ||
xmlns="http://javacoredoc.fugerit.org" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://javacoredoc.fugerit.org https://www.fugerit.org/data/java/doc/xsd/doc-2-1.xsd" > | ||
|
||
<metadata> | ||
<!-- Margin for document : left;right;top;bottom --> | ||
<info name="margins">10;10;10;30</info> | ||
<info name="excel-table-id">excel-table=print</info> | ||
<!-- documenta meta information --> | ||
<info name="doc-title">Basic example</info> | ||
<info name="doc-subject">fj doc venus sample source xml</info> | ||
<info name="doc-author">fugerit79</info> | ||
<info name="doc-language">en</info> | ||
<!-- additional properties --> | ||
<info name="set-total-page">true</info> | ||
<info name="html-css-link">/css/test.css</info> | ||
<!-- CSV options --> | ||
<info name="csv-table-id">excel-table</info> | ||
<header-ext> | ||
<para align="center" fore-color="#eeeeee">header test</para> | ||
</header-ext> | ||
<footer-ext> | ||
<para align="left">test</para> | ||
<para align="center">${r"${currentPage}"} / ${r"${pageCount}"}</para> | ||
<para align="right">test</para> | ||
</footer-ext> | ||
<bookmark-tree> | ||
<bookmark ref="title">Test</bookmark> | ||
</bookmark-tree> | ||
</metadata> | ||
<body> | ||
<h id="title" head-level="1">main title h1</h> | ||
<para font-name="times-roman" style="bold">Test times roman</para> | ||
<para font-name="courier" style="bolditalic">Courier</para> | ||
<para font-name="symbol" style="italic">Symbol</para> | ||
<para font-name="helvetica" style="underline">Symbol</para> | ||
<para size="3" fore-color="#dddddd">Test default font</para> | ||
<br/> | ||
<page-break/> | ||
<table columns="3" colwidths="30;30;40" width="100" id="excel-table" padding="2"> | ||
<row> | ||
<cell align="center" border-color="#000000" border-width="1"><para style="bold">Name</para></cell> | ||
<cell align="center"><para style="bold">Surname</para></cell> | ||
<cell align="center"><para style="bold">Title</para></cell> | ||
</row> | ||
<row> | ||
<cell><para><![CDATA[Luthien]]></para></cell> | ||
<cell><para><![CDATA[Tinuviel]]></para></cell> | ||
<cell><para><![CDATA[Queen]]></para></cell> | ||
</row> | ||
<row> | ||
<cell><para><![CDATA[Thorin]]></para></cell> | ||
<cell><para><![CDATA[Oakshield]]></para></cell> | ||
<cell><para><![CDATA[King]]></para></cell> | ||
</row> | ||
<row> | ||
<cell><phrase><![CDATA[Phrase]]></phrase></cell> | ||
<cell><phrase anchor="1"><![CDATA[Oakshield]]></phrase></cell> | ||
<cell><phrase link="1"><![CDATA[King]]></phrase></cell> | ||
</row> | ||
</table> | ||
<list> | ||
<li><para>test 1</para></li> | ||
</list> | ||
<list list-type="ul"> | ||
<li><para>test 2</para></li> | ||
</list> | ||
<list list-type="ol"> | ||
<li><para>test 3</para></li> | ||
</list> | ||
<list list-type="uld"> | ||
<li><para>test 4</para></li> | ||
</list> | ||
<list list-type="ulm"> | ||
<li><para>test 5</para></li> | ||
</list> | ||
<list list-type="oll"> | ||
<li><para>test 6</para></li> | ||
</list> | ||
<list list-type="oln"> | ||
<li><para>test 7</para></li> | ||
</list> | ||
</body> | ||
|
||
</doc> |
Oops, something went wrong.