|
5 | 5 | import net.lightbody.bmp.core.har.HarEntry;
|
6 | 6 | import net.lightbody.bmp.core.har.HarLog;
|
7 | 7 | import net.lightbody.bmp.core.har.HarNameValuePair;
|
8 |
| -import net.lightbody.bmp.core.har.HarNameVersion; |
9 | 8 | import net.lightbody.bmp.core.har.HarPage;
|
10 | 9 | import net.lightbody.bmp.core.har.HarPageTimings;
|
11 | 10 | import net.lightbody.bmp.core.har.HarPostData;
|
12 | 11 | import net.lightbody.bmp.core.har.HarRequest;
|
13 | 12 | import net.lightbody.bmp.core.har.HarResponse;
|
14 |
| -import net.lightbody.bmp.core.har.HarTimings; |
15 | 13 | import net.lightbody.bmp.proxy.test.util.LocalServerTest;
|
16 | 14 | import net.lightbody.bmp.proxy.util.IOUtils;
|
17 | 15 | import org.apache.http.HttpEntity;
|
|
20 | 18 | import org.apache.http.client.methods.HttpPost;
|
21 | 19 | import org.apache.http.entity.StringEntity;
|
22 | 20 | import org.apache.http.message.BasicNameValuePair;
|
23 |
| -import org.apache.http.util.EntityUtils; |
24 | 21 | import org.junit.Test;
|
25 | 22 |
|
26 | 23 | import java.io.ByteArrayOutputStream;
|
|
30 | 27 | import java.util.Collections;
|
31 | 28 | import java.util.List;
|
32 | 29 | import java.util.Random;
|
33 |
| -import java.util.concurrent.TimeUnit; |
34 | 30 | import java.util.zip.GZIPInputStream;
|
35 | 31 |
|
36 | 32 | import static org.hamcrest.Matchers.containsString;
|
@@ -285,82 +281,6 @@ public void testThatGzippedContentIsProperlyCapturedInHar() throws IOException,
|
285 | 281 | assertEquals("Text not matched", "this is a.txt", text);
|
286 | 282 | }
|
287 | 283 |
|
288 |
| - @Test |
289 |
| - public void testHarTimingsPopulated() throws IOException, InterruptedException { |
290 |
| - proxy.setCaptureHeaders(true); |
291 |
| - proxy.newHar("testHarTimingsPopulated"); |
292 |
| - |
293 |
| - HttpGet httpGet = new HttpGet("https://www.msn.com"); |
294 |
| - EntityUtils.consumeQuietly(client.execute(httpGet).getEntity()); |
295 |
| - |
296 |
| - Thread.sleep(500); |
297 |
| - Har har = proxy.getHar(); |
298 |
| - assertNotNull("Har is null", har); |
299 |
| - HarLog log = har.getLog(); |
300 |
| - assertNotNull("Log is null", log); |
301 |
| - |
302 |
| - assertNotNull("No log entries", log.getEntries()); |
303 |
| - assertThat("No log entries", log.getEntries(), not(empty())); |
304 |
| - |
305 |
| - HarEntry firstEntry = log.getEntries().get(0); |
306 |
| - HarTimings timings = firstEntry.getTimings(); |
307 |
| - |
308 |
| - assertNotNull("No har timings", timings); |
309 |
| - assertThat("blocked timing should be greater than 0", timings.getBlocked(TimeUnit.NANOSECONDS), greaterThan(0L)); |
310 |
| - assertThat("dns timing should be greater than 0", timings.getDns(TimeUnit.NANOSECONDS), greaterThan(0L)); |
311 |
| - assertThat("connect timing should be greater than 0", timings.getConnect(TimeUnit.NANOSECONDS), greaterThan(0L)); |
312 |
| - assertThat("send timing should be greater than 0", timings.getSend(TimeUnit.NANOSECONDS), greaterThan(0L)); |
313 |
| - assertThat("wait timing should be greater than 0", timings.getWait(TimeUnit.NANOSECONDS), greaterThan(0L)); |
314 |
| - assertThat("receive timing should be greater than 0", timings.getReceive(TimeUnit.NANOSECONDS), greaterThan(0L)); |
315 |
| - assertThat("ssl timing should be greater than 0", timings.getSsl(TimeUnit.NANOSECONDS), greaterThan(0L)); |
316 |
| - } |
317 |
| - |
318 |
| - @Test |
319 |
| - public void testChunkedRequestSizeAndSendTimingPopulated() throws IOException, InterruptedException { |
320 |
| - proxy.setCaptureContent(true); |
321 |
| - proxy.newHar("testChunkedRequestSizeAndSendTimingPopulated"); |
322 |
| - |
323 |
| - // using this POST dumping ground so that we get a "reasonable" send time. using the server at localhost |
324 |
| - // may not actually take more than 1ms. that would cause the send time to be 0ms, which would be indistinguishable |
325 |
| - // for testing purposes from a failed-to--populate-send-time error condition. |
326 |
| - // thanks to Henry Cipolla for creating this POST testing website! |
327 |
| - HttpPost post = new HttpPost("http://posttestserver.com/"); |
328 |
| - |
329 |
| - // fill the POST data with some random ascii text |
330 |
| - String lengthyPost = createRandomString(30000); |
331 |
| - |
332 |
| - HttpEntity entity = new StringEntity(lengthyPost); |
333 |
| - post.setEntity(entity); |
334 |
| - post.addHeader("Content-Type", "text/unknown; charset=UTF-8"); |
335 |
| - |
336 |
| - String body = IOUtils.toStringAndClose(client.execute(post).getEntity().getContent()); |
337 |
| - |
338 |
| - Thread.sleep(500); |
339 |
| - Har har = proxy.getHar(); |
340 |
| - assertNotNull("Har is null", har); |
341 |
| - HarLog log = har.getLog(); |
342 |
| - assertNotNull("Log is null", log); |
343 |
| - |
344 |
| - assertNotNull("No log entries", log.getEntries()); |
345 |
| - assertThat("No log entries", log.getEntries(), not(empty())); |
346 |
| - |
347 |
| - HarEntry firstEntry = log.getEntries().get(0); |
348 |
| - HarTimings timings = firstEntry.getTimings(); |
349 |
| - |
350 |
| - HarResponse response = firstEntry.getResponse(); |
351 |
| - assertNotNull("Response is null", response); |
352 |
| - HarRequest request = firstEntry.getRequest(); |
353 |
| - assertNotNull("Request is null", request); |
354 |
| - HarPostData postdata = request.getPostData(); |
355 |
| - assertNotNull("PostData is null", postdata); |
356 |
| - |
357 |
| - assertEquals("Expected body size to match POST length", lengthyPost.length(), request.getBodySize()); |
358 |
| - |
359 |
| - assertNotNull("No har timings", timings); |
360 |
| - |
361 |
| - assertThat("send timing should be greater than 0", timings.getSend(TimeUnit.NANOSECONDS), greaterThan(0L)); |
362 |
| - } |
363 |
| - |
364 | 284 | @Test
|
365 | 285 | public void testHarPagesPopulated() throws IOException, InterruptedException {
|
366 | 286 | proxy.newHar("testpage1");
|
@@ -439,120 +359,6 @@ public void testHarPageTitlePopulated() throws Exception {
|
439 | 359 | assertEquals("incorrect har page title", "Test Page 2", page2.getTitle());
|
440 | 360 | }
|
441 | 361 |
|
442 |
| - @Test |
443 |
| - public void testEntryFieldsPopulatedForHttp() throws IOException, InterruptedException { |
444 |
| - proxy.newHar("testEntryFieldsPopulatedForHttp"); |
445 |
| - |
446 |
| - // not using localhost so we get >0ms timing |
447 |
| - HttpGet get = new HttpGet("http://www.msn.com"); |
448 |
| - IOUtils.toStringAndClose(client.execute(get).getEntity().getContent()); |
449 |
| - |
450 |
| - proxy.endPage(); |
451 |
| - |
452 |
| - Thread.sleep(500); |
453 |
| - Har firstPageHar = proxy.getHar(); |
454 |
| - assertNotNull("Har is null", firstPageHar); |
455 |
| - HarLog firstPageHarLog = firstPageHar.getLog(); |
456 |
| - assertNotNull("Log is null", firstPageHarLog); |
457 |
| - |
458 |
| - List<HarEntry> firstPageEntries = firstPageHarLog.getEntries(); |
459 |
| - assertNotNull("Entries are null", firstPageEntries); |
460 |
| - assertThat("Entries are empty", firstPageEntries, not(empty())); |
461 |
| - |
462 |
| - HarEntry firstPageEntry = firstPageHarLog.getEntries().get(0); |
463 |
| - assertNotEquals("entry time should be greater than 0 but was " + firstPageEntry.getTime(), firstPageEntry.getTime(), 0L); |
464 |
| - assertNotNull("entry startedDateTime is null", firstPageEntry.getStartedDateTime()); |
465 |
| - |
466 |
| - assertEquals("entry pageref is incorrect", "testEntryFieldsPopulatedForHttp", firstPageEntry.getPageref()); |
467 |
| - |
468 |
| - assertNotNull("entry ip address is not populated", firstPageEntry.getServerIPAddress()); |
469 |
| - |
470 |
| - // make a second request for the same page, and make sure the address is still populated |
471 |
| - proxy.newPage("testEntryFieldsPopulatedForHttp - page 2"); |
472 |
| - IOUtils.toStringAndClose(client.execute(get).getEntity().getContent()); |
473 |
| - |
474 |
| - proxy.endPage(); |
475 |
| - |
476 |
| - // this is technically the same HAR, but aliasing for clarity |
477 |
| - Har secondPageHar = proxy.getHar(); |
478 |
| - assertNotNull("Har is null", secondPageHar); |
479 |
| - HarLog secondPageHarLog = secondPageHar.getLog(); |
480 |
| - assertNotNull("Log is null", secondPageHarLog); |
481 |
| - |
482 |
| - List<HarEntry> secondPageEntries = secondPageHarLog.getEntries(); |
483 |
| - assertNotNull("Entries are null", secondPageEntries); |
484 |
| - assertThat("Entries are empty", secondPageEntries, not(empty())); |
485 |
| - |
486 |
| - HarEntry secondPageEntry = secondPageHarLog.getEntries().get(1); |
487 |
| - assertNotEquals("entry time should be greater than 0 but was " + secondPageEntry.getTime(), secondPageEntry.getTime(), 0L); |
488 |
| - assertNotNull("entry startedDateTime is null", secondPageEntry.getStartedDateTime()); |
489 |
| - |
490 |
| - assertEquals("entry pageref is incorrect", "testEntryFieldsPopulatedForHttp - page 2", secondPageEntry.getPageref()); |
491 |
| - |
492 |
| - // this fails on the jetty implementation, but it shouldn't |
493 |
| - if (Boolean.getBoolean("bmp.use.littleproxy")) { |
494 |
| - assertNotNull("entry ip address is not populated", secondPageEntry.getServerIPAddress()); |
495 |
| - assertEquals("expected ip address of first and second request to same host to be equal", firstPageEntry.getServerIPAddress(), secondPageEntry.getServerIPAddress()); |
496 |
| - } |
497 |
| - } |
498 |
| - |
499 |
| - @Test |
500 |
| - public void testEntryFieldsPopulatedForHttps() throws IOException, InterruptedException { |
501 |
| - proxy.newHar("testEntryFieldsPopulatedForHttps"); |
502 |
| - |
503 |
| - // not using localhost so we get >0ms timing |
504 |
| - HttpGet get = new HttpGet("https://www.msn.com"); |
505 |
| - IOUtils.toStringAndClose(client.execute(get).getEntity().getContent()); |
506 |
| - |
507 |
| - proxy.endPage(); |
508 |
| - |
509 |
| - Thread.sleep(500); |
510 |
| - Har firstPageHar = proxy.getHar(); |
511 |
| - assertNotNull("Har is null", firstPageHar); |
512 |
| - HarLog firstPageHarLog = firstPageHar.getLog(); |
513 |
| - assertNotNull("Log is null", firstPageHarLog); |
514 |
| - |
515 |
| - List<HarEntry> firstPageEntries = firstPageHarLog.getEntries(); |
516 |
| - assertNotNull("Entries are null", firstPageEntries); |
517 |
| - assertThat("Entries are empty", firstPageEntries, not(empty())); |
518 |
| - |
519 |
| - HarEntry firstPageEntry = firstPageHarLog.getEntries().get(0); |
520 |
| - assertNotEquals("entry time should be greater than 0 but was " + firstPageEntry.getTime(), firstPageEntry.getTime(), 0L); |
521 |
| - assertNotNull("entry startedDateTime is null", firstPageEntry.getStartedDateTime()); |
522 |
| - |
523 |
| - assertEquals("entry pageref is incorrect", "testEntryFieldsPopulatedForHttps", firstPageEntry.getPageref()); |
524 |
| - |
525 |
| - assertNotNull("entry ip address is not populated", firstPageEntry.getServerIPAddress()); |
526 |
| - |
527 |
| - // make a second request for the same page, and make sure the address is still populated |
528 |
| - proxy.newPage("testEntryFieldsPopulatedForHttps - page 2"); |
529 |
| - IOUtils.toStringAndClose(client.execute(get).getEntity().getContent()); |
530 |
| - |
531 |
| - proxy.endPage(); |
532 |
| - |
533 |
| - // this is technically the same HAR, but aliasing for clarity |
534 |
| - Har secondPageHar = proxy.getHar(); |
535 |
| - assertNotNull("Har is null", secondPageHar); |
536 |
| - HarLog secondPageHarLog = secondPageHar.getLog(); |
537 |
| - assertNotNull("Log is null", secondPageHarLog); |
538 |
| - |
539 |
| - List<HarEntry> secondPageEntries = secondPageHarLog.getEntries(); |
540 |
| - assertNotNull("Entries are null", secondPageEntries); |
541 |
| - assertThat("Entries are empty", secondPageEntries, not(empty())); |
542 |
| - |
543 |
| - HarEntry secondPageEntry = secondPageHarLog.getEntries().get(1); |
544 |
| - assertNotEquals("entry time should be greater than 0 but was " + secondPageEntry.getTime(), secondPageEntry.getTime(), 0L); |
545 |
| - assertNotNull("entry startedDateTime is null", secondPageEntry.getStartedDateTime()); |
546 |
| - |
547 |
| - assertEquals("entry pageref is incorrect", "testEntryFieldsPopulatedForHttps - page 2", secondPageEntry.getPageref()); |
548 |
| - |
549 |
| - // this fails on the jetty implementation, but it shouldn't |
550 |
| - if (Boolean.getBoolean("bmp.use.littleproxy")) { |
551 |
| - assertNotNull("entry ip address is not populated", secondPageEntry.getServerIPAddress()); |
552 |
| - assertEquals("expected ip address of first and second request to same host to be equal", firstPageEntry.getServerIPAddress(), secondPageEntry.getServerIPAddress()); |
553 |
| - } |
554 |
| - } |
555 |
| - |
556 | 362 | @Test
|
557 | 363 | public void testIpAddressPopulatedForLocalhost() throws IOException, InterruptedException {
|
558 | 364 | proxy.newHar("testIpAddressPopulated");
|
|
0 commit comments