-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8867e76
commit 460f425
Showing
6 changed files
with
117 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
raft-java-core/src/test/java/com/github/wenweihu86/raft/util/RaftUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.wenweihu86.raft.util; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by wenweihu86 on 2017/7/3. | ||
*/ | ||
public class RaftUtilsTest { | ||
|
||
@Test | ||
public void testGetSortedFilesInDirectory() throws IOException { | ||
File queue0 = new File("./data/message/example-topic/0"); | ||
queue0.mkdirs(); | ||
File segmentLog00 = new File("./data/message/example-topic/0/segment0"); | ||
segmentLog00.createNewFile(); | ||
File segmentLog01 = new File("./data/message/example-topic/0/segment1"); | ||
segmentLog01.createNewFile(); | ||
|
||
File queue1 = new File("./data/message/example-topic/1"); | ||
queue1.mkdirs(); | ||
File segmentLog12 = new File("./data/message/example-topic/1/segment2"); | ||
segmentLog12.createNewFile(); | ||
File segmentLog13 = new File("./data/message/example-topic/1/segment3"); | ||
segmentLog13.createNewFile(); | ||
|
||
List<String> files = RaftFileUtils.getSortedFilesInDirectory( | ||
"./data/message", "./data/message"); | ||
System.out.println(files); | ||
Assert.assertTrue(files.size() == 4); | ||
Assert.assertTrue(files.contains("example-topic/0/segment0")); | ||
|
||
File dataDir = new File("./data"); | ||
FileUtils.deleteDirectory(dataDir); | ||
} | ||
} |