Exemplo n.º 1
0
//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
            }
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecognizeDatabaseIdFromBoltURI() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRecognizeDatabaseIdFromBoltURI()
        {
            // given
            Copier             copier  = mock(typeof(Copier));
            PushToCloudCommand command = command().copier(copier).Build();

            // when
            command.Execute(array(Arg(ARG_DUMP, CreateSimpleDatabaseDump().ToString()), Arg(ARG_BOLT_URI, "bolt+routing://mydbid.databases.neo4j.io")));

            // then
            verify(copier).copy(anyBoolean(), eq("https://console.neo4j.io/v1/databases/mydbid"), any(), any());
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAcceptDumpAsSource() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAcceptDumpAsSource()
        {
            // given
            Copier             targetCommunicator = MockedTargetCommunicator();
            PushToCloudCommand command            = command().copier(targetCommunicator).Build();

            // when
            Path dump = CreateSimpleDatabaseDump();

            command.Execute(array(Arg(ARG_DUMP, dump.ToString()), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));

            // then
            verify(targetCommunicator).copy(anyBoolean(), any(), eq(dump), any());
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldChooseToDumpDefaultDatabaseIfNeitherDumpNorDatabaseIsGiven() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldChooseToDumpDefaultDatabaseIfNeitherDumpNorDatabaseIsGiven()
        {
            // given
            DumpCreator        dumpCreator = mock(typeof(DumpCreator));
            Copier             copier      = mock(typeof(Copier));
            PushToCloudCommand command     = command().dumpCreator(dumpCreator).Copier(copier).build();

            // when
            command.Execute(array(Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));

            // then
            string defaultDatabase = (new Database()).defaultValue();

            verify(dumpCreator).dumpDatabase(eq(defaultDatabase), any());
            verify(copier).copy(anyBoolean(), any(), any(), any());
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAcceptBothDumpAndDatabaseNameAsSource() 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 ShouldNotAcceptBothDumpAndDatabaseNameAsSource()
        {
            // given
            PushToCloudCommand command = command().copier(MockedTargetCommunicator()).Build();

            // when
            try
            {
                command.Execute(array(Arg(ARG_DUMP, Directory.file("some-dump-file").toPath().ToString()), Arg(ARG_DATABASE, "neo4j"), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));
                fail("Should have failed");
            }
            catch (IncorrectUsage)
            {
                // then good
            }
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAcceptDatabaseNameAsSource() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAcceptDatabaseNameAsSource()
        {
            // given
            Copier             targetCommunicator = MockedTargetCommunicator();
            DumpCreator        dumpCreator        = mock(typeof(DumpCreator));
            PushToCloudCommand command            = command().copier(targetCommunicator).DumpCreator(dumpCreator).build();

            // when
            string databaseName = "neo4j";

            command.Execute(array(Arg(ARG_DATABASE, databaseName), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));

            // then
            verify(dumpCreator).dumpDatabase(eq(databaseName), any());
            verify(targetCommunicator).copy(anyBoolean(), any(), any(), any());
        }
Exemplo n.º 7
0
//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());
        }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAuthenticateBeforeDumping() throws org.neo4j.commandline.admin.CommandFailed, java.io.IOException, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAuthenticateBeforeDumping()
        {
            // given
            Copier             copier  = MockedTargetCommunicator();
            DumpCreator        dumper  = mock(typeof(DumpCreator));
            PushToCloudCommand command = command().copier(copier).DumpCreator(dumper).build();

            // when
            command.Execute(array(Arg(ARG_BOLT_URI, "bolt+routing://mydbid.databases.neo4j.io")));

            // then
            InOrder inOrder = inOrder(copier, dumper);

            inOrder.verify(copier).authenticate(anyBoolean(), anyString(), anyString(), any(), anyBoolean());
            inOrder.verify(dumper).dumpDatabase(anyString(), any());
            inOrder.verify(copier).copy(anyBoolean(), anyString(), any(), anyString());
        }
Exemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailOnDumpPointingToMissingFile() throws java.io.IOException, org.neo4j.commandline.admin.IncorrectUsage, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailOnDumpPointingToMissingFile()
        {
            // given
            PushToCloudCommand command = command().copier(MockedTargetCommunicator()).Build();

            // when
            try
            {
                File dumpFile = Directory.file("some-dump-file");
                command.Execute(array(Arg(ARG_DUMP, dumpFile.AbsolutePath), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));
                fail("Should have failed");
            }
            catch (CommandFailed)
            {
                // then good
            }
        }
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAcceptDatabaseNameAsSourceUsingGivenDumpTarget() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAcceptDatabaseNameAsSourceUsingGivenDumpTarget()
        {
            // given
            Copier             targetCommunicator = MockedTargetCommunicator();
            DumpCreator        dumpCreator        = mock(typeof(DumpCreator));
            PushToCloudCommand command            = command().copier(targetCommunicator).DumpCreator(dumpCreator).build();

            // when
            string databaseName = "neo4j";
            Path   dumpFile     = Directory.file("some-dump-file").toPath();

            command.Execute(array(Arg(ARG_DATABASE, databaseName), Arg(ARG_DUMP_TO, dumpFile.ToString()), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));

            // then
            verify(dumpCreator).dumpDatabase(databaseName, dumpFile);
            verify(targetCommunicator).copy(anyBoolean(), any(), any(), any());
        }
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailOnDatabaseNameAsSourceUsingExistingDumpTarget() throws java.io.IOException, org.neo4j.commandline.admin.IncorrectUsage, org.neo4j.commandline.admin.CommandFailed
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailOnDatabaseNameAsSourceUsingExistingDumpTarget()
        {
            // given
            Copier             targetCommunicator = MockedTargetCommunicator();
            DumpCreator        dumpCreator        = mock(typeof(DumpCreator));
            PushToCloudCommand command            = command().copier(targetCommunicator).DumpCreator(dumpCreator).build();

            // when
            string databaseName = "neo4j";
            Path   dumpFile     = Directory.file("some-dump-file").toPath();

            Files.write(dumpFile, "some data".GetBytes());
            try
            {
                command.Execute(array(Arg(ARG_DATABASE, databaseName), Arg(ARG_DUMP_TO, dumpFile.ToString()), Arg(ARG_BOLT_URI, SOME_EXAMPLE_BOLT_URI)));
                fail("Should have failed");
            }
            catch (CommandFailed commandFailed)
            {
                // then
                assertThat(commandFailed.Message, containsString("already exists"));
            }
        }