Search in sources :

Example 81 with CleanDatabaseTestSetup

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

the class RollBackWrappingWhenFailOnImportTest method suite.

public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("RollBackWrappingWhenFailOnImportTest");
    if (!JDBC.vmSupportsJDBC3()) {
        return suite;
    }
    Test test = new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(RollBackWrappingWhenFailOnImportTest.class));
    suite.addTest(test);
    return suite;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 82 with CleanDatabaseTestSetup

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

the class ToolScripts method getAuthorizationSuite.

/**
 * Return a suite of tool tests from the list of script names. Each test is
 * surrounded in a decorator that cleans the database, and adds
 * authentication and authorization for each script.
 * @param list <ul><li>list[i][0][0]: script name,
 *                 <li>list[i][1]: users,
 *                 <li>list[i][2][0]: run-as-user
 *             </ul>
 */
private static Test getAuthorizationSuite(String[][][] list) {
    BaseTestSuite suite = new BaseTestSuite("Tool scripts w/authorization");
    final String PWSUFFIX = "pwSuffix";
    for (int i = 0; i < list.length; i++) {
        Test clean;
        if (list[i][0][0].startsWith("ij_show_roles")) {
            clean = new CleanDatabaseTestSetup(new ToolScripts(list[i][0][0], list[i][2][0])) {

                protected void decorateSQL(Statement s) throws SQLException {
                    s.execute("create role a");
                    s.execute("create role b");
                    s.execute("create role \"\"\"eve\"\"\"");
                    s.execute("create role publicrole");
                    s.execute("grant a to b");
                    s.execute("grant publicrole to public");
                    s.execute("grant b to donald");
                }
            };
        } else {
            clean = new CleanDatabaseTestSetup(new ToolScripts(list[i][0][0], list[i][2][0]));
        }
        suite.addTest(TestConfiguration.sqlAuthorizationDecorator(DatabasePropertyTestSetup.builtinAuthentication(clean, list[i][1], PWSUFFIX)));
    }
    return getIJConfig(suite);
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SQLException(java.sql.SQLException) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 83 with CleanDatabaseTestSetup

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

the class HoldCursorExternalSortJDBC30Test method suite.

public static Test suite() {
    Properties sysProps = new Properties();
    sysProps.put("derby.storage.sortBufferMax", "5");
    sysProps.put("derby.debug.true", "testSort");
    Test suite = TestConfiguration.embeddedSuite(HoldCursorExternalSortJDBC30Test.class);
    return new CleanDatabaseTestSetup(new SystemPropertyTestSetup(suite, sysProps, true)) {

        /**
         * Creates the table used in the test cases.
         */
        protected void decorateSQL(Statement s) throws SQLException {
            Connection conn = s.getConnection();
            conn.setAutoCommit(false);
            /* This table is used by testOrder_Hold and testOrder_NoHold */
            s.executeUpdate("create table foo (a int, data varchar(2000))");
            /* This one is specific for testOrderWithMultipleLevel since
                 * it requires some more records to be inserted */
            s.executeUpdate("create table bar (a int, data varchar(2000))");
            PreparedStatement ps = conn.prepareStatement("insert into foo values(?,?), (?,?), (?,?), (?,?), (?,?), " + "(?,?), (?,?), (?,?), (?,?), (?,?)");
            for (int i = 0; i <= 9; i++) {
                ps.setInt(i * 2 + 1, i + 1);
                ps.setString(i * 2 + 2, Formatters.padString("" + (i + 1), 2000));
            }
            ps.executeUpdate();
            ps.close();
            s.execute("INSERT INTO bar SELECT * FROM foo");
        }
    };
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Properties(java.util.Properties)

Example 84 with CleanDatabaseTestSetup

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

the class UpdateLocksTest method suite.

public static Test suite() {
    Test suite = TestConfiguration.defaultSuite(UpdateLocksTest.class);
    Properties p = new Properties();
    p.put("derby.storage.pageSize", "4096");
    return new CleanDatabaseTestSetup(new SystemPropertyTestSetup(suite, p, false));
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Properties(java.util.Properties)

Example 85 with CleanDatabaseTestSetup

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

the class Derby94Test method suite.

public static Test suite() {
    Test test = TestConfiguration.embeddedSuite(Derby94Test.class);
    // Reduce lock escalation threshold to make it possible to test
    // with fewer rows.
    test = DatabasePropertyTestSetup.singleProperty(test, "derby.locks.escalationThreshold", "102");
    test = new CleanDatabaseTestSetup(test);
    return test;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup)

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