aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-api/src
diff options
context:
space:
mode:
authorJacek Poreda <jacek.poreda@sonarsource.com>2024-12-11 13:08:24 +0100
committersonartech <sonartech@sonarsource.com>2024-12-18 20:03:11 +0000
commit6a146e820674a08f14b03db7f48f3ec7d393d38b (patch)
tree18e1663e8c7399f31bbc99f627d5223adfe472b3 /server/sonar-webserver-api/src
parent086f2ce821d41363460d1b897b3631dc498524c5 (diff)
downloadsonarqube-6a146e820674a08f14b03db7f48f3ec7d393d38b.tar.gz
sonarqube-6a146e820674a08f14b03db7f48f3ec7d393d38b.zip
SONAR-19122 Upgrade to Spring 6
Diffstat (limited to 'server/sonar-webserver-api/src')
-rw-r--r--server/sonar-webserver-api/src/main/java/org/sonar/server/http/JakartaHttpRequest.java (renamed from server/sonar-webserver-api/src/main/java/org/sonar/server/http/JavaxHttpRequest.java)16
-rw-r--r--server/sonar-webserver-api/src/main/java/org/sonar/server/http/JakartaHttpResponse.java (renamed from server/sonar-webserver-api/src/main/java/org/sonar/server/http/JavaxHttpResponse.java)18
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/http/JakartaHttpRequestTest.java (renamed from server/sonar-webserver-api/src/test/java/org/sonar/server/http/JavaxHttpRequestTest.java)12
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/http/JakartaHttpResponseTest.java (renamed from server/sonar-webserver-api/src/test/java/org/sonar/server/http/JavaxHttpResponseTest.java)10
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java8
5 files changed, 32 insertions, 32 deletions
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JavaxHttpRequest.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JakartaHttpRequest.java
index 7ac7e31143c..1fd9fecbf86 100644
--- a/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JavaxHttpRequest.java
+++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JakartaHttpRequest.java
@@ -19,22 +19,22 @@
*/
package org.sonar.server.http;
+import jakarta.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
import org.sonar.api.server.http.Cookie;
import org.sonar.api.server.http.HttpRequest;
/**
* Implementation of {@link HttpRequest} based on a delegate of {@link HttpServletRequest} from the Javax Servlet API.
*/
-public class JavaxHttpRequest implements HttpRequest {
+public class JakartaHttpRequest implements HttpRequest {
private final HttpServletRequest delegate;
- public JavaxHttpRequest(HttpServletRequest delegate) {
+ public JakartaHttpRequest(HttpServletRequest delegate) {
this.delegate = delegate;
}
@@ -134,19 +134,19 @@ public class JavaxHttpRequest implements HttpRequest {
@Override
public Cookie[] getCookies() {
- javax.servlet.http.Cookie[] cookies = delegate.getCookies();
+ jakarta.servlet.http.Cookie[] cookies = delegate.getCookies();
if (cookies != null) {
return Arrays.stream(cookies)
- .map(JavaxCookie::new)
+ .map(JakartaCookie::new)
.toArray(Cookie[]::new);
}
return new Cookie[0];
}
- public static class JavaxCookie implements Cookie {
- private final javax.servlet.http.Cookie delegate;
+ public static class JakartaCookie implements Cookie {
+ private final jakarta.servlet.http.Cookie delegate;
- public JavaxCookie(javax.servlet.http.Cookie delegate) {
+ public JakartaCookie(jakarta.servlet.http.Cookie delegate) {
this.delegate = delegate;
}
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JavaxHttpResponse.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JakartaHttpResponse.java
index d9842c26059..5938caf1059 100644
--- a/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JavaxHttpResponse.java
+++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/http/JakartaHttpResponse.java
@@ -19,22 +19,22 @@
*/
package org.sonar.server.http;
+import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
-import javax.servlet.http.HttpServletResponse;
import org.sonar.api.server.http.Cookie;
import org.sonar.api.server.http.HttpResponse;
/**
* Implementation of {@link HttpResponse} based on a delegate of {@link HttpServletResponse} from the Javax Servlet API.
*/
-public class JavaxHttpResponse implements HttpResponse {
+public class JakartaHttpResponse implements HttpResponse {
private final HttpServletResponse delegate;
- public JavaxHttpResponse(HttpServletResponse delegate) {
+ public JakartaHttpResponse(HttpServletResponse delegate) {
this.delegate = delegate;
}
@@ -89,12 +89,12 @@ public class JavaxHttpResponse implements HttpResponse {
@Override
public void addCookie(Cookie cookie) {
- javax.servlet.http.Cookie javaxCookie = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue());
- javaxCookie.setPath(cookie.getPath());
- javaxCookie.setSecure(cookie.isSecure());
- javaxCookie.setHttpOnly(cookie.isHttpOnly());
- javaxCookie.setMaxAge(cookie.getMaxAge());
- delegate.addCookie(javaxCookie);
+ jakarta.servlet.http.Cookie jakartaCookie = new jakarta.servlet.http.Cookie(cookie.getName(), cookie.getValue());
+ jakartaCookie.setPath(cookie.getPath());
+ jakartaCookie.setSecure(cookie.isSecure());
+ jakartaCookie.setHttpOnly(cookie.isHttpOnly());
+ jakartaCookie.setMaxAge(cookie.getMaxAge());
+ delegate.addCookie(jakartaCookie);
}
@Override
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JavaxHttpRequestTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JakartaHttpRequestTest.java
index 356d83bebf2..425d1148434 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JavaxHttpRequestTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JakartaHttpRequestTest.java
@@ -19,11 +19,11 @@
*/
package org.sonar.server.http;
+import jakarta.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
-import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
import org.sonar.api.server.http.Cookie;
@@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-public class JavaxHttpRequestTest {
+public class JakartaHttpRequestTest {
@Test
public void delegate_methods() throws IOException {
@@ -43,7 +43,7 @@ public class JavaxHttpRequestTest {
when(requestMock.getServletPath()).thenReturn("/servlet-path");
BufferedReader bufferedReader = mock(BufferedReader.class);
when(requestMock.getReader()).thenReturn(bufferedReader);
- javax.servlet.http.Cookie[] cookies = new javax.servlet.http.Cookie[0];
+ jakarta.servlet.http.Cookie[] cookies = new jakarta.servlet.http.Cookie[0];
when(requestMock.getCookies()).thenReturn(cookies);
when(requestMock.getServerPort()).thenReturn(80);
when(requestMock.isSecure()).thenReturn(true);
@@ -60,7 +60,7 @@ public class JavaxHttpRequestTest {
Enumeration<String> headers = mock(Enumeration.class);
when(requestMock.getHeaders("header1")).thenReturn(headers);
- JavaxHttpRequest underTest = new JavaxHttpRequest(requestMock);
+ JakartaHttpRequest underTest = new JakartaHttpRequest(requestMock);
assertThat(underTest.getDelegate()).isSameAs(requestMock);
assertThat(underTest.getServerPort()).isEqualTo(80);
@@ -88,13 +88,13 @@ public class JavaxHttpRequestTest {
@Test
public void delegate_methods_for_cookie() {
- javax.servlet.http.Cookie mockCookie = new javax.servlet.http.Cookie("name", "value");
+ jakarta.servlet.http.Cookie mockCookie = new jakarta.servlet.http.Cookie("name", "value");
mockCookie.setSecure(true);
mockCookie.setPath("path");
mockCookie.setHttpOnly(true);
mockCookie.setMaxAge(100);
- Cookie cookie = new JavaxHttpRequest.JavaxCookie(mockCookie);
+ Cookie cookie = new JakartaHttpRequest.JakartaCookie(mockCookie);
assertThat(cookie.getName()).isEqualTo("name");
assertThat(cookie.getValue()).isEqualTo("value");
assertThat(cookie.getPath()).isEqualTo("path");
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JavaxHttpResponseTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JakartaHttpResponseTest.java
index a936cfcddd2..b6b289bc72f 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JavaxHttpResponseTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/http/JakartaHttpResponseTest.java
@@ -22,8 +22,8 @@ package org.sonar.server.http;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletResponse;
import org.junit.Test;
import org.sonar.api.server.http.Cookie;
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-public class JavaxHttpResponseTest {
+public class JakartaHttpResponseTest {
@Test
public void delegate_methods() throws IOException {
@@ -46,7 +46,7 @@ public class JavaxHttpResponseTest {
PrintWriter writer = mock(PrintWriter.class);
when(responseMock.getWriter()).thenReturn(writer);
- JavaxHttpResponse underTest = new JavaxHttpResponse(responseMock);
+ JakartaHttpResponse underTest = new JakartaHttpResponse(responseMock);
assertThat(underTest.getDelegate()).isSameAs(responseMock);
assertThat(underTest.getHeader("h1")).isEqualTo("hvalue1");
@@ -72,6 +72,6 @@ public class JavaxHttpResponseTest {
verify(responseMock).setContentType("text/plain");
verify(responseMock).sendRedirect("http://redirect");
verify(responseMock).setCharacterEncoding("UTF-8");
- verify(responseMock).addCookie(any(javax.servlet.http.Cookie.class));
+ verify(responseMock).addCookie(any(jakarta.servlet.http.Cookie.class));
}
}
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java
index f4813f63fd3..f99b5bea620 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/UpdateCenterServlet.java
@@ -21,10 +21,10 @@ package org.sonar.server.plugins;
import java.io.IOException;
import java.util.Properties;
-import javax.servlet.GenericServlet;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.GenericServlet;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
public class UpdateCenterServlet extends GenericServlet {