All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.jdbc.CallableStatementResultSetHandler Maven / Gradle / Ivy

Go to download

Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions. It includes a JDBC a JMS and a JCA test framework and can be used to test EJB based applications.

The newest version!
package com.mockrunner.jdbc;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import com.mockrunner.mock.jdbc.MockCallableStatement;

/**
 * Concrete handler for {@link MockCallableStatement}.
 */
public class CallableStatementResultSetHandler extends AbstractOutParameterResultSetHandler
{
    private List callableStatements;
    private Map callbaleStatementMap;

    public CallableStatementResultSetHandler()
    {
        callableStatements = new ArrayList();
        callbaleStatementMap = new TreeMap();
    }

    /**
     * The Connection adds new statements with
     * this method.
     * @param statement the {@link MockCallableStatement}
     */
    public void addCallableStatement(MockCallableStatement statement)
    { 
        statement.setCallableStatementResultSetHandler(this);
        List list = (List)callbaleStatementMap.get(statement.getSQL());
        if(null == list)
        {
            list = new ArrayList();
            callbaleStatementMap.put(statement.getSQL(), list);
        }
        list.add(statement);
        callableStatements.add(statement);
    }

    /**
     * Returns a List of all callable statements.
     * @return the List of {@link MockCallableStatement} objects
     */
    public List getCallableStatements()
    {
        return Collections.unmodifiableList(callableStatements);
    }

    /**
     * Returns a Map of all callable statements.
     * The SQL strings map to the corresponding {@link MockCallableStatement}
     * object.
     * @return the Map of {@link MockCallableStatement} objects
     */
    public Map getCallableStatementMap()
    {
        return Collections.unmodifiableMap(callbaleStatementMap);
    }

    /**
     * Clears all callable statements
     */
    public void clearCallableStatements()
    {
        callableStatements.clear();
        callbaleStatementMap.clear();
    }   
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy