<commit_before>/*
* @author <a href="mailto:<EMAIL>"><NAME></a>
* @version $Id$
*/
package org.gridlab.gridsphere.portletcontainer;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
import org.gridlab.gridsphere.portlet.PortletContext;
import org.gridlab.gridsphere.portlet.PortletLog;
import org.gridlab.gridsphere.portlet.impl.SportletLog;
import org.gridlab.gridsphere.portlet.service.spi.impl.SportletServiceFactory;

/**
 * This is the base fixture for service testing. Provides a service factory and the
 * properties file.
 */
public class GridSphereServletTest extends ServletTestCase {

    protected static SportletServiceFactory factory = null;
    protected static PortletLog log = SportletLog.getInstance(GridSphereServletTest.class);
    protected PortletContext context = null;
    protected GridSphereServlet gsServlet = null;

    public GridSphereServletTest(String name) {
        super(name);
    }

    protected void setUp() {
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }

    public void testInitGridSphere() {
        gsServlet = new GridSphereServlet();
        assertNotNull(gsServlet);
        try {
            gsServlet.init(config);
        } catch (Exception e) {
            fail("Unable to perform init() of GridSphereServlet!");
        }
        try {
            gsServlet.initializeServices();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unable to initialize GridSphere Portlet services!");
            log.error("Unable to initialize GridSphere Portlet services!", e);
        }
        factory = SportletServiceFactory.getInstance();
    }

    public static Test suite() {
        return new TestSuite(GridSphereServletTest.class);
    }

    protected void tearDown() {
    }
}<commit_msg>Added a guard to the base class GridSphereServletTest so that the services do not get initialized with each test case instance.<commit_after>/*
* @author <a href="mailto:<EMAIL>"><NAME></a>
* @version $Id$
*/
package org.gridlab.gridsphere.portletcontainer;

import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.ServletTestCase;
import org.gridlab.gridsphere.portlet.PortletContext;
import org.gridlab.gridsphere.portlet.PortletLog;
import org.gridlab.gridsphere.portlet.impl.SportletLog;
import org.gridlab.gridsphere.portlet.service.spi.impl.SportletServiceFactory;

/**
 * This is the base fixture for service testing. Provides a service factory and the
 * properties file.
 */
public class GridSphereServletTest extends ServletTestCase {

    protected static SportletServiceFactory factory = null;
    protected static PortletLog log = SportletLog.getInstance(GridSphereServletTest.class);
    protected PortletContext context = null;
    protected static GridSphereServlet gsServlet = null;    
    private static boolean bInited = false;

    public GridSphereServletTest(String name) {
        super(name);
    }

    protected void setUp() {
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }

    public void testInitGridSphere() {
        if (!bInited ){
            gsServlet = new GridSphereServlet();
            assertNotNull(gsServlet);
            try {
                gsServlet.init(config);
            } catch (Exception e) {
                fail("Unable to perform init() of GridSphereServlet!");
            }
            try {
                gsServlet.initializeServices();
            } catch (Exception e) {
                e.printStackTrace();
                fail("Unable to initialize GridSphere Portlet services!");
                log.error("Unable to initialize GridSphere Portlet services!", e);
            }
            factory = SportletServiceFactory.getInstance();
            bInited = true;
        }
    }

    public static Test suite() {
        return new TestSuite(GridSphereServletTest.class);
    }

    protected void tearDown() {
    }
}
{'fraction_non_alphanumeric': 0.09411185020941118, 'fraction_numerical': 0.0, 'mean_word_length': 2.941747572815534, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1696081', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1073, 'n_words': 276}