Search in sources :

Example 6 with DatabasePropertyTestSetup

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

the class StressMultiTest method suite.

/**
 * Set up the testsuite to run in embedded, client and encryption mode.
 * Default run is 10 threads for 10 minutes in each mode
 */
public static Test suite() {
    Properties dbprops = new Properties();
    dbprops.put("derby.locks.deadlockTimeout", "2");
    dbprops.put("derby.locks.waitTimeout", "3");
    Properties sysprops = new Properties();
    sysprops.put("derby.storage.keepTransactionLog", "true");
    sysprops.put("derby.language.logStatementText", "true");
    sysprops.put("derby.infolog.append", "true");
    Test embedded = new BaseTestSuite(StressMultiTest.class);
    embedded = new SystemPropertyTestSetup(embedded, sysprops, true);
    embedded = new DatabasePropertyTestSetup(embedded, dbprops);
    // make this a singleUseDatabase so the datbase and
    // transaction log will be preserved.
    embedded = TestConfiguration.singleUseDatabaseDecorator(newCleanDatabase(embedded));
    // SystemPropertyTestSetup for static properties
    // does not work for client because shutting down the
    // engine causes protocol errors on the client. Run
    // with -Dderby.storage.keepTransactionLog=true if
    // you need to save the transaction log for client.
    Test client = TestConfiguration.clientServerDecorator(new BaseTestSuite(StressMultiTest.class));
    client = newCleanDatabase(new DatabasePropertyTestSetup(client, dbprops));
    Test encrypted = new BaseTestSuite(StressMultiTest.class);
    // SystemPropertyTestSetup for static properties
    // does not work for encrypted databases because the
    // database has to be rebooted and we don't have access
    // to the boot password (local to Decorator.encryptedDatabase()
    // Run with -Dderby.storage.keepTransactionLog=true if you
    // need to save the transaction log for encrypted.
    BaseTestSuite unencrypted = new BaseTestSuite("StressMultiTest:unencrypted");
    unencrypted.addTest((embedded));
    unencrypted.addTest((client));
    BaseTestSuite suite = new BaseTestSuite("StressMultiTest, " + THREADS + " Threads " + MINUTES + " Minutes");
    suite.addTest(newCleanDatabase(unencrypted));
    // Encrypted uses a different database so it needs its own newCleanDatabase
    suite.addTest(Decorator.encryptedDatabase(new DatabasePropertyTestSetup(newCleanDatabase(encrypted), dbprops)));
    return suite;
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 7 with DatabasePropertyTestSetup

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

the class StressMultiTest method embeddedSuite.

/**
 * Get at testsuite that runs only the embedded suite with
 * the given number of threads for the given number of minutes.
 *
 * @param threads
 * @param minutes
 */
public static Test embeddedSuite(int threads, int minutes) {
    THREADS = threads;
    MINUTES = minutes;
    Properties dbprops = new Properties();
    dbprops.put("derby.locks.deadlockTimeout", "2");
    dbprops.put("derby.locks.waitTimeout", "3");
    dbprops.put("derby.language.logStatementText", "true");
    dbprops.put("derby.storage.keepTransactionLog", "true");
    Properties sysprops = new Properties();
    sysprops.put("derby.storage.keepTransactionLog", "true");
    sysprops.put("derby.language.logStatementText", "true");
    sysprops.put("derby.infolog.append", "true");
    Test embedded = new BaseTestSuite(StressMultiTest.class);
    embedded = new SystemPropertyTestSetup(embedded, sysprops, true);
    embedded = new DatabasePropertyTestSetup(embedded, dbprops);
    embedded = TestConfiguration.singleUseDatabaseDecorator(newCleanDatabase(embedded));
    return embedded;
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 8 with DatabasePropertyTestSetup

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

the class SysinfoTest method suite.

/**
 * Creates a suite with two testcases, with and without some extra
 * system properties.
 *
 * @return an empty suite if derbynet.jar is not available, and
 *      if the JVM only supports JSR169, otherwise, return a suite with
 *      6 tests, 3 with properties set, 3 without.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("SysinfoTest");
    // we need to be able to run the server
    if (!Derby.hasServer())
        return suite;
    // don't run with JSR169 for this is a network server test
    if (JDBC.vmSupportsJSR169())
        return suite;
    useProperties = false;
    // the slashes adjusted.
    if (!TestConfiguration.loadingFromJars()) {
        Properties propstmp = new Properties();
        propstmp.put("sysinfotest.classesdir", findClassDir());
        suite.addTest(new SystemPropertyTestSetup(decorateTest(), propstmp));
    } else
        suite.addTest(decorateTest());
    useProperties = true;
    Properties sysprops = new Properties();
    if (!TestConfiguration.loadingFromJars())
        sysprops.put("sysinfotest.classesdir", findClassDir());
    sysprops.put("derby.infolog.append", "true");
    sysprops.put("derby.language.logStatementText", "true");
    // #drda property ,test for it in sysinfo output
    sysprops.put("derby.drda.securityMechanism", "USER_ONLY_SECURITY");
    Test test = new SystemPropertyTestSetup(decorateTest(), sysprops);
    Properties prop = new Properties();
    prop.put("derby.locks.waitTimeout", "120");
    test = new DatabasePropertyTestSetup(test, prop);
    // suite.addTest(new SystemPropertyTestSetup(decorateTest(), props));
    suite.addTest(test);
    return suite;
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 9 with DatabasePropertyTestSetup

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

the class SQLAuthorizationPropTest method suite.

public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite(SQLAuthorizationPropTest.class, "SQLAuthorizationPropTest");
    // Use DatabasePropertyTestSetup decorator to set the property
    // required by this test (and shutdown the database for the
    // property to take effect.
    Properties props = new Properties();
    props.setProperty("derby.database.sqlAuthorization", "true");
    Test test = new SQLAuthorizationPropTest("grantRevokeAfterSettingSQLAuthProperty");
    suite.addTest(new DatabasePropertyTestSetup(test, props, true));
    // This test has to be run after SQL authorization property has been
    // set to true.
    suite.addTest(new SQLAuthorizationPropTest("resetSQLAuthProperty"));
    // which cannot be undone.
    return TestConfiguration.singleUseDatabaseDecorator(suite);
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 10 with DatabasePropertyTestSetup

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

the class SubqueryTest method suite.

public static Test suite() {
    Properties props = new Properties();
    props.setProperty("derby.language.statementCacheSize", "0");
    return new DatabasePropertyTestSetup(new SystemPropertyTestSetup(new CleanDatabaseTestSetup(new BaseTestSuite(SubqueryTest.class, "SubqueryTest")) {

        /**
         * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
         */
        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("CREATE FUNCTION ConsistencyChecker() " + "RETURNS VARCHAR(128) " + "EXTERNAL NAME " + "'org.apache.derbyTesting.functionTests." + "util.T_ConsistencyChecker.runConsistencyChecker' " + "LANGUAGE JAVA PARAMETER STYLE JAVA");
            s.execute("create table s " + "(i int, s smallint, c char(30), " + "vc char(30), b bigint)");
            s.execute("create table t " + "(i int, s smallint, c char(30), " + "vc char(30), b bigint)");
            s.execute("create table tt " + "(ii int, ss smallint, cc char(30), " + "vcvc char(30), b bigint)");
            s.execute("create table ttt " + "(iii int, sss smallint, ccc char(30), " + "vcvcvc char(30))");
            // populate the tables
            s.execute("insert into s values " + "(null, null, null, null, null)");
            s.execute("insert into s values (0, 0, '0', '0', 0)");
            s.execute("insert into s values (1, 1, '1', '1', 1)");
            s.execute("insert into t values " + "(null, null, null, null, null)");
            s.execute("insert into t values (0, 0, '0', '0', 0)");
            s.execute("insert into t values (1, 1, '1', '1', 1)");
            s.execute("insert into t values (1, 1, '1', '1', 1)");
            s.execute("insert into t values (2, 2, '2', '2', 1)");
            s.execute("insert into tt values " + "(null, null, null, null, null)");
            s.execute("insert into tt values (0, 0, '0', '0', 0)");
            s.execute("insert into tt values (1, 1, '1', '1', 1)");
            s.execute("insert into tt values (1, 1, '1', '1', 1)");
            s.execute("insert into tt values (2, 2, '2', '2', 1)");
            s.execute("insert into ttt values (null, null, null, null)");
            s.execute("insert into ttt values (11, 11, '11', '11')");
            s.execute("insert into ttt values (11, 11, '11', '11')");
            s.execute("insert into ttt values (22, 22, '22', '22')");
        }
    }, props), props, true);
}
Also used : DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Aggregations

DatabasePropertyTestSetup (org.apache.derbyTesting.junit.DatabasePropertyTestSetup)16 Properties (java.util.Properties)15 BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)11 Test (junit.framework.Test)9 CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)7 SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)6 Statement (java.sql.Statement)4 PreparedStatement (java.sql.PreparedStatement)2 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1