Package net.officefloor.jdbc.test
Class ValidateConnectionDecoratorFactory
- java.lang.Object
-
- net.officefloor.jdbc.test.ValidateConnectionDecoratorFactory
-
- All Implemented Interfaces:
ConnectionDecorator
,ConnectionDecoratorFactory
,PooledConnectionDecorator
,PooledConnectionDecoratorFactory
public class ValidateConnectionDecoratorFactory extends java.lang.Object implements ConnectionDecoratorFactory, ConnectionDecorator, PooledConnectionDecoratorFactory, PooledConnectionDecorator
ConnectionDecoratorFactory
to validate all createdConnection
andPooledConnection
instances are closed on closingOfficeFloor
.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ValidateConnectionDecoratorFactory.PooledConnectionClosed
Indicates if thePooledConnection
is closed.
-
Constructor Summary
Constructors Constructor Description ValidateConnectionDecoratorFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
assertAllConnectionsClosed()
Ensures all connections are closed.static void
assertNoPreviousTestConnections()
Ensure that the previous test has not leaked connections into this test.ConnectionDecorator
createConnectionDecorator(SourceContext context)
Creates theConnectionDecorator
.PooledConnectionDecorator
createPooledConnectionDecorator(SourceContext context)
Creates thePooledConnectionDecorator
.java.sql.Connection
decorate(java.sql.Connection connection)
Allows decorating theConnection
.javax.sql.PooledConnection
decorate(javax.sql.PooledConnection connection)
Allows decorating thePooledConnection
.static int
getConnectionsRegisteredCount()
Obtains the number of connections registered.
-
-
-
Method Detail
-
getConnectionsRegisteredCount
public static int getConnectionsRegisteredCount()
Obtains the number of connections registered.- Returns:
- Number of connections registered.
-
assertNoPreviousTestConnections
public static void assertNoPreviousTestConnections()
Ensure that the previous test has not leaked connections into this test.
-
assertAllConnectionsClosed
public static void assertAllConnectionsClosed()
Ensures all connections are closed.
-
createConnectionDecorator
public ConnectionDecorator createConnectionDecorator(SourceContext context) throws java.lang.Exception
Description copied from interface:ConnectionDecoratorFactory
Creates theConnectionDecorator
.- Specified by:
createConnectionDecorator
in interfaceConnectionDecoratorFactory
- Parameters:
context
-SourceContext
to configure theConnectionDecorator
.- Returns:
ConnectionDecorator
.- Throws:
java.lang.Exception
- If fails to create theConnectionDecorator
.
-
decorate
public java.sql.Connection decorate(java.sql.Connection connection)
Description copied from interface:ConnectionDecorator
Allows decorating theConnection
.- Specified by:
decorate
in interfaceConnectionDecorator
- Parameters:
connection
-Connection
to decorate.- Returns:
- Decorated
Connection
or possibly new wrappingConnection
implementation.
-
createPooledConnectionDecorator
public PooledConnectionDecorator createPooledConnectionDecorator(SourceContext context) throws java.lang.Exception
Description copied from interface:PooledConnectionDecoratorFactory
Creates thePooledConnectionDecorator
.- Specified by:
createPooledConnectionDecorator
in interfacePooledConnectionDecoratorFactory
- Parameters:
context
-SourceContext
to configure thePooledConnectionDecorator
.- Returns:
PooledConnectionDecorator
.- Throws:
java.lang.Exception
- If fails to create thePooledConnectionDecorator
.
-
decorate
public javax.sql.PooledConnection decorate(javax.sql.PooledConnection connection)
Description copied from interface:PooledConnectionDecorator
Allows decorating thePooledConnection
.- Specified by:
decorate
in interfacePooledConnectionDecorator
- Parameters:
connection
-PooledConnection
to decorate.- Returns:
- Decorated
PooledConnection
or possibly new wrappingConnection
implementation.
-
-