Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void failedFileCopyShouldRetry() throws StoreCopyFailedException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailedFileCopyShouldRetry()
        {
            // given a file will fail twice before succeeding
            _fileB.RemainingFailed = 2;

            // and remote node has a store
            // and local client has a store
            InMemoryStoreStreamProvider clientStoreFileStream = new InMemoryStoreStreamProvider();

            // when catchup is performed for valid transactionId and StoreId
            CatchupAddressProvider catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(From(_catchupServer.address().Port));

            _subject.copyStoreFiles(catchupAddressProvider, _serverHandler.StoreId, clientStoreFileStream, () => _defaultTerminationCondition, _targetLocation);

            // then the catchup is successful
            ISet <string> expectedFiles = new HashSet <string>(Arrays.asList(_fileA.Filename, _fileB.Filename, _indexFileA.Filename));

            assertEquals(expectedFiles, clientStoreFileStream.FileStreams().Keys);

            // and
            assertEquals(FileContent(Relative(_fileA.Filename)), ClientFileContents(clientStoreFileStream, _fileA.Filename));
            assertEquals(FileContent(Relative(_fileB.Filename)), ClientFileContents(clientStoreFileStream, _fileB.Filename));

            // and verify server had exactly 2 failed calls before having a 3rd succeeding request
            assertEquals(3, _serverHandler.getRequestCount(_fileB.Filename));

            // and verify server had exactly 1 call for all other files
            assertEquals(1, _serverHandler.getRequestCount(_fileA.Filename));
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogConnetionRefusedMessage()
        public virtual void ShouldLogConnetionRefusedMessage()
        {
            InMemoryStoreStreamProvider clientStoreFileStream = new InMemoryStoreStreamProvider();
            int port = PortAuthority.allocatePort();

            try
            {
                _subject.copyStoreFiles(new CatchupAddressProviderAnonymousInnerClass(this, port)
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                                        , _serverHandler.StoreId, clientStoreFileStream, Once::new, _targetLocation);
                fail();
            }
            catch (StoreCopyFailedException)
            {
                _assertableLogProvider.rawMessageMatcher().assertContainsSingle(Matchers.allOf(Matchers.containsString("Connection refused: localhost/127.0.0.1:" + port)));
            }
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canPerformCatchup() throws StoreCopyFailedException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CanPerformCatchup()
        {
            // given local client has a store
            InMemoryStoreStreamProvider storeFileStream = new InMemoryStoreStreamProvider();

            // when catchup is performed for valid transactionId and StoreId
            CatchupAddressProvider catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(From(_catchupServer.address().Port));

            _subject.copyStoreFiles(catchupAddressProvider, _serverHandler.StoreId, storeFileStream, () => _defaultTerminationCondition, _targetLocation);

            // then the catchup is successful
            ISet <string> expectedFiles = new HashSet <string>(Arrays.asList(_fileA.Filename, _fileB.Filename, _indexFileA.Filename));

            assertEquals(expectedFiles, storeFileStream.FileStreams().Keys);
            assertEquals(FileContent(Relative(_fileA.Filename)), ClientFileContents(storeFileStream, _fileA.Filename));
            assertEquals(FileContent(Relative(_fileB.Filename)), ClientFileContents(storeFileStream, _fileB.Filename));
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogUpstreamIssueMessage()
        public virtual void ShouldLogUpstreamIssueMessage()
        {
            InMemoryStoreStreamProvider       clientStoreFileStream             = new InMemoryStoreStreamProvider();
            CatchupAddressResolutionException catchupAddressResolutionException = new CatchupAddressResolutionException(new MemberId(System.Guid.randomUUID()));

            try
            {
                _subject.copyStoreFiles(new CatchupAddressProviderAnonymousInnerClass2(this, catchupAddressResolutionException)
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
                                        , _serverHandler.StoreId, clientStoreFileStream, Once::new, _targetLocation);
                fail();
            }
            catch (StoreCopyFailedException)
            {
                _assertableLogProvider.rawMessageMatcher().assertContains(Matchers.allOf(Matchers.containsString("Unable to resolve address for '%s'. %s")));

                // assertableLogProvider.assertLogStringContains(catchupAddressResolutionException.getMessage() );
            }
        }
Пример #5
0
 private static string ClientFileContents(InMemoryStoreStreamProvider storeFileStreamsProvider, string filename)
 {
     return(storeFileStreamsProvider.FileStreams()[filename].ToString());
 }
Пример #6
0
 internal InMemoryStoreStream(InMemoryStoreStreamProvider outerInstance, StringBuilder stringBuffer)
 {
     this._outerInstance = outerInstance;
     this.StringBuffer   = stringBuffer;
 }