示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = IllegalStateException.class) public void createIdGeneratorMustRefuseOverwritingExistingFile() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void CreateIdGeneratorMustRefuseOverwritingExistingFile()
        {
            IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, false);
            IdGenerator idGenerator = new IdGeneratorImpl(_fs, IdGeneratorFile(), 1008, 1000, false, IdType.NODE, () => 0L);

            try
            {
                IdGeneratorImpl.createGenerator(_fs, IdGeneratorFile(), 0, true);
            }
            finally
            {
                CloseIdGenerator(idGenerator);
                // verify that id generator is ok
                StoreChannel fileChannel = _fs.open(IdGeneratorFile(), OpenMode.READ_WRITE);
                ByteBuffer   buffer      = ByteBuffer.allocate(9);
                fileChannel.ReadAll(buffer);
                buffer.flip();
                assertEquals(( sbyte )0, buffer.get());
                assertEquals(0L, buffer.Long);
                buffer.flip();
                int readCount = fileChannel.read(buffer);
                if (readCount != -1 && readCount != 0)
                {
                    fail("Id generator header not ok read 9 + " + readCount + " bytes from file");
                }
                fileChannel.close();

                File file = IdGeneratorFile();
                if (file.exists())
                {
                    assertTrue(file.delete());
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void allowStoreThatExceedDefaultSize() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void AllowStoreThatExceedDefaultSize()
        {
            File         aFile   = new File("test");
            StoreChannel channel = _fs.open(aFile, OpenMode.READ_WRITE);

            ByteBuffer buffer    = allocate(Long.BYTES);
            int        mebiBytes = ( int )ByteUnit.mebiBytes(1);

            for (int position = mebiBytes + 42; position < 10_000_000; position += mebiBytes)
            {
                buffer.putLong(1);
                buffer.flip();
                channel.WriteAll(buffer, position);
                buffer.clear();
            }
            channel.close();
        }