예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void symbolicLinkAsTargetShouldNotBreakTheMove() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SymbolicLinkAsTargetShouldNotBreakTheMove()
        {
            /*
             * Setup the following structure
             * - realSourceFile: a dummy file serving as the file to copy, the original source
             * - realTargetDirectory: the real directory to move the file into
             * - linkTargetDirectory: a symbolic link pointing to realTargetDirectory.
             */
            string realFileFilename    = "realFile";            // we need this for the assert at the end
            Path   realSourceFile      = Files.createFile((new File(TestDirectory.absolutePath(), realFileFilename)).toPath());
            Path   realTargetDirectory = Files.createDirectory((new File(TestDirectory.absolutePath(), "realTargetDirectory")).toPath());
            Path   linkTargetDirectory = Files.createSymbolicLink((new File(TestDirectory.absolutePath(), "linkToTarget")).toPath(), realTargetDirectory);

            /*
             * We now try to copy the realSourceFile to the linkTargetDirectory. This must succeed.
             * As a reminder, the FileMoveAction.copyViaFileSystem() will prepare a file move operation for the real source file
             *  (contained in the top level test directory). The move() call will accept as an argument the symbolic link and
             *  try to move the source in there.
             */
            FileMoveAction.copyViaFileSystem(realSourceFile.toFile(), TestDirectory.absolutePath()).move(linkTargetDirectory.toFile());

            File target = new File(linkTargetDirectory.toFile(), realFileFilename);

            assertTrue(Files.exists(target.toPath()));
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void fullPathFileNamesUsedForMonitoringBackup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FullPathFileNamesUsedForMonitoringBackup()
        {
            // given
            AtomicBoolean          wasActivated = new AtomicBoolean(false);
            StoreCopyClientMonitor monitor      = new StoreCopyClientMonitor_AdapterAnonymousInnerClass(this, wasActivated);

            // and
            ToFileStoreWriter writer     = new ToFileStoreWriter(_directory.absolutePath(), _fs, monitor);
            ByteBuffer        tempBuffer = ByteBuffer.allocate(128);

            // when
            writer.Write("expectedFileName", new DataProducer(16), tempBuffer, true, 16);

            // then
            assertTrue(wasActivated.get());
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeEmptyWhenFirstStarted()
        public virtual void ShouldBeEmptyWhenFirstStarted()
        {
            // When
            File storeDir           = TestDir.absolutePath();
            GraphDatabaseService db = (new TestGraphDatabaseFactory()).newEmbeddedDatabase(storeDir);

            // Then
            using (Transaction ignore = Db.beginTx())
            {
                assertEquals(0, count(Db.AllNodes));
                assertEquals(0, count(Db.AllRelationships));
                assertEquals(0, count(Db.AllRelationshipTypes));
                assertEquals(0, count(Db.AllLabels));
                assertEquals(0, count(Db.AllPropertyKeys));
            }

            Db.shutdown();
        }
예제 #4
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));
        }