Search in sources :

Example 11 with DatabasePropertyTestSetup

use of org.apache.derbyTesting.junit.DatabasePropertyTestSetup 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 12 with DatabasePropertyTestSetup

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

the class LockTableVtiTest method suite.

/**
 * Construct top level suite in this JUnit test
 * The suite is wrapped in a DatabasePropertyTestSetup to set
 * the lock wait timeout.
 *
 * @return A suite containing embedded fixtures
 */
public static Test suite() {
    Properties properties = new Properties();
    // setting to 60, which is the default, for starters
    properties.setProperty("derby.locks.waitTimeout", "60");
    Test suite = TestConfiguration.defaultSuite(LockTableVtiTest.class);
    suite = new DatabasePropertyTestSetup(suite, properties, true);
    return new CleanDatabaseTestSetup(suite);
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Properties(java.util.Properties)

Example 13 with DatabasePropertyTestSetup

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

the class AuthenticationTest method setBaseProps.

private static void setBaseProps(BaseTestSuite suite, Test test, Properties extraDbProps) {
    // Use DatabasePropertyTestSetup.builtinAuthentication decorator
    // to set the user properties required by this test (and shutdown
    // the database for the property to take effect).
    // DatabasePropertyTestSetup uses SYSCS_SET_DATABASE_PROPERTY
    // so that is database level setting.
    // Additionally use DatabasePropertyTestSetup to add some
    // possibly useful settings
    // Finally SystemPropertyTestSetup sets up system level users
    Properties props = new Properties();
    props.setProperty("derby.infolog.append", "true");
    props.setProperty("derby.debug.true", "AuthenticationTrace");
    if (extraDbProps != null) {
        props.putAll(extraDbProps);
    }
    Properties sysprops = new Properties();
    sysprops.put("derby.user.system", "admin");
    sysprops.put("derby.user.mickey", "mouse");
    test = DatabasePropertyTestSetup.builtinAuthentication(test, USERS, PASSWORD_SUFFIX);
    test = new DatabasePropertyTestSetup(test, props, true);
    suite.addTest(new SystemPropertyTestSetup(test, sysprops));
}
Also used : DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Properties(java.util.Properties)

Example 14 with DatabasePropertyTestSetup

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

the class DriverTest method setBaseProps.

private static void setBaseProps(BaseTestSuite suite, Test test) {
    Properties dbprops = new Properties();
    // Use DatabasePropertyTestSetup to add some settings.
    // DatabasePropertyTestSetup uses SYSCS_SET_DATABASE_PROPERTY
    // so users are added at database level.
    // Note, that authentication is not switched on.
    dbprops.setProperty("derby.infolog.append", "true");
    dbprops.setProperty("derby.debug.true", "AuthenticationTrace");
    dbprops.setProperty("derby.user.APP", "xxxx");
    dbprops.setProperty("derby.user.testuser", "testpass");
    test = new DatabasePropertyTestSetup(test, dbprops, true);
    suite.addTest(test);
}
Also used : DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) Properties(java.util.Properties)

Example 15 with DatabasePropertyTestSetup

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

the class UpdateCursorTest method suite.

/**
 * Returns the implemented tests.
 *
 * @return An instance of <code>Test</code> with the implemented tests to
 *         run.
 */
public static Test suite() {
    Properties props = new Properties();
    props.setProperty("derby.language.maxMemoryPerTable", "1");
    return new DatabasePropertyTestSetup(new SystemPropertyTestSetup(new CleanDatabaseTestSetup(new BaseTestSuite(UpdateCursorTest.class, "UpdateCursorTest")) {

        /**
         * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
         */
        protected void decorateSQL(Statement s) throws SQLException {
            StringBuffer sb = new StringBuffer(1000);
            String largeString;
            PreparedStatement pstmt;
            assertUpdateCount(s, 0, "create table T1 (" + "  c1	int," + "  c2	char(50)," + "  c3	int," + "  c4   char(50)," + "  c5   int," + "  c6   varchar(1000))");
            assertUpdateCount(s, 0, "create index I11 on T1(c3, c1, c5)");
            assertUpdateCount(s, 0, "create table T2(" + "  c1 	int)");
            assertUpdateCount(s, 0, "create table T3(" + "  c1	char(20) not null primary key)");
            assertUpdateCount(s, 0, "create table T4(" + "  c1 	char(20) references T3(c1) on delete cascade)");
            /* fill the newly created tables */
            for (int i = 0; i < 1000; i++) {
                sb.append('a');
            }
            pstmt = s.getConnection().prepareStatement("insert into T1 values (?, ?, ?, ?, ?, ?), " + "(?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?), " + "(?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?)");
            largeString = new String(sb);
            for (int i = 246; i > 0; i = i - 5) {
                int k = 0;
                for (int j = 0; j < 5; j++) {
                    pstmt.setInt(1 + k, i + (4 - j));
                    pstmt.setString(2 + k, Integer.toString(i));
                    pstmt.setInt(3 + k, i + j);
                    pstmt.setString(4 + k, Integer.toString(i));
                    pstmt.setInt(5 + k, i);
                    pstmt.setString(6 + k, largeString);
                    k += 6;
                }
                assertUpdateCount(pstmt, 5);
            }
            s.executeUpdate("insert into t2 values (1)");
            pstmt.close();
        }
    }, 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) PreparedStatement(java.sql.PreparedStatement) 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