Package org.hibernate.testing.orm.jdbc
Class PreparedStatementSpyConnectionProvider
- java.lang.Object
-
- org.hibernate.testing.jdbc.ConnectionProviderDelegate
-
- org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProvider
-
- All Implemented Interfaces:
Serializable,org.hibernate.engine.jdbc.connections.spi.ConnectionProvider,org.hibernate.service.Service,org.hibernate.service.spi.Configurable,org.hibernate.service.spi.ServiceRegistryAwareService,org.hibernate.service.spi.Stoppable,org.hibernate.service.spi.Wrapped
public class PreparedStatementSpyConnectionProvider extends ConnectionProviderDelegate
ThisConnectionProviderextends any other ConnectionProvider that would be used by default taken the current configuration properties, and it intercept the underlyingPreparedStatementmethod calls.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PreparedStatementSpyConnectionProvider()Deprecated.best use thePreparedStatementSpyConnectionProvider(boolean,boolean)method to be explicit about the limitations.PreparedStatementSpyConnectionProvider(boolean allowMockVerificationOnStatements, boolean allowMockVerificationOnConnections)Careful: the default is to use mocks which do not allow to verify invocations, as otherwise the memory usage of the testsuite is extremely high.PreparedStatementSpyConnectionProvider(boolean allowMockVerificationOnStatements, boolean allowMockVerificationOnConnections, boolean forceSupportsAggressiveRelease)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ConnectionactualConnection()voidclear()Clears the recorded PreparedStatements and reset the associated Mocks.voidcloseConnection(Connection conn)List<Connection>getAcquiredConnections()Get a list of current acquired Connections.ConnectiongetConnection()List<String>getExecuteStatements()Get the SQL statements that were executed since the last clear operation.List<String>getExecuteUpdateStatements()Get the SQL update statements that were executed since the last clear operation.List<String>getPreparedSQLStatements()Get the PreparedStatements SQL statements.PreparedStatementgetPreparedStatement(String sql)Get one and only one PreparedStatement associated to the given SQL statement.List<PreparedStatement>getPreparedStatements()Get the PreparedStatements that were executed since the last clear operation.List<PreparedStatement>getPreparedStatements(String sql)Get the PreparedStatements that are associated to the following SQL statement.List<Connection>getReleasedConnections()Get a list of current released Connections.voidstop()-
Methods inherited from class org.hibernate.testing.jdbc.ConnectionProviderDelegate
configure, getConnectionProvider, injectServices, isUnwrappableAs, setConnectionProvider, supportsAggressiveRelease, unwrap
-
-
-
-
Constructor Detail
-
PreparedStatementSpyConnectionProvider
@Deprecated public PreparedStatementSpyConnectionProvider()
Deprecated.best use thePreparedStatementSpyConnectionProvider(boolean,boolean)method to be explicit about the limitations.
-
PreparedStatementSpyConnectionProvider
public PreparedStatementSpyConnectionProvider(boolean allowMockVerificationOnStatements, boolean allowMockVerificationOnConnections)Careful: the default is to use mocks which do not allow to verify invocations, as otherwise the memory usage of the testsuite is extremely high. When you really need to verify invocations, set the relevant constructor parameter to true.
-
PreparedStatementSpyConnectionProvider
public PreparedStatementSpyConnectionProvider(boolean allowMockVerificationOnStatements, boolean allowMockVerificationOnConnections, boolean forceSupportsAggressiveRelease)
-
-
Method Detail
-
actualConnection
protected Connection actualConnection() throws SQLException
- Throws:
SQLException
-
getConnection
public Connection getConnection() throws SQLException
- Specified by:
getConnectionin interfaceorg.hibernate.engine.jdbc.connections.spi.ConnectionProvider- Overrides:
getConnectionin classConnectionProviderDelegate- Throws:
SQLException
-
closeConnection
public void closeConnection(Connection conn) throws SQLException
- Specified by:
closeConnectionin interfaceorg.hibernate.engine.jdbc.connections.spi.ConnectionProvider- Overrides:
closeConnectionin classConnectionProviderDelegate- Throws:
SQLException
-
stop
public void stop()
- Specified by:
stopin interfaceorg.hibernate.service.spi.Stoppable- Overrides:
stopin classConnectionProviderDelegate
-
clear
public void clear()
Clears the recorded PreparedStatements and reset the associated Mocks.
-
getPreparedStatement
public PreparedStatement getPreparedStatement(String sql)
Get one and only one PreparedStatement associated to the given SQL statement.- Parameters:
sql- SQL statement.- Returns:
- matching PreparedStatement.
- Throws:
IllegalArgumentException- If there is no matching PreparedStatement or multiple instances, an exception is being thrown.
-
getPreparedStatements
public List<PreparedStatement> getPreparedStatements(String sql)
Get the PreparedStatements that are associated to the following SQL statement.- Parameters:
sql- SQL statement.- Returns:
- list of recorded PreparedStatements matching the SQL statement.
-
getPreparedStatements
public List<PreparedStatement> getPreparedStatements()
Get the PreparedStatements that were executed since the last clear operation.- Returns:
- list of recorded PreparedStatements.
-
getPreparedSQLStatements
public List<String> getPreparedSQLStatements()
Get the PreparedStatements SQL statements.- Returns:
- list of recorded PreparedStatements SQL statements.
-
getExecuteStatements
public List<String> getExecuteStatements()
Get the SQL statements that were executed since the last clear operation.- Returns:
- list of recorded update statements.
-
getExecuteUpdateStatements
public List<String> getExecuteUpdateStatements()
Get the SQL update statements that were executed since the last clear operation.- Returns:
- list of recorded update statements.
-
getAcquiredConnections
public List<Connection> getAcquiredConnections()
Get a list of current acquired Connections.- Returns:
- list of current acquired Connections
-
getReleasedConnections
public List<Connection> getReleasedConnections()
Get a list of current released Connections.- Returns:
- list of current released Connections
-
-