コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRestartServicesIfCopyStoreFails() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRestartServicesIfCopyStoreFails()
        {
            when(_updatePuller.tryPullUpdates()).thenReturn(true);

            PageCache pageCacheMock = MockPageCache();

            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));

            doThrow(new Exception()).doNothing().when(storeCopyClient).copyStore(any(typeof(StoreCopyClient.StoreCopyRequester)), any(typeof(CancellationRequest)), any(typeof(MoveAfterCopy)));

            SwitchToSlaveBranchThenCopy switchToSlave = NewSwitchToSlaveSpy(pageCacheMock, storeCopyClient);

            URI localhost = LocalhostUri;

            try
            {
                switchToSlave.SwitchToSlaveConflict(mock(typeof(LifeSupport)), localhost, localhost, mock(typeof(CancellationRequest)));
                fail("Should have thrown an Exception");
            }
            catch (Exception)
            {
                verify(_requestContextFactory, never()).start();
                // Store should have been deleted due to failure in copy
                verify(switchToSlave).cleanStoreDir();

                // Try again, should succeed
                switchToSlave.SwitchToSlaveConflict(mock(typeof(LifeSupport)), localhost, localhost, mock(typeof(CancellationRequest)));
                verify(_requestContextFactory).start();
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void updatesPulledAndPullingScheduledOnSwitchToSlave() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UpdatesPulledAndPullingScheduledOnSwitchToSlave()
        {
            SwitchToSlaveBranchThenCopy switchToSlave = NewSwitchToSlaveSpy();

            when(_fs.fileExists(any(typeof(File)))).thenReturn(true);
            JobScheduler jobScheduler      = mock(typeof(JobScheduler));
            LifeSupport  communicationLife = mock(typeof(LifeSupport));
            URI          localhost         = LocalhostUri;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.ha.UpdatePullerScheduler pullerScheduler = new org.neo4j.kernel.ha.UpdatePullerScheduler(jobScheduler, org.neo4j.logging.NullLogProvider.getInstance(), updatePuller, 10L);
            UpdatePullerScheduler pullerScheduler = new UpdatePullerScheduler(jobScheduler, NullLogProvider.Instance, _updatePuller, 10L);

            when(_pullerFactory.createUpdatePullerScheduler(_updatePuller)).thenReturn(pullerScheduler);
            // emulate lifecycle start call on scheduler
            doAnswer(invocationOnMock =>
            {
                pullerScheduler.Init();
                return(null);
            }).when(communicationLife).start();

            switchToSlave.SwitchToSlaveConflict(communicationLife, localhost, localhost, mock(typeof(CancellationRequest)));

            verify(_updatePuller).tryPullUpdates();
            verify(communicationLife).add(pullerScheduler);
            verify(jobScheduler).scheduleRecurring(eq(Group.PULL_UPDATES), any(typeof(ThreadStart)), eq(10L), eq(10L), eq(TimeUnit.MILLISECONDS));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNullIfWhenFailingToPullingUpdatesFromMaster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnNullIfWhenFailingToPullingUpdatesFromMaster()
        {
            // Given
            SwitchToSlaveBranchThenCopy switchToSlave = NewSwitchToSlaveSpy();

            when(_fs.fileExists(any(typeof(File)))).thenReturn(true);
            when(_updatePuller.tryPullUpdates()).thenReturn(false);

            // when
            URI localhost = LocalhostUri;
            URI uri       = switchToSlave.SwitchToSlaveConflict(mock(typeof(LifeSupport)), localhost, localhost, mock(typeof(CancellationRequest)));

            // then
            assertNull(uri);
        }