Example usage for org.apache.commons.io FileUtils forceDelete

List of usage examples for org.apache.commons.io FileUtils forceDelete

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils forceDelete.

Prototype

public static void forceDelete(File file) throws IOException 

Source Link

Document

Deletes a file.

Usage

From source file:edu.ur.ir.researcher.ResearcherTest.java

/**
 * Setup for testing//from  www . ja v a2s.  c  om
 * 
 * this deletes exiting test directories if they exist
 */
@BeforeMethod
public void cleanDirectory() {
    try {
        File f = new File(properties.getProperty("a_repo_path"));
        if (f.exists()) {
            FileUtils.forceDelete(f);
        }
        File f2 = new File(properties.getProperty("FileInfoTest.base.equals"));
        if (f2.exists()) {
            FileUtils.forceDelete(f2);
        }

    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}

From source file:com.linkedin.pinot.core.data.readers.CSVRecordReaderTest.java

@AfterClass
public void tearDown() throws Exception {
    FileUtils.forceDelete(TEMP_DIR);
}

From source file:com.agiletec.plugins.jpavatar.aps.system.services.avatar.TestAvatarManager.java

public void testSaveAvatar() throws Throwable {
    this.setAvatarStyle(AvatarConfig.STYLE_LOCAL);
    File file = new File("target/test/entando_logo.jpg");
    String username = "admin";
    this._avatarManager.saveAvatar(username, file, "entando_logo.jpg");
    File avatarFile = this._avatarManager.getAvatarResource(username);
    assertTrue(avatarFile.exists());//from w w w  . j av  a2  s . c  o m
    FileUtils.forceDelete(avatarFile);
    assertFalse(avatarFile.exists());
}

From source file:de.eiswind.jackrabbit.persistence.orient.PersistenceManagerTest.java

protected void tearDown() throws Exception {
    FileUtils.forceDelete(directory);
}

From source file:com.github.brandtg.switchboard.TestFileLogServer.java

@AfterClass
public void afterClass() throws Exception {
    server.stop();
    FileUtils.forceDelete(rootDir);
}

From source file:com.github.ipaas.ideploy.agent.handler.DownloadCodeHandlerTest.java

/**
 * ??,???,/*from  w w w .j  ava2 s.c  o  m*/
 * 
 * @throws Exception
 */
@Test
public void downloadCodeTest() throws Exception {
    String usingRoot = "/www/apptemp/" + USING_VERSION;
    String doingRoot = "/www/apptemp/" + DOING_VERSION;
    DownloadCodeHandler downLoadHandler = new DownloadCodeHandler();
    File usingfile = new File(usingRoot);
    if (usingfile.exists()) {
        FileUtils.forceDelete(usingfile);
    }
    File doingFile = new File(doingRoot);
    if (doingFile.exists()) {
        FileUtils.forceDelete(doingFile);
    }

    String flowId = "flowIdNotNeed";
    String cmd = "cmdNotNeed";
    Integer hostStatus4New = 1;
    Integer updateAll = 1;
    Map<String, Object> firstDownLoadParams = new HashMap<String, Object>();
    firstDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION);
    firstDownLoadParams.put("hostStatus", hostStatus4New);
    firstDownLoadParams.put("savePath", usingRoot);// ??
    firstDownLoadParams.put("updateAll", updateAll);
    downLoadHandler.execute(flowId, cmd, firstDownLoadParams, null);

    Assert.assertTrue(new File(usingRoot + "/update.txt").exists());

    Integer notUpdateAll = 2;
    Integer hostStatus4Old = 2;
    Map<String, Object> secondDownLoadParams = new HashMap<String, Object>();
    secondDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + DOING_VERSION);
    secondDownLoadParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION);
    secondDownLoadParams.put("hostStatus", hostStatus4Old);
    secondDownLoadParams.put("savePath", doingRoot);// ??
    secondDownLoadParams.put("updateAll", notUpdateAll);
    downLoadHandler.execute(flowId, cmd, secondDownLoadParams, null);
    File updateFile = new File(doingRoot + "/update.txt");

    Assert.assertTrue(updateFile.exists());

    // ?
    //String do
    List<String> updateList = FileUtils.readLines(updateFile);
    for (String str : updateList) {
        if (str.startsWith("+")) {
            Assert.assertTrue(
                    new File(doingRoot + "/code" + StringUtils.removeStart(str, "+").trim()).exists());
        } else if (str.startsWith("-")) {
            String f = usingRoot + "/code" + StringUtils.removeStart(str, "-").trim();
            Assert.assertTrue(new File(f).exists());
        }
    }

    if (usingfile.exists()) {
        FileUtils.forceDelete(usingfile);
    }
    if (doingFile.exists()) {
        FileUtils.forceDelete(doingFile);
    }
}

From source file:io.druid.segment.realtime.firehose.SqlFirehoseFactoryTest.java

@BeforeClass
public static void setup() throws IOException {
    TEST_DIR = File.createTempFile(SqlFirehoseFactoryTest.class.getSimpleName(), "testDir");
    FileUtils.forceDelete(TEST_DIR);
    FileUtils.forceMkdir(TEST_DIR);/*from www.ja v  a2  s  .  c  om*/
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.RemoveRawFileListener.java

@Override
public void handleEvent(Event event) {
    Vector<File> files = this.selectRawFilesUI.getSelectedRemovedFile();
    if (files.size() < 1) {
        this.selectRawFilesUI.displayMessage("No file selected");
        return;//www . j a  v a  2s . co  m
    }
    File mapping = ((GeneExpressionData) this.dataType).getStsmf();
    boolean confirm = this.selectRawFilesUI.confirm(
            "The column mapping file and the word mapping file will be removed consequently.\nAre you sure to remove these files?");
    for (File file : files) {
        if (file == null) {
            return;
        }
        if (((GeneExpressionData) this.dataType).getRawFiles().size() == files.size()) {
            if (mapping != null) {
                if (confirm) {
                    ((GeneExpressionData) this.dataType).setSTSMF(null);
                    try {
                        FileUtils.forceDelete(mapping);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        this.selectRawFilesUI.displayMessage("File error: " + e.getLocalizedMessage());
                        e.printStackTrace();
                    }

                    ((GeneExpressionData) this.dataType).getRawFiles().remove(file);
                    FileUtils.deleteQuietly(file);
                    UsedFilesPart.sendFilesChanged(dataType);
                }
            } else {
                if (confirm) {
                    ((GeneExpressionData) this.dataType).getRawFiles().remove(file);
                    FileUtils.deleteQuietly(file);
                    UsedFilesPart.sendFilesChanged(dataType);
                }
            }
        }
    }
    this.selectRawFilesUI.updateViewer();
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:com.dchq.docker.volume.driver.adaptor.LocalVolumeAdaptorImpl.java

@Override
public BaseResponse remove(RemoveRequest request) {
    BaseResponse response = new BaseResponse();
    try {/*w  ww . j  a  va2  s .  c  o  m*/
        File file = new File(new File(TMP_LOC), request.getName());
        FileUtils.forceDelete(file);
        logger.info("Removed Volume [{}] on path [{}]", file.getName(), file.getAbsoluteFile());
    } catch (Exception e) {
        logger.warn(e.getLocalizedMessage(), e);
        response.setErr(e.getLocalizedMessage());
    }
    return response;
}

From source file:com.blockwithme.longdb.leveldb.Util.java

/** Force drop. */
public static void forceDrop(final File theFile) {
    if (!theFile.isDirectory()) {
        try {/* www . ja  va  2s .  c o  m*/
            theFile.setWritable(true);
            FileUtils.forceDelete(theFile);
        } catch (final IOException e) {
            LOG.warn("exception ignored - forceDrop(File f=" + theFile + ")");
            // ignore.
        }
    } else {
        final File[] files = theFile.listFiles();
        for (final File file : files) {
            forceDrop(file);
        }
    }
}