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

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

Introduction

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

Prototype

public static File toFile(URL url) 

Source Link

Document

Convert from a URL to a File.

Usage

From source file:sernet.verinice.search.ESOsgiDirectoryCreator.java

private String getTierDependentIndexLocation() {
    String location = null;//from w w w .j  ava  2s  . c o m
    try {
        // should be the case for tier2 mode, store index in <userhome>/elasticsearch
        location = FileUtils
                .toFile(new URL(
                        FilenameUtils.concat(System.getProperty("osgi.instance.area"), getIndexLocation())))
                .getAbsolutePath();
    } catch (Exception e) {
        LOG.error("Error while getting directory path", e);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("Storing ES-Index in: " + location);
    }
    return location;
}

From source file:sernet.verinice.service.DummyReportDepositService.java

public String getReportDepositPath() {
    try {//from ww  w.j av  a2  s. co m
        URL url = FileLocator.find(Activator.getDefault().getBundle(),
                new Path("/WebContent/WEB-INF/reportDeposit/"), null);
        URL fileUrl = FileLocator.toFileURL(url);
        return FileUtils.toFile(fileUrl).getAbsolutePath();
    } catch (IOException ex) {
        LOG.error("jar file with reports not found", ex);
    }

    return null;
}

From source file:uk.ac.ebi.fgpt.conan.core.context.scheduler.lsf.LSFSchedulerTest.java

@Test
public void testParseLsfOutput() throws IOException {

    File lsfFile = FileUtils.toFile(this.getClass().getResource("/lsfoutput.lsf"));

    ResourceUsage ru = this.lsfScheduler.getResourceUsageFromMonitorFile(lsfFile);

    assertTrue(ru.getCpuTime() == 137);//from ww w  .  j  a va 2  s.  co  m
    assertTrue(ru.getMaxMem() == 214);
}

From source file:uk.ac.tgac.jellyswarm.FileFinderTest.java

@Before
public void setup() {
    jsDirGood = FileUtils.toFile(this.getClass().getResource("/tools/jellyswarm/good"));
    jsDirBad = FileUtils.toFile(this.getClass().getResource("/tools/jellyswarm/bad"));
}

From source file:uk.ac.tgac.rampart.RampartConfigTest.java

@Test
public void testConfigLoad() throws IOException {

    File cfgFile = FileUtils.toFile(this.getClass().getResource("/config/test_rampart_config.xml"));
    File outDir = temp.newFolder("configTest");
    String jobPrefix = "configTestJob";

    RampartConfig args = new RampartConfig(cfgFile, outDir, jobPrefix, RampartStageList.parse("ALL"), null,
            null, true);// w w  w  . j ava2s .  c  om

    Assert.assertTrue(true);
}

From source file:uk.ac.tgac.rampart.RampartConfigTest.java

@Test
public void setupTest() throws IOException, TaskExecutionException, InterruptedException {

    File testFile = FileUtils.toFile(RampartConfigTest.class.getResource("/config/rampart_config_1.xml"));

    /*RampartCLI rampart = new RampartCLI();
    rampart.setJobConfig(testFile);/*  ww  w  .  j a va  2 s .c  o m*/
    rampart.setSkipChecks(true);
            
    rampart.initialise();
            
    String kr0 = rampart.getArgs().getMassArgs().getMassJobArgList().get(0).getKmerRange().toString();   */

    //rampart.execute();

    assertTrue(true);
}

From source file:uk.ac.tgac.rampart.stage.FinaliseTest.java

@Test
public void test1() throws InterruptedException, ProcessExecutionException, IOException {

    File outputDir = temp.newFolder("test1");

    File test1File = FileUtils.toFile(this.getClass().getResource("/tools/finalise/test1.fa"));

    Finalise.Args args = new Finalise.Args();
    args.setInputFile(test1File);
    args.setOutputDir(outputDir);/*from w ww  .  ja  va2 s .  c  o  m*/
    args.setMinN(5);
    args.setOutputPrefix("TGAC_TS_V1");
    args.setCompress(false);

    Finalise process = new Finalise(null, args);

    ExecutionResult result = process.execute(new DefaultExecutionContext());

    assertTrue(result.getExitCode() == 0);
    //assertTrue(new File(outputDir, "TGAC_TS_V1.tar.gz").exists());
}

From source file:uk.ac.tgac.rampart.stage.MassJobTest.java

@Test
public void testExecuteAbyss() throws ProcessExecutionException, InterruptedException, IOException,
        CommandExecutionException, ConanParameterException {

    File outputDir = temp.newFolder("testExecuteAbyss");

    File cfgFile = FileUtils.toFile(this.getClass().getResource("/tools/test_rampart_1.cfg"));

    MassJob.Args args = new MassJob.Args();
    args.setTool("ABYSS_V1.5");
    args.setKmerRange(new KmerRange(51, 65, KmerRange.StepSize.MEDIUM));
    args.setJobPrefix("testExecuteAbyss");
    args.setOutputDir(outputDir);/*from w w  w . j  av  a2  s  . c  om*/
    args.initialise();

    MassJob massJob = new MassJob(conanExecutorService, args);
    MassJob spy = Mockito.spy(massJob);

    AbstractConanProcess smParent = massJob;

    when(conanProcessService.execute(massJob, ec))
            .thenReturn(new DefaultExecutionResult("test", 0, null, null, -1));
    doReturn(new DefaultExecutionResult("test", 0, null, null, -1)).when(spy)
            .executeAssembler((Assembler) any(), anyString(), (List<Integer>) any());

    ReflectionTestUtils.setField(smParent, "conanExecutorService", conanExecutorService);

    spy.execute(ec);

    assertTrue(new File(outputDir, "k-51").exists());
    assertTrue(new File(outputDir, "k-61").exists());
    assertTrue(new File(outputDir, "unitigs").exists());
}

From source file:uk.ac.tgac.rampart.stage.MecqTest.java

@Test
public void testQT() throws InterruptedException, ProcessExecutionException, IOException,
        CommandExecutionException, ConanParameterException {

    File outputDir = temp.newFolder("qtTest");

    File cfgFile = FileUtils.toFile(this.getClass().getResource("/tools/test_rampart_1.cfg"));

    Mecq.Args mecqArgs = new Mecq.Args();
    mecqArgs.setMecqDir(outputDir);//from   w ww  .j a v a2 s. c o m

    Mecq mecq = new Mecq(this.conanExecutorService, mecqArgs);

    when(conanExecutorService.getConanProcessService().execute(sickle, ec))
            .thenReturn(new DefaultExecutionResult("test", 0, null, null, -1));

    ReflectionTestUtils.setField(mecq, "conanExecutorService", conanExecutorService);

    ExecutionResult result = mecq.execute(ec);

    assertTrue(result.getExitCode() == 0);
}

From source file:wtf.cowbay.libraven.bencode.BCoderChecker.java

@Test
public void checkLoadFromFStream() throws IOException {
    File input = FileUtils.toFile(getClass().getResource("/test.torrent"));
    FileInputStream in = new FileInputStream(input);
    Map map = (Map) new BDecoder(in).decode();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    in = new FileInputStream(input);

    int r = -1;//ww w. j  a v  a2  s . co  m

    while ((r = in.read()) != -1) {
        out.write(r);
    }

    BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream("/tmp/a.torrent"));
    bout.write(BEncoder.encode(map).value());
    bout.flush();

    byte[] val = ((ByteString) ((Map) map.get("info")).get("pieces")).value();

    Assert.assertArrayEquals(BEncoder.encode(map).value(), out.toByteArray());
}