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