com.mockrunner.jdbc.PreparedStatementResultSetHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
Show all versions of mockrunner-jdk1.3-j2ee1.3 Show documentation
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.MockPreparedStatement;
/**
* Concrete handler for {@link MockPreparedStatement}.
*/
public class PreparedStatementResultSetHandler extends AbstractParameterResultSetHandler
{
private List preparedStatements;
private Map preparedStatementMap;
public PreparedStatementResultSetHandler()
{
preparedStatements = new ArrayList();
preparedStatementMap = new TreeMap();
}
/**
* The Connection
adds new statements with
* this method.
* @param statement the {@link MockPreparedStatement}
*/
public void addPreparedStatement(MockPreparedStatement statement)
{
statement.setPreparedStatementResultSetHandler(this);
List list = (List)preparedStatementMap.get(statement.getSQL());
if(null == list)
{
list = new ArrayList();
preparedStatementMap.put(statement.getSQL(), list);
}
list.add(statement);
preparedStatements.add(statement);
}
/**
* Returns a List
of all prepared statements.
* @return the List
of {@link MockPreparedStatement} objects
*/
public List getPreparedStatements()
{
return Collections.unmodifiableList(preparedStatements);
}
/**
* Returns a Map
of all prepared statements.
* The SQL strings map to the corresponding {@link MockPreparedStatement}
* object.
* @return the Map
of {@link MockPreparedStatement} objects
*/
public Map getPreparedStatementMap()
{
return Collections.unmodifiableMap(preparedStatementMap);
}
/**
* Clears all prepared statements
*/
public void clearPreparedStatements()
{
preparedStatements.clear();
preparedStatementMap.clear();
}
}