Search in sources :

Example 91 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project gridss by PapenfussLab.

the class IntervalBedTest method should_round_trip.

@Test
public void should_round_trip() throws IOException {
    IntervalBed bed = new IntervalBed(getContext().getDictionary(), getContext().getLinear());
    bed.addInterval(1, 3, 5);
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();
    File f = folder.newFile("IntervalBedTest.bed");
    f.delete();
    bed.write(f, "IntervalBedTest");
    IntervalBed bed2 = new IntervalBed(getContext().getDictionary(), getContext().getLinear(), f);
    assertFalse(bed2.overlaps(1, 2, 2));
    assertTrue(bed2.overlaps(1, 3, 3));
    assertTrue(bed2.overlaps(1, 4, 4));
    assertTrue(bed2.overlaps(1, 5, 5));
    assertFalse(bed2.overlaps(1, 6, 6));
    f.delete();
    folder.delete();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Test(org.junit.Test)

Example 92 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project contribution by checkstyle.

the class TemplateProcessorTest method setup.

@BeforeClass
public static void setup() throws IOException {
    tmpDir = new TemporaryFolder();
    tmpDir.create();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BeforeClass(org.junit.BeforeClass)

Example 93 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project flink by apache.

the class FileUtilsTest method testReadAllBytes.

// ------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------
@Test
public void testReadAllBytes() throws Exception {
    TemporaryFolder tmpFolder = null;
    try {
        tmpFolder = new TemporaryFolder(new File(this.getClass().getResource("/").getPath()));
        tmpFolder.create();
        final int fileSize = 1024;
        final String testFilePath = tmpFolder.getRoot().getAbsolutePath() + File.separator + this.getClass().getSimpleName() + "_" + fileSize + ".txt";
        {
            String expectedMD5 = generateTestFile(testFilePath, 1024);
            final byte[] data = FileUtils.readAllBytes((new File(testFilePath)).toPath());
            assertEquals(expectedMD5, md5Hex(data));
        }
        {
            String expectedMD5 = generateTestFile(testFilePath, 4096);
            final byte[] data = FileUtils.readAllBytes((new File(testFilePath)).toPath());
            assertEquals(expectedMD5, md5Hex(data));
        }
        {
            String expectedMD5 = generateTestFile(testFilePath, 5120);
            final byte[] data = FileUtils.readAllBytes((new File(testFilePath)).toPath());
            assertEquals(expectedMD5, md5Hex(data));
        }
    } finally {
        if (tmpFolder != null) {
            tmpFolder.delete();
        }
    }
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Test(org.junit.Test)

Example 94 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project alluxio by Alluxio.

the class PersistenceTest method before.

@Before
public void before() throws Exception {
    UserState s = UserState.Factory.create(ServerConfiguration.global());
    AuthenticatedClientUser.set(s.getUser().getName());
    TemporaryFolder tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    File ufsRoot = tmpFolder.newFolder();
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS);
    ServerConfiguration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, ufsRoot.getAbsolutePath());
    ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_INITIAL_INTERVAL_MS, 0);
    ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_INTERVAL_MS, 1000);
    ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_TOTAL_WAIT_TIME_MS, 1000);
    mJournalFolder = tmpFolder.newFolder();
    mSafeModeManager = new DefaultSafeModeManager();
    mStartTimeMs = System.currentTimeMillis();
    mPort = ServerConfiguration.getInt(PropertyKey.MASTER_RPC_PORT);
    startServices();
}
Also used : UserState(alluxio.security.user.UserState) TemporaryFolder(org.junit.rules.TemporaryFolder) DefaultSafeModeManager(alluxio.master.DefaultSafeModeManager) File(java.io.File) Before(org.junit.Before)

Example 95 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project alluxio by Alluxio.

the class FileSystemMasterSyncMetadataTest method before.

@Before
public void before() throws Exception {
    UserState s = UserState.Factory.create(ServerConfiguration.global());
    AuthenticatedClientUser.set(s.getUser().getName());
    TemporaryFolder tmpFolder = new TemporaryFolder();
    tmpFolder.create();
    File ufsRoot = tmpFolder.newFolder();
    ServerConfiguration.set(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS);
    ServerConfiguration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, ufsRoot.getAbsolutePath());
    ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_INITIAL_INTERVAL_MS, 0);
    ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_INTERVAL_MS, 1000);
    ServerConfiguration.set(PropertyKey.MASTER_PERSISTENCE_MAX_TOTAL_WAIT_TIME_MS, 1000);
    mJournalFolder = tmpFolder.newFolder();
    startServices();
}
Also used : UserState(alluxio.security.user.UserState) TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Before(org.junit.Before)

Aggregations

TemporaryFolder (org.junit.rules.TemporaryFolder)106 File (java.io.File)40 Before (org.junit.Before)28 Test (org.junit.Test)28 BeforeClass (org.junit.BeforeClass)13 URL (java.net.URL)7 Path (java.nio.file.Path)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)3 UserState (alluxio.security.user.UserState)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URISyntaxException (java.net.URISyntaxException)2 BdpDataPlanePlugin (org.batfish.bdp.BdpDataPlanePlugin)2 Batfish (org.batfish.main.Batfish)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultSafeModeManager (alluxio.master.DefaultSafeModeManager)1 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)1 SynchronousReferenceLookupAdapter (au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter)1