Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionForHalfWrittenInstance() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionForHalfWrittenInstance()
        {
            // given
            // a CoreMember and a ByteBuffer to write it to
            MemberId.Marshal marshal = new MemberId.Marshal();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.identity.MemberId aRealMember = new org.neo4j.causalclustering.identity.MemberId(java.util.UUID.randomUUID());
            MemberId aRealMember = new MemberId(System.Guid.randomUUID());

            ByteBuf buffer = Unpooled.buffer(1000);

            // and the CoreMember is serialized but for 5 bytes at the end
            marshal.MarshalConflict(aRealMember, new BoundedNetworkWritableChannel(buffer));
            ByteBuf bufferWithMissingBytes = buffer.copy(0, buffer.writerIndex() - 5);

            // when
            try
            {
                marshal.Unmarshal(new NetworkReadableClosableChannelNetty4(bufferWithMissingBytes));
                fail("Should have thrown exception");
            }
            catch (EndOfStreamException)
            {
                // expected
            }
        }