-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
308 additions
and
65 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/java/org/fugerit/java/doc/mod/openpdf/helpers/OpenPdfFontHelper.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
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
59 changes: 56 additions & 3 deletions
59
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestDefaultDoc.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 |
---|---|---|
@@ -1,25 +1,78 @@ | ||
package test.org.fugerit.java.doc.mod.itext.poc; | ||
|
||
import org.fugerit.java.core.cfg.ConfigRuntimeException; | ||
import org.fugerit.java.doc.mod.openpdf.HtmlTypeHandler; | ||
import org.fugerit.java.doc.mod.openpdf.PdfTypeHandler; | ||
import org.fugerit.java.doc.mod.openpdf.RtfTypeHandler; | ||
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPpfDocHandler; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import com.lowagie.text.pdf.BaseFont; | ||
|
||
public class TestDefaultDoc extends TestDocBase { | ||
|
||
private static final String CUSTOM_FONT = "TitilliumWeb"; | ||
|
||
@BeforeClass | ||
public static void init() { | ||
try { | ||
OpenPpfDocHandler.registerFont( CUSTOM_FONT , "src/test/resources/font/TitilliumWeb-Regular.ttf"); | ||
} catch (Exception e) { | ||
throw new ConfigRuntimeException( e ); | ||
} | ||
} | ||
|
||
private static final String DEFAULT_DOC = "default_doc"; | ||
|
||
private static final String DEFAULT_DOC_ALT = "default_doc_alt"; | ||
|
||
@Test | ||
public void testOpenFailPDF() { | ||
Assert.assertThrows( AssertionError.class , () -> this.testDocWorker( "default_doc_fail1" , PdfTypeHandler.HANDLER ) ); | ||
} | ||
|
||
@Test | ||
public void testCustomFont() { | ||
BaseFont font = OpenPpfDocHandler.findFont( CUSTOM_FONT ); | ||
Assert.assertNotNull(font); | ||
} | ||
|
||
@Test | ||
public void testOpenPDF() { | ||
this.testDocWorker( "default_doc" , PdfTypeHandler.HANDLER ); | ||
boolean ok = this.testDocWorker( DEFAULT_DOC , PdfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenHTML() { | ||
this.testDocWorker( "default_doc" , HtmlTypeHandler.HANDLER ); | ||
boolean ok = this.testDocWorker( DEFAULT_DOC , HtmlTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenRTF() { | ||
this.testDocWorker( "default_doc" , RtfTypeHandler.HANDLER ); | ||
boolean ok = this.testDocWorker( DEFAULT_DOC , RtfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenAltPDF() { | ||
boolean ok = this.testDocWorker( DEFAULT_DOC_ALT , PdfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenAltHTML() { | ||
boolean ok = this.testDocWorker( DEFAULT_DOC_ALT , HtmlTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
@Test | ||
public void testOpenAltRTF() { | ||
boolean ok = this.testDocWorker( DEFAULT_DOC_ALT , RtfTypeHandler.HANDLER ); | ||
Assert.assertTrue(ok); | ||
} | ||
|
||
} |
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
19 changes: 19 additions & 0 deletions
19
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestOpenPdfHelper.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,19 @@ | ||
package test.org.fugerit.java.doc.mod.itext.poc; | ||
|
||
import org.fugerit.java.doc.mod.openpdf.helpers.PhraseParent; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.lowagie.text.Paragraph; | ||
import com.lowagie.text.Phrase; | ||
|
||
public class TestOpenPdfHelper { | ||
|
||
@Test | ||
public void test001() throws Exception { | ||
PhraseParent parent = new PhraseParent( new Phrase() ); | ||
parent.add( new Paragraph() ); | ||
Assert.assertNotNull( parent ); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestPdfHelper.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.mod.itext.poc; | ||
|
||
import org.fugerit.java.core.cfg.ConfigRuntimeException; | ||
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPdfFontHelper; | ||
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPpfDocHandler; | ||
import org.fugerit.java.doc.mod.openpdf.helpers.PdfHelper; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class TestPdfHelper { | ||
|
||
@Test | ||
public void testSetGet() { | ||
PdfHelper helper = new PdfHelper( null ); | ||
log.info( "getCurrentPageNumber -> {}", helper.getCurrentPageNumber() ); | ||
int current = 10; | ||
helper.setPageNumberAlignment(current); | ||
log.info( "getPageNumberAlignment -> {}", helper.getPageNumberAlignment() ); | ||
Assert.assertEquals( current , helper.getPageNumberAlignment() ); | ||
} | ||
|
||
|
||
@Test | ||
public void testTandleElementSafe() { | ||
Assert.assertThrows( ConfigRuntimeException.class , () -> OpenPpfDocHandler.handleElementsSafe(null, null, null) ); | ||
} | ||
|
||
@Test | ||
public void testCreateFontSafe() { | ||
Assert.assertThrows( RuntimeException.class , () -> OpenPdfFontHelper.createBaseFontSafe(null, null, false) ); | ||
} | ||
|
||
@Test | ||
public void testCreateFontSafe1() { | ||
Assert.assertThrows( ConfigRuntimeException.class , () -> OpenPdfFontHelper.createBaseFontSafe( "no", "no", false) ); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/test/org/fugerit/java/doc/mod/itext/poc/TestPhraseParent.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,22 @@ | ||
package test.org.fugerit.java.doc.mod.itext.poc; | ||
|
||
import java.util.Properties; | ||
|
||
import org.fugerit.java.doc.mod.openpdf.helpers.OpenPdfHelper; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class TestPhraseParent { | ||
|
||
@Test | ||
public void test001() throws Exception { | ||
OpenPdfHelper helper = new OpenPdfHelper(); | ||
helper.setParams( new Properties() ); | ||
log.info( "helper.getDefFontStyle() -> {}", helper.getDefFontStyle() ); | ||
Assert.assertNotNull( helper.getParams() ); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.