//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)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @SuppressWarnings("unchecked") public void shouldHandleBranchedStoreWhenMyStoreIdDiffersFromMasterStoreId() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleBranchedStoreWhenMyStoreIdDiffersFromMasterStoreId() { // Given SwitchToSlaveBranchThenCopy switchToSlave = NewSwitchToSlaveSpy(); URI me = new URI("cluster://localhost?serverId=2"); MasterClient masterClient = mock(typeof(MasterClient)); Response <HandshakeResult> response = mock(typeof(Response)); when(response.ResponseConflict()).thenReturn(new HandshakeResult(1, 2)); when(masterClient.Handshake(anyLong(), any(typeof(StoreId)))).thenReturn(response); StoreId storeId = newStoreIdForCurrentVersion(1, 2, 3, 4); TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(42, 42, 42)); when(transactionIdStore.LastCommittedTransactionId).thenReturn(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID); // When try { switchToSlave.CheckDataConsistency(masterClient, transactionIdStore, storeId, new URI("cluster://localhost?serverId=1"), me, Org.Neo4j.Helpers.CancellationRequest_Fields.NeverCancelled); fail("Should have thrown " + typeof(MismatchingStoreIdException).Name + " exception"); } catch (MismatchingStoreIdException) { // good we got the expected exception } // Then verify(switchToSlave).stopServicesAndHandleBranchedStore(any(typeof(BranchedDataPolicy))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleBranchedStoreWhenHandshakeFailsWithBranchedDataException() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleBranchedStoreWhenHandshakeFailsWithBranchedDataException() { // Given SwitchToSlaveBranchThenCopy switchToSlave = NewSwitchToSlaveSpy(); URI masterUri = new URI("cluster://localhost?serverId=1"); URI me = new URI("cluster://localhost?serverId=2"); MasterClient masterClient = mock(typeof(MasterClient)); when(masterClient.Handshake(anyLong(), any(typeof(StoreId)))).thenThrow(new BranchedDataException("")); TransactionIdStore transactionIdStore = mock(typeof(TransactionIdStore)); when(transactionIdStore.LastCommittedTransaction).thenReturn(new TransactionId(42, 42, 42)); when(transactionIdStore.LastCommittedTransactionId).thenReturn(Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID); // When try { switchToSlave.CheckDataConsistency(masterClient, transactionIdStore, _storeId, masterUri, me, Org.Neo4j.Helpers.CancellationRequest_Fields.NeverCancelled); fail("Should have thrown " + typeof(BranchedDataException).Name + " exception"); } catch (BranchedDataException) { // good we got the expected exception } // Then verify(switchToSlave).stopServicesAndHandleBranchedStore(any(typeof(BranchedDataPolicy))); }
//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(); } }
//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); }