Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPropagateIOExceptions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPropagateIOExceptions()
        {
            // Given
            TransactionFailureException exceptionThrown = null;

            File storeDir = TestDirectory.storeDir();
            LimitedFileSystemGraphDatabase db = new LimitedFileSystemGraphDatabase(storeDir);

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }

            long logVersion = Db.DependencyResolver.resolveDependency(typeof(LogVersionRepository)).CurrentLogVersion;

            Db.runOutOfDiskSpaceNao();

            // When
            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode();
                    tx.Success();
                }
            }
            catch (TransactionFailureException e)
            {
                exceptionThrown = e;
            }
            finally
            {
                assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", exceptionThrown);
                assertTrue(Exceptions.contains(exceptionThrown, typeof(IOException)));
            }

            Db.somehowGainMoreDiskSpace();               // to help shutting down the db
            Db.shutdown();

            PageCache pageCache = PageCacheRule.getPageCache(Db.FileSystem);
            File      neoStore  = TestDirectory.databaseLayout().metadataStore();

            assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldStopDatabaseWhenOutOfDiskSpace() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStopDatabaseWhenOutOfDiskSpace()
        {
            // Given
            TransactionFailureException expectedCommitException = null;
            TransactionFailureException expectedStartException  = null;
            File storeDir = TestDirectory.absolutePath();
            LimitedFileSystemGraphDatabase db = Cleanup.add(new LimitedFileSystemGraphDatabase(storeDir));

            using (Transaction tx = Db.beginTx())
            {
                Db.createNode();
                tx.Success();
            }

            long logVersion = Db.DependencyResolver.resolveDependency(typeof(LogVersionRepository)).CurrentLogVersion;

            Db.runOutOfDiskSpaceNao();

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    Db.createNode();
                    tx.Success();
                }
            }
            catch (TransactionFailureException e)
            {
                expectedCommitException = e;
            }
            finally
            {
                assertNotNull("Expected tx finish to throw TransactionFailureException when filesystem is full.", expectedCommitException);
            }

            // When
            try
            {
                using (Transaction transaction = Db.beginTx())
                {
                    fail("Expected tx begin to throw TransactionFailureException when tx manager breaks.");
                }
            }
            catch (TransactionFailureException e)
            {
                expectedStartException = e;
            }
            finally
            {
                assertNotNull("Expected tx begin to throw TransactionFailureException when tx manager breaks.", expectedStartException);
            }

            // Then
            Db.somehowGainMoreDiskSpace();               // to help shutting down the db
            Db.shutdown();

            PageCache pageCache = PageCacheRule.getPageCache(Db.FileSystem);
            File      neoStore  = TestDirectory.databaseLayout().metadataStore();

            assertEquals(logVersion, MetaDataStore.getRecord(pageCache, neoStore, MetaDataStore.Position.LOG_VERSION));
        }