Example usage for java.io File deleteOnExit

List of usage examples for java.io File deleteOnExit

Introduction

In this page you can find the example usage for java.io File deleteOnExit.

Prototype

public void deleteOnExit() 

Source Link

Document

Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.

Usage

From source file:com.twitter.heron.common.config.ConfigReaderTest.java

@Test
public void testLoadFile() throws IOException {
    InputStream inputStream = loadResource();
    File file = File.createTempFile("defaults_temp", "yaml");
    file.deleteOnExit();
    OutputStream outputStream = new FileOutputStream(file);
    IOUtils.copy(inputStream, outputStream);
    outputStream.close();/*from w  w w. j  av  a 2  s  .  c  o m*/
    Map<String, Object> props = ConfigReader.loadFile(file.getAbsolutePath());
    testProperty(props);
}

From source file:gov.nih.nci.caarray.plugins.agilent.EndOfLineCorrectingReaderTest.java

private File createTestFile() throws IOException {
    File file = File.createTempFile("EndOfLineCorrectingReaderTest", null);
    file.deleteOnExit();

    final FileWriter fileWriter = new FileWriter(file);
    try {/*from  w w w .  j  a  v  a 2  s  . com*/
        IOUtils.copy(new StringReader(originalData), fileWriter);
    } finally {
        fileWriter.close();
    }

    return file;
}

From source file:com.milaboratory.core.io.sequence.fasta.FastaWriterTest.java

@Test
public void test1() throws Exception {
    int count = 100;
    SingleRead[] reads = new SingleRead[count];
    File temp = File.createTempFile("temp", ".fasta");
    temp.deleteOnExit();
    FastaWriter writer = new FastaWriter(temp, 50);
    for (int i = 0; i < count; ++i) {
        reads[i] = randomRead(i);//from  w  ww  . j  a  v  a2  s  .co  m
        writer.write(reads[i]);
    }
    writer.close();
    FastaReader reader = new FastaReader(temp, false);
    for (int i = 0; i < count; ++i) {
        SingleRead actual = reader.take();
        Assert.assertEquals(reads[i].getDescription(), actual.getDescription());
        Assert.assertEquals(reads[i].getData(), actual.getData());
    }
    Assert.assertTrue(reader.take() == null);
    reader.close();
    temp.delete();
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractNoPackageNameFromProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertNull(javaProperties.getJavaPackageName());
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractPackageNameFromProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "option java_package = \"com.example.tutorial\";");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertEquals("com.example.tutorial", javaProperties.getJavaPackageName());
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractPackageNameNoWhiteSpacesFromProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "option java_package=\"com.example.tutorial\";");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertEquals("com.example.tutorial", javaProperties.getJavaPackageName());
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractPackageNameExtraWhiteSpacesFromProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "option  java_package  =  \"com.example.tutorial\"  ;");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertEquals("com.example.tutorial", javaProperties.getJavaPackageName());
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractPackageNameFromDefaultInProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "package tutorial;");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertEquals("tutorial", javaProperties.getJavaPackageName());
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractDefaultClassNameFromProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertEquals(ProtoCobolUtils.getDefaultJavaClassName(protoFile), javaProperties.getJavaClassName());
}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java

public void testExtractClassNameFromProtoFile() throws Exception {
    File protoFile = File.createTempFile(getName(), ".proto");
    protoFile.deleteOnExit();
    FileUtils.writeStringToFile(protoFile, "option java_outer_classname = \"AddressBookProtos\";");
    ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile);
    assertEquals("AddressBookProtos.java", javaProperties.getJavaClassName());
}