Search in sources :

Example 86 with CleanDatabaseTestSetup

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

the class IJRunScriptTest method suite.

public static Test suite() {
    if (Derby.hasTools()) {
        BaseTestSuite suite = new BaseTestSuite("IJRunScriptTest");
        suite.addTestSuite(IJRunScriptTest.class);
        return new CleanDatabaseTestSetup(suite);
    }
    return new BaseTestSuite("empty: no tools support");
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 87 with CleanDatabaseTestSetup

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

the class IjConnNameTest method suite.

public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("IjConnNameTest");
    // Test does not run on J2ME
    if (JDBC.vmSupportsJSR169())
        return suite;
    Properties props = new Properties();
    props.setProperty("ij.connection.connOne", "jdbc:derby:wombat;create=true");
    props.setProperty("ij.connection.connFour", "jdbc:derby:nevercreated");
    props.setProperty("ij.showNoConnectionsAtStart", "true");
    props.setProperty("ij.showNoCountForSelect", "true");
    Test test = new SystemPropertyTestSetup(new IjConnNameTest(test_script), props);
    // test = SecurityManagerSetup.noSecurityManager(test);
    test = new CleanDatabaseTestSetup(test);
    return getIJConfig(test);
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 88 with CleanDatabaseTestSetup

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

the class ImportExportIJTest method suite.

/**
 * Return the suite that runs the script.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("importExportIJ");
    // only run with embedded
    // network server makes slightly different output
    // ('statement executed' instead of '# rows inserted/deteled', etc.)
    // and this test would never work if the server were on
    // a remote system because the export file would be on the
    // server side, and import would be looking on the client.
    // Also, running client & embedded would require some cleanup magic to
    // remove the exported files (see e.g. ImportExportTest).
    Test test = new ImportExportIJTest("importExportIJ");
    // This test should run in English locale since it compares error
    // messages against a canon based on the English message text. Also,
    // run the test in a fresh database, since the language of the message
    // text is determined when the database is created.
    test = new LocaleTestSetup(test, Locale.ENGLISH);
    test = TestConfiguration.singleUseDatabaseDecorator(test);
    suite.addTest(new CleanDatabaseTestSetup(test));
    return new SupportFilesSetup(suite, new String[] { "functionTests/testData/ImportExport/TwoLineBadEOF.dat", "functionTests/testData/ImportExport/NoEOR.dat", "functionTests/testData/ImportExport/Access1.txt", "functionTests/testData/ImportExport/AccountData_defaultformat.dat", "functionTests/testData/ImportExport/AccountData_format1.dat", "functionTests/testData/ImportExport/AccountData_format2.dat", "functionTests/testData/ImportExport/AccountData_format2oops.dat", "functionTests/testData/ImportExport/AccountData_NullFields.dat", "functionTests/testData/ImportExport/UnsupportedFormat1.dat", "functionTests/testData/ImportExport/UnsupportedFormat2.dat", "functionTests/testData/ImportExport/derby-2193.txt", "functionTests/testData/ImportExport/derby-2193-linenumber.txt" });
}
Also used : Test(junit.framework.Test) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) LocaleTestSetup(org.apache.derbyTesting.junit.LocaleTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Example 89 with CleanDatabaseTestSetup

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

the class ImportExportLobTest method suite.

/**
 * Runs the tests in the default embedded configuration and then
 * the client server configuration.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite(ImportExportLobTest.class);
    suite.addTest(TestConfiguration.clientServerSuite(ImportExportLobTest.class));
    Test test = suite;
    test = new SupportFilesSetup(test);
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            // table used to test  export.
            s.execute("CREATE TABLE BOOKS(id int," + "name varchar(30)," + "content clob, " + "pic blob )");
            // load some data into the above table.
            loadData(s);
            // table used to test import.
            s.execute("CREATE TABLE BOOKS_IMP(id int," + "name varchar(30)," + "content clob," + "pic blob )");
            // table that holds some invalid hex strings.
            s.execute("CREATE TABLE hex_tab(id int," + "C1 varchar(20)," + "C2 varchar(20)," + "C3 varchar(20))");
            s.execute("CREATE TABLE derby_2925_lob(id int," + "name varchar(30), content clob," + "pic blob)");
        }
    };
}
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 90 with CleanDatabaseTestSetup

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

the class LargeDataLocksTest method baseSuite.

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

        /**
         * Create and populate table
         * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
         */
        protected void decorateSQL(Statement s) throws SQLException {
            Connection conn = getConnection();
            conn.setAutoCommit(false);
            PreparedStatement ps = null;
            String sql;
            sql = "CREATE TABLE t1 (bc CLOB(1M), bincol BLOB(1M), datalen int)";
            s.executeUpdate(sql);
            // Insert big and little values
            sql = "INSERT into t1 values(?,?,?)";
            ps = conn.prepareStatement(sql);
            ps.setCharacterStream(1, new java.io.StringReader(Utilities.repeatChar("a", 38000)), 38000);
            try {
                ps.setBytes(2, Utilities.repeatChar("a", 38000).getBytes("US-ASCII"));
            } catch (UnsupportedEncodingException ue) {
                // Shouldn't happen US-ASCII should always be supported
                BaseTestCase.fail(ue.getMessage(), ue);
            }
            ps.setInt(3, 38000);
            ps.executeUpdate();
            ps.close();
            // Create a procedure for use by assertLockCount() to ensure
            // that the background worker thread has completed all the
            // post-commit work.
            s.execute("CREATE PROCEDURE WAIT_FOR_POST_COMMIT() " + "LANGUAGE JAVA EXTERNAL NAME " + "'org.apache.derbyTesting.functionTests.util." + "T_Access.waitForPostCommitToFinish' " + "PARAMETER STYLE JAVA");
            conn.commit();
        }
    };
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) UnsupportedEncodingException(java.io.UnsupportedEncodingException) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) PreparedStatement(java.sql.PreparedStatement)

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