-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commons: add new functionality to FileUtils: get owner and group for …
…a given path, #46
- Loading branch information
Showing
2 changed files
with
107 additions
and
0 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
53 changes: 53 additions & 0 deletions
53
commons-lib/src/test/java/org/opencb/commons/utils/FileUtilsTest.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,53 @@ | ||
package org.opencb.commons.utils; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class FileUtilsTest { | ||
|
||
Path path = Paths.get("/tmp"); | ||
|
||
@Test | ||
public void getUser() throws IOException { | ||
String user = FileUtils.getUser(path); | ||
Assert.assertEquals("root", user); | ||
} | ||
|
||
@Test | ||
public void getUserNumeric() throws IOException { | ||
String user = FileUtils.getUser(path, true); | ||
Assert.assertEquals("0", user); | ||
} | ||
|
||
@Test | ||
public void getGroup() throws IOException { | ||
String group = FileUtils.getGroup(path); | ||
Assert.assertEquals("root", group); | ||
} | ||
|
||
@Test | ||
public void getGroupNumeric() throws IOException { | ||
String group = FileUtils.getGroup(path, true); | ||
Assert.assertEquals("0", group); | ||
} | ||
|
||
@Test | ||
public void getUserAndGroup() throws IOException { | ||
String[] user = FileUtils.getUserAndGroup(path); | ||
Assert.assertEquals("root", user[0]); | ||
Assert.assertEquals("root", user[1]); | ||
} | ||
|
||
@Test | ||
public void getUserAndGroupNumeric() throws IOException { | ||
String[] user = FileUtils.getUserAndGroup(path, true); | ||
Assert.assertEquals("0", user[0]); | ||
Assert.assertEquals("0", user[1]); | ||
} | ||
} |