Search in sources :

Example 6 with SystemPropertyTestSetup

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

the class StressMultiTest method embeddedSuite.

/**
 * Get at testsuite that runs only the embedded suite with
 * the given number of threads for the given number of minutes.
 *
 * @param threads
 * @param minutes
 */
public static Test embeddedSuite(int threads, int minutes) {
    THREADS = threads;
    MINUTES = minutes;
    Properties dbprops = new Properties();
    dbprops.put("derby.locks.deadlockTimeout", "2");
    dbprops.put("derby.locks.waitTimeout", "3");
    dbprops.put("derby.language.logStatementText", "true");
    dbprops.put("derby.storage.keepTransactionLog", "true");
    Properties sysprops = new Properties();
    sysprops.put("derby.storage.keepTransactionLog", "true");
    sysprops.put("derby.language.logStatementText", "true");
    sysprops.put("derby.infolog.append", "true");
    Test embedded = new BaseTestSuite(StressMultiTest.class);
    embedded = new SystemPropertyTestSetup(embedded, sysprops, true);
    embedded = new DatabasePropertyTestSetup(embedded, dbprops);
    embedded = TestConfiguration.singleUseDatabaseDecorator(newCleanDatabase(embedded));
    return embedded;
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 7 with SystemPropertyTestSetup

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

the class NetIjTest method suite.

/**
 * Return the suite that runs all the derbynet scripts.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("NetScripts");
    // Set up the scripts run with the network client
    BaseTestSuite clientTests = new BaseTestSuite("NetScripts:client");
    clientTests.addTest(getSuite(CLIENT_TESTS));
    int port = TestConfiguration.getCurrent().getPort();
    Properties prop = new Properties();
    prop.setProperty("ij.protocol", "jdbc:derby://localhost:" + port + "/");
    Test client = new SystemPropertyTestSetup(TestConfiguration.clientServerDecoratorWithPort(clientTests, port), prop);
    // add those client tests into the top-level suite.
    suite.addTest(client);
    return suite;
}
Also used : Test(junit.framework.Test) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 8 with SystemPropertyTestSetup

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

the class NetworkServerControlApiTest method decorateShutdownTest.

/**
 * Decorate a test case that will attempt to shut down a network server
 * using the supplied credentials. The network server will run with
 * authentication enabled.
 *
 * @param testName name of the test case to decorate
 * @param user the user that should attempt to shut down the server
 * @param password the password to be used when shutting down the server
 * @return the decorated test case
 */
private static Test decorateShutdownTest(String testName, String user, String password) {
    Properties props = new Properties();
    props.setProperty("derby.connection.requireAuthentication", "true");
    props.setProperty("derby.authentication.provider", "BUILTIN");
    props.setProperty("derby.user." + user, password);
    Test test = new NetworkServerControlApiTest(testName);
    test = TestConfiguration.clientServerDecorator(test);
    test = new SystemPropertyTestSetup(test, props, true);
    test = TestConfiguration.changeUserDecorator(test, user, password);
    return test;
}
Also used : Test(junit.framework.Test) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) Properties(java.util.Properties)

Example 9 with SystemPropertyTestSetup

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

the class SysinfoTest method suite.

/**
 * Creates a suite with two testcases, with and without some extra
 * system properties.
 *
 * @return an empty suite if derbynet.jar is not available, and
 *      if the JVM only supports JSR169, otherwise, return a suite with
 *      6 tests, 3 with properties set, 3 without.
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("SysinfoTest");
    // we need to be able to run the server
    if (!Derby.hasServer())
        return suite;
    // don't run with JSR169 for this is a network server test
    if (JDBC.vmSupportsJSR169())
        return suite;
    useProperties = false;
    // the slashes adjusted.
    if (!TestConfiguration.loadingFromJars()) {
        Properties propstmp = new Properties();
        propstmp.put("sysinfotest.classesdir", findClassDir());
        suite.addTest(new SystemPropertyTestSetup(decorateTest(), propstmp));
    } else
        suite.addTest(decorateTest());
    useProperties = true;
    Properties sysprops = new Properties();
    if (!TestConfiguration.loadingFromJars())
        sysprops.put("sysinfotest.classesdir", findClassDir());
    sysprops.put("derby.infolog.append", "true");
    sysprops.put("derby.language.logStatementText", "true");
    // #drda property ,test for it in sysinfo output
    sysprops.put("derby.drda.securityMechanism", "USER_ONLY_SECURITY");
    Test test = new SystemPropertyTestSetup(decorateTest(), sysprops);
    Properties prop = new Properties();
    prop.put("derby.locks.waitTimeout", "120");
    test = new DatabasePropertyTestSetup(test, prop);
    // suite.addTest(new SystemPropertyTestSetup(decorateTest(), props));
    suite.addTest(test);
    return suite;
}
Also used : Test(junit.framework.Test) DatabasePropertyTestSetup(org.apache.derbyTesting.junit.DatabasePropertyTestSetup) SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties)

Example 10 with SystemPropertyTestSetup

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

the class RestrictiveFilePermissionsTest method suite.

public static Test suite() throws Exception {
    File f = new File("system/testPermissions");
    assertTrue(f.mkdirs());
    supportsLaxTesting = checkAccessToOwner(f, false, UNKNOWN);
    if (!supportsLaxTesting) {
        println("warning: testing of lax file permissions in" + "RestrictiveFilePermissionsTest can not take place, " + "use a more liberal runtime default (umask) for the tests");
    }
    assertDirectoryDeleted(f);
    // First collect the tests that check that, if we actually do restrict
    // permissions, the files created by Derby actually *are*
    // restricted. We test that with an embedded Derby with explicit
    // setting of the property derby.storage.useDefaultFilePermissions.
    // The extra setup file is for testJarFiles.
    BaseTestSuite totalSuite = new BaseTestSuite("RestrictiveFilePermissionsTest");
    Properties p = new Properties();
    p.put("derby.storage.useDefaultFilePermissions", "false");
    p.put("derby.stream.error.file", derbyDotLog);
    totalSuite.addTest(new SystemPropertyTestSetup(TestConfiguration.singleUseDatabaseDecorator(new SupportFilesSetup(new BaseTestSuite(RestrictiveFilePermissionsTest.class, "haveWeGotAllCreatedFilesSuite"), new String[] { "functionTests/tests/lang/dcl_id.jar" }), dbName), p, true));
    // permissions.
    if (Derby.hasServer()) {
        totalSuite.addTest(new NetworkServerTestSetup(new RestrictiveFilePermissionsTest("doTestCliServerIsRestrictive"), // system properties
        new String[] {}, // non-default start up arguments
        new String[] {}, true));
    }
    // 
    if (supportsLaxTesting) {
        totalSuite.addTest(TestConfiguration.clientServerDecorator(new RestrictiveFilePermissionsTest("doTestNonCliServerIsLax")));
        // For embedded, we should see lax permissions also.
        // 
        p = new Properties();
        p.put("derby.stream.error.file", derbyDotLog + ".lax");
        totalSuite.addTest(new SystemPropertyTestSetup(new RestrictiveFilePermissionsTest("dotestEmbeddedIsLax"), p, true));
    }
    return totalSuite;
}
Also used : SystemPropertyTestSetup(org.apache.derbyTesting.junit.SystemPropertyTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) Properties(java.util.Properties) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup) File(java.io.File) NetworkServerTestSetup(org.apache.derbyTesting.junit.NetworkServerTestSetup)

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