1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
public class ImageTestCaseLectureEnBase {
static EntityManager em;
static EntityTransaction tx;
@BeforeClass
public static void createEntityManager() {
EntityManagerFactory emFactory = Persistence
.createEntityManagerFactory("myproject");
em = emFactory.createEntityManager();
}
@Before
public void clearEntityManager() {
em.clear();
}
@Test
public void testLecturePDF() {
try {
tx = em.getTransaction();
tx.begin();
Image find = em.find(Image.class, 3);
Blob pdf = find.getImage();
long lengthOfPdf=pdf.length();
} catch (SQLException e) {
e.printStackTrace();
}
tx.commit();
}
@AfterClass
public static void closeEntityManager() {
em.close();
}
} |
Partager