/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2014 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
package com.sun.faces.mock;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.EventListener;
import java.util.Hashtable;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
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;
// Mock Object for ServletContext (Version 2.5)
public class MockServletContext implements ServletContext {
private Hashtable attributes = new Hashtable();
private Hashtable parameters = new Hashtable();
// --------------------------------------------------------- Public Methods
public void addInitParameter(String name, String value) {
parameters.put(name, value);
}
// ------------------------------------------------- ServletContext Methods
public Object getAttribute(String name) {
return (attributes.get(name));
}
public Enumeration getAttributeNames() {
return (attributes.keys());
}
public ServletContext getContext(String uripath) {
throw new UnsupportedOperationException();
}
public String getContextPath() {
throw new UnsupportedOperationException();
}
public String getInitParameter(String name) {
return ((String) parameters.get(name));
}
public Enumeration getInitParameterNames() {
return (parameters.keys());
}
public int getMajorVersion() {
return (2);
}
public String getMimeType(String path) {
throw new UnsupportedOperationException();
}
public int getMinorVersion() {
return (5);
}
public RequestDispatcher getNamedDispatcher(String name) {
throw new UnsupportedOperationException();
}
public String getRealPath(String path) {
throw new UnsupportedOperationException();
}
public RequestDispatcher getRequestDispatcher(String path) {
throw new UnsupportedOperationException();
}
public URL getResource(String path) throws MalformedURLException {
throw new UnsupportedOperationException();
}
public InputStream getResourceAsStream(String path) {
throw new UnsupportedOperationException();
}
public Set getResourcePaths(String path) {
return new HashSet(0);
}
public Servlet getServlet(String name) throws ServletException {
throw new UnsupportedOperationException();
}
public String getServletContextName() {
return ("MockServletContext");
}
public String getServerInfo() {
return ("MockServletContext");
}
public Enumeration getServlets() {
throw new UnsupportedOperationException();
}
public Enumeration getServletNames() {
throw new UnsupportedOperationException();
}
public void log(String message) {
throw new UnsupportedOperationException();
}
public void log(Exception exception, String message) {
throw new UnsupportedOperationException();
}
public void log(String message, Throwable exception) {
throw new UnsupportedOperationException();
}
public void removeAttribute(String name) {
attributes.remove(name);
}
public void setAttribute(String name, Object value) {
attributes.put(name, value);
}
@Override
public int getEffectiveMajorVersion() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public int getEffectiveMinorVersion() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean setInitParameter(String string, String string1) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ServletRegistration.Dynamic addServlet(String string, String string1) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ServletRegistration.Dynamic addServlet(String string, Servlet srvlt) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ServletRegistration.Dynamic addServlet(String string, Class<? extends Servlet> type) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T extends Servlet> T createServlet(Class<T> type) throws ServletException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ServletRegistration getServletRegistration(String string) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Map<String, ? extends ServletRegistration> getServletRegistrations() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FilterRegistration.Dynamic addFilter(String string, String string1) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FilterRegistration.Dynamic addFilter(String string, Filter filter) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FilterRegistration.Dynamic addFilter(String string, Class<? extends Filter> type) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T extends Filter> T createFilter(Class<T> type) throws ServletException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FilterRegistration getFilterRegistration(String string) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public SessionCookieConfig getSessionCookieConfig() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setSessionTrackingModes(Set<SessionTrackingMode> set) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void addListener(String string) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T extends EventListener> void addListener(T t) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void addListener(Class<? extends EventListener> type) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public <T extends EventListener> T createListener(Class<T> type) throws ServletException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public JspConfigDescriptor getJspConfigDescriptor() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public ClassLoader getClassLoader() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void declareRoles(String... strings) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public String getVirtualServerName() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}