Example usage for com.squareup.okhttp ConnectionPool getMultiplexedConnectionCount

List of usage examples for com.squareup.okhttp ConnectionPool getMultiplexedConnectionCount

Introduction

In this page you can find the example usage for com.squareup.okhttp ConnectionPool getMultiplexedConnectionCount.

Prototype

public synchronized int getMultiplexedConnectionCount() 

Source Link

Document

Returns total number of multiplexed connections in the pool.

Usage

From source file:twitter4j.Http2ClientTest.java

License:Apache License

public void testNoPreferOption() throws Exception {
    AlternativeHttpClientImpl http = callOembed();

    // check HTTP/2.0
    Field f = http.getClass().getDeclaredField("okHttpClient");
    f.setAccessible(true);/*from   w w w  .  ja  v  a 2 s  .  c o m*/
    OkHttpClient client = (OkHttpClient) f.get(http);
    assertNotNull("ensure that OkHttpClient is used", client);

    ConnectionPool p = client.getConnectionPool();
    assertEquals(1, p.getConnectionCount());
    assertEquals(0, p.getHttpConnectionCount());
    assertEquals(1, p.getMultiplexedConnectionCount());

    assertEquals("h2", http.getLastRequestProtocol());
}

From source file:twitter4j.Http2ClientTest.java

License:Apache License

public void testSpdy() throws Exception {
    AlternativeHttpClientImpl.sPreferSpdy = true;
    AlternativeHttpClientImpl.sPreferHttp2 = false;
    AlternativeHttpClientImpl http = callOembed();

    // check SPDY
    Field f = http.getClass().getDeclaredField("okHttpClient");
    f.setAccessible(true);//from   w  ww .  j a v a 2  s .c  o m
    OkHttpClient client = (OkHttpClient) f.get(http);
    assertNotNull("ensure that OkHttpClient is used", client);

    ConnectionPool p = client.getConnectionPool();
    assertEquals(1, p.getConnectionCount());
    assertEquals(0, p.getHttpConnectionCount());
    assertEquals(1, p.getMultiplexedConnectionCount());

    assertEquals("spdy/3.1", http.getLastRequestProtocol());
}

From source file:twitter4j.Http2ClientTest.java

License:Apache License

public void testHttp2() throws Exception {
    AlternativeHttpClientImpl.sPreferSpdy = false;
    AlternativeHttpClientImpl.sPreferHttp2 = true;
    AlternativeHttpClientImpl http = callOembed();

    // check HTTP/2.0
    Field f = http.getClass().getDeclaredField("okHttpClient");
    f.setAccessible(true);//from  w  w w .  ja  v  a 2 s .c  o m
    OkHttpClient client = (OkHttpClient) f.get(http);
    assertNotNull("ensure that OkHttpClient is used", client);

    ConnectionPool p = client.getConnectionPool();
    assertEquals(1, p.getConnectionCount());
    assertEquals(0, p.getHttpConnectionCount());
    assertEquals(1, p.getMultiplexedConnectionCount());

    assertEquals("h2", http.getLastRequestProtocol());
}

From source file:twitter4j.Http2ClientTest.java

License:Apache License

public void testNoSpdy() throws Exception {
    AlternativeHttpClientImpl.sPreferSpdy = false;
    AlternativeHttpClientImpl.sPreferHttp2 = false;

    AlternativeHttpClientImpl http = callOembed();

    // check not SPDY
    Field f = http.getClass().getDeclaredField("okHttpClient");
    f.setAccessible(true);//from  ww  w .j av a  2 s .  c o m
    OkHttpClient client = (OkHttpClient) f.get(http);

    ConnectionPool p = client.getConnectionPool();
    assertEquals(1, p.getConnectionCount());
    assertEquals(1, p.getHttpConnectionCount());
    assertEquals(0, p.getMultiplexedConnectionCount());

    assertEquals("http/1.1", http.getLastRequestProtocol());
}