Revert "BAEL-3651: [Do Not Merge] Add diagnostic logging"
This reverts commit 1f18b3a051
.
This commit is contained in:
parent
1f18b3a051
commit
fccdc24ad5
|
@ -1,21 +1,15 @@
|
||||||
package com.baeldung.file;
|
package com.baeldung.file;
|
||||||
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringJoiner;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class FileClassUnitTest {
|
public class FileClassUnitTest {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("FileClassUnitTest");
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenDir_whenMkdir_thenDirIsDeleted() {
|
public void givenDir_whenMkdir_thenDirIsDeleted() {
|
||||||
File directory = new File("dir");
|
File directory = new File("dir");
|
||||||
|
@ -143,17 +137,11 @@ public class FileClassUnitTest {
|
||||||
public void givenDataWritten_whenWrite_thenFreeSpaceReduces() {
|
public void givenDataWritten_whenWrite_thenFreeSpaceReduces() {
|
||||||
|
|
||||||
String home = System.getProperty("user.home");
|
String home = System.getProperty("user.home");
|
||||||
log.info("user.home: " + home);
|
|
||||||
String sep = File.separator;
|
String sep = File.separator;
|
||||||
File testDir = makeDir(home + sep + "test");
|
File testDir = makeDir(home + sep + "test");
|
||||||
log.info("testDir: " + testDir.toString());
|
|
||||||
File sample = new File(testDir, "sample.txt");
|
File sample = new File(testDir, "sample.txt");
|
||||||
log.info("sample: " + sample.toString());
|
|
||||||
|
|
||||||
long freeSpaceBefore = testDir.getFreeSpace();
|
long freeSpaceBefore = testDir.getFreeSpace();
|
||||||
log.info("freeSpaceBefore: " + freeSpaceBefore);
|
|
||||||
|
|
||||||
log.info("testDir list before: " + getListOfFiles(testDir));
|
|
||||||
try {
|
try {
|
||||||
writeSampleDataToFile(sample);
|
writeSampleDataToFile(sample);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -161,21 +149,11 @@ public class FileClassUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
long freeSpaceAfter = testDir.getFreeSpace();
|
long freeSpaceAfter = testDir.getFreeSpace();
|
||||||
log.info("freeSpaceAfter: " + freeSpaceAfter);
|
|
||||||
log.info("testDir list after: " + getListOfFiles(testDir));
|
|
||||||
assertTrue(freeSpaceAfter < freeSpaceBefore);
|
assertTrue(freeSpaceAfter < freeSpaceBefore);
|
||||||
|
|
||||||
removeDir(testDir);
|
removeDir(testDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getListOfFiles(File dir){
|
|
||||||
String list = "";
|
|
||||||
for(String l : dir.list()){
|
|
||||||
list += " _ " + l;
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static File makeDir(String name) {
|
private static File makeDir(String name) {
|
||||||
File directory = new File(name);
|
File directory = new File(name);
|
||||||
directory.mkdir();
|
directory.mkdir();
|
||||||
|
|
Loading…
Reference in New Issue