MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / sameFile

Method sameFile

src/test/java/org/htmlunit/util/UrlUtilsTest.java:551–591  ·  view source on GitHub ↗

@throws Exception if the test fails

()

Source from the content-addressed store, hash-verified

549 * @throws Exception if the test fails
550 */
551 @Test
552 public void sameFile() throws Exception {
553 assertTrue(UrlUtils.sameFile(null, null));
554 assertFalse(UrlUtils.sameFile(new URL("http://localhost/bug.htm"), null));
555 assertFalse(UrlUtils.sameFile(null, new URL("http://localhost/bug.html")));
556
557 assertTrue(UrlUtils.sameFile(new URL("http://localhost/bug.html"), new URL("http://localhost/bug.html")));
558 assertFalse(UrlUtils.sameFile(new URL("http://localhost/bug.htm"), new URL("http://localhost/bug.html")));
559
560 // assertTrue(new URL("http://localhost/bug.html").sameFile(new URL("http://localhost/test/../bug.html")));
561 assertTrue(UrlUtils.sameFile(new URL("http://localhost/bug.html"),
562 new URL("http://localhost/test/../bug.html")));
563
564 assertTrue(UrlUtils.sameFile(new URL("http://localhost"), new URL("http://localhost")));
565 assertTrue(UrlUtils.sameFile(new URL("http://localhost/"), new URL("http://localhost/")));
566 assertTrue(UrlUtils.sameFile(new URL("http://localhost/"), new URL("http://localhost")));
567
568 assertTrue(UrlUtils.sameFile(new URL("http://localhost/bug.html?test"),
569 new URL("http://localhost/bug.html?test")));
570 assertFalse(UrlUtils.sameFile(new URL("http://localhost/bug.html?test"),
571 new URL("http://localhost/bug.html?rest")));
572
573 assertTrue(UrlUtils.sameFile(new URL("http://localhost/bug.html#test"),
574 new URL("http://localhost/bug.html#rest")));
575
576 assertTrue(UrlUtils.sameFile(new URL("https://localhost/bug.html"), new URL("https://localhost/bug.html")));
577 assertFalse(UrlUtils.sameFile(new URL("http://localhost/bug.htm"), new URL("https://localhost/bug.html")));
578
579 assertTrue(UrlUtils.sameFile(new URL("http://localhost:81/bug.html"), new URL("http://localhost:81/bug.html")));
580 assertFalse(UrlUtils.sameFile(new URL("http://localhost:81/bug.htm"), new URL("http://localhost:80/bug.html")));
581 assertTrue(UrlUtils.sameFile(new URL("http://localhost/bug.html"), new URL("http://localhost:80/bug.html")));
582 assertTrue(UrlUtils.sameFile(new URL("https://localhost:443/bug.html"), new URL("https://localhost/bug.html")));
583
584 // issue #1787
585 // final URL u1 = new URL("http://sourceforge.net/");
586 // final URL u2 = new URL("http://ch3.sourceforge.net/");
587 final URL u1 = new URL("http://htmlunit-dev.org/");
588 final URL u2 = new URL("http://host1.htmlunit-dev.org/");
589 assertEquals(InetAddress.getByName(u1.getHost()), InetAddress.getByName(u2.getHost()));
590 assertFalse(UrlUtils.sameFile(u1, u2));
591 }
592
593 /**
594 * @throws Exception if the test fails

Callers

nothing calls this directly

Calls 5

sameFileMethod · 0.95
getHostMethod · 0.95
assertTrueMethod · 0.80
assertFalseMethod · 0.80
assertEqualsMethod · 0.45

Tested by

no test coverage detected