use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class SetDefaultAdminCommandIT method execute.
private void execute(String username) {
final var command = new SetDefaultAdminCommand(new ExecutionContext(homeDir, confDir, out, err, fileSystem));
CommandLine.populateCommand(command, username);
command.execute();
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class DiagnosticsReportCommandTest method printUsageHelp.
@Test
void printUsageHelp() {
final var baos = new ByteArrayOutputStream();
final var command = new DiagnosticsReportCommand(new ExecutionContext(Path.of("."), Path.of(".")));
try (var out = new PrintStream(baos)) {
CommandLine.usage(command, new PrintStream(out), CommandLine.Help.Ansi.OFF);
}
assertThat(baos.toString().trim()).isEqualTo(String.format("Produces a zip/tar of the most common information needed for remote assessments.%n" + "%n" + "USAGE%n" + "%n" + "report [--expand-commands] [--force] [--list] [--verbose] [--pid=<pid>]%n" + " [--to=<path>] [<classifier>...]%n" + "%n" + "DESCRIPTION%n" + "%n" + "Will collect information about the system and package everything in an archive.%n" + "If you specify 'all', everything will be included. You can also fine tune the%n" + "selection by passing classifiers to the tool, e.g 'logs tx threads'.%n" + "%n" + "PARAMETERS%n" + "%n" + " [<classifier>...] Default: [config, logs, metrics, plugins, ps,%n" + " sysprop, threads, tree, version]%n" + "%n" + "OPTIONS%n" + "%n" + " --verbose Enable verbose output.%n" + " --expand-commands Allow command expansion in config value evaluation.%n" + " --list List all available classifiers%n" + " --force Ignore disk full warning%n" + " --to=<path> Destination directory for reports. Defaults to a%n" + " system tmp directory.%n" + " --pid=<pid> Specify process id of running neo4j instance"));
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class DiagnosticsReportCommandTest method listShouldDisplayAllClassifiers.
@Test
void listShouldDisplayAllClassifiers() throws Exception {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
PrintStream ps = new PrintStream(baos);
String[] args = { "--list" };
ctx = new ExecutionContext(homeDir, configDir, ps, System.err, fs);
DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand(ctx);
CommandLine.populateCommand(diagnosticsReportCommand, args);
diagnosticsReportCommand.execute();
assertThat(baos.toString()).isEqualTo(String.format("Finding running instance of neo4j%n" + "No running instance of neo4j was found. Online reports will be omitted.%n" + "If neo4j is running but not detected, you can supply the process id of the running instance with --pid%n" + "All available classifiers:%n" + " config include configuration file%n" + " logs include log files%n" + " plugins include a view of the plugin directory%n" + " ps include a list of running processes%n" + " tree include a view of the tree structure of the data directory%n" + " tx include transaction logs%n" + " version include version of neo4j%n"));
}
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class DiagnosticsReportCommandTest method setUp.
@BeforeEach
void setUp() throws Exception {
homeDir = testDirectory.directory("home-dir");
configDir = testDirectory.directory("config-dir");
// Touch config
configFile = configDir.resolve("neo4j.conf");
Files.createFile(configFile);
// To make sure files are resolved from the working directory
originalUserDir = System.setProperty("user.dir", testDirectory.absolutePath().toString());
ctx = new ExecutionContext(homeDir, configDir, System.out, System.err, fs);
}
use of org.neo4j.cli.ExecutionContext in project neo4j by neo4j.
the class LoadCommandTest method infoMustPrintArchiveMetaData.
@Test
void infoMustPrintArchiveMetaData() throws IOException {
when(loader.getMetaData(archive)).thenReturn(new Loader.DumpMetaData("ZSTD", "42", "1337"));
var baos = new ByteArrayOutputStream();
try (PrintStream out = new PrintStream(baos)) {
Path dir = Path.of(".");
var command = new LoadCommand(new ExecutionContext(dir, dir, out, out, testDirectory.getFileSystem()), loader);
CommandLine.populateCommand(command, "--info", "--from", archive.toAbsolutePath().toString());
command.execute();
out.flush();
}
String output = baos.toString();
assertThat(output).contains("ZSTD", "42", "1337");
}
Aggregations