| /******************************************************************************* |
| * Copyright (c) 2008, 2014 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.ua.tests.help.webapp; |
| |
| import java.io.BufferedReader; |
| import java.io.IOException; |
| import java.io.UnsupportedEncodingException; |
| import java.security.Principal; |
| import java.util.Collection; |
| import java.util.Enumeration; |
| import java.util.HashMap; |
| import java.util.Locale; |
| import java.util.Map; |
| |
| 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; |
| |
| /** |
| * Class used for tests which require an HttpServletRequest parameter |
| */ |
| |
| public class MockServletRequest implements HttpServletRequest { |
| |
| private Locale locale; |
| private Map<String, String[]> parameterMap = new HashMap<String, String[]>(); |
| private Cookie[] cookies = new Cookie[0]; |
| private String pathInfo = null; |
| |
| public MockServletRequest() { |
| |
| } |
| |
| public String getAuthType() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getContextPath() { |
| return "/help"; |
| } |
| |
| public Cookie[] getCookies() { |
| return cookies; |
| } |
| |
| public void setCookies(Cookie[] cookies) { |
| this.cookies = cookies; |
| } |
| |
| public long getDateHeader(String arg0) { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public String getHeader(String arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Enumeration<String> getHeaderNames() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Enumeration<String> getHeaders(String arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getIntHeader(String arg0) { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public String getMethod() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getPathInfo() { |
| return pathInfo; |
| } |
| |
| public void setPathInfo(String info) { |
| this.pathInfo = info; |
| } |
| |
| public String getPathTranslated() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getQueryString() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getRemoteUser() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getRequestURI() { |
| return "/help/context.jsp"; |
| } |
| |
| public StringBuffer getRequestURL() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getRequestedSessionId() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getServletPath() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public HttpSession getSession() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public HttpSession getSession(boolean arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Principal getUserPrincipal() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public boolean isRequestedSessionIdFromCookie() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean isRequestedSessionIdFromURL() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean isRequestedSessionIdFromUrl() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean isRequestedSessionIdValid() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean isUserInRole(String arg0) { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public Object getAttribute(String arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Enumeration<String> getAttributeNames() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getCharacterEncoding() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getContentLength() { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public String getContentType() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public ServletInputStream getInputStream() throws IOException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getLocalAddr() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getLocalName() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getLocalPort() { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public Locale getLocale() { |
| return locale; |
| } |
| |
| public void setLocale(Locale locale) { |
| this.locale = locale; |
| } |
| |
| |
| public Enumeration<Locale> getLocales() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getParameter(String arg0) { |
| String[] values= parameterMap.get(arg0); |
| return values != null ? parameterMap.get(arg0)[0] : null; |
| } |
| |
| public Map<String, String[]> getParameterMap() { |
| return parameterMap; |
| } |
| |
| public Enumeration<String> getParameterNames() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String[] getParameterValues(String arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getProtocol() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public BufferedReader getReader() throws IOException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getRealPath(String arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getRemoteAddr() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getRemoteHost() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getRemotePort() { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public RequestDispatcher getRequestDispatcher(String arg0) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getScheme() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public String getServerName() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public int getServerPort() { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public boolean isSecure() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public void removeAttribute(String arg0) { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void setAttribute(String arg0, Object arg1) { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void setCharacterEncoding(String arg0) |
| throws UnsupportedEncodingException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public ServletContext getServletContext() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public AsyncContext startAsync() throws IllegalStateException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public AsyncContext startAsync(ServletRequest servletRequest, |
| ServletResponse servletResponse) throws IllegalStateException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public boolean isAsyncStarted() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public boolean isAsyncSupported() { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public AsyncContext getAsyncContext() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public DispatcherType getDispatcherType() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public boolean authenticate(HttpServletResponse response) |
| throws IOException, ServletException { |
| // TODO Auto-generated method stub |
| return false; |
| } |
| |
| public void login(String username, String password) throws ServletException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public void logout() throws ServletException { |
| // TODO Auto-generated method stub |
| |
| } |
| |
| public Collection<Part> getParts() throws IOException, ServletException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public Part getPart(String name) throws IOException, ServletException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public long getContentLengthLong() { |
| // TODO Auto-generated method stub |
| return 0; |
| } |
| |
| public String changeSessionId() { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| |
| } |