Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReturnToDelegatePoolIfLocalPoolIsFull()
        internal virtual void ShouldReturnToDelegatePoolIfLocalPoolIsFull()
        {
            // Given
            Pool <object> delegatePool = mock(typeof(Pool));

            when(delegatePool.Acquire()).thenReturn(1337);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MarshlandPool<Object> pool = new MarshlandPool<>(delegatePool);
            MarshlandPool <object> pool = new MarshlandPool <object>(delegatePool);

            object first  = pool.Acquire();
            object second = pool.Acquire();
            object third  = pool.Acquire();

            // When
            pool.Release(first);
            pool.Release(second);
            pool.Release(third);

            // Then
            verify(delegatePool, times(3)).acquire();
            verify(delegatePool, times(2)).release(any());
            verifyNoMoreInteractions(delegatePool);
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void claimAndReleaseInSeparateThread(final MarshlandPool<Object> pool) throws InterruptedException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        private void ClaimAndReleaseInSeparateThread(MarshlandPool <object> pool)
        {
            Thread thread = new Thread(() =>
            {
                object obj = pool.Acquire();
                pool.Release(obj);
            });

            thread.Start();
            thread.Join();
        }
Exemple #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotLooseObjectsWhenThreadsDie() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotLooseObjectsWhenThreadsDie()
        {
            // Given
            Pool <object> delegatePool = mock(typeof(Pool));

            when(delegatePool.Acquire()).thenReturn(1337, -1);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MarshlandPool<Object> pool = new MarshlandPool<>(delegatePool);
            MarshlandPool <object> pool = new MarshlandPool <object>(delegatePool);

            // When
            ClaimAndReleaseInSeparateThread(pool);

            // Then
            verify(delegatePool).acquire();
            verifyNoMoreInteractions(delegatePool);
            AssertPoolEventuallyReturns(pool, 1337);
        }