Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tools] fix TestRunMain test #12675

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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