/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you 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
 *
 * http://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.apache.deltaspike.cdise.owb;

import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Set;
import java.util.StringTokenizer;

import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;

/**
 * Mock ServletContext needed to startup the container.
 *
 */
public class MockServletContext implements ServletContext
{
    private static MockServletContext instance = new MockServletContext();


    private Hashtable attributes = new Hashtable();


    private MockServletContext()
    {
        // this class is only accessible via getInstance
    }

    public static synchronized MockServletContext getInstance()
    {
        return instance;
    }

    public static ServletContextEvent getServletContextEvent()
    {
        return new ServletContextEvent(getInstance());
    }



    public Object getAttribute(String name)
    {
        return attributes.get(name);
    }

    public Enumeration getAttributeNames()
    {
        return attributes.keys();
    }

    public ServletContext getContext(String uripath)
    {
        return this;
    }

    public String getContextPath()
    {
        return "mockContextpath";
    }

    public String getInitParameter(String name)
    {
        return null;
    }

    public Enumeration getInitParameterNames()
    {
        return new StringTokenizer(""); // 'standard' empty Enumeration
    }

    public int getMajorVersion()
    {
        return 2;
    }

    public String getMimeType(String file)
    {
        return null;
    }

    public int getMinorVersion()
    {
        return 0;
    }

    public RequestDispatcher getNamedDispatcher(String name)
    {
        return null;
    }

    public String getRealPath(String path)
    {
        return "mockRealPath";
    }

    public RequestDispatcher getRequestDispatcher(String path)
    {
        return null;
    }

    public URL getResource(String path) throws MalformedURLException
    {
        return null;
    }

    public InputStream getResourceAsStream(String path)
    {
        return null;
    }

    public Set getResourcePaths(String path)
    {
        return null;
    }

    public String getServerInfo()
    {
        return "mockServer";
    }

    public Servlet getServlet(String name) throws ServletException
    {
        return null;
    }

    public String getServletContextName()
    {
        return null;
    }

    public Enumeration getServletNames()
    {
        return null;
    }

    public Enumeration getServlets()
    {
        return null;
    }

    public void log(String msg)
    {
        // TODO
    }

    public void log(Exception exception, String msg)
    {
        // TODO
    }

    public void log(String message, Throwable throwable)
    {
        // TODO
    }

    public void removeAttribute(String name)
    {
        attributes.remove(name);
    }

    @SuppressWarnings("unchecked")
    public void setAttribute(String name, Object object)
    {
        attributes.put(name, object);
    }
}

@@ -3588,36 +3588,45 @@
    %7B%0A        // 
-TODO
+nothing to do
 %0A    %7D%0A%0A    publ
@@ -3679,36 +3679,45 @@
    %7B%0A        // 
-TODO
+nothing to do
 %0A    %7D%0A%0A    publ
@@ -3786,12 +3786,21 @@
  // 
-TODO
+nothing to do
 %0A   

remove useless TODOs