提交 41b3d6ab 编写于 作者: S Sam Brannen

URL Cleanup - Fix broken tests

See gh-22676
上级 a7254ce7
/* /*
* Copyright 2002-2010 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.
...@@ -74,7 +74,7 @@ public abstract class AbstractMarshallerTests { ...@@ -74,7 +74,7 @@ public abstract class AbstractMarshallerTests {
marshaller.marshal(flights, domResult); marshaller.marshal(flights, domResult);
Document expected = builder.newDocument(); Document expected = builder.newDocument();
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights"); Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns"); Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
namespace.setNodeValue("http://samples.springframework.org/flight"); namespace.setNodeValue("http://samples.springframework.org/flight");
flightsElement.setAttributeNode(namespace); flightsElement.setAttributeNode(namespace);
expected.appendChild(flightsElement); expected.appendChild(flightsElement);
...@@ -98,7 +98,7 @@ public abstract class AbstractMarshallerTests { ...@@ -98,7 +98,7 @@ public abstract class AbstractMarshallerTests {
Document result = (Document) domResult.getNode(); Document result = (Document) domResult.getNode();
Document expected = builder.newDocument(); Document expected = builder.newDocument();
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights"); Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns"); Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
namespace.setNodeValue("http://samples.springframework.org/flight"); namespace.setNodeValue("http://samples.springframework.org/flight");
flightsElement.setAttributeNode(namespace); flightsElement.setAttributeNode(namespace);
expected.appendChild(flightsElement); expected.appendChild(flightsElement);
......
/* /*
* Copyright 2002-2015 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.
...@@ -79,7 +79,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests { ...@@ -79,7 +79,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
*/ */
private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + private static final String XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + "<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xmlns:java=\"https://java.sun.com\"" + " xmlns:java=\"http://java.sun.com\"" +
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" + " xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>"; "<name>test</name><value>8</value></castor-object></objects>";
...@@ -94,7 +94,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests { ...@@ -94,7 +94,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
*/ */
private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + private static final String ROOT_WITH_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + "<objects xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xmlns:java=\"https://java.sun.com\"" + " xmlns:java=\"http://java.sun.com\"" +
" xsi:type=\"java:java.util.Arrays$ArrayList\">" + " xsi:type=\"java:java.util.Arrays$ArrayList\">" +
"<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" + "<castor-object xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>"; "<name>test</name><value>8</value></castor-object></objects>";
...@@ -104,7 +104,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests { ...@@ -104,7 +104,7 @@ public class CastorMarshallerTests extends AbstractMarshallerTests {
*/ */
private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + private static final String ROOT_WITHOUT_XSI_EXPECTED_STRING = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + "<objects><castor-object xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
" xmlns:java=\"https://java.sun.com\"" + " xmlns:java=\"http://java.sun.com\"" +
" xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" + " xsi:type=\"java:org.springframework.oxm.castor.CastorObject\">" +
"<name>test</name><value>8</value></castor-object></objects>"; "<name>test</name><value>8</value></castor-object></objects>";
......
/* /*
* Copyright 2002-2013 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.
...@@ -77,9 +77,9 @@ public class Jaxb2UnmarshallerTests extends AbstractUnmarshallerTests { ...@@ -77,9 +77,9 @@ public class Jaxb2UnmarshallerTests extends AbstractUnmarshallerTests {
given(mimeContainer.getAttachment("<99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws>")).willReturn(dataHandler); given(mimeContainer.getAttachment("<99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws>")).willReturn(dataHandler);
given(mimeContainer.getAttachment("696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png")).willReturn(dataHandler); given(mimeContainer.getAttachment("696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png")).willReturn(dataHandler);
String content = "<binaryObject xmlns='http://springframework.org/spring-ws'>" + "<bytes>" + String content = "<binaryObject xmlns='http://springframework.org/spring-ws'>" + "<bytes>" +
"<xop:Include href='cid:6b76528d-7a9c-4def-8e13-095ab89e9bb7@http://springframework.org/spring-ws' xmlns:xop='https://www.w3.org/2004/08/xop/include'/>" + "<xop:Include href='cid:6b76528d-7a9c-4def-8e13-095ab89e9bb7@http://springframework.org/spring-ws' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
"</bytes>" + "<dataHandler>" + "</bytes>" + "<dataHandler>" +
"<xop:Include href='cid:99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws' xmlns:xop='https://www.w3.org/2004/08/xop/include'/>" + "<xop:Include href='cid:99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
"</dataHandler>" + "</dataHandler>" +
"<swaDataHandler>696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png</swaDataHandler>" + "<swaDataHandler>696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png</swaDataHandler>" +
"</binaryObject>"; "</binaryObject>";
......
/* /*
* Copyright 2002-2014 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.
...@@ -57,6 +57,7 @@ public class ServletServerHttpRequestTests { ...@@ -57,6 +57,7 @@ public class ServletServerHttpRequestTests {
@Test @Test
public void getURI() throws Exception { public void getURI() throws Exception {
URI uri = new URI("https://example.com/path?query"); URI uri = new URI("https://example.com/path?query");
mockRequest.setScheme(uri.getScheme());
mockRequest.setServerName(uri.getHost()); mockRequest.setServerName(uri.getHost());
mockRequest.setServerPort(uri.getPort()); mockRequest.setServerPort(uri.getPort());
mockRequest.setRequestURI(uri.getPath()); mockRequest.setRequestURI(uri.getPath());
......
/* /*
* Copyright 2002-2012 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.
...@@ -58,6 +58,7 @@ public class RequestPartServletServerHttpRequestTests { ...@@ -58,6 +58,7 @@ public class RequestPartServletServerHttpRequestTests {
@Test @Test
public void getURI() throws Exception { public void getURI() throws Exception {
URI uri = new URI("https://example.com/path?query"); URI uri = new URI("https://example.com/path?query");
mockRequest.setScheme("https");
mockRequest.setServerName(uri.getHost()); mockRequest.setServerName(uri.getHost());
mockRequest.setServerPort(uri.getPort()); mockRequest.setServerPort(uri.getPort());
mockRequest.setRequestURI(uri.getPath()); mockRequest.setRequestURI(uri.getPath());
......
/* /*
* Copyright 2002-2014 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.
...@@ -41,8 +41,8 @@ public class UriComponentsBuilderTests { ...@@ -41,8 +41,8 @@ public class UriComponentsBuilderTests {
@Test @Test
public void plain() throws URISyntaxException { public void plain() throws URISyntaxException {
UriComponentsBuilder builder = UriComponentsBuilder.newInstance(); UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
UriComponents result = builder.scheme("http").host("example.com").path("foo").queryParam("bar").fragment("baz").build(); UriComponents result = builder.scheme("https").host("example.com").path("foo").queryParam("bar").fragment("baz").build();
assertEquals("http", result.getScheme()); assertEquals("https", result.getScheme());
assertEquals("example.com", result.getHost()); assertEquals("example.com", result.getHost());
assertEquals("foo", result.getPath()); assertEquals("foo", result.getPath());
assertEquals("bar", result.getQuery()); assertEquals("bar", result.getQuery());
...@@ -54,18 +54,18 @@ public class UriComponentsBuilderTests { ...@@ -54,18 +54,18 @@ public class UriComponentsBuilderTests {
@Test @Test
public void multipleFromSameBuilder() throws URISyntaxException { public void multipleFromSameBuilder() throws URISyntaxException {
UriComponentsBuilder builder = UriComponentsBuilder.newInstance().scheme("http").host("example.com").pathSegment("foo"); UriComponentsBuilder builder = UriComponentsBuilder.newInstance().scheme("https").host("example.com").pathSegment("foo");
UriComponents result1 = builder.build(); UriComponents result1 = builder.build();
builder = builder.pathSegment("foo2").queryParam("bar").fragment("baz"); builder = builder.pathSegment("foo2").queryParam("bar").fragment("baz");
UriComponents result2 = builder.build(); UriComponents result2 = builder.build();
assertEquals("http", result1.getScheme()); assertEquals("https", result1.getScheme());
assertEquals("example.com", result1.getHost()); assertEquals("example.com", result1.getHost());
assertEquals("/foo", result1.getPath()); assertEquals("/foo", result1.getPath());
URI expected = new URI("https://example.com/foo"); URI expected = new URI("https://example.com/foo");
assertEquals("Invalid result URI", expected, result1.toUri()); assertEquals("Invalid result URI", expected, result1.toUri());
assertEquals("http", result2.getScheme()); assertEquals("https", result2.getScheme());
assertEquals("example.com", result2.getHost()); assertEquals("example.com", result2.getHost());
assertEquals("/foo/foo2", result2.getPath()); assertEquals("/foo/foo2", result2.getPath());
assertEquals("bar", result2.getQuery()); assertEquals("bar", result2.getQuery());
...@@ -97,7 +97,7 @@ public class UriComponentsBuilderTests { ...@@ -97,7 +97,7 @@ public class UriComponentsBuilderTests {
public void fromHierarchicalUri() throws URISyntaxException { public void fromHierarchicalUri() throws URISyntaxException {
URI uri = new URI("https://example.com/foo?bar#baz"); URI uri = new URI("https://example.com/foo?bar#baz");
UriComponents result = UriComponentsBuilder.fromUri(uri).build(); UriComponents result = UriComponentsBuilder.fromUri(uri).build();
assertEquals("http", result.getScheme()); assertEquals("https", result.getScheme());
assertEquals("example.com", result.getHost()); assertEquals("example.com", result.getHost());
assertEquals("/foo", result.getPath()); assertEquals("/foo", result.getPath());
assertEquals("bar", result.getQuery()); assertEquals("bar", result.getQuery());
...@@ -131,7 +131,7 @@ public class UriComponentsBuilderTests { ...@@ -131,7 +131,7 @@ public class UriComponentsBuilderTests {
@Test @Test
public void fromUriString() { public void fromUriString() {
UriComponents result = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc3986.txt").build(); UriComponents result = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc3986.txt").build();
assertEquals("http", result.getScheme()); assertEquals("https", result.getScheme());
assertNull(result.getUserInfo()); assertNull(result.getUserInfo());
assertEquals("www.ietf.org", result.getHost()); assertEquals("www.ietf.org", result.getHost());
assertEquals(-1, result.getPort()); assertEquals(-1, result.getPort());
...@@ -143,7 +143,7 @@ public class UriComponentsBuilderTests { ...@@ -143,7 +143,7 @@ public class UriComponentsBuilderTests {
result = UriComponentsBuilder.fromUriString( result = UriComponentsBuilder.fromUriString(
"https://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)") "https://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)")
.build(); .build();
assertEquals("http", result.getScheme()); assertEquals("https", result.getScheme());
assertEquals("arjen:foobar", result.getUserInfo()); assertEquals("arjen:foobar", result.getUserInfo());
assertEquals("java.sun.com", result.getHost()); assertEquals("java.sun.com", result.getHost());
assertEquals(80, result.getPort()); assertEquals(80, result.getPort());
......
/* /*
* Copyright 2002-2008 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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册