Search in sources :

Example 21 with BaseTestSuite

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

the class SavepointJdbc30Test method getEmbeddedSuite.

/**
 * Create a testsuite containing the tests that can only run in embedded
 * mode. These tests have names starting with x and are added automatically.
 */
private static Test getEmbeddedSuite(String name) {
    BaseTestSuite embedded = new BaseTestSuite(name);
    Method[] methods = SavepointJdbc30Test.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 methodName = m.getName();
        if (methodName.startsWith("x")) {
            embedded.addTest(new SavepointJdbc30Test(methodName));
        }
    }
    return embedded;
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Method(java.lang.reflect.Method) Savepoint(java.sql.Savepoint)

Example 22 with BaseTestSuite

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

the class SetTransactionIsolationTest method baseSuite.

public static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(SetTransactionIsolationTest.class);
    // Some test cases expect lock timeouts, so reduce the timeout to
    // make the test go faster.
    Test test = DatabasePropertyTestSetup.setLockTimeouts(suite, 1, 3);
    return new CleanDatabaseTestSetup(test) {

        /**
         * Create and populate table
         *
         * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
         */
        protected void decorateSQL(Statement s) throws SQLException {
            Connection conn = getConnection();
            /**
             * Creates the table used in the test cases.
             */
            final int stringLength = 400;
            s.executeUpdate("CREATE TABLE TAB1 (c11 int, " + "c12 varchar(" + stringLength + "))");
            PreparedStatement insertStmt = conn.prepareStatement("INSERT INTO TAB1 VALUES(?,?)");
            // We need to ensure that there is more data in the table than
            // the
            // client can fetch in one message (about 32K). Otherwise, the
            // cursor might be closed on the server and we are not testing
            // the
            // same thing in embedded mode and client/server mode.
            final int rows = 40000 / stringLength;
            StringBuffer buff = new StringBuffer(stringLength);
            for (int i = 0; i < stringLength; i++) {
                buff.append(" ");
            }
            for (int i = 1; i <= rows; i++) {
                insertStmt.setInt(1, i);
                insertStmt.setString(2, buff.toString());
                insertStmt.executeUpdate();
            }
            insertStmt.close();
            s.execute("create table t1(I int, B char(15))");
            s.execute("create table t1copy(I int, B char(15))");
            s.executeUpdate("INSERT INTO T1 VALUES(1,'First Hello')");
            s.executeUpdate("INSERT INTO T1 VALUES(2,'Second Hello')");
            s.executeUpdate("INSERT INTO T1 VALUES(3,'Third Hello')");
            s.executeUpdate("create table t3 (i integer)");
        }
    };
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) PreparedStatement(java.sql.PreparedStatement)

Example 23 with BaseTestSuite

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

the class StatementJdbc20Test method baseSuite.

private static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(StatementJdbc20Test.class);
    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 {
            Connection conn = getConnection();
            /**
             * 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)");
            stmt.execute("create procedure dynamic_results() " + "language java parameter style java external name '" + StatementJdbc20Test.class.getName() + ".dynamicResults' " + "dynamic result sets 2");
            stmt.execute("create table t_autogen( a int generated always as identity, b int )");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) Connection(java.sql.Connection) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 24 with BaseTestSuite

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

the class StatementJdbc30Test method suite.

/**
 * Create suite containing client and embedded tests and to run all tests in
 * this class
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("StatementJdbc30Test");
    suite.addTest(baseSuite("StatementJdbc30Test:embedded"));
    suite.addTest(TestConfiguration.clientServerDecorator(baseSuite(CLIENT_SUITE_NAME)));
    return suite;
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 25 with BaseTestSuite

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

the class DataSourceSerializationTest method suite.

/**
 * Returns an appropariate suite of tests to run.
 *
 * @return A test suite.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("DataSourceSerializationTest");
    String filePrefix = "functionTests/testData/serializedDataSources/";
    // De-serialize embedded data sources only if we have the engine code.
    if (Derby.hasEmbedded()) {
        suite.addTest(new DataSourceSerializationTest("serTestEmbeddedDataSource"));
        suite.addTest(new DataSourceSerializationTest("serTestEmbeddedConnectionPoolDataSource"));
        suite.addTest(new DataSourceSerializationTest("serTestEmbeddedXADataSource"));
    }
    // De-serialize client data sources only if we have the client code.
    if (Derby.hasClient()) {
        suite.addTest(new DataSourceSerializationTest("serTestClientDataSource"));
        suite.addTest(new DataSourceSerializationTest("serTestClientConnectionPoolDataSource"));
        suite.addTest(new DataSourceSerializationTest("serTestClientXADataSource"));
    }
    return new SupportFilesSetup(suite, new String[] { // 10.0 resources
    filePrefix + "EmbeddedDataSource-10_0_2_1.ser", filePrefix + "EmbeddedConnectionPoolDataSource-10_0_2_1.ser", filePrefix + "EmbeddedXADataSource-10_0_2_1.ser", // 10.1 resources
    filePrefix + "EmbeddedDataSource-10_1_3_1.ser", filePrefix + "EmbeddedConnectionPoolDataSource-10_1_3_1.ser", filePrefix + "EmbeddedXADataSource-10_1_3_1.ser", filePrefix + "ClientDataSource-10_1_3_1.ser", filePrefix + "ClientConnectionPoolDataSource-10_1_3_1.ser", filePrefix + "ClientXADataSource-10_1_3_1.ser", // 10.2 resources
    filePrefix + "EmbeddedDataSource-10_2_2_0.ser", filePrefix + "EmbeddedConnectionPoolDataSource-10_2_2_0.ser", filePrefix + "EmbeddedXADataSource-10_2_2_0.ser", filePrefix + "ClientDataSource-10_2_2_0.ser", filePrefix + "ClientConnectionPoolDataSource-10_2_2_0.ser", filePrefix + "ClientXADataSource-10_2_2_0.ser", // 10.3 resources
    filePrefix + "EmbeddedDataSource-10_3_2_1.ser", filePrefix + "EmbeddedConnectionPoolDataSource-10_3_2_1.ser", filePrefix + "EmbeddedXADataSource-10_3_2_1.ser", filePrefix + "ClientDataSource-10_3_2_1.ser", filePrefix + "ClientConnectionPoolDataSource-10_3_2_1.ser", filePrefix + "ClientXADataSource-10_3_2_1.ser", // 10.10 resources
    filePrefix + "EmbeddedDataSource-10_10_1_0.ser", filePrefix + "EmbeddedDataSource40-10_10_1_0.ser", filePrefix + "EmbeddedConnectionPoolDataSource-10_10_1_0.ser", filePrefix + "EmbeddedConnectionPoolDataSource40-10_10_1_0.ser", filePrefix + "EmbeddedXADataSource-10_10_1_0.ser", filePrefix + "EmbeddedXADataSource40-10_10_1_0.ser", filePrefix + "ClientDataSource-10_10_1_0.ser", filePrefix + "ClientDataSource40-10_10_1_0.ser", filePrefix + "ClientConnectionPoolDataSource-10_10_1_0.ser", filePrefix + "ClientConnectionPoolDataSource40-10_10_1_0.ser", filePrefix + "ClientXADataSource-10_10_1_0.ser", filePrefix + "ClientXADataSource40-10_10_1_0.ser", filePrefix + "BasicEmbeddedDataSource40-10_10_1_0.ser", filePrefix + "BasicEmbeddedConnectionPoolDataSource40-10_10_1_0.ser", filePrefix + "BasicEmbeddedXADataSource40-10_10_1_0.ser", filePrefix + "BasicClientDataSource40-10_10_1_0.ser", filePrefix + "BasicClientConnectionPoolDataSource40-10_10_1_0.ser", filePrefix + "BasicClientXADataSource40-10_10_1_0.ser", // 10.11 resources
    filePrefix + "EmbeddedDataSource-10_11_1_0.ser", filePrefix + "EmbeddedDataSource40-10_11_1_0.ser", filePrefix + "EmbeddedConnectionPoolDataSource-10_11_1_0.ser", filePrefix + "EmbeddedConnectionPoolDataSource40-10_11_1_0.ser", filePrefix + "EmbeddedXADataSource-10_11_1_0.ser", filePrefix + "EmbeddedXADataSource40-10_11_1_0.ser", filePrefix + "ClientDataSource-10_11_1_0.ser", filePrefix + "ClientDataSource40-10_11_1_0.ser", filePrefix + "ClientConnectionPoolDataSource-10_11_1_0.ser", filePrefix + "ClientConnectionPoolDataSource40-10_11_1_0.ser", filePrefix + "ClientXADataSource-10_11_1_0.ser", filePrefix + "ClientXADataSource40-10_11_1_0.ser", filePrefix + "BasicEmbeddedDataSource40-10_11_1_0.ser", filePrefix + "BasicEmbeddedConnectionPoolDataSource40-10_11_1_0.ser", filePrefix + "BasicEmbeddedXADataSource40-10_11_1_0.ser", filePrefix + "BasicClientDataSource40-10_11_1_0.ser", filePrefix + "BasicClientConnectionPoolDataSource40-10_11_1_0.ser", filePrefix + "BasicClientXADataSource40-10_11_1_0.ser" });
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Aggregations

BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)476 Test (junit.framework.Test)136 CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)118 Statement (java.sql.Statement)81 PreparedStatement (java.sql.PreparedStatement)68 SupportFilesSetup (org.apache.derbyTesting.junit.SupportFilesSetup)49 Properties (java.util.Properties)43 SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)34 CallableStatement (java.sql.CallableStatement)19 Connection (java.sql.Connection)14 SecurityManagerSetup (org.apache.derbyTesting.junit.SecurityManagerSetup)13 DatabasePropertyTestSetup (org.apache.derbyTesting.junit.DatabasePropertyTestSetup)11 TestSetup (junit.extensions.TestSetup)10 SQLException (java.sql.SQLException)7 LocaleTestSetup (org.apache.derbyTesting.junit.LocaleTestSetup)7 Method (java.lang.reflect.Method)5 Locale (java.util.Locale)5 BaseJDBCTestSetup (org.apache.derbyTesting.junit.BaseJDBCTestSetup)4 NetworkServerTestSetup (org.apache.derbyTesting.junit.NetworkServerTestSetup)4 ResultSet (java.sql.ResultSet)3