Package com.google.collide.client.xhrmonitor.XhrWarden

Examples of com.google.collide.client.xhrmonitor.XhrWarden.WardenXhrRequest


  /**
   * Creates a mock request but does not automatically replay it!
   */
  private static WardenXhrRequest createRequest(int id, double timestamp) {
    WardenXhrRequest request = EasyMock.createNiceMock(WardenXhrRequest.class);
    expect(request.getId()).andReturn(String.valueOf(id)).anyTimes();
    expect(request.getTime()).andReturn(timestamp).anyTimes();
    return request;
  }
View Full Code Here


   */
  private static List<WardenXhrRequest> createMultipleRequests(
      int number, int startid, int timestamp) {
    List<WardenXhrRequest> requests = new ArrayList<WardenXhrRequest>();
    for (int i = 0; i < number; i++) {
      WardenXhrRequest request = createRequest(startid++, timestamp++);
      replay(request);
      requests.add(request);
    }
    return requests;
  }
View Full Code Here

    // This will cause another log to the listener
    warden.onRequestOpening(requests.get(TEST_WARNING_LIMIT - 1));
    warden.onRequestOpen(requests.get(TEST_WARNING_LIMIT - 1));

    // This should not trigger another warning since we are still over the limit
    WardenXhrRequest lastRequest = createRequest(TEST_WARNING_LIMIT, TEST_WARNING_LIMIT);
    replay(lastRequest);
    warden.onRequestOpen(lastRequest);

    assertEquals(TEST_WARNING_LIMIT, warden.getRequestCount());
    verify(listener);
View Full Code Here

    verify(listener);
  }

  public void testErrorsAreIssuedWhenRequestHitRequestLimit() {
    List<WardenXhrRequest> requests = createMultipleRequests(TEST_ERROR_LIMIT, 2, 2);
    WardenXhrRequest killedRequest = createRequest(1, 1);
    killedRequest.kill();
    replay(killedRequest);

    // Mock up listener behavior
    listener.onWarning(warden);
    listener.onEmergency(warden, killedRequest);
View Full Code Here

    XMLHttpRequest mockXHR = EasyMock.createMock(XMLHttpRequest.class);
    mockXHR.setRequestHeader("X-Test", "test");
    replay(mockXHR);
   
    WardenXhrRequest request = createRequest(1, 1);
    expect(request.getRequest()).andReturn(mockXHR).anyTimes();
    replay(request);
   
    warden.addCustomHeader("X-Test", "test");
    warden.onRequestOpen(request);
   
View Full Code Here

TOP

Related Classes of com.google.collide.client.xhrmonitor.XhrWarden.WardenXhrRequest

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.