コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParserOnePhaseCommitEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParserOnePhaseCommitEntry()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryCommit commit = new LogEntryCommit(version, 42, 21);
            LogEntryCommit commit = new LogEntryCommit(_version, 42, 21);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.PutLong(commit.TxId);
            channel.PutLong(commit.TimeWritten);

            channel.GetCurrentPosition(_marker);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryParser parser = version.entryParser(LogEntryByteCodes.TX_COMMIT);
            LogEntryParser parser = _version.entryParser(LogEntryByteCodes.TxCommit);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
            LogEntry logEntry = parser.parse(_version, channel, _marker, _commandReader);

            // then
            assertEquals(commit, logEntry);
            assertFalse(parser.skip());
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParseCheckPointEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParseCheckPointEntry()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CheckPoint checkPoint = new CheckPoint(new org.neo4j.kernel.impl.transaction.log.LogPosition(43, 44));
            CheckPoint checkPoint = new CheckPoint(new LogPosition(43, 44));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.PutLong(checkPoint.LogPosition.LogVersion);
            channel.PutLong(checkPoint.LogPosition.ByteOffset);

            channel.GetCurrentPosition(_marker);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryParser parser = version.entryParser(LogEntryByteCodes.CHECK_POINT);
            LogEntryParser parser = _version.entryParser(LogEntryByteCodes.CheckPoint);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
            LogEntry logEntry = parser.parse(_version, channel, _marker, _commandReader);

            // then
            assertEquals(checkPoint, logEntry);
            assertFalse(parser.skip());
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParserStartEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParserStartEntry()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryStart start = new LogEntryStart(version, 1, 2, 3, 4, new byte[]{5}, position);
            LogEntryStart start = new LogEntryStart(_version, 1, 2, 3, 4, new sbyte[] { 5 }, _position);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.PutInt(start.MasterId);
            channel.PutInt(start.LocalId);
            channel.PutLong(start.TimeWritten);
            channel.PutLong(start.LastCommittedTxWhenTransactionStarted);
            channel.PutInt(start.AdditionalHeader.Length);
            channel.Put(start.AdditionalHeader, start.AdditionalHeader.Length);

            channel.GetCurrentPosition(_marker);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryParser parser = version.entryParser(LogEntryByteCodes.TX_START);
            LogEntryParser parser = _version.entryParser(LogEntryByteCodes.TxStart);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
            LogEntry logEntry = parser.parse(_version, channel, _marker, _commandReader);

            // then
            assertEquals(start, logEntry);
            assertFalse(parser.skip());
        }
コード例 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadACheckPointLogEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadACheckPointLogEntry()
        {
            // given
            LogEntryVersion version = LogEntryVersion.CURRENT;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition logPosition = new org.neo4j.kernel.impl.transaction.log.LogPosition(42, 43);
            LogPosition logPosition = new LogPosition(42, 43);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CheckPoint checkPoint = new CheckPoint(version, logPosition);
            CheckPoint checkPoint = new CheckPoint(version, logPosition);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(version.byteCode());
            channel.Put(LogEntryByteCodes.CheckPoint);
            channel.PutLong(logPosition.LogVersion);
            channel.PutLong(logPosition.ByteOffset);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertEquals(checkPoint, logEntry);
        }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadAStartLogEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadAStartLogEntry()
        {
            // given
            LogEntryVersion version = LogEntryVersion.CURRENT;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryStart start = new LogEntryStart(version, 1, 2, 3, 4, new byte[]{5}, new org.neo4j.kernel.impl.transaction.log.LogPosition(0, 31));
            LogEntryStart start = new LogEntryStart(version, 1, 2, 3, 4, new sbyte[] { 5 }, new LogPosition(0, 31));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(version.byteCode());                 // version
            channel.Put(LogEntryByteCodes.TxStart);          // type
            channel.PutInt(start.MasterId);
            channel.PutInt(start.LocalId);
            channel.PutLong(start.TimeWritten);
            channel.PutLong(start.LastCommittedTxWhenTransactionStarted);
            channel.PutInt(start.AdditionalHeader.Length);
            channel.Put(start.AdditionalHeader, start.AdditionalHeader.Length);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertEquals(start, logEntry);
        }
コード例 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadACommandLogEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadACommandLogEntry()
        {
            // given
            LogEntryVersion version = LogEntryVersion.CURRENT;

            Command.NodeCommand nodeCommand = new Command.NodeCommand(new NodeRecord(11), new NodeRecord(11));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
            LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(version.byteCode());
            channel.Put(LogEntryByteCodes.Command);
            nodeCommand.Serialize(channel);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertEquals(command, logEntry);
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadALongString() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadALongString()
        {
            // given

            // build a string longer than 32k
            int           stringSize = 32 * 1024 + 1;
            StringBuilder sb         = new StringBuilder();

            for (int i = 0; i < stringSize; i++)
            {
                sb.Append("x");
            }
            string lengthyString = sb.ToString();

            // we need 3 more bytes for writing the string length
            InMemoryClosableChannel channel = new InMemoryClosableChannel(stringSize + 3);

            IoPrimitiveUtils.write3bLengthAndString(channel, lengthyString);

            // when
            string stringFromChannel = IoPrimitiveUtils.read3bLengthAndString(channel);

            // then
            assertEquals(lengthyString, stringFromChannel);
        }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteALogHeaderInTheGivenChannel() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWriteALogHeaderInTheGivenChannel()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            // when
            writeLogHeader(channel, _expectedLogVersion, _expectedTxId);

            // then
            long encodedLogVersions = channel.Long;

            assertEquals(encodeLogVersion(_expectedLogVersion), encodedLogVersions);

            sbyte logFormatVersion = decodeLogFormatVersion(encodedLogVersions);

            assertEquals(CURRENT_LOG_VERSION, logFormatVersion);

            long logVersion = decodeLogVersion(encodedLogVersions);

            assertEquals(_expectedLogVersion, logVersion);

            long txId = channel.Long;

            assertEquals(_expectedTxId, txId);
        }
コード例 #9
0
ファイル: LogTruncationTest.cs プロジェクト: Neo4Net/Neo4Net
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testInMemoryLogChannel() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestInMemoryLogChannel()
        {
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            for (int i = 0; i < 25; i++)
            {
                channel.PutInt(i);
            }
            for (int i = 0; i < 25; i++)
            {
                assertEquals(i, channel.Int);
            }
            channel.Reset();
            for (long i = 0; i < 12; i++)
            {
                channel.PutLong(i);
            }
            for (long i = 0; i < 12; i++)
            {
                assertEquals(i, channel.Long);
            }
            channel.Reset();
            for (long i = 0; i < 8; i++)
            {
                channel.PutLong(i);
                channel.PutInt(( int )i);
            }
            for (long i = 0; i < 8; i++)
            {
                assertEquals(i, channel.Long);
                assertEquals(i, channel.Int);
            }
            channel.Dispose();
        }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNullWhenNotEnoughDataInTheChannel() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnNullWhenNotEnoughDataInTheChannel()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertNull(logEntry);
        }
コード例 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNullWhenThereIsNoCommand() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnNullWhenThereIsNoCommand()
        {
            // given
            LogEntryVersion version = LogEntryVersion.CURRENT;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(version.byteCode());
            channel.Put(LogEntryByteCodes.Command);
            channel.Put(Org.Neo4j.Kernel.impl.transaction.command.NeoCommandType_Fields.None);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertNull(logEntry);
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParserCommandsUsingAGivenFactory() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParserCommandsUsingAGivenFactory()
        {
            // given
            // The record, it will be used as before and after
            NodeRecord theRecord = new NodeRecord(1);

            Command.NodeCommand nodeCommand = new Command.NodeCommand(theRecord, theRecord);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryCommand command = new LogEntryCommand(version, nodeCommand);
            LogEntryCommand command = new LogEntryCommand(_version, nodeCommand);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(Org.Neo4j.Kernel.impl.transaction.command.NeoCommandType_Fields.NodeCommand);
            channel.PutLong(theRecord.Id);

            // record image before
            channel.Put(( sbyte )0);           // not in use
            channel.PutInt(0);                 // number of dynamic records in use
            // record image after
            channel.Put(( sbyte )0);           // not in use
            channel.PutInt(0);                 // number of dynamic records in use

            channel.GetCurrentPosition(_marker);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryParser parser = version.entryParser(LogEntryByteCodes.COMMAND);
            LogEntryParser parser = _version.entryParser(LogEntryByteCodes.Command);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = parser.parse(version, channel, marker, commandReader);
            LogEntry logEntry = parser.parse(_version, channel, _marker, _commandReader);

            // then
            assertEquals(command, logEntry);
            assertFalse(parser.skip());
        }
コード例 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadACommitLogEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadACommitLogEntry()
        {
            // given
            LogEntryVersion version = LogEntryVersion.CURRENT;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntryCommit commit = new LogEntryCommit(version, 42, 21);
            LogEntryCommit commit = new LogEntryCommit(version, 42, 21);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(version.byteCode());
            channel.Put(LogEntryByteCodes.TxCommit);
            channel.PutLong(commit.TxId);
            channel.PutLong(commit.TimeWritten);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertEquals(commit, logEntry);
        }
コード例 #14
0
 public ChannelBufferWrapper(InMemoryClosableChannel @delegate)
 {
     this.@delegate = @delegate;
 }