//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldExit0WhenEverythingWorks() internal virtual void ShouldExit0WhenEverythingWorks() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); (new AdminTool(new CannedLocator(new NullCommandProvider()), new NullBlockerLocator(), outsideWorld, false)).Execute(null, null, "null"); verify(outsideWorld).exit(STATUS_SUCCESS); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAcceptOnlyUsernameOrPasswordFromEnvVar() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAcceptOnlyUsernameOrPasswordFromEnvVar() { // given Copier targetCommunicator = MockedTargetCommunicator(); string username = "******"; char[] password = new char[] { 'a', 'b', 'c' }; OutsideWorld outsideWorld = (new ControlledOutsideWorld(new DefaultFileSystemAbstraction())).withPromptResponse(username).withPasswordResponse(password); PushToCloudCommand command = command().copier(targetCommunicator).OutsideWorld(outsideWorld).build(); // when try { EnvironmentVariables.set("NEO4J_USERNAME", "neo4j"); EnvironmentVariables.set("NEO4J_PASSWORD", null); command.Execute(array(Arg(ARG_DUMP, CreateSimpleDatabaseDump().ToString()), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI))); fail("Should have failed"); } catch (IncorrectUsage) { // then good } try { EnvironmentVariables.set("NEO4J_USERNAME", null); EnvironmentVariables.set("NEO4J_PASSWORD", "pass"); command.Execute(array(Arg(ARG_DUMP, CreateSimpleDatabaseDump().ToString()), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI))); fail("Should have failed"); } catch (IncorrectUsage) { // then good } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldAddTheHelpCommandToThoseProvidedByTheLocator() internal virtual void ShouldAddTheHelpCommandToThoseProvidedByTheLocator() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); (new AdminTool(new NullCommandLocator(), new NullBlockerLocator(), outsideWorld, false)).Execute(null, null, "help"); verify(outsideWorld).stdOutLine(" help"); }
internal BackupStrategyCoordinator(ConsistencyCheckService consistencyCheckService, OutsideWorld outsideWorld, LogProvider logProvider, ProgressMonitorFactory progressMonitorFactory, IList <BackupStrategyWrapper> strategies) { this._consistencyCheckService = consistencyCheckService; this._outsideWorld = outsideWorld; this._logProvider = logProvider; this._progressMonitorFactory = progressMonitorFactory; this._strategies = strategies; }
internal DiagnosticsReportCommand(Path homeDir, Path configDir, OutsideWorld outsideWorld) { this._homeDir = homeDir; this._configDir = configDir; this._fs = outsideWorld.FileSystem(); this.@out = outsideWorld.OutStream(); _err = outsideWorld.ErrorStream(); }
public AdminTool(CommandLocator commandLocator, BlockerLocator blockerLocator, OutsideWorld outsideWorld, bool debug) { this._commandLocator = CommandLocator.withAdditionalCommand(Help(), commandLocator); this._blockerLocator = blockerLocator; this._outsideWorld = outsideWorld; this._debug = debug; this._usage = new Usage(SCRIPT_NAME, this._commandLocator); }
internal BackupStrategyCoordinatorFactory(BackupModule backupModule) { this._logProvider = backupModule.LogProvider; this._outsideWorld = backupModule.OutsideWorld; this._consistencyCheckService = new ConsistencyCheckService(); this._addressResolver = new AddressResolver(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldProvideFeedbackWhenNoCommandIsProvided() internal virtual void ShouldProvideFeedbackWhenNoCommandIsProvided() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); (new AdminTool(new NullCommandLocator(), new NullBlockerLocator(), outsideWorld, false)).Execute(null, null); verify(outsideWorld).stdErrLine("you must provide a command"); verify(outsideWorld).stdErrLine("usage: neo4j-admin <command>"); verify(outsideWorld).exit(STATUS_ERROR); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { File graphDir = new File(GraphDatabaseSettings.DEFAULT_DATABASE_NAME); _confDir = new File(graphDir, "conf"); _homeDir = new File(graphDir, "home"); @out = mock(typeof(OutsideWorld)); ResetOutsideWorldMock(); _tool = new AdminTool(CommandLocator.fromServiceLocator(), BlockerLocator.fromServiceLocator(), @out, true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { _fileSystem = _fileSystemRule.get(); OutsideWorld mock = mock(typeof(OutsideWorld)); when(mock.FileSystem()).thenReturn(_fileSystem); _setPasswordCommand = new SetInitialPasswordCommand(_testDir.directory("home").toPath(), _testDir.directory("conf").toPath(), mock); _authInitFile = CommunitySecurityModule.getInitialUserRepositoryFile(_setPasswordCommand.loadNeo4jConfig()); CommunitySecurityModule.getUserRepositoryFile(_setPasswordCommand.loadNeo4jConfig()); }
protected internal BackupSupportingClassesFactory(BackupModule backupModule) { this.LogProvider = backupModule.LogProvider; this.Clock = backupModule.Clock; this.Monitors = backupModule.Monitors; this.FileSystemAbstraction = backupModule.FileSystemAbstraction; this.TransactionLogCatchUpFactory = backupModule.TransactionLogCatchUpFactory; this._jobScheduler = backupModule.JobScheduler(); this.LogDestination = backupModule.OutsideWorld.outStream(); this.OutsideWorld = backupModule.OutsideWorld; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void versionArgumentPrintsVersionEvenWithCommand() internal virtual void VersionArgumentPrintsVersionEvenWithCommand() { AdminCommand command = mock(typeof(AdminCommand)); OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); (new AdminTool(CannedCommand("command", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "command", "--version"); verifyNoMoreInteractions(command); verify(outsideWorld).stdOutLine("neo4j-admin " + neo4jVersion()); verify(outsideWorld).exit(STATUS_SUCCESS); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldProvideFeedbackIfTheCommandFails() internal virtual void ShouldProvideFeedbackIfTheCommandFails() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); AdminCommand command = args => { throw new CommandFailed("the-failure-message"); }; (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception"); verify(outsideWorld).stdErrLine("command failed: the-failure-message"); verify(outsideWorld).exit(STATUS_ERROR); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldPrintTheStacktraceWhenTheCommandThrowsARuntimeExceptionIfTheDebugFlagIsSet() internal virtual void ShouldPrintTheStacktraceWhenTheCommandThrowsARuntimeExceptionIfTheDebugFlagIsSet() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); Exception exception = new Exception(""); AdminCommand command = args => { throw exception; }; (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, true)).execute(null, null, "exception"); verify(outsideWorld).printStacktrace(exception); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldProvideFeedbackIfTheCommandThrowsARuntimeException() internal virtual void ShouldProvideFeedbackIfTheCommandThrowsARuntimeException() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); AdminCommand command = args => { throw new Exception("the-exception-message"); }; (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception"); verify(outsideWorld).stdErrLine("unexpected error: the-exception-message"); verify(outsideWorld).exit(STATUS_ERROR); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldNotPrintTheStacktraceWhenTheCommandFailsIfTheDebugFlagIsNotSet() internal virtual void ShouldNotPrintTheStacktraceWhenTheCommandFailsIfTheDebugFlagIsNotSet() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); CommandFailed exception = new CommandFailed(""); AdminCommand command = args => { throw exception; }; (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception"); verify(outsideWorld, never()).printStacktrace(exception); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void helpArgumentPrintsHelpForCommand() internal virtual void HelpArgumentPrintsHelpForCommand() { AdminCommand command = mock(typeof(AdminCommand)); OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); (new AdminTool(CannedCommand("command", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "command", "--help"); verifyNoMoreInteractions(command); verify(outsideWorld).stdErrLine("unknown argument: --help"); verify(outsideWorld).stdErrLine("usage: neo4j-admin command "); verify(outsideWorld).exit(STATUS_ERROR); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() throws java.io.IOException, org.neo4j.kernel.api.exceptions.InvalidArgumentsException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void Setup() { OutsideWorld mock = mock(typeof(OutsideWorld)); when(mock.FileSystem()).thenReturn(_fileSystem); _setDefaultAdmin = new SetDefaultAdminCommand(TestDir.directory("home").toPath(), TestDir.directory("conf").toPath(), mock); _config = _setDefaultAdmin.loadNeo4jConfig(); UserRepository users = CommunitySecurityModule.getUserRepository(_config, NullLogProvider.Instance, _fileSystem); users.create(new User.Builder("jake", LegacyCredential.forPassword("123")) .withRequiredPasswordChange(false).build()); _adminIniFile = new File(CommunitySecurityModule.getUserRepositoryFile(_config).ParentFile, "admin.ini"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldProvideFeedbackIfTheCommandReportsAUsageProblem() internal virtual void ShouldProvideFeedbackIfTheCommandReportsAUsageProblem() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); AdminCommand command = args => { throw new IncorrectUsage("the-usage-message"); }; (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception"); InOrder inOrder = inOrder(outsideWorld); inOrder.verify(outsideWorld).stdErrLine("the-usage-message"); verify(outsideWorld).exit(STATUS_ERROR); }
private static OnlineBackupCommand NewOnlineBackupCommand(OutsideWorld outsideWorld, OnlineBackupContext onlineBackupContext, BackupSupportingClassesFactory backupSupportingClassesFactory, BackupStrategyCoordinatorFactory backupStrategyCoordinatorFactory) { OnlineBackupContextFactory contextBuilder = mock(typeof(OnlineBackupContextFactory)); try { when(contextBuilder.CreateContext(any())).thenReturn(onlineBackupContext); } catch (Exception e) when(e is IncorrectUsage || e is CommandFailed) { throw new Exception("Shouldn't happen", e); } return(new OnlineBackupCommand(outsideWorld, contextBuilder, backupSupportingClassesFactory, backupStrategyCoordinatorFactory)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void listShouldDisplayAllClassifiers() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ListShouldDisplayAllClassifiers() { using (MemoryStream baos = new MemoryStream()) { PrintStream ps = new PrintStream(baos); string[] args = new string[] { "--list" }; OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); when(outsideWorld.FileSystem()).thenReturn(_fs); when(outsideWorld.OutStream()).thenReturn(ps); DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand(_homeDir, _configDir, outsideWorld); diagnosticsReportCommand.Execute(args); assertThat(baos.ToString(), @is(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"))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReadUsernameAndPasswordFromUserInput() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReadUsernameAndPasswordFromUserInput() { // given Copier targetCommunicator = MockedTargetCommunicator(); string username = "******"; char[] password = new char[] { 'a', 'b', 'c' }; OutsideWorld outsideWorld = (new ControlledOutsideWorld(new DefaultFileSystemAbstraction())).withPromptResponse(username).withPasswordResponse(password); PushToCloudCommand command = command().copier(targetCommunicator).OutsideWorld(outsideWorld).build(); // when command.Execute(array(Arg(ARG_DUMP, CreateSimpleDatabaseDump().ToString()), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI))); // then verify(targetCommunicator).authenticate(anyBoolean(), any(), eq(username), eq(password), anyBoolean()); verify(targetCommunicator).copy(anyBoolean(), any(), any(), any()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldBlockDumpIfABlockerSaysSo() internal virtual void ShouldBlockDumpIfABlockerSaysSo() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); AdminCommand command = mock(typeof(AdminCommand)); AdminCommand_Blocker blocker = mock(typeof(AdminCommand_Blocker)); when(blocker.DoesBlock(any(), any())).thenReturn(true); when(blocker.Commands()).thenReturn(Collections.singleton("command")); when(blocker.Explanation()).thenReturn("the explanation"); BlockerLocator blockerLocator = mock(typeof(BlockerLocator)); when(blockerLocator.FindBlockers("command")).thenReturn(Collections.singletonList(blocker)); (new AdminTool(CannedCommand("command", command), blockerLocator, outsideWorld, false)).execute(null, null, "command"); verify(outsideWorld).stdErrLine("command failed: the explanation"); verify(outsideWorld).exit(STATUS_ERROR); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldBlockDumpIfOneBlockerOutOfManySaysSo() internal virtual void ShouldBlockDumpIfOneBlockerOutOfManySaysSo() { OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); AdminCommand command = mock(typeof(AdminCommand)); AdminCommand_Blocker trueBlocker = mock(typeof(AdminCommand_Blocker)); when(trueBlocker.DoesBlock(any(), any())).thenReturn(true); when(trueBlocker.Explanation()).thenReturn("trueBlocker explanation"); AdminCommand_Blocker falseBlocker = mock(typeof(AdminCommand_Blocker)); when(falseBlocker.DoesBlock(any(), any())).thenReturn(false); when(falseBlocker.Explanation()).thenReturn("falseBlocker explanation"); BlockerLocator blockerLocator = mock(typeof(BlockerLocator)); when(blockerLocator.FindBlockers("command")).thenReturn(Arrays.asList(falseBlocker, trueBlocker, falseBlocker)); (new AdminTool(CannedCommand("command", command), blockerLocator, outsideWorld, false)).execute(null, null, "command"); verify(outsideWorld).stdErrLine("command failed: trueBlocker explanation"); verify(outsideWorld).exit(STATUS_ERROR); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: CsvImporter(org.neo4j.helpers.Args args, org.neo4j.kernel.configuration.Config databaseConfig, org.neo4j.commandline.admin.OutsideWorld outsideWorld) throws org.neo4j.commandline.admin.IncorrectUsage internal CsvImporter(Args args, Config databaseConfig, OutsideWorld outsideWorld) { this._args = args; this._outsideWorld = outsideWorld; _nodesFiles = extractInputFiles(args, "nodes", outsideWorld.ErrorStream()); _relationshipsFiles = extractInputFiles(args, "relationships", outsideWorld.ErrorStream()); _reportFileName = args.InterpretOption("report-file", withDefault(ImportCommand.DEFAULT_REPORT_FILE_NAME), s => s); _ignoreExtraColumns = args.GetBoolean("ignore-extra-columns", false).Value; _ignoreDuplicateNodes = args.GetBoolean("ignore-duplicate-nodes", false).Value; _ignoreBadRelationships = args.GetBoolean("ignore-missing-nodes", false).Value; try { validateInputFiles(_nodesFiles, _relationshipsFiles); } catch (System.ArgumentException e) { throw new IncorrectUsage(e.Message); } _idType = args.InterpretOption("id-type", withDefault(IdType.STRING), from => IdType.valueOf(from.ToUpper())); _inputEncoding = Charset.forName(args.Get("input-encoding", defaultCharset().name())); _highIO = args.GetBoolean("high-io", null, true); // intentionally left as null if not specified this._databaseConfig = databaseConfig; }
internal MemoryRecommendationsCommand(Path homeDir, Path configDir, OutsideWorld outsideWorld) { this._homeDir = homeDir; this._outsideWorld = outsideWorld; this._configDir = configDir; }
internal SetDefaultAdminCommand(Path homeDir, Path configDir, OutsideWorld outsideWorld) { this._homeDir = homeDir; this._configDir = configDir; this._outsideWorld = outsideWorld; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @Nonnull public AdminCommand create(java.nio.file.Path homeDir, java.nio.file.Path configDir, OutsideWorld outsideWorld) public override AdminCommand Create(Path homeDir, Path configDir, OutsideWorld outsideWorld) { return(new HelpCommand(_usage, outsideWorld.stdOutLine, CommandLocator.fromServiceLocator())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @Nonnull public org.neo4j.commandline.admin.AdminCommand create(java.nio.file.Path homeDir, java.nio.file.Path configDir, org.neo4j.commandline.admin.OutsideWorld outsideWorld) public override AdminCommand Create(Path homeDir, Path configDir, OutsideWorld outsideWorld) { return(new SetInitialPasswordCommand(homeDir, configDir, outsideWorld)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @Nonnull public org.neo4j.commandline.admin.AdminCommand create(java.nio.file.Path homeDir, java.nio.file.Path configDir, org.neo4j.commandline.admin.OutsideWorld outsideWorld) public override AdminCommand Create(Path homeDir, Path configDir, OutsideWorld outsideWorld) { return(new SetDefaultAdminCommand(homeDir, configDir, outsideWorld)); }