Skip to content

Commit

Permalink
Merge pull request #181 from Flowdalic/runtime-exec
Browse files Browse the repository at this point in the history
GroupTest: do not use deprecated Runtime.exec(String)
  • Loading branch information
enebo committed Aug 23, 2023
2 parents b59e8c3 + 7229547 commit bdffe77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/test/java/jnr/posix/GroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void getgrent() {
@Test
public void getgroups() throws Throwable {
if (jnr.ffi.Platform.getNativePlatform().isUnix()) {
String[] groupIdsAsStrings = exec("id -G").split(" ");
String[] groupIdsAsStrings = exec("id", "-G").split(" ");
long[] expectedGroupIds = new long[groupIdsAsStrings.length];

for (int i = 0; i < groupIdsAsStrings.length; i++) {
Expand All @@ -103,7 +103,7 @@ public void getgroups() throws Throwable {
// If the actual list is shorter than the expected list by 1, alter the expected list by removing the
// effective group ID before comparing the two arrays.
if (actualGroupIds.length == expectedGroupIds.length - 1) {
long effectiveGroupId = Long.parseLong(exec("id -g"));
long effectiveGroupId = Long.parseLong(exec("id", "-g"));
expectedGroupIds = removeElement(expectedGroupIds, effectiveGroupId);
}

Expand All @@ -114,7 +114,7 @@ public void getgroups() throws Throwable {
}
}

private String exec(String command) throws IOException {
private String exec(String... command) throws IOException {
InputStreamReader isr = null;
BufferedReader reader = null;

Expand Down

0 comments on commit bdffe77

Please sign in to comment.