|
|
@ -1,17 +1,27 @@ |
|
|
|
import org.junit.jupiter.api.AfterAll; |
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
class StorageTest { |
|
|
|
|
|
|
|
static Storage storage; |
|
|
|
static String testFilePath = "/tmp/test.txt"; |
|
|
|
|
|
|
|
@BeforeAll |
|
|
|
static void init() { |
|
|
|
storage = new Storage(); |
|
|
|
} |
|
|
|
|
|
|
|
@AfterAll |
|
|
|
static void clear() { |
|
|
|
File myObj = new File(testFilePath); |
|
|
|
myObj.delete(); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void constructor() { |
|
|
|
assertInstanceOf(Storage.class, storage); |
|
|
@ -27,6 +37,10 @@ class StorageTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
void writeFile() { |
|
|
|
assertTrue(storage.writeFile("/tmp/test.txt", "test")); |
|
|
|
String content = "test"; |
|
|
|
assertTrue(storage.writeFile(testFilePath, content)); |
|
|
|
|
|
|
|
File f = new File(testFilePath); |
|
|
|
assertTrue(f.isFile()); |
|
|
|
} |
|
|
|
} |