<commit_before>package com.ecyrd.jspwiki;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Vector;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;

/**
 * This is a mock HttpSession implementation. It is used for testing.
 * Most methods work as the should; notable exceptions include
 * getSessionContext/getServletContext.
 * @author <NAME>
 * @version $Revision: 1.3 $ $Date: 2006-02-04 21:51:39 $
 */
public class TestHttpSession implements HttpSession
{

    protected final long          m_createTime;

    protected static final Random RANDOM = new Random();

    protected final String        m_id;

    protected final long          m_lastAccessTime;

    protected final Map           m_attributes;

    protected boolean             m_invalidated;

    /**
     * Constructs a new instance of this class.
     */
    public TestHttpSession()
    {
        m_createTime = System.currentTimeMillis();
        m_lastAccessTime = m_createTime;
        m_id = String.valueOf( RANDOM.nextLong() );
        m_attributes = new HashMap();
        m_invalidated = false;
    }

    /**
     * @see javax.servlet.http.HttpSession#getCreationTime()
     */
    public long getCreationTime()
    {
        return m_createTime;
    }

    /**
     * @see javax.servlet.http.HttpSession#getId()
     */
    public String getId()
    {
        return m_id;
    }

    /**
     * @see javax.servlet.http.HttpSession#getLastAccessedTime()
     */
    public long getLastAccessedTime()
    {
        return m_lastAccessTime;
    }

    /**
     * Always returns null.
     * @see javax.servlet.http.HttpSession#getServletContext()
     */
    public ServletContext getServletContext()
    {
        return null;
    }

    /**
     * No-op.
     * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
     */
    public void setMaxInactiveInterval( int arg0 )
    {
    }

    /**
     * No-op; returns 0.
     * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
     */
    public int getMaxInactiveInterval()
    {
        return 0;
    }

    /**
     * No-op; returns null;
     * @see javax.servlet.http.HttpSession#getSessionContext()
     * @deprecated
     */
    public HttpSessionContext getSessionContext()<commit_msg>Bug fix: added sensible session timeout defaults to TestHttpSession to prevent some tests from failing.<commit_after>package com.ecyrd.jspwiki;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.Vector;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;

/**
 * This is a mock HttpSession implementation. It is used for testing.
 * Most methods work as the should; notable exceptions include
 * getSessionContext/getServletContext.
 * @author <NAME>
 * @version $Revision: 1.4 $ $Date: 2006-06-17 23:21:08 $
 */
public class TestHttpSession implements HttpSession
{

    protected final long          m_createTime;

    protected static final Random RANDOM = new Random();

    protected final String        m_id;

    protected final long          m_lastAccessTime;

    protected final Map           m_attributes;
    
    protected int                 m_inactiveInterval;

    protected boolean             m_invalidated;

    /**
     * Constructs a new instance of this class.
     */
    public TestHttpSession()
    {
        m_createTime = System.currentTimeMillis();
        m_lastAccessTime = m_createTime;
        m_id = String.valueOf( RANDOM.nextLong() );
        m_attributes = new HashMap();
        m_invalidated = false;
        m_inactiveInterval = 1800;
    }

    /**
     * @see javax.servlet.http.HttpSession#getCreationTime()
     */
    public long getCreationTime()
    {
        return m_createTime;
    }

    /**
     * @see javax.servlet.http.HttpSession#getId()
     */
    public String getId()
    {
        return m_id;
    }

    /**
     * @see javax.servlet.http.HttpSession#getLastAccessedTime()
     */
    public long getLastAccessedTime()
    {
        return m_lastAccessTime;
    }

    /**
     * Always returns null.
     * @see javax.servlet.http.HttpSession#getServletContext()
     */
    public ServletContext getServletContext()
    {
        return null;
    }

    /**
     * No-op.
     * @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
     */
    public void setMaxInactiveInterval( int arg0 )
    {
        m_inactiveInterval = arg0;
    }

    /**
     * Returns the number of seconds of allowed inactivity;
     * returns 1800 seconds (30 minutes) by default.
     * @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
     */
    public int getMaxInactiveInterval()
    {
        return m_inactiveInterval;
    }

    /**
     * No-op; returns null;
     * @see javax.servlet.http.HttpSession#getSessionContext()
     * @deprecated
     */
    public HttpSessionContext getSessionContext()
{'fraction_non_alphanumeric': 0.09635517642497092, 'fraction_numerical': 0.009112058937572703, 'mean_word_length': 2.497627118644068, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3739040', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1475, 'n_words': 350}