Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMarshalIdRangeRequest() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMarshalIdRangeRequest()
        {
            ByteBuf           buffer  = Unpooled.buffer();
            ReplicatedContent message = new ReplicatedIdAllocationRequest(new MemberId(System.Guid.randomUUID()), IdType.PROPERTY, 100, 200);

            AssertMarshalingEquality(buffer, message);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowErrorWithRemoteAddressWhenClosed() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowErrorWithRemoteAddressWhenClosed()
        {
            Channel          channel   = mock(typeof(Channel));
            ByteBufAllocator allocator = mock(typeof(ByteBufAllocator));

            when(allocator.buffer(anyInt())).thenReturn(Unpooled.buffer());
            when(channel.alloc()).thenReturn(allocator);
            SocketAddress remoteAddress       = mock(typeof(SocketAddress));
            string        remoteAddressString = "client.server.com:7687";

            when(remoteAddress.ToString()).thenReturn(remoteAddressString);
            when(channel.remoteAddress()).thenReturn(remoteAddress);

            ChunkedOutput output = new ChunkedOutput(channel, DEFAULT_TEST_BUFFER_SIZE, DEFAULT_TEST_BUFFER_SIZE, NO_THROTTLE);

            output.Dispose();

            try
            {
                output.WriteInt(42);
                fail("Exception expected");
            }
            catch (PackOutputClosedException e)
            {
                assertThat(e.Message, containsString(remoteAddressString));
            }
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMarshalMemberSet() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMarshalMemberSet()
        {
            ByteBuf           buffer  = Unpooled.buffer();
            ReplicatedContent message = new MemberIdSet(asSet(new MemberId(System.Guid.randomUUID()), new MemberId(System.Guid.randomUUID())
                                                              ));

            AssertMarshalingEquality(buffer, message);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMarshalTransactionReferenceWithMissingHeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMarshalTransactionReferenceWithMissingHeader()
        {
            ByteBuf buffer = Unpooled.buffer();
            PhysicalTransactionRepresentation representation = new PhysicalTransactionRepresentation(Collections.emptyList());

            TransactionRepresentationReplicatedTransaction replicatedTx = ReplicatedTransaction.from(representation);

            AssertMarshalingEquality(buffer, replicatedTx);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldMarshalTokenRequest() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldMarshalTokenRequest()
        {
            ByteBuf buffer = Unpooled.buffer();

            List <StorageCommand> commands = new List <StorageCommand>();
            LabelTokenRecord      before   = new LabelTokenRecord(0);
            LabelTokenRecord      after    = new LabelTokenRecord(0);

            after.InUse = true;
            after.SetCreated();
            after.NameId = 3232;
            commands.Add(new Command.LabelTokenCommand(before, after));
            ReplicatedContent message = new ReplicatedTokenRequest(TokenType.LABEL, "theLabel", ReplicatedTokenRequestSerializer.commandBytes(commands));

            AssertMarshalingEquality(buffer, message);
        }
Esempio n. 6
0
        public static sbyte[] CommandBytes(ICollection <StorageCommand> commands)
        {
            ByteBuf commandBuffer = Unpooled.buffer();
            BoundedNetworkWritableChannel channel = new BoundedNetworkWritableChannel(commandBuffer);

            try
            {
                (new LogEntryWriter(channel)).serialize(commands);
            }
            catch (IOException e)
            {
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);                           // TODO: Handle or throw.
            }

            /*
             * This trims down the array to send up to the actual index it was written. Not doing this would send additional
             * zeroes which not only wasteful, but also not handled by the LogEntryReader receiving this.
             */
            sbyte[] commandsBytes = Arrays.copyOf(commandBuffer.array(), commandBuffer.writerIndex());
            commandBuffer.release();

            return(commandsBytes);
        }