Example usage for com.squareup.okhttp ConnectionPool getHttpConnectionCount

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

Introduction

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

Prototype

public synchronized int getHttpConnectionCount() 

Source Link

Document

Returns total number of http 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  ww w  .  j  a v a  2 s .com*/
    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 a2 s .c om
    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);/*  ww  w.  j av  a2s . 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);/* ww w. j  av a  2s. com*/
    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());
}

From source file:twitter4j.SpdyHttpClientTest.java

License:Apache License

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

    // check HTTP/2.0
    Field f = http.getClass().getDeclaredField("client");
    f.setAccessible(true);//from ww  w. 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.getSpdyConnectionCount());

    assertEquals("HTTP-draft-09/2.0", http.getLastRequestProtocol());
}

From source file:twitter4j.SpdyHttpClientTest.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("client");
    f.setAccessible(true);/*from  www  .  j  a  v  a  2  s  . co  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.getSpdyConnectionCount());

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

From source file:twitter4j.SpdyHttpClientTest.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("client");
    f.setAccessible(true);//from w  ww.j  a va2 s.co 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.getSpdyConnectionCount());

    assertEquals("HTTP-draft-09/2.0", http.getLastRequestProtocol());
}