Android HttpTransportMetricsImpl - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpTransportMetricsImpl class.

This code example shows how to use the following methods:
    public SessionOutputBufferMock( 
            final ByteArrayOutputStream buffer,
            final int buffersize,
            final int fragementSizeHint,
            final CharsetEncoder encoder) {
        super(new HttpTransportMetricsImpl(), buffersize, fragementSizeHint, encoder);
        bind(buffer);
        this.buffer = buffer;
    } 
 
    public SessionOutputBufferMock( 
            final ByteArrayOutputStream buffer,
            final int buffersize) {
        this(buffer, buffersize, buffersize, null);
    } 
 
    public SessionOutputBufferMock( 
            final CharsetEncoder encoder) {
        this(new ByteArrayOutputStream(), BUFFER_SIZE, BUFFER_SIZE, encoder);
    } 
5
CodeRank
This code example shows how to use the following methods:
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"a"}, "US-ASCII");
        HttpParams params = new BasicHttpParams();
 
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        IdentityDecoder decoder = new IdentityDecoder(
                channel, inbuf, metrics);
 
        File fileHandle = File.createTempFile("testFile", ".txt");
 
        RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw");
        FileChannel fchannel = testfile.getChannel();
        assertEquals(0, testfile.length());
 
        try { 
            decoder.transfer(fchannel, 5, 10);
            fail("expected IOException");
        } catch(IOException iox) {}
 
5
CodeRank
This code example shows how to use the following methods:
    public SessionInputBufferMock( 
            final InputStream instream,
            final int buffersize,
            final MessageConstraints constrains,
            final CharsetDecoder decoder) {
        super(new HttpTransportMetricsImpl(), buffersize, -1, constrains, decoder);
        bind(instream);
    } 
 
    public SessionInputBufferMock( 
            final InputStream instream,
            final int buffersize) {
        this(instream, buffersize, null, null);
    } 
 
    public SessionInputBufferMock( 
            final byte[] bytes,
            final int buffersize,
            final MessageConstraints constrains,
            final CharsetDecoder decoder) {
4
CodeRank
This code example shows how to use the following methods:
 
    /** 
     * @since 4.1 
     */ 
    protected HttpTransportMetricsImpl createTransportMetrics() {
        return new HttpTransportMetricsImpl();
    } 
 
    /** 
     * @since 4.1 
     */ 
    protected HttpConnectionMetricsImpl createConnectionMetrics(
            final HttpTransportMetrics inTransportMetric,
            final HttpTransportMetrics outTransportMetric) {
        return new HttpConnectionMetricsImpl(inTransportMetric, outTransportMetric);
    } 
 
    public int getStatus() { 
        return this.status;
    } 
4
CodeRank
This code example shows how to use the following methods:
 
    @Test 
    public void testCodingCompleted() throws Exception { 
        final WritableByteChannelMock channel = new WritableByteChannelMock(64);
        final SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128);
        final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        final ChunkEncoder encoder = new ChunkEncoder(channel, outbuf, metrics);
 
        encoder.write(CodecTestUtils.wrap("12345"));
        encoder.write(CodecTestUtils.wrap("678"));
        encoder.write(CodecTestUtils.wrap("90"));
        encoder.complete();
 
        try { 
            encoder.write(CodecTestUtils.wrap("more stuff"));
            Assert.fail("IllegalStateException should have been thrown");
        } catch (final IllegalStateException ex) {
            // ignore 
        } 
        try { 
4
CodeRank
This code example shows how to use the following methods:
    public void testInvalidConstructor() { 
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        WritableByteChannel channel = newChannel(baos);
        HttpParams params = new BasicHttpParams();
        SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
 
        try { 
            new LengthDelimitedEncoder(null, null, null, 10); 
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // ignore 
        } 
        try { 
            new LengthDelimitedEncoder(channel, null, null, 10);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // ignore 
        } 
        try { 
4
CodeRank
This code example shows how to use the following methods:
        ReadableByteChannel channel = new ReadableByteChannelMockup(
                new String[] {"a"}, "US-ASCII");
        HttpParams params = new BasicHttpParams();
 
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 256, params);
        HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl();
        LengthDelimitedDecoder decoder = new LengthDelimitedDecoder(
                channel, inbuf, metrics, 1);
 
        File fileHandle = File.createTempFile("testFile", ".txt");
 
        RandomAccessFile testfile = new RandomAccessFile(fileHandle, "rw");
        FileChannel fchannel = testfile.getChannel();
        assertEquals(0, testfile.length());
 
        try { 
            decoder.transfer(fchannel, 5, 10);
            fail("expected IOException");
        } catch(IOException iox) {}
 
3
CodeRank
This code example shows how to use the following methods:
 
    /** 
     * @since 4.1 
     */ 
    protected HttpTransportMetricsImpl createTransportMetrics() {
        return new HttpTransportMetricsImpl();
    } 
 
    /** 
     * @since 4.1 
     */ 
    protected HttpConnectionMetricsImpl createConnectionMetrics(
            final HttpTransportMetrics inTransportMetric,
            final HttpTransportMetrics outTransportMetric) {
        return new HttpConnectionMetricsImpl(inTransportMetric, outTransportMetric);
    } 
 
    public int getStatus() { 
        return this.status;
    } 
3
CodeRank
This code example shows how to use the following methods:incrementBytesTransferred
        if (!this.buffer.hasData()) {
            return 0; 
        } 
        final int bytesWritten = this.buffer.flush(this.channel);
        if (bytesWritten > 0) {
            this.metrics.incrementBytesTransferred(bytesWritten);
        } 
        return bytesWritten;
    } 
 
    /** 
     * Flushes content of the given buffer to the channel and updates transport metrics. 
     * 
     * @return number of bytes written to the channel. 
     * 
     * @since 4.3 
     */ 
    protected int writeToChannel(final ByteBuffer src) throws IOException {
        if (!src.hasRemaining()) {
            return 0; 
4
CodeRank
This code example shows how to use the following methods:
    public SessionInputBufferMock( 
            final InputStream instream,
            final int buffersize,
            final MessageConstraints constrains,
            final CharsetDecoder decoder) {
        super(new HttpTransportMetricsImpl(), buffersize, -1, constrains, decoder);
        bind(instream);
    } 
 
    public SessionInputBufferMock( 
            final InputStream instream,
            final int buffersize) {
        this(instream, buffersize, null, null);
    } 
 
    public SessionInputBufferMock( 
            final byte[] bytes,
            final int buffersize,
            final MessageConstraints constrains,
            final CharsetDecoder decoder) {
4
CodeRank
See Code Examples for Android HttpTransportMetricsImpl Methods: