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());
}
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());
}
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);
}
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;
}
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");
}
Aggregations