|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
package org.apache.zookeeper.test;
|
|
|
|
|
|
+import static java.nio.charset.StandardCharsets.UTF_8;
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
@@ -27,6 +28,7 @@ import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.OutputStream;
|
|
|
+import java.nio.file.Files;
|
|
|
import org.apache.zookeeper.ZKTestCase;
|
|
|
import org.apache.zookeeper.common.AtomicFileOutputStream;
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
@@ -64,7 +66,7 @@ public class AtomicFileOutputStreamTest extends ZKTestCase {
|
|
|
fos.close();
|
|
|
assertTrue(dstFile.exists());
|
|
|
|
|
|
- String readBackData = ClientBase.readFile(dstFile);
|
|
|
+ String readBackData = new String(Files.readAllBytes(dstFile.toPath()), UTF_8);
|
|
|
assertEquals(TEST_STRING, readBackData);
|
|
|
}
|
|
|
|
|
@@ -82,12 +84,12 @@ public class AtomicFileOutputStreamTest extends ZKTestCase {
|
|
|
fos.flush();
|
|
|
|
|
|
// Original contents still in place
|
|
|
- assertEquals("", ClientBase.readFile(dstFile));
|
|
|
+ assertEquals("", new String(Files.readAllBytes(dstFile.toPath()), UTF_8));
|
|
|
|
|
|
fos.close();
|
|
|
|
|
|
// New contents replace original file
|
|
|
- String readBackData = ClientBase.readFile(dstFile);
|
|
|
+ String readBackData = new String(Files.readAllBytes(dstFile.toPath()), UTF_8);
|
|
|
assertEquals(TEST_STRING, readBackData);
|
|
|
}
|
|
|
|
|
@@ -112,9 +114,9 @@ public class AtomicFileOutputStreamTest extends ZKTestCase {
|
|
|
}
|
|
|
|
|
|
// Should not have touched original file
|
|
|
- assertEquals(TEST_STRING_2, ClientBase.readFile(dstFile));
|
|
|
+ assertEquals(TEST_STRING_2, new String(Files.readAllBytes(dstFile.toPath()), UTF_8));
|
|
|
|
|
|
- assertEquals(dstFile.getName(), ClientBase.join(",", testDir.list()), "Temporary file should have been cleaned up");
|
|
|
+ assertEquals(dstFile.getName(), String.join(",", testDir.list()), "Temporary file should have been cleaned up");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -172,7 +174,7 @@ public class AtomicFileOutputStreamTest extends ZKTestCase {
|
|
|
fos2.abort();
|
|
|
|
|
|
// Should not have touched original file
|
|
|
- assertEquals(TEST_STRING, ClientBase.readFile(dstFile));
|
|
|
+ assertEquals(TEST_STRING, new String(Files.readAllBytes(dstFile.toPath()), UTF_8));
|
|
|
assertEquals(1, testDir.list().length);
|
|
|
}
|
|
|
|
|
@@ -193,7 +195,7 @@ public class AtomicFileOutputStreamTest extends ZKTestCase {
|
|
|
fos2.abort();
|
|
|
|
|
|
// Should not have touched original file
|
|
|
- assertEquals(TEST_STRING, ClientBase.readFile(dstFile));
|
|
|
+ assertEquals(TEST_STRING, new String(Files.readAllBytes(dstFile.toPath()), UTF_8));
|
|
|
assertEquals(1, testDir.list().length);
|
|
|
}
|
|
|
|