use of com.seleniumtests.reporter.logger.GenericFile in project seleniumRobot by bhecquet.
the class TestGenericFile method testFileMovedOnCreation.
@Test(groups = { "ut" })
public void testFileMovedOnCreation() throws IOException {
File videoFile = File.createTempFile("video", ".avi");
videoFile.deleteOnExit();
GenericFile genericFile = new GenericFile(videoFile, "description");
Assert.assertEquals(genericFile.getFile(), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile());
}
use of com.seleniumtests.reporter.logger.GenericFile in project seleniumRobot by bhecquet.
the class TestGenericFile method testFileReplaceOnCreation.
@Test(groups = { "ut" })
public void testFileReplaceOnCreation() throws IOException {
File videoFile = File.createTempFile("video", ".avi");
videoFile.deleteOnExit();
FileUtils.write(videoFile, "bar", StandardCharsets.UTF_8);
// put a file in the destination
File dest = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile();
FileUtils.write(dest, "foo", StandardCharsets.UTF_8);
GenericFile genericFile = new GenericFile(videoFile, "description");
Assert.assertEquals(genericFile.getFile(), dest);
// check file has been replaced
Assert.assertEquals(FileUtils.readFileToString(dest, StandardCharsets.UTF_8), "bar");
}
use of com.seleniumtests.reporter.logger.GenericFile in project seleniumRobot by bhecquet.
the class TestGenericFile method testFileReplaceOnRelocate.
/**
* Check relocate can replace file on move
* @throws IOException
*/
@Test(groups = { "ut" })
public void testFileReplaceOnRelocate() throws IOException {
File videoFile = File.createTempFile("video", ".avi");
videoFile.deleteOnExit();
FileUtils.write(videoFile, "bar", StandardCharsets.UTF_8);
GenericFile genericFile = new GenericFile(videoFile, "description");
File outputDir = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), "dest").toFile();
File dest = Paths.get(outputDir.getAbsolutePath(), videoFile.getName()).toFile();
FileUtils.write(dest, "foo", StandardCharsets.UTF_8);
File previousLocation = genericFile.getFile();
Assert.assertTrue(previousLocation.exists());
genericFile.relocate(outputDir.getAbsolutePath());
Assert.assertEquals(genericFile.getFile(), dest);
Assert.assertTrue(genericFile.getFile().exists());
// check file has been replaced
Assert.assertEquals(FileUtils.readFileToString(dest, StandardCharsets.UTF_8), "bar");
}
use of com.seleniumtests.reporter.logger.GenericFile in project seleniumRobot by bhecquet.
the class TestGenericFile method testFileNoReplaceOnCreation.
/**
* Test case when file cannot be moved
* @throws IOException
*/
@Test(groups = { "ut" })
public void testFileNoReplaceOnCreation() throws IOException {
File videoFile = File.createTempFile("video", ".avi");
videoFile.deleteOnExit();
FileUtils.write(videoFile, "bar", StandardCharsets.UTF_8);
// put a file in the destination
File dest = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), videoFile.getName()).toFile();
FileUtils.write(dest, "foo", StandardCharsets.UTF_8);
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(dest), StandardCharsets.UTF_8)) {
GenericFile genericFile = new GenericFile(videoFile, "description");
// file field has been updated with the source value as file has not been copied
Assert.assertEquals(genericFile.getFile(), videoFile);
}
// check file has not been replaced
Assert.assertEquals(FileUtils.readFileToString(dest, StandardCharsets.UTF_8), "foo");
}
use of com.seleniumtests.reporter.logger.GenericFile in project seleniumRobot by bhecquet.
the class TestGenericFile method testRelocate.
@Test(groups = { "ut" })
public void testRelocate() throws IOException {
File videoFile = File.createTempFile("video", ".avi");
videoFile.deleteOnExit();
GenericFile genericFile = new GenericFile(videoFile, "description");
File outputDir = Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), "dest").toFile();
File previousLocation = genericFile.getFile();
Assert.assertTrue(previousLocation.exists());
genericFile.relocate(outputDir.getAbsolutePath());
Assert.assertEquals(genericFile.getFile(), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), "dest", videoFile.getName()).toFile());
Assert.assertTrue(genericFile.getFile().exists());
}
Aggregations