Search in sources :

Example 76 with CleanDatabaseTestSetup

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

the class OptimizerOverridesTest method suite.

public static Test suite() {
    Test suite = TestConfiguration.defaultSuite(OptimizerOverridesTest.class, false);
    suite = new CleanDatabaseTestSetup(suite) {

        /* Create tables, indices and views.
             * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
             */
        protected void decorateSQL(Statement st) throws SQLException {
            st.getConnection().setAutoCommit(false);
            st.addBatch("create table t1 (c1 int, " + "c2 int, c3 int," + " constraint cons1 primary key(c1, c2))");
            st.addBatch("create table t2 (c1 int not null, " + "c2 int not null, c3 int, " + "constraint cons2 unique(c1, c2))");
            st.addBatch("insert into t1 values (1, 1, 1), " + "(2, 2, 2), (3, 3, 3), (4, 4, 4)");
            ;
            st.addBatch("insert into t2 values (1, 1, 1), " + "(2, 2, 2), (3, 3, 3), (4, 4, 4)");
            st.addBatch("create index t1_c1c2c3 on t1(c1, c2, c3)");
            st.addBatch("create index t1_c3c2c1 on t1(c3, c2, c1)");
            st.addBatch("create index t1_c1 on t1(c1)");
            st.addBatch("create index t1_c2 on t1(c2)");
            st.addBatch("create index t1_c3 on t1(c3)");
            st.addBatch("create index \"t1_c2c1\" on t1(c2, c1)");
            st.addBatch("create index t2_c1c2c3 on t2(c1, c2, c3)");
            st.addBatch("create index t2_c3c2c1 on t2(c3, c2, c1)");
            st.addBatch("create index t2_c1 on t2(c1)");
            st.addBatch("create index t2_c2 on t2(c2)");
            st.addBatch("create index t2_c3 on t2(c3)");
            st.addBatch("create view v1 as select * from t1 " + "--derby-properties index = t1_c1");
            st.addBatch("create view v2 as select t1.* from t1, t2");
            st.addBatch("create view v3 as select * from v1");
            st.addBatch("create view neg_v1 as select * from t1" + " --derby-properties asdf = fdsa");
            st.executeBatch();
        }
    };
    return suite;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SQLException(java.sql.SQLException) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement)

Example 77 with CleanDatabaseTestSetup

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

the class PredicatePushdownTest method suite.

public static Test suite() {
    Properties systemProperties = new Properties();
    systemProperties.setProperty("derby.optimizer.noTimeout", "true");
    BaseTestSuite suite = new BaseTestSuite("predicatePushdown Test");
    suite.addTest(new SystemPropertyTestSetup(new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(PredicatePushdownTest.class)), systemProperties));
    return suite;
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 78 with CleanDatabaseTestSetup

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

the class IndexSplitDeadlockTest method suite.

public static Test suite() {
    Test test = TestConfiguration.embeddedSuite(IndexSplitDeadlockTest.class);
    // DERBY-4273: Include the lock table in the error message to help
    // debugging in case of lock timeouts.
    test = DatabasePropertyTestSetup.singleProperty(test, "derby.locks.deadlockTrace", "true");
    test = new CleanDatabaseTestSetup(test);
    return test;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup)

Example 79 with CleanDatabaseTestSetup

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

the class LiveLockTest method suite.

public static Test suite() {
    Test suite = TestConfiguration.embeddedSuite(LiveLockTest.class);
    return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 1, 10)) {

        /**
         * Creates the table used in the test cases.
         */
        protected void decorateSQL(Statement s) throws SQLException {
            s.executeUpdate("CREATE TABLE T (I INT)");
            s.executeUpdate("INSERT INTO T VALUES(456)");
        }
    };
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement)

Example 80 with CleanDatabaseTestSetup

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

the class ImportExportTest method baseSuite.

public static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(ImportExportTest.class, name);
    Test test = new SupportFilesSetup(suite, new String[] { "functionTests/testData/ImportExport/TwoLineBadEOF.dat" });
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create type Price external name 'org.apache.derbyTesting.functionTests.tests.lang.Price' language java");
            s.execute("create type hashmap external name 'java.util.HashMap' language java");
            s.execute("create function makePrice( ) returns price " + "language java parameter style java no sql " + "external name 'org.apache.derbyTesting.functionTests.tests.lang.Price.makePrice'");
            s.execute("create function makeHashMap( ) returns hashmap " + "language java parameter style java no sql " + "external name 'org.apache.derbyTesting.functionTests.tests.lang.UDTTest.makeHashMap'");
            s.execute("CREATE TABLE T1 (COLUMN1 VARCHAR(5) , COLUMN2 VARCHAR(8) , " + "COLUMN3 SMALLINT , COLUMN4 CHAR(11) , COLUMN5 DATE , COLUMN6 DECIMAL(5,1) , " + "COLUMN7 DOUBLE PRECISION , COLUMN8 INT , COLUMN9 BIGINT , COLUMN10 NUMERIC , " + "COLUMN11 REAL , COLUMN12 SMALLINT , COLUMN13 TIME , COLUMN14 TIMESTAMP , " + "COLUMN15 SMALLINT , COLUMN16 VARCHAR(1), COLUMN17 PRICE)");
            s.execute("CREATE TABLE T2 (COLUMN1 VARCHAR(5) , COLUMN2 VARCHAR(8) , " + "COLUMN3 SMALLINT, COLUMN4 CHAR(11) , COLUMN5 DATE , COLUMN6 DECIMAL(5,1) , " + "COLUMN7 DOUBLE PRECISION , COLUMN8 INT , COLUMN9 BIGINT , COLUMN10 NUMERIC , " + "COLUMN11 REAL , COLUMN12 SMALLINT , COLUMN13 TIME , COLUMN14 TIMESTAMP , " + "COLUMN15 SMALLINT , COLUMN16 VARCHAR(1), COLUMN17 PRICE)");
            s.execute("create table T4 (   Account int,    Name   char(30), Jobdesc char(40), " + "Company varchar(35), Address1 varchar(40), Address2 varchar(40), " + "City    varchar(20), State   char(5), Zip char(10), Country char(10), " + "Phone1  char(20), Phone2  char(20), email   char(30), web     char(30), " + "Fname   char(30), Lname   char(30), Comment char(30), AccDate char(30), " + "Payment decimal(8,2), Balance decimal(8,2))");
            s.execute("create table t5( a int, b price )");
            s.execute("create table t6( a int, b hashmap )");
        }
    };
}
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) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

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