Ejemplo n.º 1
0
 private void AssertClosedChannelException(string hostname, int port, CatchUpClient closingClient)
 {
     try
     {
         closingClient.MakeBlockingRequest(new AdvertisedSocketAddress(hostname, port), new GetStoreIdRequest(), NeverCompletingAdaptor());
         fail();
     }
     catch (CatchUpClientException e)
     {
         Exception cause = e.InnerException;
         assertEquals(cause.GetType(), typeof(ExecutionException));
         Exception actualCause = cause.InnerException;
         assertEquals(actualCause.GetType(), typeof(ClosedChannelException));
     }
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldTimeoutDueToInactivity()
        internal virtual void ShouldTimeoutDueToInactivity()
        {
            // given
            string hostname = "localhost";
            int    port     = PortAuthority.allocatePort();
            ListenSocketAddress listenSocketAddress = new ListenSocketAddress(hostname, port);

            _inactivityTimeoutMillis = 0;

            Server        closingChannelServer = CatchupServer(listenSocketAddress);
            CatchUpClient emptyClient          = emptyClient();

            _lifeSupport.add(closingChannelServer);
            _lifeSupport.add(emptyClient);

            // when
            _lifeSupport.init();
            _lifeSupport.start();

            // then
            CatchUpClientException catchUpClientException = assertThrows(typeof(CatchUpClientException), () => emptyClient.MakeBlockingRequest(new AdvertisedSocketAddress(hostname, port), new GetStoreIdRequest(), NeverCompletingAdaptor()));

            assertEquals(typeof(TimeoutException), Exceptions.rootCause(catchUpClientException).GetType());
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCloseHandlerIfChannelIsClosedOnServer()
        internal virtual void ShouldCloseHandlerIfChannelIsClosedOnServer()
        {
            // given
            string hostname = "localhost";
            int    port     = PortAuthority.allocatePort();
            ListenSocketAddress listenSocketAddress = new ListenSocketAddress(hostname, port);
            AtomicBoolean       wasClosedByServer   = new AtomicBoolean(false);

            Server        closingChannelServer = ClosingChannelCatchupServer(listenSocketAddress, wasClosedByServer);
            CatchUpClient emptyClient          = emptyClient();

            _lifeSupport.add(closingChannelServer);
            _lifeSupport.add(emptyClient);

            // when
            _lifeSupport.init();
            _lifeSupport.start();

            // then
            CatchUpClientException catchUpClientException = assertThrows(typeof(CatchUpClientException), () => emptyClient.MakeBlockingRequest(new AdvertisedSocketAddress(hostname, port), new GetStoreIdRequest(), NeverCompletingAdaptor()));

            assertEquals(typeof(ClosedChannelException), Exceptions.rootCause(catchUpClientException).GetType());
            assertTrue(wasClosedByServer.get());
        }