示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetLastPulledTransactionId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetLastPulledTransactionId()
        {
            // given
            long    lastFlushedTxId           = 12;
            StoreId wantedStoreId             = new StoreId(1, 2, 3, 4);
            AdvertisedSocketAddress localhost = new AdvertisedSocketAddress("127.0.0.1", 1234);
            CatchupAddressProvider  catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(localhost);

            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));

            when(storeCopyClient.CopyStoreFiles(eq(catchupAddressProvider), eq(wantedStoreId), any(typeof(StoreFileStreamProvider)), any(), any())).thenReturn(lastFlushedTxId);

            TxPullClient txPullClient = mock(typeof(TxPullClient));

            when(txPullClient.PullTransactions(eq(localhost), eq(wantedStoreId), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));

            TransactionLogCatchUpWriter writer = mock(typeof(TransactionLogCatchUpWriter));

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            // when
            remoteStore.Copy(catchupAddressProvider, wantedStoreId, DatabaseLayout.of(new File("destination")), true);

            // then
            long previousTxId = lastFlushedTxId - 1;               // the interface is defined as asking for the one preceding

            verify(txPullClient).pullTransactions(eq(localhost), eq(wantedStoreId), eq(previousTxId), any());
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCopyStoreFilesAndPullTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCopyStoreFilesAndPullTransactions()
        {
            // given
            StoreId         storeId         = new StoreId(1, 2, 3, 4);
            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));
            TxPullClient    txPullClient    = mock(typeof(TxPullClient));

            when(txPullClient.PullTransactions(any(), any(), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));
            TransactionLogCatchUpWriter writer = mock(typeof(TransactionLogCatchUpWriter));

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            // when
            AdvertisedSocketAddress localhost = new AdvertisedSocketAddress("127.0.0.1", 1234);
            CatchupAddressProvider  catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(localhost);

            remoteStore.Copy(catchupAddressProvider, storeId, DatabaseLayout.of(new File("destination")), true);

            // then
            verify(storeCopyClient).copyStoreFiles(eq(catchupAddressProvider), eq(storeId), any(typeof(StoreFileStreamProvider)), any(), any());
            verify(txPullClient).pullTransactions(eq(localhost), eq(storeId), anyLong(), any());
        }