Search in sources :

Example 11 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project lionengine by b3dgs.

the class UtilFileTest method testGetFilesByName.

/**
 * Test get files by name.
 *
 * @throws IOException If error.
 */
@Test
public void testGetFilesByName() throws IOException {
    Assert.assertTrue(UtilFile.getFilesByName(new File("void"), "name").isEmpty());
    final File folder = TEMP.newFolder("temp");
    final File file1 = File.createTempFile("temp", ".tmp", folder);
    final File file2 = File.createTempFile("temp", ".tmp", folder);
    final TemporaryFolder tempFolder = new TemporaryFolder(folder);
    tempFolder.create();
    final File folder2 = tempFolder.newFolder("temp");
    final File file3 = File.createTempFile("temp", ".tmp", folder2);
    Assert.assertEquals(Arrays.asList(file2), UtilFile.getFilesByName(folder, file2.getName()));
    Assert.assertTrue(file1.delete());
    Assert.assertTrue(file2.delete());
    Assert.assertTrue(file3.delete());
    Assert.assertTrue(folder2.delete());
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Test(org.junit.Test)

Example 12 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project lionengine by b3dgs.

the class UtilFileTest method testGetFilesByExtension.

/**
 * Test get files by extension.
 *
 * @throws IOException If error.
 */
@Test
public void testGetFilesByExtension() throws IOException {
    Assert.assertTrue(UtilFile.getFilesByExtension(new File("void"), "txt").isEmpty());
    final File folder = TEMP.newFolder("temp");
    final File file1 = File.createTempFile("temp", ".tmp", folder);
    final File file2 = File.createTempFile("temp", ".txt", folder);
    final TemporaryFolder tempFolder = new TemporaryFolder(folder);
    tempFolder.create();
    final File folder2 = tempFolder.newFolder("temp");
    final File file3 = File.createTempFile("temp", ".txt", folder2);
    final List<File> expected = Arrays.asList(file2, file3);
    final List<File> result = UtilFile.getFilesByExtension(folder, "txt");
    Collections.sort(expected);
    Collections.sort(result);
    Assert.assertEquals(expected, result);
    Assert.assertTrue(file1.delete());
    Assert.assertTrue(file2.delete());
    Assert.assertTrue(file3.delete());
    Assert.assertTrue(folder2.delete());
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Test(org.junit.Test)

Example 13 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project dkpro-tc by dkpro.

the class TestFoldUtil method createNoSequenceCas.

private void createNoSequenceCas() throws Exception {
    tmpFoldNoSeq = new TemporaryFolder();
    tmpFoldNoSeq.create();
    jcasNoSequence = JCasFactory.createJCas();
    jcasNoSequence.setDocumentText("Mr. Hawksley said yesterday he would be willing to go before the city .");
    setUnit(jcasNoSequence, 0, 2);
    setUnit(jcasNoSequence, 4, 12);
    setUnit(jcasNoSequence, 13, 18);
    setUnit(jcasNoSequence, 18, 28);
    setUnit(jcasNoSequence, 31, 36);
    setUnit(jcasNoSequence, 37, 39);
    setUnit(jcasNoSequence, 40, 47);
    setUnit(jcasNoSequence, 48, 50);
    setUnit(jcasNoSequence, 51, 53);
    setUnit(jcasNoSequence, 54, 60);
    setUnit(jcasNoSequence, 61, 64);
    setUnit(jcasNoSequence, 65, 69);
    setUnit(jcasNoSequence, 70, 71);
    DocumentMetaData dmd = new DocumentMetaData(jcasNoSequence);
    dmd.setDocumentId("id");
    dmd.addToIndexes();
    createJCasIdAnnotation(jcasNoSequence);
    AnalysisEngine xmiWriter = AnalysisEngineFactory.createEngine(BinaryCasWriter.class, BinaryCasWriter.PARAM_TARGET_LOCATION, tmpFoldNoSeq.getRoot(), BinaryCasWriter.PARAM_FORMAT, "6+");
    xmiWriter.process(jcasNoSequence);
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) DocumentMetaData(de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData) AnalysisEngine(org.apache.uima.analysis_engine.AnalysisEngine)

Example 14 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project latexdraw by arnobl.

the class ParameteriseShapeData method setPictureData1.

public IPicture setPictureData1(final IPicture pic) throws IOException {
    final TemporaryFolder folder = new TemporaryFolder();
    folder.create();
    tempFolders.add(folder);
    pic.setPathSource(getTestPNG(folder).toString());
    return pic;
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder)

Example 15 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project app-maven-plugin by GoogleCloudPlatform.

the class AbstractDevServerTest method setUpAppEngineWebXml.

protected void setUpAppEngineWebXml() throws IOException {
    TemporaryFolder tempFolder = new TemporaryFolder();
    tempFolder.create();
    File webInf = tempFolder.newFolder("build", "artifact", "WEB-INF");
    new File(webInf, "appengine-web.xml").createNewFile();
    when(mavenProjectMock.getBuild()).thenReturn(mock(Build.class));
    when(mavenProjectMock.getBuild().getDirectory()).thenReturn(webInf.getParentFile().getParentFile().getAbsolutePath());
    when(mavenProjectMock.getBuild().getFinalName()).thenReturn("artifact");
}
Also used : Build(org.apache.maven.model.Build) TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File)

Aggregations

TemporaryFolder (org.junit.rules.TemporaryFolder)88 File (java.io.File)33 Test (org.junit.Test)25 Before (org.junit.Before)24 BeforeClass (org.junit.BeforeClass)13 Path (java.nio.file.Path)7 URL (java.net.URL)6 IOException (java.io.IOException)3 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 DocumentMetaData (de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URISyntaxException (java.net.URISyntaxException)2 BdpDataPlanePlugin (org.batfish.bdp.BdpDataPlanePlugin)2 Batfish (org.batfish.main.Batfish)2 DefaultSafeModeManager (alluxio.master.DefaultSafeModeManager)1 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)1 SynchronousReferenceLookupAdapter (au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter)1