Search in sources :

Example 16 with CleanDatabaseTestSetup

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

the class StandardTests method all.

/* All the above are pure Tests. To handle suites
     * we will have to duplicate the .suite() structure starting at .suites.all!
     *
     * The following is WORK IN PROGRESS: NOT READY FOR USE! FIXME!
     */
public static Test all(String serverHost, int serverPort) throws Exception {
    BaseTestSuite suite = new BaseTestSuite("All_" + serverHost + ":" + serverPort);
    // All package tests
    // This won't work as there are no 'testXXXX' methods
    // in AllPackages. Must create a suite() following the pattern of suites.All suite().
    // This is probably correct anyway as we presumably won't use all
    // tests in the replication testing?
    // Problem is we get a parallell structure which needs maintenance!
    suite.addTest(// false: because adds clean/decorate below
    TestConfiguration.existingServerSuite(// false: because adds clean/decorate below
    AllPackages.class, // false: because adds clean/decorate below
    false, serverHost, serverPort));
    // Instead:
    suite.addTest(// false: because adds clean/decorate below
    TestConfiguration.existingServerSuite(// false: because adds clean/decorate below
    allPackagesSuite(), // false: because adds clean/decorate below
    false, serverHost, serverPort));
    // Encrypted tests
    suite.addTest(// false: because adds clean/decorate below
    TestConfiguration.existingServerSuite(// false: because adds clean/decorate below
    EncryptionSuite.class, // false: because adds clean/decorate below
    false, serverHost, serverPort));
    CleanDatabaseTestSetup cdts = new CleanDatabaseTestSetup(suite, // Use networkclient when running setUp/decorateSQL
    true, serverHost, serverPort) {

        public void decorateSQL(Statement s) throws SQLException {
        // decorate(s);
        }
    };
    return cdts;
}
Also used : EncryptionSuite(org.apache.derbyTesting.functionTests.suites.EncryptionSuite) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) AllPackages(org.apache.derbyTesting.functionTests.suites.AllPackages) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 17 with CleanDatabaseTestSetup

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

the class StandardTests method ansiTrimTest.

public static Test ansiTrimTest(String serverHost, int serverPort) {
    Test t = // false: because adds clean/decorate below
    TestConfiguration.existingServerSuite(// false: because adds clean/decorate below
    AnsiTrimTest.class, // false: because adds clean/decorate below
    false, serverHost, serverPort);
    CleanDatabaseTestSetup cdts = new CleanDatabaseTestSetup(t, // Use networkclient when running setUp/decorateSQL
    true, serverHost, serverPort) {

        public void decorateSQL(Statement s) throws SQLException {
            AnsiTrimTest.decorate(s);
        }
    };
    return cdts;
}
Also used : PrepareStatementTest(org.apache.derbyTesting.functionTests.tests.derbynet.PrepareStatementTest) Test(junit.framework.Test) SimpleTest(org.apache.derbyTesting.functionTests.tests.lang.SimpleTest) DatabaseClassLoadingTest(org.apache.derbyTesting.functionTests.tests.lang.DatabaseClassLoadingTest) CreateTableFromQueryTest(org.apache.derbyTesting.functionTests.tests.lang.CreateTableFromQueryTest) AnsiTrimTest(org.apache.derbyTesting.functionTests.tests.lang.AnsiTrimTest) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement)

Example 18 with CleanDatabaseTestSetup

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

the class NistScripts method suite.

/**
 * Return the suite that runs the NIST SQL scripts.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("NIST");
    String suiteUser = null;
    BaseTestSuite userSuite = null;
    for (int i = 0; i < TESTS.length; i++) {
        String testScript = TESTS[i][0];
        String testUser = TESTS[i][1];
        Test test = new NistScripts(testScript);
        if (testUser.equals(suiteUser)) {
            userSuite.addTest(test);
            continue;
        }
        // Add the new user suite with the change user decorator to
        // the main suite but continue to add tests to the user suite.
        userSuite = new BaseTestSuite("NIST user=" + testUser);
        String password = testUser.concat("ni8s4T");
        suite.addTest(TestConfiguration.changeUserDecorator(userSuite, testUser, password));
        suiteUser = testUser;
        userSuite.addTest(test);
    }
    Test test = getIJConfig(suite);
    // Setup user authentication
    test = DatabasePropertyTestSetup.builtinAuthentication(test, new String[] { "APP", "HU", "FLATER", "SUN", "CTS1", "SULLIVAN1", "SCHANZLE" }, "ni8s4T");
    // Lock timeout settings that were set for the old harness when
    // running nist.
    test = DatabasePropertyTestSetup.setLockTimeouts(test, 2, 4);
    return new CleanDatabaseTestSetup(test);
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 19 with CleanDatabaseTestSetup

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

the class BlobAccessTest method suite.

/**
 * Generates a suite of tests.
 * <p>
 * The required test data will be generated. Note that a subset of the
 * tests can be disabled by using a system property.
 *
 * @return A suite of tests.
 */
public static Test suite() {
    BaseTestSuite mainSuite = new BaseTestSuite("BlobAccessTest suite");
    if (!disableSmallBlobs) {
        int iters = 50;
        int reps = 3;
        println("Adding small Blob tests.");
        BaseTestSuite smallSuite = new BaseTestSuite("Small Blob suite");
        smallSuite.addTest(new BlobAccessTest("testFetchSmallBlobs", iters, reps));
        smallSuite.addTest(new BlobAccessTest("testFetchSmallBlobsInaccurateLength", iters, reps));
        smallSuite.addTest(new BlobAccessTest("testModifySmallBlobs", iters, reps));
        mainSuite.addTest(smallSuite);
    }
    if (!disableLargeBlobs) {
        int iters = 5;
        int reps = 3;
        println("Adding large Blob tests.");
        BaseTestSuite largeSuite = new BaseTestSuite("Large Blob suite");
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobs", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobOneByOneByteBaseline", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobOneByOneByteModified", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobOneByOneByte", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlob", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobModified", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobPieceByPiece", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testFetchLargeBlobPieceByPieceModified", iters, reps));
        largeSuite.addTest(new BlobAccessTest("testLargeBlobGetLength", iters, reps));
        mainSuite.addTest(largeSuite);
    }
    if (!disableConcurrencyTest) {
        mainSuite.addTest(new BlobAccessTest("testConcurrency", 1, 1));
    }
    return new CleanDatabaseTestSetup(mainSuite) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            try {
                initializeBlobData(stmt);
            } catch (UnsupportedEncodingException uee) {
                // Compiled with JDK 1.4, can't use constructor.
                SQLException sqle = new SQLException();
                sqle.initCause(uee);
                throw sqle;
            }
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 20 with CleanDatabaseTestSetup

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

the class IndexScanTest method suite.

/**
 * Create a test suite with all the test cases in this class.
 * @return a test suite
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("IndexScanTest");
    suite.addTest(new IndexScanTest("varchar10", 5000, 4));
    suite.addTest(new IndexScanTest("varchar100", 5000, 4));
    suite.addTest(new IndexScanTest("varchar1000", 5000, 4));
    suite.addTest(new IndexScanTest("varcharAll", 5000, 4));
    suite.addTest(new IndexScanTest("decimal1column", 5000, 4));
    suite.addTest(new IndexScanTest("decimal10columns", 5000, 4));
    return new CleanDatabaseTestSetup(suite) {

        protected void decorateSQL(Statement s) throws SQLException {
            // Create a table with some character data and decimal data
            // that we can use in our tests.
            s.execute("CREATE TABLE T (VC10 VARCHAR(10), " + "VC100 VARCHAR(100), " + "VC1000 VARCHAR(1000), " + "DEC1 DECIMAL(10,10), " + "DEC2 DECIMAL(10,10), " + "DEC3 DECIMAL(10,10), " + "DEC4 DECIMAL(10,10), " + "DEC5 DECIMAL(10,10), " + "DEC6 DECIMAL(10,10), " + "DEC7 DECIMAL(10,10), " + "DEC8 DECIMAL(10,10), " + "DEC9 DECIMAL(10,10), " + "DEC10 DECIMAL(10,10))");
            // Fill the table with 1000 rows containing random data.
            PreparedStatement ps = s.getConnection().prepareStatement("INSERT INTO T(VC10,VC100,VC1000,DEC1,DEC2,DEC3," + "DEC4,DEC5,DEC6,DEC7,DEC8,DEC9,DEC10) VALUES (?,?,?," + "RANDOM(),RANDOM(),RANDOM(),RANDOM(),RANDOM()," + "RANDOM(),RANDOM(),RANDOM(),RANDOM(),RANDOM())");
            char[] chars = new char[1000];
            Random r = new Random();
            for (int i = 0; i < 1000; i++) {
                fillWithRandomChars(r, chars);
                ps.setString(1, new String(chars, 0, 10));
                ps.setString(2, new String(chars, 0, 100));
                ps.setString(3, new String(chars, 0, 1000));
                ps.executeUpdate();
            }
            ps.close();
            // Create various indexes on the table.
            s.execute("CREATE INDEX T_VC10 ON T(VC10)");
            s.execute("CREATE INDEX T_VC100 ON T(VC100)");
            s.execute("CREATE INDEX T_VC1000 ON T(VC1000)");
            s.execute("CREATE INDEX T_VC_ALL ON T(VC10,VC100,VC1000)");
            s.execute("CREATE INDEX T_DEC1 ON T(DEC1)");
            s.execute("CREATE INDEX T_DEC_ALL ON T(DEC1,DEC2,DEC3,DEC4," + "DEC5,DEC6,DEC7,DEC8,DEC9,DEC10)");
        }
    };
}
Also used : Random(java.util.Random) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) PreparedStatement(java.sql.PreparedStatement)

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