DaoManager { public void destroy() { if ( entityManagerFactory != null && entityManagerFactory.isOpen() ) { entityManagerFactory.close(); } } DaoManager(); void init(); void destroy(); EntityManager getEntityManager(); EntityManager getEntityManagerFromFactory(); void setEntityManager( final EntityManager entityManager ); EntityManagerFactory getEntityManagerFactory(); void setEntityManagerFactory( final EntityManagerFactory entityManagerFactory ); short rollBackTransaction( EntityManager em ); short startTransaction( EntityManager em ); short commitTransaction( EntityManager em ); short closeEntityManager( EntityManager em ); synchronized short mergeExt( EntityManager em, Object obj ); synchronized short persistExt( EntityManager em, Object obj ); synchronized short removeExt( EntityManager em, Object obj ); boolean isAutoCommit(); void setAutoCommit( final boolean autoCommit );  }
@Test public void testDestroy() throws Exception { when( entityManagerFactory.isOpen() ).thenReturn( true ); daoManager.destroy(); verify( entityManagerFactory ).close(); }