Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
fochoac committed May 13, 2019
1 parent 10f80f0 commit 849658b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
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 added src/test/resources/test.docx
Binary file not shown.
Binary file added src/test/resources/test_results/contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/test/resources/test_results/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 849658b

Please sign in to comment.