Search in sources :

Example 11 with CleanDatabaseTestSetup

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

the class OLAPTest method makeSuite.

public static Test makeSuite() {
    Test clean = new CleanDatabaseTestSetup(new BaseTestSuite(OLAPTest.class)) {

        protected void decorateSQL(Statement s) throws SQLException {
            getConnection().setAutoCommit(false);
            s.executeUpdate("create table t1 (a int, b int)");
            s.executeUpdate("create table t2 (x int)");
            s.executeUpdate("create table t3 (y int)");
            s.executeUpdate("create table t4 (a int, b int)");
            s.executeUpdate("create table t5 (a int, b int)");
            s.executeUpdate("insert into t1 values (10,100),(20,200)," + "                      (30,300),(40,400)," + "                      (50,500)");
            s.executeUpdate("insert into t2 values (1),(2),(3),(4),(5)");
            s.executeUpdate("insert into t3 values (4),(5),(6),(7),(8)");
            s.executeUpdate("insert into t4 values (10,100),(20,200)");
            s.executeUpdate("insert into t5 values (1,1),(2,4),(3,4),(4,4),(5,9)");
            getConnection().commit();
        }
    };
    return clean;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 12 with CleanDatabaseTestSetup

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

the class OrderByAndOffsetFetchInSubqueries method makeSuite.

/**
 * Construct suite of tests
 *
 * @return A suite containing the test cases.
 */
private static Test makeSuite() {
    return new CleanDatabaseTestSetup(new BaseTestSuite(OrderByAndOffsetFetchInSubqueries.class)) {

        @Override
        protected void decorateSQL(Statement s) throws SQLException {
            getConnection().setAutoCommit(false);
            s.execute("create table temp1(s varchar(10))");
            // GENERATED ALWAYS AS IDENTITY
            s.execute("create table temp2(" + "i integer not null " + "    generated always as identity," + "s varchar(10))");
            s.execute("create table temp2b(" + "i integer not null " + "    generated always as identity," + "s varchar(10))");
            // DEFAULT value
            s.execute("create table temp3(" + "i integer not null " + "    generated always as identity," + "s varchar(10)," + "j integer not null " + "    default 66," + "t varchar(10))");
            // GENERATED ALWAYS AS (expression)
            s.execute("create table temp4(" + "i integer not null " + "    generated always as identity," + "s varchar(10)," + "j integer not null " + "    generated always as (2*i)," + "t varchar(10))");
            s.execute("create table t01(c1 int)");
            s.execute("create table t02(c2 int)");
            s.execute("create table t_source(c1 int, c2 varchar(10))");
            s.execute("create table t(i int not null, " + "               constraint c unique (i), " + "               j int, k int)");
            getConnection().commit();
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 13 with CleanDatabaseTestSetup

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

the class AutomaticIndexStatisticsTest method suite.

public static Test suite() {
    Test test = new BaseTestSuite(AutomaticIndexStatisticsTest.class);
    test = new CleanDatabaseTestSetup(test);
    test = TestConfiguration.additionalDatabaseDecorator(test, MASTERDB);
    // TimeZoneTestSetup can probably be removed once DERBY-5974 is fixed.
    return new TimeZoneTestSetup(test, "GMT");
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) TimeZoneTestSetup(org.apache.derbyTesting.junit.TimeZoneTestSetup)

Example 14 with CleanDatabaseTestSetup

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

the class ClassLoaderBootTest method suite.

/**
 * Runs the tests in the default embedded configuration and then
 * the client server configuration.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite(ClassLoaderBootTest.class);
    Test test = suite;
    TestSetup setup = new CleanDatabaseTestSetup(test) {

        protected void setUp() throws Exception {
            super.setUp();
            // shutdown the database.
            DataSource ds = JDBCDataSource.getDataSource();
            JDBCDataSource.shutdownDatabase(ds);
        }
    };
    Properties p = new Properties();
    p.setProperty("derby.infolog.append", "true");
    setup = new SystemPropertyTestSetup(setup, p);
    // on. Have to run without security manager for now.
    return SecurityManagerSetup.noSecurityManager(setup);
// return setup;
}
Also used : TestSetup(junit.extensions.TestSetup) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties) DataSource(javax.sql.DataSource) JDBCDataSource(org.apache.derbyTesting.junit.JDBCDataSource)

Example 15 with CleanDatabaseTestSetup

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

the class Derby4577Test method baseSuite.

protected static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(Derby4577Test.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 {
            Connection conn = stmt.getConnection();
            // create a table, with blob it will be 32k page size
            stmt.executeUpdate("CREATE TABLE testBadUpdate (id int, value blob(1M))");
            stmt.executeUpdate("CREATE TABLE testSmallRow1 (id char(1))");
            stmt.executeUpdate("CREATE TABLE testSmallRow2 (id char(1))");
            stmt.executeUpdate("CREATE TABLE testSmallRow3 (id char(20), id2 int)");
            conn.setAutoCommit(false);
        }
    };
}
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)

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