Search in sources :

Example 46 with CleanDatabaseTestSetup

use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.

the class PreparedStatementTest method statementCachingSuite.

/**
 * Returns a suite for tests that need JDBC statement caching to be enabled.
 */
private static Test statementCachingSuite() {
    BaseTestSuite suite = new BaseTestSuite("JDBC statement caching suite");
    suite.addTest(new PreparedStatementTest("cpTestIsPoolableHintFalse"));
    suite.addTest(new PreparedStatementTest("cpTestIsPoolableHintTrue"));
    return TestConfiguration.connectionCPDecorator(new CleanDatabaseTestSetup(suite) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.execute("create table " + BLOBTBL + " (sno int, dBlob BLOB(1M))");
            stmt.execute("create table " + CLOBTBL + " (sno int, dClob CLOB(1M))");
            stmt.execute("create table " + LONGVARCHAR + " (sno int, dLongVarchar LONG VARCHAR)");
        }
    });
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 47 with CleanDatabaseTestSetup

use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.

the class PreparedStatementTest method baseSuite.

private static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(PreparedStatementTest.class);
    return new CleanDatabaseTestSetup(suite) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.execute("create table " + BLOBTBL + " (sno int, dBlob BLOB(1M))");
            stmt.execute("create table " + CLOBTBL + " (sno int, dClob CLOB(1M))");
            stmt.execute("create table " + LONGVARCHAR + " (sno int, dLongVarchar LONG VARCHAR)");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 48 with CleanDatabaseTestSetup

use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.

the class AutoGenJDBC30Test method baseSuite.

/**
 * Tests are only run if JDBC 3.0 available, and database objects get
 * created only once for the suite run.
 *
 * @param name name of the test
 */
private static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    if (!JDBC.vmSupportsJDBC3()) {
        // empty suite
        return suite;
    }
    suite.addTestSuite(AutoGenJDBC30Test.class);
    // Create database objects only once for entire test run
    return new CleanDatabaseTestSetup(suite) {

        /**
         * Creates the database objects used in the test cases.
         * @throws SQLException
         */
        protected void decorateSQL(Statement s) throws SQLException {
            for (int i = 0; i < ROUTINES.length; i++) {
                s.execute(ROUTINES[i]);
            }
            for (int i = 0; i < TABLES.length; i++) {
                s.execute(TABLES[i][1]);
            }
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Savepoint(java.sql.Savepoint)

Example 49 with CleanDatabaseTestSetup

use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.

the class TestDbMetaData method baseSuite.

private static Test baseSuite(String name) {
    BaseTestSuite testSuite = new BaseTestSuite(name);
    testSuite.addTestSuite(TestDbMetaData.class);
    return new CleanDatabaseTestSetup(testSuite) {

        protected void decorateSQL(Statement s) throws SQLException {
            createFunctions(s);
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 50 with CleanDatabaseTestSetup

use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.

the class DataSourceTest method suite.

/**
 * Return suite with all tests of the class.
 */
public static Test suite() {
    // Use explicit ordering of fixtures until fix of DERBY-5988
    BaseTestSuite s = new BaseTestSuite("datasourcetestsuite-embedded");
    s.addTest(new DataSourceTest("testIsNotWrapperForPoolDataSource"));
    s.addTest(new DataSourceTest("testIsNotWrapperForXADataSource"));
    s.addTest(new DataSourceTest("testUnwrapConnectionPoolDataSource"));
    s.addTest(new DataSourceTest("testIsWrapperForDataSource"));
    s.addTest(new DataSourceTest("testIsNotWrapperForResultSet"));
    s.addTest(new DataSourceTest("testUnwrapXADataSource"));
    s.addTest(new DataSourceTest("testConnectionErrorEvent"));
    s.addTest(new DataSourceTest("testUnwrapResultSet"));
    s.addTest(new DataSourceTest("testUnwrapDataSource"));
    s.addTest(new DataSourceTest("test_jdbc4_1"));
    BaseTestSuite ns = new BaseTestSuite("datasourcetestsuite-net");
    ns.addTest(new DataSourceTest("testIsNotWrapperForPoolDataSource"));
    ns.addTest(new DataSourceTest("testIsNotWrapperForXADataSource"));
    ns.addTest(new DataSourceTest("testUnwrapConnectionPoolDataSource"));
    ns.addTest(new DataSourceTest("testIsWrapperForDataSource"));
    ns.addTest(new DataSourceTest("testIsNotWrapperForResultSet"));
    ns.addTest(new DataSourceTest("testUnwrapXADataSource"));
    ns.addTest(new DataSourceTest("testConnectionErrorEvent"));
    ns.addTest(new DataSourceTest("testUnwrapResultSet"));
    ns.addTest(new DataSourceTest("testUnwrapDataSource"));
    ns.addTest(new DataSourceTest("test_jdbc4_1"));
    BaseTestSuite totalsuite = new BaseTestSuite("datasourcetest");
    totalsuite.addTest(new CleanDatabaseTestSetup(s));
    totalsuite.addTest(TestConfiguration.clientServerDecorator(new CleanDatabaseTestSetup(ns)));
    return totalsuite;
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Aggregations

CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)147 BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)118 Statement (java.sql.Statement)95 PreparedStatement (java.sql.PreparedStatement)77 Test (junit.framework.Test)77 Properties (java.util.Properties)25 CallableStatement (java.sql.CallableStatement)21 Connection (java.sql.Connection)20 SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)20 SupportFilesSetup (org.apache.derbyTesting.junit.SupportFilesSetup)19 SQLException (java.sql.SQLException)7 DatabasePropertyTestSetup (org.apache.derbyTesting.junit.DatabasePropertyTestSetup)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Random (java.util.Random)3 TestSetup (junit.extensions.TestSetup)3 LocaleTestSetup (org.apache.derbyTesting.junit.LocaleTestSetup)3 ResultSet (java.sql.ResultSet)2 Locale (java.util.Locale)2 PrepareStatementTest (org.apache.derbyTesting.functionTests.tests.derbynet.PrepareStatementTest)2 AnsiTrimTest (org.apache.derbyTesting.functionTests.tests.lang.AnsiTrimTest)2