예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.core.replication.ReplicatedContent unmarshal0(org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException
            public override ReplicatedContent unmarshal0(ReadableChannel channel)
            {
                sbyte type = channel.Get();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.core.replication.ReplicatedContent content;
                ReplicatedContent content;

                switch (type)
                {
                case 1:
                    content = ReplicatedInteger.valueOf(channel.Int);
                    break;

                default:
                    throw new System.ArgumentException(string.Format("Unknown content type 0x{0:x}", type));
                }

                try
                {
                    channel.Get();
                    throw new System.ArgumentException("Bytes remain in buffer after deserialization");
                }
                catch (ReadPastEndException)
                {
                    // expected
                }
                return(content);
            }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodeAppendEntriesRequest()
        public virtual void ShouldEncodeAndDecodeAppendEntriesRequest()
        {
            // given
            MemberId     member   = new MemberId(System.Guid.randomUUID());
            RaftLogEntry logEntry = new RaftLogEntry(1, ReplicatedInteger.valueOf(1));

            Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Request request = new Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Request(member, 1, 1, 99, new RaftLogEntry[] { logEntry }, 1);

            // when
            _channel.writeOutbound(request);
            object message = _channel.readOutbound();

            _channel.writeInbound(message);

            // then
            assertEquals(request, _channel.readInbound());
        }