Jakarta EE 9 migration
Upgrades many dependency declarations; removes old EJB 2.x support and outdated Servlet-based integrations (Commons FileUpload, FreeMarker JSP support, Tiles). Closes gh-22093 Closes gh-25354 Closes gh-26185 Closes gh-27423 See gh-27424
This commit is contained in:
@@ -39,7 +39,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* configure JNDI appropriately, so that {@code new InitialContext()}
|
||||
* will expose the required objects. Also usable for standalone applications,
|
||||
* e.g. for binding a JDBC DataSource to a well-known JNDI location, to be
|
||||
* able to use traditional Java EE data access code outside of a Java EE
|
||||
* able to use traditional Jakarta EE data access code outside of a Jakarta EE
|
||||
* container.
|
||||
*
|
||||
* <p>There are various choices for DataSource implementations:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* <p>Useful for setting up a simple JNDI environment for test suites
|
||||
* or stand-alone applications. If, for example, JDBC DataSources get bound to the
|
||||
* same JNDI names as within a Java EE container, both application code and
|
||||
* same JNDI names as within a Jakarta EE container, both application code and
|
||||
* configuration can be reused without changes.
|
||||
*/
|
||||
@NonNullApi
|
||||
|
||||
@@ -19,13 +19,13 @@ package org.springframework.mock.web;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import jakarta.servlet.ReadListener;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Delegating implementation of {@link javax.servlet.ServletInputStream}.
|
||||
* Delegating implementation of {@link jakarta.servlet.ServletInputStream}.
|
||||
*
|
||||
* <p>Used by {@link MockHttpServletRequest}; typically not directly
|
||||
* used for testing application controllers.
|
||||
|
||||
@@ -19,13 +19,13 @@ package org.springframework.mock.web;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.WriteListener;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.WriteListener;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Delegating implementation of {@link javax.servlet.ServletOutputStream}.
|
||||
* Delegating implementation of {@link jakarta.servlet.ServletOutputStream}.
|
||||
*
|
||||
* <p>Used by {@link MockHttpServletResponse}; typically not directly
|
||||
* used for testing application controllers.
|
||||
|
||||
@@ -20,15 +20,15 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.AsyncEvent;
|
||||
import javax.servlet.AsyncListener;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.AsyncEvent;
|
||||
import jakarta.servlet.AsyncListener;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import javax.servlet.jsp.tagext.BodyContent;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.jsp.JspWriter;
|
||||
import jakarta.servlet.jsp.tagext.BodyContent;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.jsp.tagext.BodyContent} class.
|
||||
* Mock implementation of the {@link jakarta.servlet.jsp.tagext.BodyContent} class.
|
||||
* Only necessary for testing applications when testing custom JSP tags.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.time.DateTimeException;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
|
||||
|
||||
/**
|
||||
* Mock implementation of the JSP 2.0 {@link javax.servlet.jsp.el.ExpressionEvaluator}
|
||||
* interface, delegating to the Apache JSTL {@link ExpressionEvaluatorManager}.
|
||||
* Only necessary for testing applications when testing custom JSP tags.
|
||||
*
|
||||
* <p>Note that the Apache JSTL implementation (jstl.jar, standard.jar) has to be
|
||||
* available on the classpath to use this expression evaluator.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.1.5
|
||||
* @see org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MockExpressionEvaluator extends javax.servlet.jsp.el.ExpressionEvaluator {
|
||||
|
||||
private final PageContext pageContext;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new MockExpressionEvaluator for the given PageContext.
|
||||
* @param pageContext the JSP PageContext to run in
|
||||
*/
|
||||
public MockExpressionEvaluator(PageContext pageContext) {
|
||||
this.pageContext = pageContext;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public javax.servlet.jsp.el.Expression parseExpression(final String expression, final Class expectedType,
|
||||
final javax.servlet.jsp.el.FunctionMapper functionMapper) throws javax.servlet.jsp.el.ELException {
|
||||
|
||||
return new javax.servlet.jsp.el.Expression() {
|
||||
@Override
|
||||
public Object evaluate(javax.servlet.jsp.el.VariableResolver variableResolver) throws javax.servlet.jsp.el.ELException {
|
||||
return doEvaluate(expression, expectedType, functionMapper);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object evaluate(String expression, Class expectedType, javax.servlet.jsp.el.VariableResolver variableResolver,
|
||||
javax.servlet.jsp.el.FunctionMapper functionMapper) throws javax.servlet.jsp.el.ELException {
|
||||
|
||||
return doEvaluate(expression, expectedType, functionMapper);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected Object doEvaluate(String expression, Class expectedType, javax.servlet.jsp.el.FunctionMapper functionMapper)
|
||||
throws javax.servlet.jsp.el.ELException {
|
||||
|
||||
try {
|
||||
return ExpressionEvaluatorManager.evaluate("JSP EL expression", expression, expectedType, this.pageContext);
|
||||
}
|
||||
catch (JspException ex) {
|
||||
throw new javax.servlet.jsp.el.ELException("Parsing of JSP EL expression \"" + expression + "\" failed", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,20 +22,20 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.Servlet;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.FilterChain} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.FilterChain} interface.
|
||||
*
|
||||
* <p>A {@link MockFilterChain} can be configured with one or more filters and a
|
||||
* Servlet to invoke. The first time the chain is called, it invokes all filters
|
||||
|
||||
@@ -21,17 +21,17 @@ import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.FilterConfig} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.FilterConfig} interface.
|
||||
*
|
||||
* <p>Used for testing the web framework; also useful for testing
|
||||
* custom {@link javax.servlet.Filter} implementations.
|
||||
* custom {@link jakarta.servlet.Filter} implementations.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 1.0.2
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import javax.servlet.http.HttpServletMapping;
|
||||
import javax.servlet.http.MappingMatch;
|
||||
import jakarta.servlet.http.HttpServletMapping;
|
||||
import jakarta.servlet.http.MappingMatch;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
||||
@@ -43,20 +43,20 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpUpgradeHandler;
|
||||
import javax.servlet.http.Part;
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpUpgradeHandler;
|
||||
import jakarta.servlet.http.Part;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -71,7 +71,7 @@ import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.http.HttpServletRequest} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.http.HttpServletRequest} interface.
|
||||
*
|
||||
* <p>The default, preferred {@link Locale} for the <em>server</em> mocked by this request
|
||||
* is {@link Locale#ENGLISH}. This value can be changed via {@link #addPreferredLocale}
|
||||
@@ -820,7 +820,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
* <p>In contrast to the Servlet specification, this mock implementation
|
||||
* does <strong>not</strong> take into consideration any locales
|
||||
* specified via the {@code Accept-Language} header.
|
||||
* @see javax.servlet.ServletRequest#getLocale()
|
||||
* @see jakarta.servlet.ServletRequest#getLocale()
|
||||
* @see #addPreferredLocale(Locale)
|
||||
* @see #setPreferredLocales(List)
|
||||
*/
|
||||
@@ -838,7 +838,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
* <p>In contrast to the Servlet specification, this mock implementation
|
||||
* does <strong>not</strong> take into consideration any locales
|
||||
* specified via the {@code Accept-Language} header.
|
||||
* @see javax.servlet.ServletRequest#getLocales()
|
||||
* @see jakarta.servlet.ServletRequest#getLocales()
|
||||
* @see #addPreferredLocale(Locale)
|
||||
* @see #setPreferredLocales(List)
|
||||
*/
|
||||
@@ -861,7 +861,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
/**
|
||||
* Return {@code true} if the {@link #setSecure secure} flag has been set
|
||||
* to {@code true} or if the {@link #getScheme scheme} is {@code https}.
|
||||
* @see javax.servlet.ServletRequest#isSecure()
|
||||
* @see jakarta.servlet.ServletRequest#isSecure()
|
||||
*/
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
|
||||
@@ -38,9 +38,9 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -51,7 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.http.HttpServletResponse} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.http.HttpServletResponse} interface.
|
||||
*
|
||||
* <p>As of Spring Framework 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
|
||||
*
|
||||
@@ -383,7 +383,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
|
||||
@Override
|
||||
public void setLocale(@Nullable Locale locale) {
|
||||
// Although the Javadoc for javax.servlet.ServletResponse.setLocale(Locale) does not
|
||||
// Although the Javadoc for jakarta.servlet.ServletResponse.setLocale(Locale) does not
|
||||
// state how a null value for the supplied Locale should be handled, both Tomcat and
|
||||
// Jetty simply ignore a null value. So we do the same here.
|
||||
if (locale == null) {
|
||||
|
||||
@@ -25,17 +25,17 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionBindingEvent;
|
||||
import javax.servlet.http.HttpSessionBindingListener;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpSessionBindingEvent;
|
||||
import jakarta.servlet.http.HttpSessionBindingListener;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.http.HttpSession} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.http.HttpSession} interface.
|
||||
*
|
||||
* <p>As of Spring 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
|
||||
*
|
||||
@@ -149,7 +149,7 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
|
||||
@Override
|
||||
public javax.servlet.http.HttpSessionContext getSessionContext() {
|
||||
public jakarta.servlet.http.HttpSessionContext getSessionContext() {
|
||||
throw new UnsupportedOperationException("getSessionContext");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.jsp.JspWriter;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.jsp.JspWriter} class.
|
||||
* Mock implementation of the {@link jakarta.servlet.jsp.JspWriter} class.
|
||||
* Only necessary for testing applications when testing custom JSP tags.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.Part;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.Part;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,24 +24,24 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.jsp.JspWriter;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import jakarta.el.ELContext;
|
||||
import jakarta.servlet.Servlet;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.jsp.JspWriter;
|
||||
import jakarta.servlet.jsp.PageContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.jsp.PageContext} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.jsp.PageContext} interface.
|
||||
* Only necessary for testing applications when testing custom JSP tags.
|
||||
*
|
||||
* <p>Note: Expects initialization via the constructor rather than via the
|
||||
@@ -293,8 +293,9 @@ public class MockPageContext extends PageContext {
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() {
|
||||
return new MockExpressionEvaluator(this);
|
||||
@Nullable
|
||||
public jakarta.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -306,7 +307,7 @@ public class MockPageContext extends PageContext {
|
||||
@Override
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public javax.servlet.jsp.el.VariableResolver getVariableResolver() {
|
||||
public jakarta.servlet.jsp.el.VariableResolver getVariableResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.servlet.http.Part;
|
||||
import jakarta.servlet.http.Part;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -30,7 +30,7 @@ import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@code javax.servlet.http.Part}.
|
||||
* Mock implementation of {@code jakarta.servlet.http.Part}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponseWrapper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.RequestDispatcher} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.RequestDispatcher} interface.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -21,14 +21,14 @@ import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletConfig;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.ServletConfig} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.ServletConfig} interface.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -31,17 +31,16 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterRegistration;
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import javax.servlet.SessionTrackingMode;
|
||||
import javax.servlet.descriptor.JspConfigDescriptor;
|
||||
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterRegistration;
|
||||
import jakarta.servlet.RequestDispatcher;
|
||||
import jakarta.servlet.Servlet;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRegistration;
|
||||
import jakarta.servlet.SessionCookieConfig;
|
||||
import jakarta.servlet.SessionTrackingMode;
|
||||
import jakarta.servlet.descriptor.JspConfigDescriptor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -59,7 +58,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.ServletContext} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.ServletContext} interface.
|
||||
*
|
||||
* <p>As of Spring 5.0, this set of mocks is designed on a Servlet 4.0 baseline.
|
||||
*
|
||||
@@ -663,7 +662,7 @@ public class MockServletContext implements ServletContext {
|
||||
|
||||
/**
|
||||
* This method always returns {@code null}.
|
||||
* @see javax.servlet.ServletContext#getServletRegistration(java.lang.String)
|
||||
* @see jakarta.servlet.ServletContext#getServletRegistration(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -673,7 +672,7 @@ public class MockServletContext implements ServletContext {
|
||||
|
||||
/**
|
||||
* This method always returns an {@linkplain Collections#emptyMap empty map}.
|
||||
* @see javax.servlet.ServletContext#getServletRegistrations()
|
||||
* @see jakarta.servlet.ServletContext#getServletRegistrations()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, ? extends ServletRegistration> getServletRegistrations() {
|
||||
@@ -702,7 +701,7 @@ public class MockServletContext implements ServletContext {
|
||||
|
||||
/**
|
||||
* This method always returns {@code null}.
|
||||
* @see javax.servlet.ServletContext#getFilterRegistration(java.lang.String)
|
||||
* @see jakarta.servlet.ServletContext#getFilterRegistration(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -712,7 +711,7 @@ public class MockServletContext implements ServletContext {
|
||||
|
||||
/**
|
||||
* This method always returns an {@linkplain Collections#emptyMap empty map}.
|
||||
* @see javax.servlet.ServletContext#getFilterRegistrations()
|
||||
* @see jakarta.servlet.ServletContext#getFilterRegistrations()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
|
||||
package org.springframework.mock.web;
|
||||
|
||||
import javax.servlet.SessionCookieConfig;
|
||||
import jakarta.servlet.SessionCookieConfig;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.servlet.SessionCookieConfig} interface.
|
||||
* Mock implementation of the {@link jakarta.servlet.SessionCookieConfig} interface.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.0
|
||||
* @see javax.servlet.ServletContext#getSessionCookieConfig()
|
||||
* @see jakarta.servlet.ServletContext#getSessionCookieConfig()
|
||||
*/
|
||||
public class MockSessionCookieConfig implements SessionCookieConfig {
|
||||
|
||||
|
||||
@@ -18,26 +18,26 @@ package org.springframework.mock.web;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.Servlet;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link javax.servlet.FilterConfig} interface which
|
||||
* Implementation of the {@link jakarta.servlet.FilterConfig} interface which
|
||||
* simply passes the call through to a given Filter/FilterChain combination
|
||||
* (indicating the next Filter in the chain along with the FilterChain that it is
|
||||
* supposed to work on) or to a given Servlet (indicating the end of the chain).
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 2.0.3
|
||||
* @see javax.servlet.Filter
|
||||
* @see javax.servlet.Servlet
|
||||
* @see jakarta.servlet.Filter
|
||||
* @see jakarta.servlet.Servlet
|
||||
* @see MockFilterChain
|
||||
*/
|
||||
public class PassThroughFilterChain implements FilterChain {
|
||||
|
||||
@@ -57,7 +57,7 @@ import org.springframework.core.annotation.AliasFor;
|
||||
* {@link org.springframework.stereotype.Component @Component},
|
||||
* {@link org.springframework.stereotype.Service @Service},
|
||||
* {@link org.springframework.stereotype.Repository @Repository}, etc.)</li>
|
||||
* <li>A JSR-330 compliant class that is annotated with {@code javax.inject} annotations</li>
|
||||
* <li>A JSR-330 compliant class that is annotated with {@code jakarta.inject} annotations</li>
|
||||
* <li>Any class that contains {@link org.springframework.context.annotation.Bean @Bean}-methods</li>
|
||||
* <li>Any other class that is intended to be registered as a Spring component (i.e., a Spring bean
|
||||
* in the {@code ApplicationContext}), potentially taking advantage of automatic autowiring of a
|
||||
|
||||
@@ -72,8 +72,8 @@ public interface ContextLoader {
|
||||
* contexts} loaded by this ContextLoader. Beans will therefore automatically
|
||||
* be candidates for annotation-based dependency injection using
|
||||
* {@link org.springframework.beans.factory.annotation.Autowired @Autowired},
|
||||
* {@link javax.annotation.Resource @Resource}, and
|
||||
* {@link javax.inject.Inject @Inject}.
|
||||
* {@link jakarta.annotation.Resource @Resource}, and
|
||||
* {@link jakarta.inject.Inject @Inject}.
|
||||
* <p>Any ApplicationContext loaded by a ContextLoader <strong>must</strong>
|
||||
* register a JVM shutdown hook for itself. Unless the context gets closed
|
||||
* early, all context instances will be automatically closed on JVM
|
||||
|
||||
@@ -101,8 +101,8 @@ public interface SmartContextLoader extends ContextLoader {
|
||||
* {@code SmartContextLoader}. Beans will therefore automatically be
|
||||
* candidates for annotation-based dependency injection using
|
||||
* {@link org.springframework.beans.factory.annotation.Autowired @Autowired},
|
||||
* {@link javax.annotation.Resource @Resource}, and
|
||||
* {@link javax.inject.Inject @Inject}. In addition, concrete implementations
|
||||
* {@link jakarta.annotation.Resource @Resource}, and
|
||||
* {@link jakarta.inject.Inject @Inject}. In addition, concrete implementations
|
||||
* should set the active bean definition profiles in the context's
|
||||
* {@link org.springframework.core.env.Environment Environment}.
|
||||
* <p>Any {@code ApplicationContext} loaded by a
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.test.context.web;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.test.context.web;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
@@ -21,16 +21,16 @@ import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.DeploymentException;
|
||||
import javax.websocket.Endpoint;
|
||||
import javax.websocket.Extension;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerContainer;
|
||||
import javax.websocket.server.ServerEndpointConfig;
|
||||
import jakarta.websocket.ClientEndpointConfig;
|
||||
import jakarta.websocket.DeploymentException;
|
||||
import jakarta.websocket.Endpoint;
|
||||
import jakarta.websocket.Extension;
|
||||
import jakarta.websocket.Session;
|
||||
import jakarta.websocket.server.ServerContainer;
|
||||
import jakarta.websocket.server.ServerEndpointConfig;
|
||||
|
||||
/**
|
||||
* Mock implementation of the {@link javax.websocket.server.ServerContainer} interface.
|
||||
* Mock implementation of the {@link jakarta.websocket.server.ServerContainer} interface.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.3.1
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.test.context.web.socket;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -27,7 +27,7 @@ import org.springframework.web.context.WebApplicationContext;
|
||||
/**
|
||||
* {@link ContextCustomizer} that instantiates a new {@link MockServerContainer}
|
||||
* and stores it in the {@code ServletContext} under the attribute named
|
||||
* {@code "javax.websocket.server.ServerContainer"}.
|
||||
* {@code "jakarta.websocket.server.ServerContainer"}.
|
||||
*
|
||||
* @author Sam Brannen
|
||||
* @since 4.3.1
|
||||
@@ -40,7 +40,7 @@ class MockServerContainerContextCustomizer implements ContextCustomizer {
|
||||
WebApplicationContext wac = (WebApplicationContext) context;
|
||||
ServletContext sc = wac.getServletContext();
|
||||
if (sc != null) {
|
||||
sc.setAttribute("javax.websocket.server.ServerContainer", new MockServerContainer());
|
||||
sc.setAttribute("jakarta.websocket.server.ServerContainer", new MockServerContainer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class MockServerContainerContextCustomizerFactory implements ContextCustomizerFa
|
||||
private static final String MOCK_SERVER_CONTAINER_CONTEXT_CUSTOMIZER_CLASS_NAME =
|
||||
"org.springframework.test.context.web.socket.MockServerContainerContextCustomizer";
|
||||
|
||||
private static final boolean webSocketPresent = ClassUtils.isPresent("javax.websocket.server.ServerContainer",
|
||||
private static final boolean webSocketPresent = ClassUtils.isPresent("jakarta.websocket.server.ServerContainer",
|
||||
MockServerContainerContextCustomizerFactory.class.getClassLoader());
|
||||
|
||||
|
||||
|
||||
@@ -45,12 +45,12 @@ import org.springframework.util.StringUtils;
|
||||
* {@code public} setter methods for properties in a domain entity.</li>
|
||||
* <li>Spring's support for annotations such as
|
||||
* {@link org.springframework.beans.factory.annotation.Autowired @Autowired},
|
||||
* {@link javax.inject.Inject @Inject}, and
|
||||
* {@link javax.annotation.Resource @Resource} which provides dependency
|
||||
* {@link jakarta.inject.Inject @Inject}, and
|
||||
* {@link jakarta.annotation.Resource @Resource} which provides dependency
|
||||
* injection for {@code private} or {@code protected} fields, setter methods,
|
||||
* and configuration methods.</li>
|
||||
* <li>Use of annotations such as {@link javax.annotation.PostConstruct @PostConstruct}
|
||||
* and {@link javax.annotation.PreDestroy @PreDestroy} for lifecycle callback
|
||||
* <li>Use of annotations such as {@link jakarta.annotation.PostConstruct @PostConstruct}
|
||||
* and {@link jakarta.annotation.PreDestroy @PreDestroy} for lifecycle callback
|
||||
* methods.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,32 +16,36 @@
|
||||
|
||||
package org.springframework.test.web.client.match;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
|
||||
import org.apache.tomcat.util.http.fileupload.FileItem;
|
||||
import org.apache.tomcat.util.http.fileupload.FileUpload;
|
||||
import org.apache.tomcat.util.http.fileupload.UploadContext;
|
||||
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.client.ClientHttpRequest;
|
||||
import org.springframework.http.converter.FormHttpMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.http.MockHttpInputMessage;
|
||||
import org.springframework.mock.http.client.MockClientHttpRequest;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.test.util.JsonExpectationsHelper;
|
||||
import org.springframework.test.util.XmlExpectationsHelper;
|
||||
import org.springframework.test.web.client.RequestMatcher;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.springframework.test.util.AssertionErrors.assertEquals;
|
||||
@@ -217,7 +221,7 @@ public class ContentRequestMatchers {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private RequestMatcher multipartData(MultiValueMap<String, ?> expectedMap, boolean containsExactly) {
|
||||
return request -> {
|
||||
MultiValueMap<String, ?> actualMap = MultipartHelper.parse(request);
|
||||
MultiValueMap<String, ?> actualMap = MultipartHelper.parse((MockClientHttpRequest) request);
|
||||
if (containsExactly) {
|
||||
assertEquals("Multipart request content: " + actualMap, expectedMap.size(), actualMap.size());
|
||||
}
|
||||
@@ -235,8 +239,8 @@ public class ContentRequestMatchers {
|
||||
expected = StreamUtils.copyToByteArray(((Resource) expected).getInputStream());
|
||||
}
|
||||
if (expected instanceof byte[]) {
|
||||
assertTrue("Multipart is not a file", actual instanceof MultipartFile);
|
||||
assertEquals("Multipart content", expected, ((MultipartFile) actual).getBytes());
|
||||
assertTrue("Multipart is not a file", actual instanceof byte[]);
|
||||
assertEquals("Multipart content", expected, (byte[]) actual);
|
||||
}
|
||||
else if (expected instanceof String) {
|
||||
assertTrue("Multipart is not a String", actual instanceof String);
|
||||
@@ -356,28 +360,42 @@ public class ContentRequestMatchers {
|
||||
|
||||
private static class MultipartHelper {
|
||||
|
||||
public static MultiValueMap<String, ?> parse(ClientHttpRequest request) {
|
||||
MultipartHttpServletRequest servletRequest = adaptToMultipartRequest(request);
|
||||
MultiValueMap<String, Object> result = new LinkedMultiValueMap<>();
|
||||
for (Map.Entry<String, List<MultipartFile>> entry : servletRequest.getMultiFileMap().entrySet()) {
|
||||
for (MultipartFile value : entry.getValue()) {
|
||||
result.add(entry.getKey(), value);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, String[]> entry : servletRequest.getParameterMap().entrySet()) {
|
||||
for (String value : entry.getValue()) {
|
||||
result.add(entry.getKey(), value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static MultiValueMap<String, ?> parse(MockClientHttpRequest request) {
|
||||
try {
|
||||
FileUpload fileUpload = new FileUpload(new DiskFileItemFactory());
|
||||
|
||||
private static MultipartHttpServletRequest adaptToMultipartRequest(ClientHttpRequest request) {
|
||||
MockClientHttpRequest source = (MockClientHttpRequest) request;
|
||||
MockHttpServletRequest target = new MockHttpServletRequest();
|
||||
target.setContent(source.getBodyAsBytes());
|
||||
source.getHeaders().forEach((name, values) -> values.forEach(v -> target.addHeader(name, v)));
|
||||
return new CommonsMultipartResolver().resolveMultipart(target);
|
||||
List<FileItem> fileItems = fileUpload.parseRequest(new UploadContext() {
|
||||
private final byte[] body = request.getBodyAsBytes();
|
||||
@Override
|
||||
@Nullable
|
||||
public String getCharacterEncoding() {
|
||||
return request.getHeaders().getFirst(HttpHeaders.CONTENT_ENCODING);
|
||||
}
|
||||
@Override
|
||||
@Nullable
|
||||
public String getContentType() {
|
||||
return request.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
|
||||
}
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(this.body);
|
||||
}
|
||||
@Override
|
||||
public long contentLength() {
|
||||
return this.body.length;
|
||||
}
|
||||
});
|
||||
|
||||
MultiValueMap<String, Object> result = new LinkedMultiValueMap<>();
|
||||
for (FileItem fileItem : fileItems) {
|
||||
result.add(fileItem.getFieldName(),
|
||||
(fileItem.isFormField() ? fileItem.getString() : fileItem.get()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Failed to parse multipart request", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,13 +20,13 @@ import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.AsyncContext;
|
||||
import javax.servlet.DispatcherType;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletResponseWrapper;
|
||||
import jakarta.servlet.AsyncContext;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpServletResponseWrapper;
|
||||
|
||||
import org.springframework.beans.Mergeable;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.test.web.servlet;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletException;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.ServletException;
|
||||
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.test.web.servlet;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.web.MockAsyncContext;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.test.web.servlet.client;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import jakarta.servlet.Filter;
|
||||
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.core.ResolvableType;
|
||||
@@ -166,7 +165,7 @@ public class MockMvcHttpConnector implements ClientHttpConnector {
|
||||
buffer.read(partBytes);
|
||||
DataBufferUtils.release(buffer);
|
||||
|
||||
// Adapt to javax.servlet.http.Part...
|
||||
// Adapt to jakarta.servlet.http.Part...
|
||||
MockPart mockPart = (part instanceof FilePart ?
|
||||
new MockPart(part.name(), ((FilePart) part).filename(), partBytes) :
|
||||
new MockPart(part.name(), partBytes));
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.test.web.servlet.client;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import jakarta.servlet.Filter;
|
||||
|
||||
import org.springframework.format.support.FormattingConversionService;
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
|
||||
@@ -33,17 +33,16 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.CookieManager;
|
||||
import com.gargoylesoftware.htmlunit.FormEncodingType;
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.gargoylesoftware.htmlunit.WebRequest;
|
||||
import com.gargoylesoftware.htmlunit.util.KeyDataPair;
|
||||
import com.gargoylesoftware.htmlunit.util.NameValuePair;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.Mergeable;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class MockMvcWebConnection implements WebConnection {
|
||||
* Create a new instance with the specified context path.
|
||||
* <p>The path may be {@code null} in which case the first path segment
|
||||
* of the URL is turned into the contextPath. Otherwise it must conform
|
||||
* to {@link javax.servlet.http.HttpServletRequest#getContextPath()}
|
||||
* to {@link jakarta.servlet.http.HttpServletRequest#getContextPath()}
|
||||
* which states that it can be an empty string and otherwise must start
|
||||
* with a "/" character and not end with a "/" character.
|
||||
* @param mockMvc the {@code MockMvc} instance to use (never {@code null})
|
||||
@@ -105,7 +105,7 @@ public final class MockMvcWebConnection implements WebConnection {
|
||||
/**
|
||||
* Validate the supplied {@code contextPath}.
|
||||
* <p>If the value is not {@code null}, it must conform to
|
||||
* {@link javax.servlet.http.HttpServletRequest#getContextPath()} which
|
||||
* {@link jakarta.servlet.http.HttpServletRequest#getContextPath()} which
|
||||
* states that it can be an empty string and otherwise must start with
|
||||
* a "/" character and not end with a "/" character.
|
||||
* @param contextPath the path to validate
|
||||
@@ -155,10 +155,10 @@ public final class MockMvcWebConnection implements WebConnection {
|
||||
return resultActions.andReturn().getResponse();
|
||||
}
|
||||
|
||||
private void storeCookies(WebRequest webRequest, javax.servlet.http.Cookie[] cookies) {
|
||||
private void storeCookies(WebRequest webRequest, jakarta.servlet.http.Cookie[] cookies) {
|
||||
Date now = new Date();
|
||||
CookieManager cookieManager = this.webClient.getCookieManager();
|
||||
for (javax.servlet.http.Cookie cookie : cookies) {
|
||||
for (jakarta.servlet.http.Cookie cookie : cookies) {
|
||||
if (cookie.getDomain() == null) {
|
||||
cookie.setDomain(webRequest.getUrl().getHost());
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public final class MockMvcWebConnection implements WebConnection {
|
||||
}
|
||||
}
|
||||
|
||||
private static com.gargoylesoftware.htmlunit.util.Cookie createCookie(javax.servlet.http.Cookie cookie) {
|
||||
private static com.gargoylesoftware.htmlunit.util.Cookie createCookie(jakarta.servlet.http.Cookie cookie) {
|
||||
Date expires = null;
|
||||
if (cookie.getMaxAge() > -1) {
|
||||
expires = new Date(System.currentTimeMillis() + cookie.getMaxAge() * 1000);
|
||||
|
||||
@@ -30,10 +30,10 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.beans.Mergeable;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
@@ -185,7 +185,7 @@ public class MockHttpServletRequestBuilder
|
||||
* the requestURI. This is because most applications don't actually depend
|
||||
* on the name under which they're deployed. If specified here, the context
|
||||
* path must start with a "/" and must not end with a "/".
|
||||
* @see javax.servlet.http.HttpServletRequest#getContextPath()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getContextPath()
|
||||
*/
|
||||
public MockHttpServletRequestBuilder contextPath(String contextPath) {
|
||||
if (StringUtils.hasText(contextPath)) {
|
||||
@@ -207,7 +207,7 @@ public class MockHttpServletRequestBuilder
|
||||
* {@code "/accounts/1"} as opposed to {@code "/main/accounts/1"}.
|
||||
* If specified here, the servletPath must start with a "/" and must not
|
||||
* end with a "/".
|
||||
* @see javax.servlet.http.HttpServletRequest#getServletPath()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getServletPath()
|
||||
*/
|
||||
public MockHttpServletRequestBuilder servletPath(String servletPath) {
|
||||
if (StringUtils.hasText(servletPath)) {
|
||||
@@ -224,7 +224,7 @@ public class MockHttpServletRequestBuilder
|
||||
* by removing the contextPath and the servletPath from the requestURI and using any
|
||||
* remaining part. If specified here, the pathInfo must start with a "/".
|
||||
* <p>If specified, the pathInfo will be used as-is.
|
||||
* @see javax.servlet.http.HttpServletRequest#getPathInfo()
|
||||
* @see jakarta.servlet.http.HttpServletRequest#getPathInfo()
|
||||
*/
|
||||
public MockHttpServletRequestBuilder pathInfo(@Nullable String pathInfo) {
|
||||
if (StringUtils.hasText(pathInfo)) {
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.Part;
|
||||
import jakarta.servlet.ServletContext;
|
||||
import jakarta.servlet.http.Part;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.test.web.servlet.request;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
import jakarta.servlet.DispatcherType;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
@@ -20,10 +20,10 @@ import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.test.web.servlet.result;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.Cookie;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
@@ -18,9 +18,8 @@ package org.springframework.test.web.servlet.result;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.mock.web.MockServletConfig;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.test.web.servlet.setup;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import jakarta.servlet.Filter;
|
||||
|
||||
import org.springframework.test.web.servlet.DispatcherServletCustomizer;
|
||||
import org.springframework.test.web.servlet.MockMvcBuilder;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.test.web.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -45,7 +45,7 @@ public final class MockMvcBuilders {
|
||||
* <p>The {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet}
|
||||
* will use the context to discover Spring MVC infrastructure and application
|
||||
* controllers in it. The context must have been configured with a
|
||||
* {@link javax.servlet.ServletContext ServletContext}.
|
||||
* {@link jakarta.servlet.ServletContext ServletContext}.
|
||||
*/
|
||||
public static DefaultMockMvcBuilder webAppContextSetup(WebApplicationContext context) {
|
||||
return new DefaultMockMvcBuilder(context);
|
||||
|
||||
@@ -20,13 +20,13 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.test.web.servlet.setup;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import jakarta.servlet.ServletContext;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
Reference in New Issue
Block a user