예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCheckConnectionOnIdleChannelFirst()
        public virtual void ShouldCheckConnectionOnIdleChannelFirst()
        {
            // given
            CatchUpChannelPool <TestChannel> pool = new CatchUpChannelPool <TestChannel>(new FuncAnonymousInnerClass(this));

            TestChannel channel = null;

            try
            {
                channel = pool.Acquire(LocalAddress(1));
                assertNotNull(channel);
            }
            catch (Exception)
            {
                fail("Not expected exception");
            }

            // when channel loses connection in idle
            channel.IsActive = false;
            pool.Release(channel);

            try
            {
                // then
                pool.Acquire(LocalAddress(1));
            }
            catch (Exception e)
            {
                assertEquals(typeof(ConnectException), e.GetType());
                assertEquals("Unable to connect to localhost:1", e.Message);
                return;
            }
            fail();
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailWithExceptionIsChannelIsNotActive()
        public virtual void ShouldFailWithExceptionIsChannelIsNotActive()
        {
            CatchUpChannelPool <TestChannel> pool = new CatchUpChannelPool <TestChannel>(advertisedSocketAddress => new TestChannel(advertisedSocketAddress, false));

            try
            {
                pool.Acquire(LocalAddress(1));
            }
            catch (Exception e)
            {
                assertEquals(typeof(ConnectException), e.GetType());
                assertEquals("Unable to connect to localhost:1", e.Message);
                return;
            }
            fail();
        }