예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readSmallPortions() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadSmallPortions()
        {
            sbyte[]       bytes         = new sbyte[255];
            ChannelBuffer wrappedBuffer = ChannelBuffers.wrappedBuffer(bytes);

            wrappedBuffer.resetWriterIndex();
            BlockLogBuffer buffer = new BlockLogBuffer(wrappedBuffer, (new Monitors()).newMonitor(typeof(ByteCounterMonitor)));

            sbyte byteValue = 5;
            int   intValue  = 1234;
            long  longValue = 574853;

            buffer.Put(byteValue);
            buffer.PutInt(intValue);
            buffer.PutLong(longValue);
            buffer.Dispose();

            ReadableByteChannel reader             = new BlockLogReader(wrappedBuffer);
            ByteBuffer          verificationBuffer = ByteBuffer.wrap(new sbyte[1]);

            reader.read(verificationBuffer);
            verificationBuffer.flip();
            assertEquals(byteValue, verificationBuffer.get());
            verificationBuffer = ByteBuffer.wrap(new sbyte[4]);
            reader.read(verificationBuffer);
            verificationBuffer.flip();
            assertEquals(intValue, verificationBuffer.Int);
            verificationBuffer = ByteBuffer.wrap(new sbyte[8]);
            reader.read(verificationBuffer);
            verificationBuffer.flip();
            assertEquals(longValue, verificationBuffer.Long);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canReaderReallyLargeByteArray()
        public virtual void CanReaderReallyLargeByteArray()
        {
            sbyte[]       bytes         = new sbyte[650];
            ChannelBuffer wrappedBuffer = ChannelBuffers.wrappedBuffer(bytes);

            wrappedBuffer.resetWriterIndex();
            BlockLogBuffer buffer = new BlockLogBuffer(wrappedBuffer, (new Monitors()).newMonitor(typeof(ByteCounterMonitor)));

            sbyte[] bytesValue = new sbyte[600];
            bytesValue[1]   = 1;
            bytesValue[99]  = 2;
            bytesValue[199] = 3;
            bytesValue[299] = 4;
            bytesValue[399] = 5;
            bytesValue[499] = 6;
            bytesValue[599] = 7;
            buffer.Put(bytesValue, bytesValue.Length);
            buffer.Dispose();

            sbyte[]        actual;
            BlockLogReader reader             = new BlockLogReader(wrappedBuffer);
            ByteBuffer     verificationBuffer = ByteBuffer.wrap(new sbyte[1000]);

            reader.Read(verificationBuffer);
            verificationBuffer.flip();
            actual = new sbyte[255];
            verificationBuffer.get(actual);
            assertThat(actual, new ArrayMatches <>(this, Arrays.copyOfRange(bytesValue, 0, 255)));
            actual = new sbyte[255];
            verificationBuffer.get(actual);
            assertThat(actual, new ArrayMatches <>(this, Arrays.copyOfRange(bytesValue, 255, 510)));
            actual = new sbyte[90];
            verificationBuffer.get(actual);
            assertThat(actual, new ArrayMatches <>(this, Arrays.copyOfRange(bytesValue, 510, 600)));
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void canWriteLargestAtomAfterFillingBuffer()
        public virtual void CanWriteLargestAtomAfterFillingBuffer()
        {
            sbyte[]       bytes         = new sbyte[300];
            ChannelBuffer wrappedBuffer = ChannelBuffers.wrappedBuffer(bytes);

            wrappedBuffer.resetWriterIndex();
            BlockLogBuffer buffer = new BlockLogBuffer(wrappedBuffer, (new Monitors()).newMonitor(typeof(ByteCounterMonitor)));

            sbyte[] bytesValue = new sbyte[255];
            bytesValue[0]   = 1;
            bytesValue[254] = -1;
            long longValue = 123456;

            buffer.Put(bytesValue, bytesValue.Length);
            buffer.PutLong(longValue);
            buffer.Dispose();

            ByteBuffer verificationBuffer = ByteBuffer.wrap(bytes);

            assertEquals(( sbyte )0, verificationBuffer.get());
            sbyte[] actualBytes = new sbyte[bytesValue.Length];
            verificationBuffer.get(actualBytes);
            assertThat(actualBytes, new ArrayMatches <>(this, bytesValue));
            assertEquals(( sbyte )8, verificationBuffer.get());
            assertEquals(longValue, verificationBuffer.Long);
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlyOneFullBlock()
        public virtual void OnlyOneFullBlock()
        {
            sbyte[]       bytes         = new sbyte[256];
            ChannelBuffer wrappedBuffer = ChannelBuffers.wrappedBuffer(bytes);

            wrappedBuffer.resetWriterIndex();
            BlockLogBuffer buffer = new BlockLogBuffer(wrappedBuffer, (new Monitors()).newMonitor(typeof(ByteCounterMonitor)));

            sbyte[] bytesValue = new sbyte[255];
            bytesValue[0]   = 1;
            bytesValue[254] = -1;
            buffer.Put(bytesValue, bytesValue.Length);
            buffer.Dispose();

            ByteBuffer verificationBuffer = ByteBuffer.wrap(bytes);

            assertEquals(unchecked (( sbyte )255), verificationBuffer.get());
            sbyte[] actualBytes = new sbyte[bytesValue.Length];
            verificationBuffer.get(actualBytes);
            assertThat(actualBytes, new ArrayMatches <>(this, bytesValue));
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void readOnlyOneNonFullBlock() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReadOnlyOneNonFullBlock()
        {
            sbyte[]       bytes         = new sbyte[255];
            ChannelBuffer wrappedBuffer = ChannelBuffers.wrappedBuffer(bytes);

            wrappedBuffer.resetWriterIndex();
            BlockLogBuffer buffer = new BlockLogBuffer(wrappedBuffer, (new Monitors()).newMonitor(typeof(ByteCounterMonitor)));

            sbyte  byteValue   = 5;
            int    intValue    = 1234;
            long   longValue   = 574853;
            float  floatValue  = 304985.5f;
            double doubleValue = 48493.22d;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] bytesValue = new byte[] { 1, 5, 2, 6, 3 };
            sbyte[] bytesValue = new sbyte[] { 1, 5, 2, 6, 3 };
            buffer.Put(byteValue);
            buffer.PutInt(intValue);
            buffer.PutLong(longValue);
            buffer.PutFloat(floatValue);
            buffer.PutDouble(doubleValue);
            buffer.Put(bytesValue, bytesValue.Length);
            buffer.Dispose();

            ReadableByteChannel reader             = new BlockLogReader(wrappedBuffer);
            ByteBuffer          verificationBuffer = ByteBuffer.wrap(new sbyte[1000]);

            reader.read(verificationBuffer);
            verificationBuffer.flip();
            assertEquals(byteValue, verificationBuffer.get());
            assertEquals(intValue, verificationBuffer.Int);
            assertEquals(longValue, verificationBuffer.Long);
            assertEquals(floatValue, verificationBuffer.Float, 0.0);
            assertEquals(doubleValue, verificationBuffer.Double, 0.0);
            sbyte[] actualBytes = new sbyte[bytesValue.Length];
            verificationBuffer.get(actualBytes);
            assertThat(actualBytes, new ArrayMatches <>(this, bytesValue));
        }