예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldComplainIfServerPortIsAlreadyTaken() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldComplainIfServerPortIsAlreadyTaken()
        {
            using (ServerSocket socket = new ServerSocket(0, 0, InetAddress.LocalHost))
            {
                ListenSocketAddress   contestedAddress = new ListenSocketAddress(socket.InetAddress.HostName, socket.LocalPort);
                AssertableLogProvider logProvider      = new AssertableLogProvider();
                CommunityNeoServer    server           = CommunityServerBuilder.server(logProvider).onAddress(contestedAddress).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build();
                try
                {
                    server.Start();

                    fail("Should have reported failure to start");
                }
                catch (ServerStartupException e)
                {
                    assertThat(e.Message, containsString("Starting Neo4j failed"));
                }

                logProvider.AssertAtLeastOnce(AssertableLogProvider.inLog(containsString("CommunityNeoServer")).error("Failed to start Neo4j on %s: %s", contestedAddress, format("Address %s is already in use, cannot bind to it.", contestedAddress)));
                server.Stop();
            }
        }