示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses()
        public virtual void ShouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses()
        {
            // GIVEN
            KernelContext context = mock(typeof(KernelContext));
            KernelExtensionFailureStrategy handler = mock(typeof(KernelExtensionFailureStrategy));
            Dependencies dependencies = new Dependencies();               // that hasn't got anything.
            UninitializableKernelExtensionFactory extensionFactory = new UninitializableKernelExtensionFactory();
            GlobalKernelExtensions extensions = new GlobalKernelExtensions(context, iterable(extensionFactory), dependencies, handler);

            // WHEN
            LifeSupport life = new LifeSupport();

            life.Add(extensions);
            try
            {
                life.Start();

                // THEN
                verify(handler).handle(eq(extensionFactory), any(typeof(System.ArgumentException)));
            }
            finally
            {
                life.Shutdown();
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldResolveMasterClientFactory()
        public virtual void ShouldResolveMasterClientFactory()
        {
            // Given
            LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            MasterClientResolver resolver = new MasterClientResolver(NullLogProvider.Instance, Org.Neo4j.com.storecopy.ResponseUnpacker_Fields.NoOpResponseUnpacker, mock(typeof(InvalidEpochExceptionHandler)), 1, 1, 1, 1024, Suppliers.singleton(logEntryReader));

            LifeSupport life = new LifeSupport();

            try
            {
                life.Start();
                MasterClient masterClient1 = resolver.Instantiate("cluster://localhost", 44, null, new Monitors(), StoreId.DEFAULT, life);
                assertThat(masterClient1, instanceOf(typeof(MasterClient320)));
            }
            finally
            {
                life.Shutdown();
            }

            IllegalProtocolVersionException illegalProtocolVersionException = new IllegalProtocolVersionException(MasterClient214.PROTOCOL_VERSION.ApplicationProtocol, MasterClient310.PROTOCOL_VERSION.ApplicationProtocol, "Protocol is too modern");

            // When
            resolver.Handle(illegalProtocolVersionException);

            // Then
            life = new LifeSupport();
            try
            {
                life.Start();
                MasterClient masterClient2 = resolver.Instantiate("cluster://localhost", 55, null, new Monitors(), StoreId.DEFAULT, life);

                assertThat(masterClient2, instanceOf(typeof(MasterClient214)));
            }
            finally
            {
                life.Shutdown();
            }
        }
示例#3
0
        private void ShouldGatherForensicsInFullBackupRequest(bool forensics)
        {
            // GIVEN
            Response <Void> response = Response.empty();
            StoreId         storeId  = response.StoreId;
            string          host     = "localhost";
            int             port     = PortAuthority.allocatePort();
            LifeSupport     life     = new LifeSupport();

            LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            NullLogProvider    logProvider        = NullLogProvider.Instance;
            ResponseUnpacker   responseUnpacker   = mock(typeof(ResponseUnpacker));
            ByteCounterMonitor byteCounterMonitor = mock(typeof(ByteCounterMonitor));
            RequestMonitor     requestMonitor     = mock(typeof(RequestMonitor));
            BackupClient       client             = new BackupClient(host, port, null, logProvider, storeId, 10_000, responseUnpacker, byteCounterMonitor, requestMonitor, reader);

            life.Add(client);
            ControlledBackupInterface backup = new ControlledBackupInterface();
            HostnamePort hostnamePort        = new HostnamePort(host, port);

            life.Add(new BackupServer(backup, hostnamePort, logProvider, byteCounterMonitor, requestMonitor));
            life.Start();

            try
            {
                // WHEN
                StoreWriter writer = mock(typeof(StoreWriter));
                client.FullBackup(writer, forensics);

                // THEN
                assertEquals(forensics, backup.ReceivedForensics);
            }
            finally
            {
                life.Shutdown();
            }
        }