Package org.apache.http.nio.reactor

Examples of org.apache.http.nio.reactor.SessionOutputBuffer.writeLine()


        encoder.onMalformedInput(CodingErrorAction.IGNORE);
        encoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
        final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder, this.allocator);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final WritableByteChannel channel = newChannel(baos);
        outbuf.writeLine(s);
        outbuf.flush(channel);

        final String result = new String(baos.toByteArray(), "US-ASCII");
        Assert.assertEquals("This text contains a circumflex !!!\r\n", result);
    }
View Full Code Here


        encoder.onMalformedInput(CodingErrorAction.IGNORE);
        encoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
        final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 16, encoder, this.allocator);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final WritableByteChannel channel = newChannel(baos);
        outbuf.writeLine(s);
        outbuf.flush(channel);

        final String result = new String(baos.toByteArray(), "US-ASCII");
        Assert.assertEquals("This text contains a circumflex ? !!!\r\n", result);
    }
View Full Code Here

        final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        final IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);

        outbuf.writeLine("header");

        createTempFile();
        RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
        try {
            testfile.write("stuff;".getBytes(Consts.ASCII));
View Full Code Here

        final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        final IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics);

        outbuf.writeLine("header");

        createTempFile();
        RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
        try {
            testfile.write("stuff".getBytes(Consts.ASCII));
View Full Code Here

    public void testCodingNoFragmentBuffering() throws Exception {
        final WritableByteChannelMock channel = Mockito.spy(new WritableByteChannelMock(64));
        final SessionOutputBuffer outbuf = Mockito.spy(new SessionOutputBufferImpl(1024, 128));
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        outbuf.writeLine("header");
        final IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics, 0);
        Assert.assertEquals(5, encoder.write(CodecTestUtils.wrap("stuff")));

        Mockito.verify(channel, Mockito.times(2)).write(Mockito.<ByteBuffer>any());
        Mockito.verify(outbuf, Mockito.never()).write(Mockito.<ByteBuffer>any());
View Full Code Here

    public void testCodingFragmentBuffering() throws Exception {
        final WritableByteChannelMock channel = Mockito.spy(new WritableByteChannelMock(64));
        final SessionOutputBuffer outbuf = Mockito.spy(new SessionOutputBufferImpl(1024, 128));
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        outbuf.writeLine("header");
        final IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics, 32);
        Assert.assertEquals(5, encoder.write(CodecTestUtils.wrap("stuff")));

        Mockito.verify(channel, Mockito.never()).write(Mockito.<ByteBuffer>any());
        Mockito.verify(outbuf, Mockito.times(1)).write(Mockito.<ByteBuffer>any());
View Full Code Here

    public void testCodingFragmentBufferingLargeFragment() throws Exception {
        final WritableByteChannelMock channel = Mockito.spy(new WritableByteChannelMock(64));
        final SessionOutputBuffer outbuf = Mockito.spy(new SessionOutputBufferImpl(1024, 128));
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        outbuf.writeLine("header");
        final IdentityEncoder encoder = new IdentityEncoder(channel, outbuf, metrics, 2);
        Assert.assertEquals(5, encoder.write(CodecTestUtils.wrap("stuff")));

        Mockito.verify(channel, Mockito.times(2)).write(Mockito.<ByteBuffer>any());
        Mockito.verify(outbuf, Mockito.never()).write(Mockito.<ByteBuffer>any());
View Full Code Here

        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        final LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
                channel, outbuf, metrics, 16);

        outbuf.writeLine("header");

        createTempFile();
        RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
        try {
            testfile.write("stuff;".getBytes(Consts.ASCII));
View Full Code Here

        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        final LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(
                channel, outbuf, metrics, 16);

        outbuf.writeLine("header");

        createTempFile();
        RandomAccessFile testfile = new RandomAccessFile(this.tmpfile, "rw");
        try {
            testfile.write("stuff".getBytes(Consts.ASCII));
View Full Code Here

    public void testCodingNoFragmentBuffering() throws Exception {
        final WritableByteChannelMock channel = Mockito.spy(new WritableByteChannelMock(64));
        final SessionOutputBuffer outbuf = Mockito.spy(new SessionOutputBufferImpl(1024, 128));
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();

        outbuf.writeLine("header");
        final LengthDelimitedEncoder encoder = new LengthDelimitedEncoder(channel, outbuf, metrics,
            100, 0);
        Assert.assertEquals(5, encoder.write(CodecTestUtils.wrap("stuff")));

        Mockito.verify(channel, Mockito.times(2)).write(Mockito.<ByteBuffer>any());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.