Simplify code in spring-test by using Collections.addAll
Closes gh-24555
This commit is contained in:
parent
e029dbf607
commit
7528b9487d
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2020 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.
|
||||||
|
@ -22,6 +22,7 @@ import java.net.URLDecoder;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -291,9 +292,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||||
|
|
||||||
Cookie[] parentCookies = request.getCookies();
|
Cookie[] parentCookies = request.getCookies();
|
||||||
if (parentCookies != null) {
|
if (parentCookies != null) {
|
||||||
for (Cookie cookie : parentCookies) {
|
Collections.addAll(cookies, parentCookies);
|
||||||
cookies.add(cookie);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ObjectUtils.isEmpty(cookies)) {
|
if (!ObjectUtils.isEmpty(cookies)) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2020 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.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.test.web.servlet.htmlunit;
|
package org.springframework.test.web.servlet.htmlunit;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.gargoylesoftware.htmlunit.WebClient;
|
import com.gargoylesoftware.htmlunit.WebClient;
|
||||||
|
@ -118,9 +119,7 @@ public abstract class MockMvcWebConnectionBuilderSupport<T extends MockMvcWebCon
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public T useMockMvc(WebRequestMatcher... matchers) {
|
public T useMockMvc(WebRequestMatcher... matchers) {
|
||||||
for (WebRequestMatcher matcher : matchers) {
|
Collections.addAll(this.requestMatchers, matchers);
|
||||||
this.requestMatchers.add(matcher);
|
|
||||||
}
|
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue