Skip to content

Commit

Permalink
[tools] fix TestRunMain test (apache#12675)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdhabalia authored Nov 9, 2021
1 parent 8992712 commit 24b0f4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.google.common.annotations.VisibleForTesting;

import java.io.FileInputStream;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -361,5 +362,9 @@ static int getLastExitCode() {
return lastExitCode;
}

@VisibleForTesting
static void resetLastExitCode() {
lastExitCode = Integer.MIN_VALUE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ public class TestRunMain {

@Test
public void runMainNoArguments() throws Exception {
PulsarAdminTool.resetLastExitCode();
PulsarAdminTool.setAllowSystemExit(false);
PulsarAdminTool.main(new String[0]);
assertEquals(PulsarAdminTool.getLastExitCode(), 1);
assertEquals(PulsarAdminTool.getLastExitCode(), 0);
}

@Test
public void runMainDummyConfigFile() throws Exception {
PulsarAdminTool.resetLastExitCode();
PulsarAdminTool.setAllowSystemExit(false);
Path dummyEmptyFile = Files.createTempFile("test", ".conf");
PulsarAdminTool.main(new String[] {dummyEmptyFile.toAbsolutePath().toString()});
Expand Down

0 comments on commit 24b0f4f

Please sign in to comment.