예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldForceStickyMark() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldForceStickyMark()
        {
            // GIVEN
            CreateEmptyFile();

            // WHEN opening the id generator, where the jvm crashes right after
            IdContainer idContainer = new IdContainer(_fs, _file, 100, false);

            idContainer.Init();

            // THEN
            try
            {
                IdContainer.ReadHighId(_fs, _file);
                fail("Should have thrown, saying something with sticky generator");
            }
            catch (InvalidIdGeneratorException)
            {
                // THEN Good
            }
            finally
            {
                idContainer.Close(0);
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTruncateTheFileIfOverwriting() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTruncateTheFileIfOverwriting()
        {
            // GIVEN
            IdContainer.CreateEmptyIdFile(_fs, _file, 30, false);
            IdContainer idContainer = new IdContainer(_fs, _file, 5, false);

            idContainer.Init();
            for (int i = 0; i < 17; i++)
            {
                idContainer.FreeId(i);
            }
            idContainer.Close(30);
            assertThat(( int )_fs.getFileSize(_file), greaterThan(IdContainer.HeaderSize));

            // WHEN
            IdContainer.CreateEmptyIdFile(_fs, _file, 30, false);

            // THEN
            assertEquals(IdContainer.HeaderSize, ( int )_fs.getFileSize(_file));
            assertEquals(30, IdContainer.ReadHighId(_fs, _file));
            idContainer = new IdContainer(_fs, _file, 5, false);
            idContainer.Init();
            assertEquals(30, idContainer.InitialHighId);

            idContainer.Close(30);
        }
예제 #3
0
        /// <summary>
        /// Read the high-id count from the given id-file.
        ///
        /// Note that this method should only be used when the file is not currently in use by an IdGenerator, since this
        /// method does not take any in-memory state into account.
        /// </summary>
        /// <param name="fileSystem"> The file system to use for accessing the given file. </param>
        /// <param name="file"> The path to the id-file from which to read the high-id. </param>
        /// <returns> The high-id from the given file. </returns>
        /// <exception cref="IOException"> If anything goes wrong when accessing the file, for instance if the file does not exist. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static long readHighId(org.neo4j.io.fs.FileSystemAbstraction fileSystem, java.io.File file) throws java.io.IOException
        public static long ReadHighId(FileSystemAbstraction fileSystem, File file)
        {
            return(IdContainer.ReadHighId(fileSystem, file));
        }