From 3b9ee9a48e4bafae2960a9217f70025b01fc1e3f Mon Sep 17 00:00:00 2001 From: Vladimir Bychkov Date: Wed, 17 Jul 2024 14:53:30 +0200 Subject: [PATCH] Migration to Jakarta EE --- .../BIRT Chart Test.launch | 10 +-- .../BIRT Report Engine Test.launch | 10 +-- .../BIRT Report Model Test.launch | 10 +-- .../BIRT Report Tests Engine Test.launch | 10 +-- .../mock/HttpServletRequestSimulator.java | 45 ++++++-------- .../mock/HttpServletResponseSimulator.java | 43 +++---------- .../viewer/mock/HttpSessionSimulator.java | 61 +------------------ .../viewer/mock/ServletContextSimulator.java | 40 ------------ .../viewer/utility/ParameterAccessorTest.java | 6 +- 9 files changed, 52 insertions(+), 183 deletions(-) diff --git a/build/org.eclipse.birt.target/BIRT Chart Test.launch b/build/org.eclipse.birt.target/BIRT Chart Test.launch index 317b9d6b3c7..9ef0ecbcb70 100644 --- a/build/org.eclipse.birt.target/BIRT Chart Test.launch +++ b/build/org.eclipse.birt.target/BIRT Chart Test.launch @@ -56,13 +56,13 @@ - - - - + + + + - + diff --git a/build/org.eclipse.birt.target/BIRT Report Engine Test.launch b/build/org.eclipse.birt.target/BIRT Report Engine Test.launch index d9284abcec3..a9b4542874a 100644 --- a/build/org.eclipse.birt.target/BIRT Report Engine Test.launch +++ b/build/org.eclipse.birt.target/BIRT Report Engine Test.launch @@ -56,12 +56,12 @@ - - - - + + + + - + diff --git a/build/org.eclipse.birt.target/BIRT Report Model Test.launch b/build/org.eclipse.birt.target/BIRT Report Model Test.launch index e85c73a5ff4..0f9ac45e867 100644 --- a/build/org.eclipse.birt.target/BIRT Report Model Test.launch +++ b/build/org.eclipse.birt.target/BIRT Report Model Test.launch @@ -56,12 +56,12 @@ - - - - + + + + - + diff --git a/build/org.eclipse.birt.target/BIRT Report Tests Engine Test.launch b/build/org.eclipse.birt.target/BIRT Report Tests Engine Test.launch index 38e81ce4895..0215d09519e 100644 --- a/build/org.eclipse.birt.target/BIRT Report Tests Engine Test.launch +++ b/build/org.eclipse.birt.target/BIRT Report Tests Engine Test.launch @@ -56,12 +56,12 @@ - - - - + + + + - + diff --git a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletRequestSimulator.java b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletRequestSimulator.java index bfef8b97fa4..5b99099fb25 100644 --- a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletRequestSimulator.java +++ b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletRequestSimulator.java @@ -27,6 +27,7 @@ import jakarta.servlet.AsyncContext; import jakarta.servlet.DispatcherType; import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletConnection; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.ServletInputStream; @@ -516,16 +517,6 @@ public boolean isRequestedSessionIdFromURL() { return false; } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpServletRequest#isRequestedSessionIdFromUrl - */ - @Override - public boolean isRequestedSessionIdFromUrl() { - return isRequestedSessionIdFromURL(); - } - /* * (non-Javadoc) * @@ -624,22 +615,6 @@ public BufferedReader getReader() throws IOException { throw new UnsupportedOperationException("Do not support getReader operation!"); //$NON-NLS-1$ } - /** - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpServletRequest#getRealPath( java.lang.String ) - * @deprecated - */ - @Deprecated - @Override - public String getRealPath(String path) { - if (path == null) { - return null; - } - - return this.context.getRealPath(path); - } - /* * (non-Javadoc) * @@ -1118,4 +1093,22 @@ public T upgrade(Class arg0) throws IOExceptio // TODO Auto-generated method stub return null; } + + @Override + public String getRequestId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getProtocolRequestId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ServletConnection getServletConnection() { + // TODO Auto-generated method stub + return null; + } } diff --git a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletResponseSimulator.java b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletResponseSimulator.java index 58001dd416a..59f45812f4e 100644 --- a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletResponseSimulator.java +++ b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpServletResponseSimulator.java @@ -24,7 +24,6 @@ import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletResponse; - import junit.framework.AssertionFailedError; /** @@ -202,17 +201,6 @@ public String encodeRedirectURL(String url) { return url; } - /* - * (non-Javadoc) - * - * @see - * jakarta.servlet.http.HttpServletResponse#encodeRedirectUrl(java.lang.String) - */ - @Override - public String encodeRedirectUrl(String url) { - return encodeRedirectURL(url); - } - /* * (non-Javadoc) * @@ -223,16 +211,6 @@ public String encodeURL(String url) { return url; } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpServletResponse#encodeUrl(java.lang.String) - */ - @Override - public String encodeUrl(String url) { - return encodeURL(url); - } - /* * (non-Javadoc) * @@ -240,7 +218,7 @@ public String encodeUrl(String url) { */ @Override public void sendError(int status) throws IOException { - setStatus(status); + this.status = status; throw new AssertionFailedError(" Response error :" + status); //$NON-NLS-1$ } @@ -251,7 +229,8 @@ public void sendError(int status) throws IOException { */ @Override public void sendError(int status, String message) throws IOException { - setStatus(status, message); + this.status = status; + this.message = message; throw new AssertionFailedError(" Response error :" + status + " " //$NON-NLS-1$//$NON-NLS-2$ + message); } @@ -327,18 +306,7 @@ public void removeHeader(String name) { */ @Override public void setStatus(int status) { - setStatus(status, null); - } - - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpServletResponse#setStatus(int, java.lang.String) - */ - @Override - public void setStatus(int status, String message) { this.status = status; - this.message = message; } /* @@ -592,4 +560,9 @@ public void setContentLengthLong(long arg0) { } + @Override + public void sendRedirect(String location, int sc, boolean clearBuffer) throws IOException { + // TODO Auto-generated method stub + } + } diff --git a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpSessionSimulator.java b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpSessionSimulator.java index 5ad5209a204..3c6a1837f22 100644 --- a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpSessionSimulator.java +++ b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/HttpSessionSimulator.java @@ -16,11 +16,10 @@ import java.util.Enumeration; import java.util.Hashtable; +import org.eclipse.birt.report.viewer.util.RandomUtil; + import jakarta.servlet.ServletContext; import jakarta.servlet.http.HttpSession; -import jakarta.servlet.http.HttpSessionContext; - -import org.eclipse.birt.report.viewer.util.RandomUtil; /** * Mock a HttpSession class for Viewer UnitTest @@ -87,51 +86,6 @@ public void removeAttribute(String name) { this.attributes.remove(name); } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpSession#getValue(java.lang.String) - */ - @Override - public Object getValue(String name) { - verify(); - return this.getAttribute(name); - } - - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpSession#getValueNames() - */ - @Override - public String[] getValueNames() { - verify(); - return (String[]) this.attributes.keySet().toArray(); - } - - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpSession#putValue(java.lang.String, - * java.lang.Object) - */ - @Override - public void putValue(String name, Object value) { - verify(); - this.setAttribute(name, value); - } - - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpSession#removeValue(java.lang.String) - */ - @Override - public void removeValue(String name) { - verify(); - this.removeAttribute(name); - } - /* * (non-Javadoc) * @@ -187,17 +141,6 @@ public ServletContext getServletContext() { return this.context; } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.http.HttpSession#getSessionContext() - */ - @Override - public HttpSessionContext getSessionContext() { - verify(); - throw new UnsupportedOperationException("Do not support getSessionContext operation!"); //$NON-NLS-1$ - } - /* * (non-Javadoc) * diff --git a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/ServletContextSimulator.java b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/ServletContextSimulator.java index c128789f669..9acfd07fadf 100644 --- a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/ServletContextSimulator.java +++ b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/mock/ServletContextSimulator.java @@ -261,16 +261,6 @@ public String getServerInfo() { return "BirtMockServletEngine"; //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.ServletContext#getServlet(java.lang.String) - */ - @Override - public Servlet getServlet(String name) throws ServletException { - throw new UnsupportedOperationException("Do not support getServlet operation!"); //$NON-NLS-1$ - } - /* * (non-Javadoc) * @@ -281,26 +271,6 @@ public String getServletContextName() { throw new UnsupportedOperationException("Do not support getServletContextName operation!"); //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.ServletContext#getServletNames() - */ - @Override - public Enumeration getServletNames() { - throw new UnsupportedOperationException("Do not support getServletNames operation!"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see jakarta.servlet.ServletContext#getServlets() - */ - @Override - public Enumeration getServlets() { - throw new UnsupportedOperationException("Do not support getServlets operation!"); //$NON-NLS-1$ - } - /* * (non-Javadoc) * @@ -311,16 +281,6 @@ public void log(String content) { System.out.println(content); } - /* - * (non-Javadoc) - * - * @see jakarta.servlet.ServletContext#log(java.lang.Exception, java.lang.String) - */ - @Override - public void log(Exception exception, String content) { - System.out.println(content + "--" + exception.getMessage()); //$NON-NLS-1$ - } - /* * (non-Javadoc) * diff --git a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/ParameterAccessorTest.java b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/ParameterAccessorTest.java index df9977b3189..34e2c69f57d 100644 --- a/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/ParameterAccessorTest.java +++ b/viewer/org.eclipse.birt.report.viewer.tests/test/org/eclipse/birt/report/viewer/utility/ParameterAccessorTest.java @@ -19,8 +19,6 @@ import java.util.Locale; import java.util.Map; -import jakarta.servlet.http.HttpServletRequest; - import org.eclipse.birt.report.IBirtConstants; import org.eclipse.birt.report.context.BirtContext; import org.eclipse.birt.report.context.ViewerAttributeBean; @@ -28,6 +26,8 @@ import org.eclipse.birt.report.utility.ParameterAccessor; import org.eclipse.birt.report.viewer.util.BaseTestCase; +import jakarta.servlet.http.HttpServletRequest; + /** * TestCases for ParameterAccessor class. For test, mock some objects over http: * ServletContext, HttpServletRequest, HttpSession. @@ -305,7 +305,7 @@ public void testGenerateFileName() { generateFileName(request, "pdf")); //$NON-NLS-1$ request.removeParameter(ParameterAccessor.PARAM_REPORT); request.removeParameter(IBirtConstants.ATTRIBUTE_BEAN); - request.setCharacterEncoding(null); + request.setCharacterEncoding((String) null); } private String generateFileName(HttpServletRequest request, String format) {