提交 3cf2c044 编写于 作者: S Sam Brannen

URL Cleanup - polishing

See gh-22680
上级 c90b6ea0
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -50,7 +50,7 @@ public class SimpleNamespaceContextTests { ...@@ -50,7 +50,7 @@ public class SimpleNamespaceContextTests {
@Test @Test
public void getNamespaceURI() { public void getNamespaceURI() {
context.bindNamespaceUri(XMLConstants.XMLNS_ATTRIBUTE, additionalNamespaceUri); context.bindNamespaceUri(XMLConstants.XMLNS_ATTRIBUTE, additionalNamespaceUri);
assertThat("Always returns \"https://www.w3.org/2000/xmlns/\" for \"xmlns\"", assertThat("Always returns \"http://www.w3.org/2000/xmlns/\" for \"xmlns\"",
context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE), is(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)); context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE), is(XMLConstants.XMLNS_ATTRIBUTE_NS_URI));
context.bindNamespaceUri(XMLConstants.XML_NS_PREFIX, additionalNamespaceUri); context.bindNamespaceUri(XMLConstants.XML_NS_PREFIX, additionalNamespaceUri);
assertThat("Always returns \"http://www.w3.org/XML/1998/namespace\" for \"xml\"", assertThat("Always returns \"http://www.w3.org/XML/1998/namespace\" for \"xml\"",
...@@ -76,7 +76,7 @@ public class SimpleNamespaceContextTests { ...@@ -76,7 +76,7 @@ public class SimpleNamespaceContextTests {
@Test @Test
public void getPrefix() { public void getPrefix() {
assertThat("Always returns \"xmlns\" for \"https://www.w3.org/2000/xmlns/\"", assertThat("Always returns \"xmlns\" for \"http://www.w3.org/2000/xmlns/\"",
context.getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI), is(XMLConstants.XMLNS_ATTRIBUTE)); context.getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI), is(XMLConstants.XMLNS_ATTRIBUTE));
assertThat("Always returns \"xml\" for \"http://www.w3.org/XML/1998/namespace\"", assertThat("Always returns \"xml\" for \"http://www.w3.org/XML/1998/namespace\"",
context.getPrefix(XMLConstants.XML_NS_URI), is(XMLConstants.XML_NS_PREFIX)); context.getPrefix(XMLConstants.XML_NS_URI), is(XMLConstants.XML_NS_PREFIX));
...@@ -103,7 +103,7 @@ public class SimpleNamespaceContextTests { ...@@ -103,7 +103,7 @@ public class SimpleNamespaceContextTests {
@Test @Test
public void getPrefixes() { public void getPrefixes() {
assertThat("Returns only \"xmlns\" for \"https://www.w3.org/2000/xmlns/\"", assertThat("Returns only \"xmlns\" for \"http://www.w3.org/2000/xmlns/\"",
getItemSet(context.getPrefixes(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)), getItemSet(context.getPrefixes(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)),
is(makeSet(XMLConstants.XMLNS_ATTRIBUTE))); is(makeSet(XMLConstants.XMLNS_ATTRIBUTE)));
assertThat("Returns only \"xml\" for \"http://www.w3.org/XML/1998/namespace\"", assertThat("Returns only \"xml\" for \"http://www.w3.org/XML/1998/namespace\"",
......
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -43,7 +43,7 @@ import com.gargoylesoftware.htmlunit.WebRequest; ...@@ -43,7 +43,7 @@ import com.gargoylesoftware.htmlunit.WebRequest;
* *
* <pre class="code">WebRequestMatcher cdnMatcher = new HostMatcher("code.jquery.com:80");</pre> * <pre class="code">WebRequestMatcher cdnMatcher = new HostMatcher("code.jquery.com:80");</pre>
* *
* <p>The above {@code cdnMatcher} would match {@code "https://code.jquery.com/jquery.js"} * <p>The above {@code cdnMatcher} would match {@code "http://code.jquery.com/jquery.js"}
* which has a default port of {@code 80} and {@code "http://code.jquery.com:80/jquery.js"}. * which has a default port of {@code 80} and {@code "http://code.jquery.com:80/jquery.js"}.
* However, it would not match {@code "https://code.jquery.com/jquery.js"} * However, it would not match {@code "https://code.jquery.com/jquery.js"}
* which has a default port of {@code 443}. * which has a default port of {@code 443}.
......
...@@ -31,14 +31,14 @@ public class HostRequestMatcherTests extends AbstractWebRequestMatcherTests { ...@@ -31,14 +31,14 @@ public class HostRequestMatcherTests extends AbstractWebRequestMatcherTests {
public void localhost() throws Exception { public void localhost() throws Exception {
WebRequestMatcher matcher = new HostRequestMatcher("localhost"); WebRequestMatcher matcher = new HostRequestMatcher("localhost");
assertMatches(matcher, "http://localhost/jquery-1.11.0.min.js"); assertMatches(matcher, "http://localhost/jquery-1.11.0.min.js");
assertDoesNotMatch(matcher, "https://example.com/jquery-1.11.0.min.js"); assertDoesNotMatch(matcher, "http://example.com/jquery-1.11.0.min.js");
} }
@Test @Test
public void multipleHosts() throws Exception { public void multipleHosts() throws Exception {
WebRequestMatcher matcher = new HostRequestMatcher("localhost", "example.com"); WebRequestMatcher matcher = new HostRequestMatcher("localhost", "example.com");
assertMatches(matcher, "http://localhost/jquery-1.11.0.min.js"); assertMatches(matcher, "http://localhost/jquery-1.11.0.min.js");
assertMatches(matcher, "https://example.com/jquery-1.11.0.min.js"); assertMatches(matcher, "http://example.com/jquery-1.11.0.min.js");
} }
@Test @Test
......
...@@ -441,7 +441,7 @@ public class ForwardedHeaderFilterTests { ...@@ -441,7 +441,7 @@ public class ForwardedHeaderFilterTests {
this.request.addHeader(X_FORWARDED_HOST, "example.com"); this.request.addHeader(X_FORWARDED_HOST, "example.com");
this.request.addHeader(X_FORWARDED_PORT, "443"); this.request.addHeader(X_FORWARDED_PORT, "443");
String location = "https://weibo.com/otherinfo/foo/bar"; String location = "https://other.info/foo/bar";
String redirectedUrl = sendRedirect(location); String redirectedUrl = sendRedirect(location);
assertEquals(location, redirectedUrl); assertEquals(location, redirectedUrl);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册