org.apache.derbyTesting.functionTests.util
Class ScriptTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.junit.BaseJDBCTestCase
                  extended by org.apache.derbyTesting.functionTests.util.CanonTestCase
                      extended by org.apache.derbyTesting.functionTests.util.ScriptTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
IjTestCase, ImportExportIJTest, LangScripts, LocalizedAttributeScriptTest, LocalizedDisplayScriptTest, NetIjTest, NistScripts, SURijTest, ToolScripts

public abstract class ScriptTestCase
extends CanonTestCase

Run a .sql script as a test comparing it to a master output file.


Field Summary
private  java.lang.String inputEncoding
           
private  java.lang.String user
           
private  boolean useSystemProperties
           
 
Fields inherited from class org.apache.derbyTesting.functionTests.util.CanonTestCase
DEFAULT_ENCODING, outputEncoding
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
ScriptTestCase(java.lang.String script)
          Create a ScriptTestCase to run a single test using a connection obtained from getConnection()
ScriptTestCase(java.lang.String script, boolean useSystemProperties)
          Create a ScriptTestCase to run a single test using a connection obtained from getConnection()
ScriptTestCase(java.lang.String script, java.lang.String encoding)
          Create a ScriptTestCase to run a single test using a connection obtained from getConnection() with a different encoding
ScriptTestCase(java.lang.String script, java.lang.String inputEnc, java.lang.String outputEnc, java.lang.String user)
          Create a ScriptTestCase to run a single test using a connection obtained from getConnection() with a different encoding.
 
Method Summary
protected  java.lang.String getArea()
          Return the folder (last element of the package) where the .sql script lives, e.g. lang.
static junit.framework.Test getIJConfig(junit.framework.Test test)
          Get a decorator to setup the ij in order to run the test.
 void runTest()
          Run the test, using the resource as the input.
 
Methods inherited from class org.apache.derbyTesting.functionTests.util.CanonTestCase
compareCanon, getOutputStream, tearDown
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestCase
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertTableRowCount, assertUpdateCount, assertUpdateCount, checkAllConsistency, checkEstimatedRowCount, commit, createStatement, createStatement, createStatement, dropTable, dropTable, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbedded
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, setName, setUp, 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

inputEncoding

private final java.lang.String inputEncoding

user

private final java.lang.String user

useSystemProperties

private boolean useSystemProperties
Constructor Detail

ScriptTestCase

public ScriptTestCase(java.lang.String script,
                      boolean useSystemProperties)
Create a ScriptTestCase to run a single test using a connection obtained from getConnection()

Parameters:
script - Base name of the .sql script
useSystemProperties - Whether to use system properties for this test excluding the .sql suffix.

ScriptTestCase

public ScriptTestCase(java.lang.String script)
Create a ScriptTestCase to run a single test using a connection obtained from getConnection()

Parameters:
script - Base name of the .sql script excluding the .sql suffix.

ScriptTestCase

public ScriptTestCase(java.lang.String script,
                      java.lang.String encoding)
Create a ScriptTestCase to run a single test using a connection obtained from getConnection() with a different encoding

Parameters:
script - Base name of the .sql script excluding the .sql suffix.

ScriptTestCase

public ScriptTestCase(java.lang.String script,
                      java.lang.String inputEnc,
                      java.lang.String outputEnc,
                      java.lang.String user)
Create a ScriptTestCase to run a single test using a connection obtained from getConnection() with a different encoding.

Parameters:
script - Base name of the .sql script excluding the .sql suffix.
inputEnc - The encoding for the script, if not null, else use "US-ASCII"
outputEnc - The encoding for the ouput from the script, if not null, else use "US-ASCII"
user - Run script as user
Method Detail

getArea

protected java.lang.String getArea()
Return the folder (last element of the package) where the .sql script lives, e.g. lang.


getIJConfig

public static junit.framework.Test getIJConfig(junit.framework.Test test)
Get a decorator to setup the ij in order to run the test. A sub-class must decorate its suite using this call.


runTest

public void runTest()
             throws java.lang.Throwable
Run the test, using the resource as the input. Compare to the master file using a very simple line by line comparision. Fails at the first difference. If a failure occurs the output is written into the current directory as testScript.out, otherwise the output is only kept in memory.

Overrides:
runTest in class junit.framework.TestCase
Throws:
java.lang.Throwable

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.