Search in sources :

Example 66 with CleanDatabaseTestSetup

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

the class MultiByteClobTest 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(MultiByteClobTest.class);
    return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 2, 4)) {

        /**
         * Creates the tables used in the test cases.
         *
         * @exception java.sql.SQLException
         *                if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.execute("CREATE TABLE MB_CLOBTABLE " + "(K INT CONSTRAINT PK PRIMARY KEY, C CLOB(" + LONG_CLOB_LENGTH + "))");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 67 with CleanDatabaseTestSetup

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

the class TriggerTests method suite.

public static Test suite() {
    Test suite = new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(TriggerTests.class));
    Properties p = new Properties();
    // use small pageCacheSize so we don't run out of memory on the insert
    // of large LOB columns.
    p.setProperty("derby.storage.pageCacheSize", "100");
    return new SystemPropertyTestSetup(suite, p);
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Properties(java.util.Properties)

Example 68 with CleanDatabaseTestSetup

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

the class ij3Test method suite.

public static Test suite() {
    Properties props = new Properties();
    props.setProperty("ij.database", "jdbc:derby:wombat;create=true");
    props.setProperty("ij.showNoConnectionsAtStart", "true");
    props.setProperty("ij.showNoCountForSelect", "true");
    Test test = new SystemPropertyTestSetup(new ij3Test("ij3"), props);
    test = new CleanDatabaseTestSetup(test);
    return getIJConfig(test);
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Properties(java.util.Properties)

Example 69 with CleanDatabaseTestSetup

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

the class HarnessJavaTest method decorate.

/**
 * Decorate a HarnessJavaTest test. Any sub-class must
 * call this decorator when adding a test to a suite.
 * This sets up the ij system properties to setup
 * the default connection to be to the default database.
 * The lock timeouts are also shortened and the test
 * will start in a clean database.
 */
protected static Test decorate(HarnessJavaTest test) {
    Test dtest = new SystemPropertyTestSetup(test, new Properties()) {

        protected void setUp() throws java.lang.Exception {
            TestConfiguration config = TestConfiguration.getCurrent();
            // With JDBC 3 connect using a JDBC URL
            if (JDBC.vmSupportsJDBC3()) {
                newValues.setProperty("ij.database", config.getJDBCUrl());
            }
            super.setUp();
        }
    };
    dtest = DatabasePropertyTestSetup.setLockTimeouts(dtest, 4, 6);
    dtest = new CleanDatabaseTestSetup(dtest);
    return dtest;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) TestConfiguration(org.apache.derbyTesting.junit.TestConfiguration) Properties(java.util.Properties)

Example 70 with CleanDatabaseTestSetup

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

the class BatchUpdateTest method baseSuite.

protected static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(BatchUpdateTest.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 t1(c1 int)");
            // for fixture testCallableStatementBatch
            stmt.execute("create table datetab(c1 date)");
            stmt.execute("create table timetab(c1 time)");
            stmt.execute("create table timestamptab(c1 timestamp)");
            stmt.execute("create table usertypetab(c1 DATE)");
            // for fixture testAssociatedParams
            stmt.execute("create table assoc" + "(x char(10) not null primary key, y char(100))");
            stmt.execute("create table assocout(x char(10))");
        }
    };
}
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)

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