Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRetainLockWhileStreaming() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRetainLockWhileStreaming()
        {
            // given
            ChannelPromise        channelPromise        = _embeddedChannel.newPromise();
            ChannelHandlerContext channelHandlerContext = mock(typeof(ChannelHandlerContext));

            when(channelHandlerContext.writeAndFlush(any(typeof(PrepareStoreCopyResponse)))).thenReturn(channelPromise);

            ReentrantReadWriteLock @lock = new ReentrantReadWriteLock();

            when(_neoStoreDataSource.StoreCopyCheckPointMutex).thenReturn(new StoreCopyCheckPointMutex(@lock));
            PrepareStoreCopyRequestHandler subjectHandler = CreateHandler();

            // and
            LongSet indexIds = LongSets.immutable.of(42);

            File[] files          = new File[] { new File("file") };
            long   lastCheckpoint = 1;

            ConfigureProvidedStoreCopyFiles(new StoreResource[0], files, indexIds, lastCheckpoint);

            // when
            subjectHandler.ChannelRead0(channelHandlerContext, new PrepareStoreCopyRequest(_storeIdMatching));

            // then
            assertEquals(1, @lock.ReadLockCount);

            // when
            channelPromise.setSuccess();

            //then
            assertEquals(0, @lock.ReadLockCount);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            Dependencies dependencies = new Dependencies();

            dependencies.SatisfyDependency(_checkPointer);
            StoreCopyCheckPointMutex storeCopyCheckPointMutex = new StoreCopyCheckPointMutex();

            when(_neoStoreDataSource.StoreCopyCheckPointMutex).thenReturn(storeCopyCheckPointMutex);
            when(_neoStoreDataSource.DependencyResolver).thenReturn(dependencies);
            PrepareStoreCopyRequestHandler subject = CreateHandler();

            _embeddedChannel = new EmbeddedChannel(subject);
        }