package edu.northwestern.bioinformatics.studycalendar.testing;

import edu.nwu.bioinformatics.commons.testing.DbTestCase;

import org.springframework.context.ApplicationContext;

import javax.sql.DataSource;

/**
 * @author Rhett Sutphin
 */
public class DaoTestCase extends DbTestCase {
    private static ApplicationContext applicationContext = null;

    protected DataSource getDataSource() {
        return (DataSource) getApplicationContext().getBean("dataSource");
    }

    public ApplicationContext getApplicationContext() {
        synchronized (DaoTestCase.class) {
            if (applicationContext == null) {
                applicationContext = ContextTools.createDeployedApplicationContext();
            }
            return applicationContext;
        }
    }
}

@@ -131,226 +131,2218 @@
 org.
-springframework.context.ApplicationContext;%0A%0Aimport javax.sql.DataSource;%0A%0A/**%0A * @author Rhett Sutphin%0A */%0Apublic class DaoTestCase extends DbTestCase %7B%0A    private static ApplicationContext applicationContext = null;
+apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport org.springframework.context.ApplicationContext;%0Aimport org.springframework.mock.web.MockHttpServletRequest;%0Aimport org.springframework.mock.web.MockHttpServletResponse;%0Aimport org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor;%0A%0Aimport javax.sql.DataSource;%0A%0A/**%0A * @author Rhett Sutphin%0A */%0Apublic class DaoTestCase extends DbTestCase %7B%0A    private static ApplicationContext applicationContext = null;%0A    protected final Log log = LogFactory.getLog(getClass());%0A%0A    protected MockHttpServletRequest request = new MockHttpServletRequest();%0A    protected MockHttpServletResponse response = new MockHttpServletResponse();%0A    private boolean shouldFlush = true;%0A%0A    protected void setUp() throws Exception %7B%0A        super.setUp();%0A        beginSession();%0A    %7D%0A%0A    protected void tearDown() throws Exception %7B%0A        endSession();%0A        findOpenSessionInViewInterceptor().setFlushModeName(%22FLUSH_NEVER%22);%0A        super.tearDown();%0A    %7D%0A%0A    public void runBare() throws Throwable %7B%0A        setUp();%0A        try %7B%0A            runTest();%0A        %7D catch (Throwable throwable) %7B%0A            shouldFlush = false;%0A            throw throwable;%0A        %7D finally %7B%0A            tearDown();%0A        %7D%0A    %7D%0A%0A    private void beginSession() %7B%0A        log.info(%22-- beginning DaoTestCase interceptor session --%22);%0A        findOpenSessionInViewInterceptor().preHandle(request, response, null);%0A    %7D%0A%0A    private void endSession() %7B%0A        log.info(%22--    ending DaoTestCase interceptor session --%22);%0A        OpenSessionInViewInterceptor interceptor = findOpenSessionInViewInterceptor();%0A        if (shouldFlush) %7B%0A            interceptor.postHandle(request, response, null, null);%0A        %7D%0A        interceptor.afterCompletion(request, response, null, null);%0A    %7D%0A%0A    protected void interruptSession() %7B%0A        endSession();%0A        log.info(%22-- interrupted DaoTestCase session --%22);%0A        beginSession();%0A    %7D%0A%0A    private OpenSessionInViewInterceptor findOpenSessionInViewInterceptor() %7B%0A        return (OpenSessionInViewInterceptor) getApplicationContext().getBean(%22openSessionInViewInterceptor%22);%0A    %7D%0A
 %0A%0A  

Add open session in view filter support to tests