Search in sources :

Example 96 with CleanDatabaseTestSetup

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

the class SURijTest method suite.

/**
 * Return the suite that runs the script.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("SURijTest");
    suite.addTest(TestConfiguration.clientServerDecorator(new CleanDatabaseTestSetup(new SURijTest(TESTS[0]))));
    suite.addTest(new CleanDatabaseTestSetup(new SURijTest(TESTS[0])));
    return suite;
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 97 with CleanDatabaseTestSetup

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

the class SavepointJdbc30Test method suite.

/**
 * Set up the test suite for embedded mode, client mode, and embedded mode
 * with XADataSources
 *
 * @return A suite containing embedded, client and embedded with XA suites
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("SavepointJdbc30_JSR169Test suite");
    // Get the tests for embedded
    BaseTestSuite embedded = new BaseTestSuite("SavepointJdbc30_JSR169Test:embedded");
    embedded.addTestSuite(SavepointJdbc30Test.class);
    embedded.addTest(getEmbeddedSuite("SavepointJdbc30_JSR169Test:" + "embedded only"));
    suite.addTest(embedded);
    // Get the tests for client.
    BaseTestSuite client = new BaseTestSuite("SavepointJdbc30_JSR169Test:client");
    client.addTestSuite(SavepointJdbc30Test.class);
    suite.addTest(TestConfiguration.clientServerDecorator(client));
    // under JSR169.
    if (JDBC.vmSupportsJDBC3()) {
        embedded = new BaseTestSuite("SavepointJdbc30_JSR169Test:embedded XADataSource");
        embedded.addTestSuite(SavepointJdbc30Test.class);
        embedded.addTest(getEmbeddedSuite("SavepointJdbc30_JSR169Test:" + "embedded only XADataSource"));
        suite.addTest(TestConfiguration.connectionXADecorator(embedded));
        // Repeat the client tests obtaining a connection from
        // an XA data source if it is supported. This is not supported
        // under JSR169.
        client = new BaseTestSuite("SavepointJdbc30_JSR169Test:client XADatasource");
        client.addTestSuite(SavepointJdbc30Test.class);
        suite.addTest(TestConfiguration.clientServerDecorator(TestConfiguration.connectionXADecorator(client)));
    }
    return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 1, 2)) {

        /**
         * Creates the database objects used in the test cases.
         *
         * @throws SQLException
         */
        protected void decorateSQL(Statement s) throws SQLException {
            /* Create a table */
            s.execute("create table t1 (c11 int, c12 smallint)");
            s.execute("create table t2 (c11 int)");
            getConnection().commit();
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 98 with CleanDatabaseTestSetup

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

the class StatementJdbc30Test method baseSuite.

private static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(StatementJdbc30Test.class);
    if (name.equals(CLIENT_SUITE_NAME)) {
        // These test CAN be run in embedded mode as well, but
        // they're only meaningful in c/s mode and also take quite
        // a bit of time to run.
        suite.addTest(new StatementJdbc30Test("xtestMultiExecWithQueryTimeout"));
        suite.addTest(new StatementJdbc30Test("xtestMaxOpenStatementsWithQueryTimeout"));
    }
    return new CleanDatabaseTestSetup(suite) {

        /**
         * Creates the tables used in the test cases.
         *
         * @exception SQLException
         *                if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            /**
             * Creates the table used in the test cases.
             */
            stmt.execute("create table tab1 (i int, s smallint, r real)");
            stmt.executeUpdate("insert into tab1 values(1, 2, 3.1)");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 99 with CleanDatabaseTestSetup

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

the class ResultSetStreamTest method basesuite.

public static Test basesuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(ResultSetStreamTest.class, name);
    Test test = new SupportFilesSetup(suite, new String[] { "functionTests/testData/ResultSetStream/littleclob.utf", "functionTests/testData/ResultSetStream/short.utf", "functionTests/testData/ResultSetStream/resultsetStream.gif" });
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table t2 (len int, data LONG VARCHAR FOR BIT DATA)");
            s.execute("create table t3(text_data clob)");
            s.execute("create table setMaxFieldSize(id int unique, " + "dVarchar VARCHAR(32672), dClob clob)");
        }
    };
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Example 100 with CleanDatabaseTestSetup

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

the class DataSourcePropertiesTest method suite.

// SETUP
/**
 * Creates a test suite with all test cases
 * only running in embedded at the moment.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("DataSourcePropertiesTest");
    // XA support (which is supported in JDBC 2 with extensions).
    if (JDBC.vmSupportsJDBC3()) {
        // Add all methods starting with 'test'.
        // suite.addTestSuite(DataSourcePropertiesTest.class);
        Method[] methods = DataSourcePropertiesTest.class.getMethods();
        for (int i = 0; i < methods.length; i++) {
            Method m = methods[i];
            if (m.getParameterTypes().length > 0 || !m.getReturnType().equals(Void.TYPE)) {
                continue;
            }
            String name = m.getName();
            if (name.startsWith("embedded")) {
                suite.addTest(new DataSourcePropertiesTest(name));
            }
        }
    }
    return new CleanDatabaseTestSetup(suite);
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Method(java.lang.reflect.Method)

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