Search in sources :

Example 91 with CleanDatabaseTestSetup

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

the class NullSQLTextTest method baseSuite.

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

        /**
         * Creates the tables and the stored procedures used in the test
         * cases.
         *
         * @exception SQLException if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            Connection conn = getConnection();
            /**
             * Creates the table used in the test cases.
             */
            stmt.execute("create table t1 (i int)");
            stmt.execute("insert into t1 values 1, 2, 3, 4, 5, 6, 7");
            stmt.execute("create procedure za() language java external name " + "'org.apache.derbyTesting.functionTests.tests.jdbcapi.NullSQLTextTest.zeroArg'" + " parameter style java");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) Connection(java.sql.Connection) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 92 with CleanDatabaseTestSetup

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

the class ParameterMetaDataJdbc30Test method baseSuite.

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

        /**
         * Creates the tables and the stored procedures used in the test
         * cases.
         *
         * @exception SQLException if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            Connection conn = getConnection();
            // Create procedure used by
            // testParameterMetadataWithDECIMALParameters() and
            // testParameterMetadataWithLITERALParameters().
            stmt.execute("CREATE PROCEDURE PMDD(IN pmdI_1 DECIMAL(5,3), " + "IN pmdI_2 DECIMAL(4,2), INOUT pmdI_3 DECIMAL(9,0), " + "OUT pmdI_4 DECIMAL(10,2)) language java " + "parameter style java external name " + "'org.apache.derbyTesting.functionTests.tests.jdbcapi." + "ParameterMetaDataJdbc30Test.dummyDecimal'");
            /**
             * Creates the table used in the test cases.
             */
            stmt.execute("create table t ( " + /* 1 */
            "c char(5), " + /* 2 */
            "iNoNull int not null, " + /* 3 */
            "i int, " + /* 4 */
            "de decimal, " + /* 5 */
            "d date)");
            stmt.executeUpdate("create function RDB(P1 INT) " + "RETURNS DECIMAL(10,2) " + "language java external name " + "'org.apache.derbyTesting.functionTests." + "tests.lang.outparams30.returnsBigDecimal' " + "parameter style java");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 93 with CleanDatabaseTestSetup

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

the class PrepStmtNullTest method baseSuite.

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

        /**
         * Creates the tables used in the test
         * cases.
         *
         * @exception SQLException if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            /**
             * Creates the table used in the test cases.
             */
            stmt.execute("create table nullTS(name varchar(10), ts timestamp)");
            stmt.executeUpdate("create table nullBlob(name varchar(10), bval blob(16K))");
            stmt.executeUpdate("create table ClobBlob(cval clob, bval blob(16K))");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 94 with CleanDatabaseTestSetup

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

the class ProcedureTest method baseSuite.

/**
 * Creates the test suite and wraps it in a <code>TestSetup</code>
 * instance which sets up and tears down the test environment.
 * @return test suite
 */
private static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    // Need JDBC DriverManager to run these tests
    if (!JDBC.vmSupportsJDBC3())
        return suite;
    suite.addTestSuite(ProcedureTest.class);
    return new CleanDatabaseTestSetup(suite) {

        /**
         * Creates the tables and the stored procedures used in the test
         * cases.
         * @exception SQLException if a database error occurs
         */
        protected void decorateSQL(Statement s) throws SQLException {
            for (int i = 0; i < PROCEDURES.length; i++) {
                s.execute(PROCEDURES[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) CallableStatement(java.sql.CallableStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 95 with CleanDatabaseTestSetup

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

the class RelativeTest method baseSuite.

/**
 * Base suite of tests that will run in both embedded and client.
 *
 * @param name
 *            Name for the suite.
 */
private static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(RelativeTest.class);
    return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 2, 4)) {

        /**
         * Creates the tables used in the test cases.
         *
         * @exception SQLException
         *                if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.execute("create table testRelative(" + "name varchar(10), i int)");
            stmt.execute("insert into testRelative values (" + "'work1', NULL)");
            stmt.execute("insert into testRelative values (" + "'work2', NULL)");
            stmt.execute("insert into testRelative values (" + "'work3', NULL)");
            stmt.execute("insert into testRelative values (" + "'work4', NULL)");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) 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