Search in sources :

Example 56 with CleanDatabaseTestSetup

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

the class ForUpdateTest method baseSuite.

protected static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(ForUpdateTest.class);
    return new CleanDatabaseTestSetup(suite) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table t1 ( i int, v varchar(10), d double precision, t time )");
            s.execute("create table t2 ( s smallint, c char(10), r real, ts timestamp )");
            s.execute("create table t3 (i int not null constraint t3pk primary key, b char(10))");
            s.execute("create table t4 (c1 int)");
            s.execute("create index t3bi on t3(b)");
            s.execute("insert into t3 values (1, 'hhhh'), (2, 'uuuu'), (3, 'yyyy'), (4, 'aaaa'), (5, 'jjjj'), (6, 'rrrr')");
            s.execute("insert into t3 values (7, 'iiii'), (8, 'wwww'), (9, 'rrrr'), (10, 'cccc'), (11, 'hhhh'), (12, 'rrrr')");
            s.execute("insert into t4 (c1) values (1),(2),(3)");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 57 with CleanDatabaseTestSetup

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

the class DBInJarTest method baseSuite.

protected static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(DBInJarTest.class);
    // the database.
    return new CleanDatabaseTestSetup(SecurityManagerSetup.noSecurityManager(suite)) {

        /**
         * Creates the procedure used in the test cases.
         * @exception SQLException if a database error occurs
         */
        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.execute("create procedure CREATEARCHIVE(jarName VARCHAR(20)" + " , path VARCHAR(20), dbName VARCHAR(20))" + " LANGUAGE JAVA PARAMETER STYLE JAVA" + " NO SQL" + " EXTERNAL NAME 'org.apache.derbyTesting.functionTests.tests.lang.dbjarUtil.createArchive'");
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 58 with CleanDatabaseTestSetup

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

the class DatabaseClassLoadingTest method suite.

/**
 * Run the tests only in embedded since this is testing
 * server side behaviour. Due to DERBY-537 and DERBY-2040
 * most of the tests are run without a security manager.
 * Ordering is important here so the fixtures are added
 * explicitly.
 */
public static Test suite() throws Exception {
    final BaseTestSuite suite = new BaseTestSuite("DatabaseClassLoadingTest");
    // Need DriverManager to execute the add contact procedure
    // as it uses server side jdbc.
    Test test = suite;
    if (JDBC.vmSupportsJDBC3()) {
        String[] orderedTests = { "testJarHandling", "testWithNoInstalledJars", "testWithNoClasspath", "testSetClasspath", "testAddContact", "testGetResource", "testAlterTable", "testClassPathRollback", "testReplaceJar", "testReplacedClass", "testSecondJar", "testSignedJar", "testCreateDatabaseJar", "testHackedJarReplacedClass", "testInvalidJar", "testRemoveJar", "testLoadJavaClassIndirectly", "testLoadJavaClassDirectly", "testLoadJavaClassDirectly2", "testLoadJavaClassDirectly3", "testLoadDerbyClassIndirectly", "testIndirectLoading", "testTableFunctionInJar", "testUDAInJar", "test_5352" };
        for (int i = 0; i < orderedTests.length; i++) {
            suite.addTest(new DatabaseClassLoadingTest(orderedTests[i]));
        }
        suite.addTest(new DatabaseClassLoadingTest("testDatabaseInJar"));
        // to delete the jar file afterwards.
        if (ClasspathSetup.supportsClose()) {
            suite.addTest(new ClasspathSetup(new DatabaseClassLoadingTest("testDatabaseInClasspath"), SupportFilesSetup.getReadOnlyURL("dclt.jar")));
        }
        // No security manager because the test uses getClass().getClassLoader()
        // in an installed jar to ensure that the class loader for
        // specific classes is correct. This operation is not allowed in general.
        suite.addTest(SecurityManagerSetup.noSecurityManager(new DatabaseClassLoadingTest("testClassLoadOrdering")));
        // Add test cases accessing a classpath database when a login
        // timeout has been specified.
        suite.addTest(loginTimeoutSuite());
        test = new SupportFilesSetup(suite, new String[] { "functionTests/tests/lang/dcl_emc1.jar", "functionTests/tests/lang/dcl_emcaddon.jar", "functionTests/tests/lang/dcl_emc2.jar", "functionTests/tests/lang/dcl_emc2s.jar", "functionTests/tests/lang/dcl_emc2sm.jar", "functionTests/tests/lang/dcl_emc2l.jar", "functionTests/tests/lang/dcl_java.jar", "functionTests/tests/lang/dcl_ot1.jar", "functionTests/tests/lang/dcl_ot2.jar", "functionTests/tests/lang/dcl_ot3.jar", "functionTests/tests/lang/dcl_id.jar", "functionTests/tests/lang/dummy_vti.jar", "functionTests/tests/lang/median_uda.jar" });
    }
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.executeUpdate("create schema emc");
            s.executeUpdate("create schema \"emcAddOn\"");
            s.executeUpdate("create table emc.contacts " + "(id int primary key, e_mail varchar(30))");
            s.executeUpdate("create procedure EMC.ADDCONTACT(id INT, e_mail VARCHAR(30)) " + "MODIFIES SQL DATA " + "external name 'org.apache.derbyTesting.databaseclassloader.emc.addContact' " + "language java parameter style java");
            s.executeUpdate("create function EMC.GETARTICLE(path VARCHAR(60)) " + "RETURNS VARCHAR(256) " + "NO SQL " + "external name 'org.apache.derbyTesting.databaseclassloader.emc.getArticle' " + "language java parameter style java");
            // function that gets the signers of the class (loaded from the jar)
            s.executeUpdate("CREATE FUNCTION EMC.GETSIGNERS(" + "CLASS_NAME VARCHAR(256)) RETURNS VARCHAR(60) " + "NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA " + "EXTERNAL NAME 'org.apache.derbyTesting.databaseclassloader.emc.getSigners'");
            s.executeUpdate("CREATE FUNCTION \"emcAddOn\".VALIDCONTACT(E_MAIL VARCHAR(30)) " + "RETURNS SMALLINT " + "READS SQL DATA LANGUAGE JAVA PARAMETER STYLE JAVA " + "EXTERNAL NAME 'org.apache.derbyTesting.databaseclassloader.addon.vendor.util.valid'");
        }
    };
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) ClasspathSetup(org.apache.derbyTesting.junit.ClasspathSetup) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Example 59 with CleanDatabaseTestSetup

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

the class HoldCursorTest method baseSuite.

private static Test baseSuite(boolean embeddedMode) {
    String name = "HoldCursorTest:" + (embeddedMode ? "embedded" : "client");
    BaseTestSuite suite = new BaseTestSuite(name);
    // Add tests that every JVM jdk1.4 or above should be able to run.
    suite.addTestSuite(HoldCursorTest.class);
    if (!JDBC.vmSupportsJSR169()) {
        suite.addTest(new HoldCursorTest("StatementsInProcedureTest"));
    }
    Test test = suite;
    if (!embeddedMode) {
        test = TestConfiguration.clientServerDecorator(suite);
    }
    return new CleanDatabaseTestSetup(test);
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 60 with CleanDatabaseTestSetup

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

the class GeneratedColumnsTest method suite.

// /////////////////////////////////////////////////////////////////////////////////
// 
// JUnit BEHAVIOR
// 
// /////////////////////////////////////////////////////////////////////////////////
/**
 * Construct top level suite in this JUnit test
 */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(GeneratedColumnsTest.class);
    Test cleanDatabaseSuite = new CleanDatabaseTestSetup(suite);
    // 
    // Copies the data file to a location which can be read.
    // 
    Test result = new SupportFilesSetup(cleanDatabaseSuite, new String[] { "functionTests/tests/lang/" + IMPORT_FILE_NAME });
    return result;
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

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