Search in sources :

Example 31 with SystemPropertyTestSetup

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

the class NativeAuthenticationServiceTest method decorate.

/**
 * <p>
 * Wrap base test with standard decorators in order to setup system
 * properties and allow for the creation of multiple databases with
 * stored properties that can't be removed at tearDown time.
 * </p>
 */
private Test decorate(boolean clientServer) throws Exception {
    String credentialsDBPhysicalName = TestConfiguration.generateUniqueDatabaseName();
    Test result = this;
    // 
    if (clientServer) {
        result = TestConfiguration.clientServerDecorator(result);
    }
    // 
    // Turn on the property which enables NATIVE authentication. This will trigger
    // an engine shutdown at the end of the test. We want to shutdown the engine
    // before deleting the physical databases. This is because we need one of the
    // databases (the credentials db) in order to authenticate engine shutdown.
    // 
    Properties systemProperties = null;
    try {
        systemProperties = systemProperties(credentialsDBPhysicalName);
    } catch (Exception e) {
        printStackTrace(e);
    }
    println(nameOfTest());
    println("    NativeAuthenticationServiceTest.decorate() systemProperties = " + systemProperties);
    result = new SystemPropertyTestSetup(result, systemProperties, true);
    // 
    if (enableSubprotocolTests()) {
        // Add a jar file to the classpath so that we can test the classpath subprotocol.
        URL nast2Jar = SupportFilesSetup.getReadOnlyURL(NAST2_JAR_FILE);
        result = new ClasspathSetup(result, nast2Jar);
        // Add the jar files needed for testing jar and classpath subprotocols.
        result = new SupportFilesSetup(result, SUPPORT_FILES_SOURCE, null, SUPPORT_FILES_TARGET, null);
    }
    // 
    // Register temporary databases, where the test will do its work.
    // We can't use the default, re-usable database because NATIVE authentication stores
    // persistent properties which cannot be turned off.
    // 
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, CREDENTIALS_DB, credentialsDBPhysicalName);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, SECOND_DB);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, THIRD_DB);
    result = _fourthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FOURTH_DB, true);
    result = _fifthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FIFTH_DB, true);
    result = _sixthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, SIXTH_DB, true);
    result = _seventhDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, SEVENTH_DB, true);
    result = _eighthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, EIGHTH_DB, true);
    result = _ninthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, NINTH_DB, true);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, TENTH_DB);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, ELEVENTH_DB);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, TWELTH_DB);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, THIRTEENTH_DB);
    result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FOURTEENTH_DB);
    result = _fifteenthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FIFTEENTH_DB, true);
    result = TestConfiguration.changeUserDecorator(result, DBO, getPassword(DBO));
    return result;
}
Also used : Test(junit.framework.Test) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) ClasspathSetup(org.apache.derbyTesting.junit.ClasspathSetup) Properties(java.util.Properties) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup) SQLException(java.sql.SQLException) URL(java.net.URL)

Example 32 with SystemPropertyTestSetup

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

the class PredicatePushdownTest method suite.

public static Test suite() {
    Properties systemProperties = new Properties();
    systemProperties.setProperty("derby.optimizer.noTimeout", "true");
    BaseTestSuite suite = new BaseTestSuite("predicatePushdown Test");
    suite.addTest(new SystemPropertyTestSetup(new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(PredicatePushdownTest.class)), systemProperties));
    return suite;
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 33 with SystemPropertyTestSetup

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

the class KeepDisposableStatsPropertyTest method suite.

/**
 * Returns a suite where the test is run without specifying the property
 * (use the default value), explicitly setting it to {@code true}, and
 * explicitly setting it to {@code false}.
 */
public static Test suite() {
    String property = "derby.storage.indexStats.debug.keepDisposableStats";
    BaseTestSuite suite = new BaseTestSuite("KeepDisposableStatsPropertyTestSuite");
    // Test the default (expected to be false).
    suite.addTest(new KeepDisposableStatsPropertyTest("testPropertyDefault"));
    // Test setting the property explicitly to true.
    Properties propsOn = new Properties();
    propsOn.setProperty(property, "true");
    BaseTestSuite suiteOn = new BaseTestSuite("Do KeepDisposableStats");
    suiteOn.addTest(new KeepDisposableStatsPropertyTest("testPropertyTrue"));
    suite.addTest(new SystemPropertyTestSetup(suiteOn, propsOn, true));
    // Test setting the property explicitly to false.
    Properties propsOff = new Properties();
    propsOff.setProperty(property, "false");
    BaseTestSuite suiteOff = new BaseTestSuite("Don't KeepDisposableStats");
    suiteOff.addTest(new KeepDisposableStatsPropertyTest("testPropertyFalse"));
    suite.addTest(new SystemPropertyTestSetup(suiteOff, propsOff, true));
    return suite;
}
Also used : SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 34 with SystemPropertyTestSetup

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

the class StreamingColumnTest method suite.

/**
 * Runs the test fixtures in embedded and client.
 *
 * @return test suite
 */
public static Test suite() {
    Properties strColProperties = new Properties();
    strColProperties.setProperty("derby.storage.sortBufferMax", "5");
    strColProperties.setProperty("derby.debug.true", "testSort");
    BaseTestSuite suite = new BaseTestSuite("StreamingColumnTest");
    suite.addTest(baseSuite("StreamingColumnTest:embedded"));
    suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("StreamingColumnTest:client")));
    return new SystemPropertyTestSetup(suite, strColProperties);
}
Also used : SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 35 with SystemPropertyTestSetup

use of org.apache.derbyTesting.junit.SystemPropertyTestSetup 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)

Aggregations

SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)55 Properties (java.util.Properties)54 BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)34 Test (junit.framework.Test)33 CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)20 PreparedStatement (java.sql.PreparedStatement)8 Statement (java.sql.Statement)8 SupportFilesSetup (org.apache.derbyTesting.junit.SupportFilesSetup)8 DatabasePropertyTestSetup (org.apache.derbyTesting.junit.DatabasePropertyTestSetup)6 Connection (java.sql.Connection)3 TestSetup (junit.extensions.TestSetup)3 JDBCClientSetup (org.apache.derbyTesting.junit.JDBCClientSetup)2 NetworkServerTestSetup (org.apache.derbyTesting.junit.NetworkServerTestSetup)2 SecurityManagerSetup (org.apache.derbyTesting.junit.SecurityManagerSetup)2 File (java.io.File)1 URL (java.net.URL)1 CallableStatement (java.sql.CallableStatement)1 SQLException (java.sql.SQLException)1 Locale (java.util.Locale)1 Random (java.util.Random)1