public void test() {
EntityManager em = this.emf.createEntityManager();
em.getTransaction().begin();
QuotationProperties qp = new QuotationProperties();
try {
qp.setLogo(LOGO_FILE);
} catch (IOException | MaxFileSizeException e) {
Assert.fail(e.getMessage());
}
try {
qp.setXSLFile(XSL_FILE);
} catch (MaxFileSizeException | IOException e) {
Assert.fail(e.getMessage());
}
em.persist(qp);
try {
Assert.assertArrayEquals(IOUtils.toByteArray(new FileInputStream(new File(LOGO_FILE))), qp.getLogo());
Assert.assertArrayEquals(IOUtils.toCharArray(new FileInputStream(new File(XSL_FILE))), qp.getXSL());
} catch (IOException e) {
Assert.fail(e.getMessage());
}
try {
System.out.println("Extracted logo file from DB generated in... "+qp.getLogoFile().getAbsoluteFile());
System.out.println("Extracted xsl file from DB generated in... "+qp.getXSLFile().getAbsoluteFile());
} catch (IOException e) {
Assert.fail(e.getMessage());
}
em.getTransaction().commit();