org.apache.derbyTesting.functionTests.tests.jdbcapi
Class ClosedObjectTest.ObjectDecorator

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.extensions.TestDecorator
          extended by junit.extensions.TestSetup
              extended by org.apache.derbyTesting.functionTests.tests.jdbcapi.ClosedObjectTest.ObjectDecorator
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
ClosedObjectTest.ConnectionObjectDecorator, ClosedObjectTest.ResultSetObjectDecorator, ClosedObjectTest.StatementObjectDecorator
Enclosing class:
ClosedObjectTest

private abstract static class ClosedObjectTest.ObjectDecorator
extends junit.extensions.TestSetup

Abstract decorator class with functionality for obtaining a closed object.


Field Summary
private  ClosedObjectTest.DataSourceDecorator decorator_
          Decorator which provides a connection.
protected  java.lang.Object object_
          The closed object.
 
Fields inherited from class junit.extensions.TestDecorator
fTest
 
Constructor Summary
ClosedObjectTest.ObjectDecorator(junit.framework.Test test, ClosedObjectTest.DataSourceDecorator decorator)
          Creates a new ObjectDecorator instance.
 
Method Summary
 void checkException(java.lang.reflect.Method method, java.sql.SQLException sqle)
          Checks whether an exception is of the expected type for that method.
protected abstract  void checkSQLState(java.lang.reflect.Method method, java.sql.SQLException sqle)
          Checks whether the SQL state is as expected.
protected  java.sql.Connection createConnection()
          Helper method for creating a connection.
protected  java.sql.Statement createStatement()
          Helper method for creating a statement.
 boolean expectsException(java.lang.reflect.Method method)
          Checks whether a method expects an exception to be thrown when the object is closed.
 java.lang.Object getClosedObject()
          Returns the closed object.
protected  java.sql.CallableStatement prepareCall(java.lang.String call)
          Helper method for creating a callable statement.
protected  java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Helper method for creating a prepared statement.
protected  void tearDown()
          Tears down the test environment.
 
Methods inherited from class junit.extensions.TestSetup
run, setUp
 
Methods inherited from class junit.extensions.TestDecorator
basicRun, countTestCases, getTest, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

decorator_

private final ClosedObjectTest.DataSourceDecorator decorator_
Decorator which provides a connection.


object_

protected java.lang.Object object_
The closed object. Must be set by a sub-class.

Constructor Detail

ClosedObjectTest.ObjectDecorator

public ClosedObjectTest.ObjectDecorator(junit.framework.Test test,
                                        ClosedObjectTest.DataSourceDecorator decorator)
Creates a new ObjectDecorator instance.

Parameters:
test - a test or suite to decorate
decorator - a decorator which provides a connection
Method Detail

tearDown

protected void tearDown()
                 throws java.lang.Exception
Tears down the test environment.

Overrides:
tearDown in class junit.extensions.TestSetup
Throws:
java.lang.Exception

getClosedObject

public java.lang.Object getClosedObject()
Returns the closed object.

Returns:
a closed object

expectsException

public boolean expectsException(java.lang.reflect.Method method)
Checks whether a method expects an exception to be thrown when the object is closed. Currently, only close(), isClosed() and isValid() don't expect exceptions.

Parameters:
method - a method
Returns:
true if an exception is expected

checkException

public final void checkException(java.lang.reflect.Method method,
                                 java.sql.SQLException sqle)
                          throws java.sql.SQLException
Checks whether an exception is of the expected type for that method.

Parameters:
method - a method
sqle - an exception
Throws:
java.sql.SQLException - if the exception was not expected

checkSQLState

protected abstract void checkSQLState(java.lang.reflect.Method method,
                                      java.sql.SQLException sqle)
                               throws java.sql.SQLException
Checks whether the SQL state is as expected.

Parameters:
method - a Method value
sqle - a SQLException value
Throws:
java.sql.SQLException - if an error occurs

createConnection

protected java.sql.Connection createConnection()
                                        throws java.sql.SQLException
Helper method for creating a connection.

Returns:
a connection
Throws:
java.sql.SQLException - if an error occurs

createStatement

protected java.sql.Statement createStatement()
                                      throws java.sql.SQLException
Helper method for creating a statement.

Returns:
a statement
Throws:
java.sql.SQLException - if an error occurs

prepareStatement

protected java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                               throws java.sql.SQLException
Helper method for creating a prepared statement.

Parameters:
sql - statement text
Returns:
a prepared statement
Throws:
java.sql.SQLException - if an error occurs

prepareCall

protected java.sql.CallableStatement prepareCall(java.lang.String call)
                                          throws java.sql.SQLException
Helper method for creating a callable statement.

Parameters:
call - statement text
Returns:
a callable statement
Throws:
java.sql.SQLException - if an error occurs

Built on Sat 2009-11-28 18:44:18-0800, from revision 885187

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.