package net.sourceforge.stripes;

import net.sourceforge.stripes.mock.MockServletContext;
import net.sourceforge.stripes.controller.StripesFilter;
import net.sourceforge.stripes.controller.DispatcherServlet;

import java.util.Map;
import java.util.HashMap;

/**
 * Test fixture that sets up a MockServletContext in a way that it can then be
 * used be any test in Stripes.
 *
 * @author Tim Fennell
 */
public class StripesTestFixture {
    private static MockServletContext context;

    /**
     * Gets a reference to the test MockServletContext. If the context is not already
     * instantiated and setup, it will be built lazily.
     *
     * @return an instance of MockServletContext for testing wiith
     */
    public static synchronized MockServletContext getServletContext() {
        if (context == null) {
            context = new MockServletContext("test");

            // Add the Stripes Filter
            Map<String,String> filterParams = new HashMap<String,String>();
            filterParams.put("ActionResolver.UrlFilters", "tests");
            filterParams.put("ActionResolver.PackageFilters", "net.sourceforge.stripes.*");
            context.addFilter(StripesFilter.class, "StripesFilter", filterParams);

            // Add the Stripes Dispatcher
            context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
        }

        return context;
    }
}

package net.sourceforge.stripes;

import net.sourceforge.stripes.mock.MockServletContext;
import net.sourceforge.stripes.controller.StripesFilter;
import net.sourceforge.stripes.controller.DispatcherServlet;

import java.util.Map;
import java.util.HashMap;

/**
 * Test fixture that sets up a MockServletContext in a way that it can then be
 * used be any test in Stripes.
 *
 * @author Tim Fennell
 */
public class StripesTestFixture {
    private static MockServletContext context;

    /**
     * Gets a reference to the test MockServletContext. If the context is not already
     * instantiated and setup, it will be built lazily.
     *
     * @return an instance of MockServletContext for testing wiith
     */
    public static synchronized MockServletContext getServletContext() {
        if (context == null) {
            context = new MockServletContext("test");

            // Add the Stripes Filter
            Map<String,String> filterParams = new HashMap<String,String>();
            filterParams.put("ActionResolver.Packages", "net.sourceforge.stripes");
            context.addFilter(StripesFilter.class, "StripesFilter", filterParams);

            // Add the Stripes Dispatcher
            context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
        }

        return context;
    }
}

Change to the Stripes test fixture to supply the new init-param ActionResolver.Packages
Change to the Stripes test fixture to supply the new init-param ActionResolver.Packages

git-svn-id: eee8cf2eb4cac5fd9f9d7b672efb1c285d99a606@436 d471f07e-d8fc-0310-a67b-dd4c8ff0e7cd
