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)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldCloseHandlerIfChannelIsClosedInClient() throws org.neo4j.kernel.lifecycle.LifecycleException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldCloseHandlerIfChannelIsClosedInClient() { // given string hostname = "localhost"; int port = PortAuthority.allocatePort(); ListenSocketAddress listenSocketAddress = new ListenSocketAddress(hostname, port); AtomicBoolean wasClosedByClient = new AtomicBoolean(false); Server emptyServer = CatchupServer(listenSocketAddress); CatchUpClient closingClient = ClosingChannelCatchupClient(wasClosedByClient); _lifeSupport.add(emptyServer); _lifeSupport.add(closingClient); // when _lifeSupport.init(); _lifeSupport.start(); // then AssertClosedChannelException(hostname, port, closingClient); assertTrue(wasClosedByClient.get()); }
//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()); }
//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()); }