/** @throws java.lang.Exception */ @Before public void setUp() throws Exception { HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().begin(); dl = new FilesystemDL(BASE); dl.createOrUpdateUser(USER.getLogin(), USER_PASSWORD, USER.getName()); dl = new FilesystemDL(BASE); dl.createResearchObject( RO_URI, new ByteArrayInputStream(MAIN_FILE_CONTENT.getBytes()), MAIN_FILE_PATH, MAIN_FILE_MIME_TYPE); files[0] = new FileRecord("singleFiles/file1.txt", "file1.txt", "text/plain"); files[1] = new FileRecord("singleFiles/file2.txt", "dir/file2.txt", "text/plain"); files[2] = new FileRecord("singleFiles/file3.jpg", "testdir/file3.jpg", "image/jpg"); Files.createDirectories(Paths.get(BASE)); HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit(); }
/** @throws java.lang.Exception */ @After public void tearDown() throws Exception { HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().begin(); dl = new FilesystemDL(BASE); dl.deleteResearchObject(RO_URI); dl = new FilesystemDL(BASE); dl.deleteUser(USER.getLogin()); HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit(); try { Files.delete(Paths.get(BASE)); } catch (DirectoryNotEmptyException | NoSuchFileException e) { // was not empty } }