Search in sources :

Example 31 with CleanDatabaseTestSetup

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

the class ReleaseCompileLocksTest method baseSuite.

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

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table t1 (s int)");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 32 with CleanDatabaseTestSetup

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

the class RestrictedVTITest method suite.

// /////////////////////////////////////////////////////////////////////////////////
// 
// JUnit BEHAVIOR
// 
// /////////////////////////////////////////////////////////////////////////////////
/**
 * Construct top level suite in this JUnit test
 */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(RestrictedVTITest.class);
    Test result = new CleanDatabaseTestSetup(suite);
    return result;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 33 with CleanDatabaseTestSetup

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

the class SpillHashTest method suite.

/**
 * Returns the implemented tests.
 *
 * @return An instance of <code>Test</code> with the implemented tests to
 *         run.
 */
public static Test suite() {
    // suite of tests with light load on the tables
    BaseTestSuite light = new BaseTestSuite();
    // suite of tests with heavy load on the tables
    BaseTestSuite heavy = new BaseTestSuite();
    light.addTest(new SpillHashTest("testJoinLight"));
    light.addTest(new SpillHashTest("testDistinctLight"));
    light.addTest(new SpillHashTest("testCursorLight"));
    heavy.addTest(new SpillHashTest("testJoinHeavy"));
    heavy.addTest(new SpillHashTest("testDistinctHeavy"));
    heavy.addTest(new SpillHashTest("testCursorHeavy"));
    Test lightSetup = new BaseJDBCTestSetup(light) {

        protected void setUp() throws Exception {
            super.setUp();
            Statement stmt = getConnection().createStatement();
            PreparedStatement insA = stmt.getConnection().prepareStatement("insert into ta(ca1,ca2) values(?,?)");
            PreparedStatement insB = stmt.getConnection().prepareStatement("insert into tb(cb1,cb2) values(?,?)");
            insertDups(insA, insB, initDupVals);
            getConnection().commit();
            stmt.close();
        // System.out.println("2");
        }
    };
    Test heavySetup = new BaseJDBCTestSetup(heavy) {

        protected void setUp() throws Exception {
            super.setUp();
            Statement stmt = getConnection().createStatement();
            PreparedStatement insA = stmt.getConnection().prepareStatement("insert into ta(ca1,ca2) values(?,?)");
            PreparedStatement insB = stmt.getConnection().prepareStatement("insert into tb(cb1,cb2) values(?,?)");
            for (int i = 1; i <= LOTS_OF_ROWS; i++) {
                insA.setInt(1, i);
                insA.setString(2, ca2Val(i));
                insA.executeUpdate();
                insB.setInt(1, i);
                insB.setString(2, cb2Val(i));
                insB.executeUpdate();
                if ((i & 0xff) == 0)
                    stmt.getConnection().commit();
            }
            insertDups(insA, insB, spillDupVals);
            getConnection().commit();
            stmt.close();
        // System.out.println("3");
        }
    };
    BaseTestSuite mainSuite = new BaseTestSuite();
    mainSuite.addTest(lightSetup);
    mainSuite.addTest(heavySetup);
    return new CleanDatabaseTestSetup(mainSuite) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            for (int i = 0; i < prep.length; i++) {
                stmt.executeUpdate(prep[i]);
            }
        // System.out.println("1");
        }
    };
}
Also used : BaseJDBCTestSetup(org.apache.derbyTesting.junit.BaseJDBCTestSetup) Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) PreparedStatement(java.sql.PreparedStatement)

Example 34 with CleanDatabaseTestSetup

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

the class StalePlansTest method suite.

/**
 * Create the test suite. This test is not run in client/server mode since
 * it only tests the query plans generated by the embedded driver.
 */
public static Test suite() {
    Properties props = new Properties();
    // Check for stale plans on every 10th execution (default 100) to
    // reduce the number of times we need to execute each statement.
    props.setProperty("derby.language.stalePlanCheckInterval", String.valueOf(STALE_PLAN_CHECK_INTERVAL));
    // Disable the index statistics daemon so that it doesn't cause
    // recompilation of statements at random times.
    props.setProperty("derby.storage.indexStats.auto", "false");
    Test suite = new DatabasePropertyTestSetup(new BaseTestSuite(StalePlansTest.class), props, true);
    return new CleanDatabaseTestSetup(suite);
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 35 with CleanDatabaseTestSetup

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

the class StatementPlanCacheTest method suite.

/**
 * Runs in embedded only since it's testing the server side cache.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("StatementPlanCacheTest");
    // default cache size
    CACHE_SIZE = 100;
    suite.addTest(baseSuite("default"));
    suite.addTest(suiteWithSizeSet(5));
    suite.addTest(suiteWithSizeSet(140));
    // no caching
    suite.addTest(DatabasePropertyTestSetup.singleProperty(new StatementPlanCacheTest("noCachingTest"), "derby.language.statementCacheSize", "0", true));
    return new CleanDatabaseTestSetup(suite);
}
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