-
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
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/test/java/ec/eppec/comun/reporte/word/WordReportContractTest.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,54 @@ | ||
|
||
package ec.eppec.comun.reporte.word; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import ec.report4j.comun.report.Report; | ||
|
||
public class WordReportContractTest { | ||
private static final String TEMPLATE_NAME_CONTRACT = "contract.docx"; | ||
private static final String TEMPLATE_NAME_TEST = "test.docx"; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
} | ||
|
||
|
||
|
||
@Test | ||
public final void testContractExportPdf() throws IOException, Throwable { | ||
byte[] pdf = Report.getWordInstance() | ||
.assignTemplate(getClass().getClassLoader().getResourceAsStream(TEMPLATE_NAME_CONTRACT), null) | ||
.buildReport().exportPdf(); | ||
File archivo = saveFile(pdf, "report-word-pdf-contract", ".pdf"); | ||
assertNotNull(archivo); | ||
} | ||
@Test | ||
public final void testTestExportPdf() throws IOException, Throwable { | ||
byte[] pdf = Report.getWordInstance() | ||
.assignTemplate(getClass().getClassLoader().getResourceAsStream(TEMPLATE_NAME_TEST), null) | ||
.buildReport().exportPdf(); | ||
File archivo = saveFile(pdf, "report-word-pdf-test", ".pdf"); | ||
assertNotNull(archivo); | ||
} | ||
|
||
|
||
private File saveFile(byte[] contenido, String nombre, String extension) | ||
throws FileNotFoundException, IOException { | ||
File archivo = Files.createTempFile(nombre, extension).toFile(); | ||
try (FileOutputStream out = new FileOutputStream(archivo)) { | ||
out.write(contenido); | ||
} | ||
return archivo; | ||
} | ||
|
||
} |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.