Package com.google.code.http4j.utils

Examples of com.google.code.http4j.utils.Metrics


    checkCharsetAndEntity(response);
    checkMetrics(response);
  }
 
  private void checkMetrics(Response response) {
    Metrics metrics = response.getMetrics();
    Assert.assertNotNull(metrics);
    Assert.assertTrue(metrics.getBytesReceived() > 0);
    Assert.assertTrue(metrics.getBytesSent() > 0);
    Assert.assertTrue(metrics.getConnectingCost() > 0);
    Assert.assertTrue(metrics.getReceivingCost() > 0);
    Assert.assertTrue(metrics.getSendingCost() > 0);
    Assert.assertTrue(metrics.getWaitingCost() > 0);
    Assert.assertTrue(metrics.getDnsLookupCost() >= 0);// cache
  }
View Full Code Here


 
  @Test
  public void getAddress() throws UnknownHostException {
    address = DNS.getAddress(host);
    Assert.assertNotNull(address);
    Metrics metrics = ThreadLocalMetricsRecorder.getInstance().captureMetrics();
    Assert.assertTrue(metrics.getDnsLookupCost() > 0);
  }
View Full Code Here

    DNS.CachedDNS cached = new DNS.CachedDNS();
    cached.cache(host, original);
    DNS.useCache(true);
    address = DNS.getAddress(host);
    Assert.assertNotNull(address);
    Metrics metrics = ThreadLocalMetricsRecorder.getInstance().captureMetrics();
    Assert.assertEquals(metrics.getDnsLookupCost(), 0);
  }
View Full Code Here

 
  @Test
  public void useConnectionPool() throws InterruptedException, IOException, URISyntaxException {
    client.useConnectionPool(false);
    Response response = client.get("http://www.baidu.com/");
    Metrics metrics = response.getMetrics();
    Assert.assertFalse(metrics.getConnectingCost() == 0);
  }
View Full Code Here

 
  @Test(dependsOnMethods = "useConnectionPool")
  public void useDNSCache() throws InterruptedException, IOException, URISyntaxException {
    client.useDNSCache(false);
    Response response = client.get("http://www.baidu.com/");
    Metrics metrics = response.getMetrics();
    Assert.assertTrue(metrics.getDnsLookupCost() > 0);
    Response response2 = client.get("http://www.baidu.com/img/baidu_logo.gif");
    Metrics metrics2 = response2.getMetrics();
    Assert.assertFalse(metrics2.equals(metrics));
    Assert.assertTrue(metrics2.getDnsLookupCost() > 0);
  }
View Full Code Here

TOP

Related Classes of com.google.code.http4j.utils.Metrics

Copyright © 2018 www.massapicom. 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.