コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly()
        {
            // GIVEN
            TransactionIdStore  transactionIdStore = mock(typeof(TransactionIdStore));
            TransactionAppender appender           = new TestableTransactionAppender(transactionIdStore);
            long txId = 11;

            when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId);
            IOException   rootCause     = new IOException("Mock exception");
            StorageEngine storageEngine = mock(typeof(StorageEngine));

            doThrow(new IOException(rootCause)).when(storageEngine).apply(any(typeof(TransactionToApply)), any(typeof(TransactionApplicationMode)));
            TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
            TransactionToApply       transaction   = MockedTransaction();

            // WHEN
            try
            {
                commitProcess.Commit(transaction, _commitEvent, INTERNAL);
            }
            catch (TransactionFailureException e)
            {
                assertThat(e.Message, containsString("Could not apply the transaction to the store"));
                assertTrue(contains(e, rootCause.Message, rootCause.GetType()));
            }

            // THEN
            // we can't verify transactionCommitted since that's part of the TransactionAppender, which we have mocked
            verify(transactionIdStore, times(1)).transactionClosed(eq(txId), anyLong(), anyLong());
        }
コード例 #2
0
 public DefaultRecoveryService(StorageEngine storageEngine, LogTailScanner logTailScanner, TransactionIdStore transactionIdStore, LogicalTransactionStore logicalTransactionStore, LogVersionRepository logVersionRepository, RecoveryStartInformationProvider.Monitor monitor)
 {
     this._storageEngine                    = storageEngine;
     this._transactionIdStore               = transactionIdStore;
     this._logicalTransactionStore          = logicalTransactionStore;
     this._logVersionRepository             = logVersionRepository;
     this._recoveryStartInformationProvider = new RecoveryStartInformationProvider(logTailScanner, monitor);
 }
コード例 #3
0
        private static Instances KernelTransactionWithInternals(LoginContext loginContext)
        {
            TransactionHeaderInformation        headerInformation        = new TransactionHeaderInformation(-1, -1, new sbyte[0]);
            TransactionHeaderInformationFactory headerInformationFactory = mock(typeof(TransactionHeaderInformationFactory));

            when(headerInformationFactory.Create()).thenReturn(headerInformation);

            StorageEngine storageEngine = mock(typeof(StorageEngine));
            StorageReader storageReader = mock(typeof(StorageReader));

            when(storageEngine.NewReader()).thenReturn(storageReader);

            KernelTransactionImplementation transaction = new KernelTransactionImplementation(Config.defaults(), mock(typeof(StatementOperationParts)), mock(typeof(SchemaWriteGuard)), new TransactionHooks(), mock(typeof(ConstraintIndexCreator)), new Procedures(), headerInformationFactory, mock(typeof(TransactionRepresentationCommitProcess)), mock(typeof(TransactionMonitor)), mock(typeof(AuxiliaryTransactionStateManager)), mock(typeof(Pool)), Clocks.nanoClock(), new AtomicReference <CpuClock>(CpuClock.NOT_AVAILABLE), new AtomicReference <HeapAllocation>(HeapAllocation.NOT_AVAILABLE), NULL, LockTracer.NONE, Org.Neo4j.Io.pagecache.tracing.cursor.PageCursorTracerSupplier_Fields.Null, storageEngine, new CanWrite(), AutoIndexing.UNSUPPORTED, mock(typeof(ExplicitIndexStore)), EmptyVersionContextSupplier.EMPTY, ON_HEAP, new StandardConstraintSemantics(), mock(typeof(SchemaState)), mock(typeof(IndexingService)), mockedTokenHolders(), new Dependencies());

            StatementLocks statementLocks = new SimpleStatementLocks(new NoOpClient());

            transaction.Initialize(0, 0, statementLocks, KernelTransaction.Type.@implicit, loginContext.Authorize(s => - 1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME), 0L, 1L);

            return(new Instances(transaction));
        }
コード例 #4
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()
        {
            _dataSource = mock(typeof(NeoStoreDataSource));
            StorageEngine storageEngine = mock(typeof(StorageEngine));
            StorageReader storageReader = mock(typeof(StorageReader));

            when(storageEngine.NewReader()).thenReturn(storageReader);
            _indexingService = mock(typeof(IndexingService));
            TokenHolders tokenHolders = MockedTokenHolders();

            when(tokenHolders.LabelTokens().getIdByName(EXISTING_LABEL)).thenReturn(LABEL_ID);
            when(tokenHolders.PropertyKeyTokens().getIdByName(EXISTING_PROPERTY)).thenReturn(PROPERTY_ID);
            when(tokenHolders.PropertyKeyTokens().getIdByName(NON_EXISTING_PROPERTY)).thenReturn(-1);
            when(tokenHolders.LabelTokens().getIdByName(NON_EXISTING_LABEL)).thenReturn(NO_TOKEN);
            DependencyResolver resolver = mock(typeof(DependencyResolver));

            when(resolver.ResolveDependency(typeof(IndexingService))).thenReturn(_indexingService);
            when(resolver.ResolveDependency(typeof(StorageEngine))).thenReturn(storageEngine);
            when(resolver.ResolveDependency(typeof(TokenHolders))).thenReturn(tokenHolders);
            when(_dataSource.DependencyResolver).thenReturn(resolver);
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailWithProperMessageOnAppendException() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailWithProperMessageOnAppendException()
        {
            // GIVEN
            TransactionAppender appender  = mock(typeof(TransactionAppender));
            IOException         rootCause = new IOException("Mock exception");

            doThrow(new IOException(rootCause)).when(appender).append(any(typeof(TransactionToApply)), any(typeof(LogAppendEvent)));
            StorageEngine            storageEngine = mock(typeof(StorageEngine));
            TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);

            // WHEN
            try
            {
                commitProcess.Commit(MockedTransaction(), _commitEvent, INTERNAL);
                fail("Should have failed, something is wrong with the mocking in this test");
            }
            catch (TransactionFailureException e)
            {
                assertThat(e.Message, containsString("Could not append transaction representation to log"));
                assertTrue(contains(e, rootCause.Message, rootCause.GetType()));
            }
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSuccessfullyCommitTransactionWithNoCommands()
        {
            // GIVEN
            long txId            = 11;
            long commitTimestamp = DateTimeHelper.CurrentUnixTimeMillis();
            TransactionIdStore  transactionIdStore = mock(typeof(TransactionIdStore));
            TransactionAppender appender           = new TestableTransactionAppender(transactionIdStore);

            when(transactionIdStore.NextCommittingTransactionId()).thenReturn(txId);

            StorageEngine storageEngine = mock(typeof(StorageEngine));

            TransactionCommitProcess          commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
            PhysicalTransactionRepresentation noCommandTx   = new PhysicalTransactionRepresentation(Collections.emptyList());

            noCommandTx.SetHeader(new sbyte[0], -1, -1, -1, -1, -1, -1);

            // WHEN

            commitProcess.Commit(new TransactionToApply(noCommandTx), _commitEvent, INTERNAL);

            verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP);
        }
コード例 #7
0
 public override TransactionCommitProcess Create(TransactionAppender appender, StorageEngine storageEngine, Config config)
 {
     if (config.Get(GraphDatabaseSettings.read_only))
     {
         return(new ReadOnlyTransactionCommitProcess());
     }
     return(new TransactionRepresentationCommitProcess(appender, storageEngine));
 }
コード例 #8
0
 internal State(StorageEngine storageEngine, IndexingService indexingService, TokenHolders tokenHolders)
 {
     this.StorageEngine   = storageEngine;
     this.IndexingService = indexingService;
     this.TokenHolders    = tokenHolders;
 }
コード例 #9
0
 internal RecoveryVisitor(StorageEngine storageEngine, TransactionApplicationMode mode)
 {
     this.StorageEngine = storageEngine;
     this.Mode          = mode;
 }