junit.framework.Test

Here are the examples of the java api class junit.framework.Test taken from open source projects.

1. RawDBReaderTest#suite()

Project: derby
File: RawDBReaderTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    Test baseTest = TestConfiguration.embeddedSuite(RawDBReaderTest.class);
    // We don't expect that users of this tool will run with a security
    // manager. The tool is run standalone behind a firewall.
    Test wideOpenTest = SecurityManagerSetup.noSecurityManager(baseTest);
    // don't teardown the corrupt database. instead, just delete it in our
    // own tearDown() method. this is to prevent the corrupt database from
    // interfering with later tests which want to use a database with sql
    // authorization turned on.
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthenticationNoTeardown(wideOpenTest, LEGAL_USERS, "RRT");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    Test encryptedTest = Decorator.encryptedDatabaseBpw(authorizedTest, "DES/CBC/NoPadding", BOOT_PASSWORD);
    Test supportFilesTest = new SupportFilesSetup(encryptedTest);
    return supportFilesTest;
}

2. SequenceGeneratorTest#suite()

Project: derby
File: SequenceGeneratorTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(SequenceGeneratorTest.class);
    Test cleanTest = new CleanDatabaseTestSetup(suite);
    Test timeoutTest = DatabasePropertyTestSetup.setLockTimeouts(cleanTest, 5, 5);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(timeoutTest, LEGAL_USERS, "sequenceGenerator");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

3. LuceneSupportPermsTest#suite()

Project: derby
File: LuceneSupportPermsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    String luceneVersion = getSystemProperty(LUCENE_VERSION_PROPERTY);
    if (luceneVersion != null) {
        LUCENE_VERSION = luceneVersion;
    }
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(LuceneSupportPermsTest.class);
    Test secureTest = new SecurityManagerSetup(suite, POLICY_FILE);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(secureTest, LEGAL_USERS, "LuceneSupportPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(authenticatedTest, DB_NAME, true);
    Test localizedTest = new LocaleTestSetup(authorizedTest, new Locale(LANGUAGE, COUNTRY));
    return localizedTest;
}

4. LuceneJarLoadingTest#suite()

Project: derby
File: LuceneJarLoadingTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(LuceneJarLoadingTest.class);
    Test secureTest = new SecurityManagerSetup(suite, POLICY_FILE);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(secureTest, LEGAL_USERS, "LuceneJarLoadingPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(authenticatedTest, DB_NAME, true);
    Test supportFilesTest = new SupportFilesSetup(authorizedTest, SUPPORT_FILES);
    return supportFilesTest;
}

5. LuceneCoarseAuthorizationTest#suite()

Project: derby
File: LuceneCoarseAuthorizationTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(LuceneCoarseAuthorizationTest.class);
    Test unsecureTest = SecurityManagerSetup.noSecurityManager(suite);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(unsecureTest, LEGAL_USERS, "LuceneCoarsePermissions");
    Test coarseTest = new DatabasePropertyTestSetup(authenticatedTest, makeProperties());
    Test singleUseTest = TestConfiguration.singleUseDatabaseDecorator(coarseTest);
    return singleUseTest;
}

6. LuceneBackupTest#suite()

Project: derby
File: LuceneBackupTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(LuceneBackupTest.class);
    Test secureTest = new SecurityManagerSetup(suite, POLICY_FILE);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(secureTest, LEGAL_USERS, "LuceneBackupPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(authenticatedTest, DB_NAME, true);
    Test supportFilesTest = new SupportFilesSetup(authorizedTest);
    return supportFilesTest;
}

7. UDTPermsTest#suite()

Project: derby
File: UDTPermsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(UDTPermsTest.class);
    Test cleanTest = new CleanDatabaseTestSetup(suite);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "udtPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

8. UDAPermsTest#suite()

Project: derby
File: UDAPermsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(UDAPermsTest.class);
    Test cleanTest = new CleanDatabaseTestSetup(suite);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "udaPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

9. SimpleJsonPermsTest#suite()

Project: derby
File: SimpleJsonPermsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(SimpleJsonPermsTest.class);
    Test customTest = new SupportFilesSetup(suite, new String[] { "functionTests/tests/lang/json.dat" });
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(customTest, LEGAL_USERS, "SimpleJsonPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(authenticatedTest, DB_NAME, true);
    return authorizedTest;
}

10. SequenceTest#suite()

Project: derby
File: SequenceTest.java
// SETUP
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite(SequenceTest.class, "Sequence Test");
    // Need atleast JSR169 to run these tests
    if (!JDBC.vmSupportsJSR169() && !JDBC.vmSupportsJDBC3()) {
        return suite;
    }
    Test cleanTest = new CleanDatabaseTestSetup(suite);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "sequence");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

11. SequencePermsTest#suite()

Project: derby
File: SequencePermsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(SequencePermsTest.class);
    Test cleanTest = new CleanDatabaseTestSetup(suite);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "sequencePermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

12. MergeStatementTest#standardDecoration()

Project: derby
File: MergeStatementTest.java
/**
     * Decorate a test with standard decorators.
     */
private static Test standardDecoration(boolean withCollation) {
    Test cleanTest;
    if (withCollation) {
        cleanTest = Decorator.territoryCollatedDatabase(TestConfiguration.embeddedSuite(MergeStatementTest.Collated.class), "en");
    } else {
        cleanTest = new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(MergeStatementTest.class));
    }
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "MergeStatementPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return new SupportFilesSetup(authorizedTest);
}

13. GeneratedColumnsPermsTest#suite()

Project: derby
File: GeneratedColumnsPermsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(GeneratedColumnsPermsTest.class);
    Test cleanTest = new CleanDatabaseTestSetup(suite);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "generatedColumnsPermissions");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

14. UpdateStatisticsTest#suite()

Project: derby
File: UpdateStatisticsTest.java
public static Test suite() {
    //       Disable automatic index statistics generation. The generation will be
    //       triggered when preparing a statement and this will interfere
    //       with some of the asserts in testUpdateStatistics.
    //       With automatic generation enabled, testUpdateStatistics may
    //       fail intermittently due to timing, mostly when run
    //       with the client driver.
    Test test = TestConfiguration.defaultSuite(UpdateStatisticsTest.class);
    Test statsDisabled = DatabasePropertyTestSetup.singleProperty(test, "derby.storage.indexStats.auto", "false", true);
    return statsDisabled;
}

15. GeneratedColumnsTest#suite()

Project: derby
File: GeneratedColumnsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// 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;
}

16. DBOAccessTest#suite()

Project: derby
File: DBOAccessTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    String[] testFiles = new String[] { "functionTests/tests/lang/" + TEST_LOG_FILE };
    Test authorizedRun = TestConfiguration.embeddedSuite(DBOAccessTest.class);
    authorizedRun = DatabasePropertyTestSetup.builtinAuthentication(authorizedRun, LEGAL_USERS, "authorizationOnDBOAccessTest");
    authorizedRun = new SupportFilesSetup(authorizedRun, testFiles);
    authorizedRun = TestConfiguration.sqlAuthorizationDecorator(authorizedRun);
    Test unauthorizedRun = TestConfiguration.embeddedSuite(NoAuthorization.class);
    unauthorizedRun = new SupportFilesSetup(unauthorizedRun, testFiles);
    BaseTestSuite suite = new BaseTestSuite();
    suite.addTest(authorizedRun);
    suite.addTest(unauthorizedRun);
    return suite;
}

17. TestBundleActivator#runSDOTests()

Project: tuscany-sdo
File: TestBundleActivator.java
public void runSDOTests() throws Exception {
    Test allTests = AllTests.suite();
    TestResult testResult = new TestResult();
    allTests.run(testResult);
    System.out.println("Runs " + testResult.runCount() + ", Errors: " + testResult.errorCount());
    Enumeration e = testResult.errors();
    while (e.hasMoreElements()) {
        TestFailure f = (TestFailure) e.nextElement();
        System.out.println(f);
        System.out.println(f.exceptionMessage());
    }
    Assert.assertEquals(0, testResult.errorCount());
}

18. TestCaseTest#testExceptionRunningAndTearDown()

Project: junit4
File: TestCaseTest.java
public void testExceptionRunningAndTearDown() {
    // With 1.4, we should
    // wrap the exception thrown while running with the exception thrown
    // while tearing down
    Test t = new TornDown() {

        @Override
        public void tearDown() {
            throw new Error("tearingDown");
        }
    };
    TestResult result = new TestResult();
    t.run(result);
    TestFailure failure = result.errors().nextElement();
    assertEquals("running", failure.thrownException().getMessage());
}

19. AccessTest#suite()

Project: derby
File: AccessTest.java
public static Test suite() {
    Properties sysProps = new Properties();
    sysProps.put("derby.optimizer.optimizeJoinOrder", "false");
    sysProps.put("derby.optimizer.ruleBasedOptimization", "true");
    sysProps.put("derby.optimizer.noTimeout", "true");
    Test suite = TestConfiguration.embeddedSuite(AccessTest.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);
            s.execute("CREATE FUNCTION  PADSTRING (DATA VARCHAR(32000), " + "LENGTH INTEGER) RETURNS VARCHAR(32000) EXTERNAL NAME " + "'org.apache.derbyTesting.functionTests.util.Formatters" + ".padString' LANGUAGE JAVA PARAMETER STYLE JAVA");
        }
    };
}

20. StandardTests#createTableFromQueryTest()

Project: derby
File: StandardTests.java
public static Test createTableFromQueryTest(String serverHost, int serverPort) {
    Test t = // false: because adds clean/decorate below
    TestConfiguration.existingServerSuite(// false: because adds clean/decorate below
    CreateTableFromQueryTest.class, // false: because adds clean/decorate below
    false, serverHost, serverPort);
    CleanDatabaseTestSetup cdts = new CleanDatabaseTestSetup(t, // Use networkclient when running setUp/decorateSQL
    true, serverHost, serverPort) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            CreateTableFromQueryTest.decorate(stmt);
        }
    };
    return cdts;
}

21. StandardTests#ansiTrimTest()

Project: derby
File: StandardTests.java
public static Test ansiTrimTest(String serverHost, int serverPort) {
    Test t = // false: because adds clean/decorate below
    TestConfiguration.existingServerSuite(// false: because adds clean/decorate below
    AnsiTrimTest.class, // false: because adds clean/decorate below
    false, serverHost, serverPort);
    CleanDatabaseTestSetup cdts = new CleanDatabaseTestSetup(t, // Use networkclient when running setUp/decorateSQL
    true, serverHost, serverPort) {

        public void decorateSQL(Statement s) throws SQLException {
            AnsiTrimTest.decorate(s);
        }
    };
    return cdts;
}

22. StressMultiTest#embeddedSuite()

Project: derby
File: StressMultiTest.java
/**
     * 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;
}

23. RolesDependencyTest#suite()

Project: derby
File: RolesDependencyTest.java
public static Test suite() {
    Test test = new BaseTestSuite(RolesDependencyTest.class);
    // Populate database with data as DBO
    test = new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create schema s1");
            s.execute("create table s1.t1(x int)");
            s.execute("insert into s1.t1 values 1");
            s.execute("create role role1");
            s.execute("grant select on s1.t1 to role1");
            s.execute("grant role1 to user1");
        }
    };
    // Enable SQL authorization
    return TestConfiguration.sqlAuthorizationDecorator(test);
}

24. LobLimitsTest#baseSuite()

Project: derby
File: LobLimitsTest.java
/**
     * Create an instance of the {@code LobLimitsTest} suite.
     *
     * @param biggestSize the size of the biggest LOB to test
     * @param bigSize the size of a typical big LOB to test
     * @return a test suite
     */
static Test baseSuite(final int biggestSize, final int bigSize) {
    //Run the suite with following properties in case we run into lock
    // time out issues. It will help debug the problem if timeouts occur.
    Properties sysprops = new Properties();
    sysprops.setProperty("derby.locks.deadlockTrace", "true");
    sysprops.setProperty("derby.locks.monitor", "true");
    // Some of the test cases depend on certain other test cases to run
    // first, so force the test cases to run in lexicographical order.
    Test suite = new CleanDatabaseTestSetup(new BaseTestSuite(LobLimitsTest.class)) {

        @Override
        protected void decorateSQL(Statement s) throws SQLException {
            setupTables(s, biggestSize, bigSize);
        }
    };
    suite = new SystemPropertyTestSetup(suite, sysprops);
    return new SupportFilesSetup(suite);
}

25. Derby6884Test#baseSuite()

Project: derby
File: Derby6884Test.java
protected static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(name);
    suite.addTestSuite(Derby6884Test.class);
    Test test = suite;
    test = new SupportFilesSetup(test);
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            Connection conn = stmt.getConnection();
            stmt.execute("CREATE TABLE DERBY_6884_TESTBLOB" + "(id BIGINT, content BLOB)");
            stmt.execute("CREATE TABLE DERBY_6884_TESTCLOB" + "(id BIGINT, content CLOB)");
            conn.commit();
        }
    };
}

26. XplainStatisticsTest#suite()

Project: derby
File: XplainStatisticsTest.java
public static Test suite() {
    timeSuiteStarted = (new Date()).getTime();
    BaseTestSuite allTests = new BaseTestSuite(XplainStatisticsTest.class, "XplainStatisticsTest");
    Test test = allTests;
    //added by DERBY-4587
    test = new SupportFilesSetup(test);
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            createSchemaObjects(s);
        }
    };
}

27. StalePlansTest#suite()

Project: derby
File: StalePlansTest.java
/**
     * Create the test suite. This test is not run in client/server mode since
     * it only tests the query plans generated by the embedded driver.
     */
public static Test suite() {
    Properties props = new Properties();
    // Check for stale plans on every 10th execution (default 100) to
    // reduce the number of times we need to execute each statement.
    props.setProperty("derby.language.stalePlanCheckInterval", String.valueOf(STALE_PLAN_CHECK_INTERVAL));
    // Disable the index statistics daemon so that it doesn't cause
    // recompilation of statements at random times.
    props.setProperty("derby.storage.indexStats.auto", "false");
    Test suite = new DatabasePropertyTestSetup(new BaseTestSuite(StalePlansTest.class), props, true);
    return new CleanDatabaseTestSetup(suite);
}

28. SQLAuthorizationPropTest#suite()

Project: derby
File: SQLAuthorizationPropTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite(SQLAuthorizationPropTest.class, "SQLAuthorizationPropTest");
    // Use DatabasePropertyTestSetup decorator to set the property
    // required by this test (and shutdown the database for the
    // property to take effect.
    Properties props = new Properties();
    props.setProperty("derby.database.sqlAuthorization", "true");
    Test test = new SQLAuthorizationPropTest("grantRevokeAfterSettingSQLAuthProperty");
    suite.addTest(new DatabasePropertyTestSetup(test, props, true));
    // This test has to be run after SQL authorization property has been 
    // set to true. 
    suite.addTest(new SQLAuthorizationPropTest("resetSQLAuthProperty"));
    // which cannot be undone.
    return TestConfiguration.singleUseDatabaseDecorator(suite);
}

29. RolesTest#positiveSyntaxSuite()

Project: derby
File: RolesTest.java
/**
     *
     * Construct suite of tests for positive syntax (edge cases)
     *
     * @param framework Derby framework indication
     * @return A suite containing the test cases for  syntax
     * edge cases. Incarnated only for sqlAuthorization, dbo.
     */
private static Test positiveSyntaxSuite(String framework) {
    String dbo = users[dboIndex];
    String dbopw = dbo.concat(pwSuffix);
    Test t = (TestConfiguration.changeUserDecorator(new RolesTest("testPositiveSyntax", SQLAUTHORIZATION, dbo, dbopw), dbo, dbopw));
    return TestConfiguration.sqlAuthorizationDecorator(DatabasePropertyTestSetup.builtinAuthentication(t, users, pwSuffix));
}

30. OptionalToolsTest#suite()

Project: derby
File: OptionalToolsTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = (BaseTestSuite) TestConfiguration.embeddedSuite(OptionalToolsTest.class);
    Test test = DatabasePropertyTestSetup.builtinAuthentication(suite, LEGAL_USERS, "optionalToolsPermissions");
    test = TestConfiguration.sqlAuthorizationDecorator(test);
    test = TestConfiguration.additionalDatabaseDecorator(test, FOREIGN_DB);
    return test;
}

31. LuceneCollationTest#suite()

Project: derby
File: LuceneCollationTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    Test collationTest = Decorator.territoryCollatedDatabase(TestConfiguration.embeddedSuite(LuceneCollationTest.class), "en");
    //
    return SecurityManagerSetup.noSecurityManager(collationTest);
}

32. LockTableTest#suite()

Project: derby
File: LockTableTest.java
/**
     * Construct top level suite in this JUnit test
     * The suite is wrapped in a DatabasePropertyTestSetup to
     * lower the locking times.
     *
     * @return A suite containing embedded fixtures
     */
public static Test suite() {
    Properties properties = new Properties();
    properties.setProperty("derby.storage.rowLocking", "false");
    properties.setProperty("derby.locks.waitTimeout", "7");
    properties.setProperty("derby.locks.deadlockTimeout", "5");
    Test suite = TestConfiguration.embeddedSuite(LockTableTest.class);
    suite = new DatabasePropertyTestSetup(suite, properties, true);
    return new CleanDatabaseTestSetup(suite) {

        /**
             * Creates the schemas and table used in the test cases.
             *
             * @throws SQLException
             */
        protected void decorateSQL(Statement s) throws SQLException {
            Connection conn = getConnection();
            conn.setAutoCommit(false);
            s.executeUpdate("create schema u1");
            s.executeUpdate("create schema u2");
            conn.commit();
        }
    };
}

33. LangScripts#suite()

Project: derby
File: LangScripts.java
/**
	 * Return the suite that runs all the langauge SQL scripts.
	 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("LangScripts");
    suite.addTest(getSuite(CLIENT_AND_EMBEDDED_TESTS));
    suite.addTest(getSuite(EMBEDDED_TESTS));
    if (JDBC.vmSupportsJDBC3())
        suite.addTest(getSuite(JDBC3_TESTS));
    // Set up the scripts run with the network client
    BaseTestSuite clientTests = new BaseTestSuite("LangScripts:client");
    clientTests.addTest(getSuite(CLIENT_AND_EMBEDDED_TESTS));
    Test client = TestConfiguration.clientServerDecorator(clientTests);
    // add those client tests into the top-level suite.
    suite.addTest(client);
    return suite;
}

34. IdentitySequenceTest#suite()

Project: derby
File: IdentitySequenceTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite();
    Test cleanTest = new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(IdentitySequenceTest.class));
    suite.addTest(cleanTest);
    return suite;
}

35. HoldCursorTest#baseSuite()

Project: derby
File: HoldCursorTest.java
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);
}

36. GrantRevokeDDLTest#suite()

Project: derby
File: GrantRevokeDDLTest.java
public static Test suite() {
    if (JDBC.vmSupportsJSR169()) {
        // return empty suite;
        return new BaseTestSuite("GrantRevokeDDLTest");
    }
    //test uses triggers and procedures that use DriverManager.
    BaseTestSuite suite = new BaseTestSuite(GrantRevokeDDLTest.class, "GrantRevokeDDL Test");
    Test test = new SupportFilesSetup(suite);
    test = new CleanDatabaseTestSetup(test);
    test = DatabasePropertyTestSetup.builtinAuthentication(test, users, "grantrevokeddl");
    test = TestConfiguration.sqlAuthorizationDecorator(test);
    return test;
}

37. Derby5652#suite()

Project: derby
File: Derby5652.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Construct top level suite in this JUnit test
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("Derby5652");
    Test test = new Derby5652("basicTest");
    // turn off security manager so that we can change system properties
    test = SecurityManagerSetup.noSecurityManager(test);
    suite.addTest(test);
    return suite;
}

38. DeadlockDetectionTest#suite()

Project: derby
File: DeadlockDetectionTest.java
public static Test suite() {
    // Deadlock detection is engine functionality, so only test embedded.
    Test test = TestConfiguration.embeddedSuite(DeadlockDetectionTest.class);
    // Reduce the deadlock timeout since this test expects deadlocks, and
    // we want to detect them quickly in order to reduce the test time.
    // We don't expect any wait timeouts, so set the wait timeout
    // sufficiently high to prevent that queries time out before we have
    // set up the deadlock on slow machines.
    test = DatabasePropertyTestSetup.setLockTimeouts(test, 1, 30);
    return new CleanDatabaseTestSetup(test);
}

39. Bug5054Test#suite()

Project: derby
File: Bug5054Test.java
/**
     * Returns the implemented tests.
     * 
     * @return An instance of <code>Test</code> with the implemented tests to
     *         run.
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("Bug5054Test");
    Test test = new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(Bug5054Test.class)) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            stmt.executeUpdate("CREATE TABLE T1 (a integer, b integer)");
            stmt.executeUpdate("INSERT INTO T1 VALUES(1, 1)");
            stmt.executeUpdate("INSERT INTO T1 VALUES(2, 2)");
        }
    };
    suite.addTest(test);
    suite.addTest(TestConfiguration.clientServerDecorator(test));
    return suite;
}

40. ResultSetStreamTest#basesuite()

Project: derby
File: ResultSetStreamTest.java
public static Test basesuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(ResultSetStreamTest.class, name);
    Test test = new SupportFilesSetup(suite, new String[] { "functionTests/testData/ResultSetStream/littleclob.utf", "functionTests/testData/ResultSetStream/short.utf", "functionTests/testData/ResultSetStream/resultsetStream.gif" });
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table t2 (len int, data LONG VARCHAR FOR BIT DATA)");
            s.execute("create table t3(text_data clob)");
            s.execute("create table setMaxFieldSize(id int unique, " + "dVarchar VARCHAR(32672), dClob clob)");
        }
    };
}

41. PoolXADSCreateShutdownDBTest#suite()

Project: derby
File: PoolXADSCreateShutdownDBTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("PoolXADSCreateShutdownTest");
    Test test = TestConfiguration.defaultSuite(PoolXADSCreateShutdownDBTest.class);
    //Test test = TestConfiguration.clientServerSuite(DSCreateShutdownDBTest.class);
    suite.addTest(test);
    TestSetup setup = TestConfiguration.singleUseDatabaseDecorator(suite);
    // we need a couple extra databases to test they get created
    for (int i = 0; i < ADDITIONAL_DBS.length; i++) {
        setup = TestConfiguration.additionalDatabaseDecorator(setup, "emb" + ADDITIONAL_DBS[i]);
        setup = TestConfiguration.additionalDatabaseDecorator(setup, "srv" + ADDITIONAL_DBS[i]);
    }
    return suite;
}

42. DSCreateShutdownDBTest#suite()

Project: derby
File: DSCreateShutdownDBTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("DSCreateShutdownDBTest");
    Test test = TestConfiguration.defaultSuite(DSCreateShutdownDBTest.class);
    //Test test = TestConfiguration.clientServerSuite(DSCreateShutdownDBTest.class);
    suite.addTest(test);
    TestSetup setup = TestConfiguration.singleUseDatabaseDecorator(suite);
    // we need a couple extra databases to test they get created
    for (int i = 0; i < ADDITIONAL_DBS.length; i++) {
        setup = TestConfiguration.additionalDatabaseDecorator(setup, "emb" + ADDITIONAL_DBS[i]);
        setup = TestConfiguration.additionalDatabaseDecorator(setup, "srv" + ADDITIONAL_DBS[i]);
    }
    return suite;
}

43. DataSourceReferenceTest#suite()

Project: derby
File: DataSourceReferenceTest.java
/**
     * Creates a suite with tests for both embedded and client data sources.
     *
     * @return A suite with the appropriate tests.
     */
public static Test suite() {
    Test suite;
    if (JDBC.vmSupportsJSR169() || !JDBC.vmSupportsJNDI()) {
        // Referenceable is not supported with JSR169 or without JNDI
        suite = new BaseTestSuite("DatasourceReferenceTest cannot run with JSR169");
    } else {
        suite = TestConfiguration.defaultSuite(DataSourceReferenceTest.class);
    }
    return suite;
}

44. LoginTimeoutTest#suite()

Project: derby
File: LoginTimeoutTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit MACHINERY
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Return suite with all tests of the class.
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite();
    Test embedded = new BaseTestSuite(LoginTimeoutTest.class, "embedded LoginTimeoutTest");
    embedded = TestConfiguration.singleUseDatabaseDecorator(embedded);
    embedded = new SystemPropertyTestSetup(embedded, systemProperties());
    suite.addTest(embedded);
    if (Derby.hasServer() && Derby.hasClient()) {
        Test clientServer = new BaseTestSuite(LoginTimeoutTest.class, "client/server LoginTimeoutTest");
        clientServer = TestConfiguration.singleUseDatabaseDecorator(clientServer);
        clientServer = new JDBCClientSetup(clientServer, JDBCClient.DERBYNETCLIENT);
        clientServer = new NetworkServerTestSetup(clientServer, systemPropertiesArray(), new String[] {}, true);
        suite.addTest(clientServer);
    }
    return suite;
}

45. Driver40UnbootedTest#suite()

Project: derby
File: Driver40UnbootedTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * Return suite with all tests of the class.
     */
public static Test suite() {
    if (JDBC.vmSupportsJSR169()) {
        return new BaseTestSuite("DriverTest tests java.sql.Driver, not supported with JSR169");
    }
    Test test = TestConfiguration.embeddedSuite(Driver40UnbootedTest.class);
    return SecurityManagerSetup.noSecurityManager(test);
}

46. ConnectionMethodsTest#baseSuite()

Project: derby
File: ConnectionMethodsTest.java
public static Test baseSuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(ConnectionMethodsTest.class, name);
    Test test = new SupportFilesSetup(suite, new String[] { "functionTests/testData/ConnectionMethods/short.txt" });
    return new CleanDatabaseTestSetup(test) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table clobtable2(n int,clobcol CLOB)");
            s.execute("create table blobtable2(n int,blobcol BLOB)");
            s.execute("create table abort_table(a int)");
            s.execute("create schema foo");
            s.execute("create table foo.set_schema_table( a int )");
        }
    };
}

47. AbortTest#baseSuite()

Project: derby
File: AbortTest.java
public static Test baseSuite(boolean hasSecurityManager) {
    AbortTest abortTest = new AbortTest("test_basic", hasSecurityManager);
    Test test = new CleanDatabaseTestSetup(abortTest) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table abort_table( a int )");
        }
    };
    if (hasSecurityManager) {
        return new SecurityManagerSetup(test, "org/apache/derbyTesting/functionTests/tests/jdbc4/noAbortPermission.policy");
    } else {
        return SecurityManagerSetup.noSecurityManager(test);
    }
}

48. UrlLocaleTest#suite()

Project: derby
File: UrlLocaleTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite();
    suite.addTestSuite(UrlLocaleTest.class);
    suite.addTest(new LocaleTestSetup(new UrlLocaleTest("messageLocale_unknown"), new Locale("rr", "TT")));
    suite.addTest(new LocaleTestSetup(new UrlLocaleTest("messageLocale_Germany"), Locale.GERMANY));
    Test tsuite = new CleanDatabaseTestSetup(suite) {

        /**
             * Creates the table used in the test cases.
             *
             */
        protected void decorateSQL(Statement s) throws SQLException {
            createLocaleProcedures(s.getConnection());
        }
    };
    tsuite = new SupportFilesSetup(tsuite);
    return tsuite;
}

49. LocalizedAttributeScriptTest#suite()

Project: derby
File: LocalizedAttributeScriptTest.java
/**
     * Return the suite that runs the Localized script.
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("LocalizedScripts");
    // statement automatically invokes DriverManager.
    if (JDBC.vmSupportsJSR169())
        return suite;
    BaseTestSuite localizedTests = new BaseTestSuite("LocalizedScripts:embedded");
    localizedTests.addTest(getSuite());
    Test local = TestConfiguration.singleUseDatabaseDecoratorNoShutdown(localizedTests);
    // add those client tests into the top-level suite.
    suite.addTest(local);
    return suite;
}

50. LockInterruptTest#suite()

Project: derby
File: LockInterruptTest.java
public static Test suite() {
    // Only run in embedded mode since we cannot interrupt the engine
    // thread from the network client.
    Test test = TestConfiguration.embeddedSuite(LockInterruptTest.class);
    // Set the lock timeout to a known value so that we know what to
    // expect for timeouts.
    test = DatabasePropertyTestSetup.setLockTimeouts(test, DEADLOCK_TIMEOUT, LOCK_TIMEOUT);
    Properties syspros = new Properties();
    //Derby-4856 interrupt error create thread dump and diagnostic
    //info. Add property to avoid the information.
    syspros.put("derby.stream.error.extendedDiagSeverityLevel", "50000");
    test = new SystemPropertyTestSetup(test, syspros, true);
    return new CleanDatabaseTestSetup(test);
}

51. RuntimeInfoTest#decorateTest()

Project: derby
File: RuntimeInfoTest.java
/**
	 * Decorate a test with SecurityManagerSetup, clientServersuite, and
	 * SupportFilesSetup.
	 * 
	 * @return the decorated test
	 */
private static Test decorateTest(Locale serverLocale, String testName) {
    Test test = new RuntimeInfoTest(testName);
    test = TestConfiguration.clientServerDecorator(test);
    /* A single use database must be used to ensure the consistent output.
         * The output would change whether the test was being ran for the first
         * or subsequent times. */
    test = TestConfiguration.singleUseDatabaseDecorator(test);
    test = new LocaleTestSetup(test, serverLocale);
    // Install a security manager using the initial policy file.
    return new SecurityManagerSetup(test, POLICY_FILE_NAME);
}

52. OutBufferedStreamTest#suite()

Project: derby
File: OutBufferedStreamTest.java
/**
     * Returns the testsuite with a clientServerDecorator and a
     * CleanDatabaseTestSetup with a table. Also sets system property
     * derby.drda.streamOutBufferSize=131072.
     *
     * @return the testsuite
     */
public static Test suite() {
    Properties properties = new Properties();
    properties.setProperty("derby.drda.streamOutBufferSize", "131072");
    Test suite = TestConfiguration.clientServerSuite(OutBufferedStreamTest.class);
    suite = new SystemPropertyTestSetup(suite, properties);
    return new CleanDatabaseTestSetup(suite) {

        /**
             * Creates the table used in the test case.
             *
             * @throws SQLException
             */
        protected void decorateSQL(Statement s) throws SQLException {
            /* Create a table */
            s.execute("create table TEST_TABLE( TEST_COL blob( 65536 ))");
            getConnection().commit();
        }
    };
}

53. NetworkServerControlClientCommandTest#suite()

Project: derby
File: NetworkServerControlClientCommandTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("NetworkServerControlClientCommandTest");
    // and we don't run on J2ME because java command is different.
    if (!Derby.hasServer() || JDBC.vmSupportsJSR169())
        return suite;
    Test test = TestConfiguration.clientServerSuite(NetworkServerControlClientCommandTest.class);
    // no security manager because we exec a process and don't have permission for that.
    test = SecurityManagerSetup.noSecurityManager(test);
    suite.addTest(test);
    return suite;
}

54. NetworkServerControlApiTest#decorateShutdownTest()

Project: derby
File: NetworkServerControlApiTest.java
/**
     * 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;
}

55. NetIjTest#suite()

Project: derby
File: NetIjTest.java
/**
     * 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;
}

56. GetCurrentPropertiesTest#suite()

Project: derby
File: GetCurrentPropertiesTest.java
public static Test suite() {
    Test test = new BaseTestSuite(GetCurrentPropertiesTest.class);
    test = TestConfiguration.clientServerDecorator(test);
    // Install a security manager using the special policy file.
    // Grant ALL FILES execute, and getPolicy permissions,
    // as well as write for the trace files.
    test = new SecurityManagerSetup(test, POLICY_FILE_NAME);
    // properties, wrap in singleUseDatabaseDecorator 
    return TestConfiguration.singleUseDatabaseDecorator(test);
}

57. SuiteMethod#testFromSuiteMethod()

Project: CallBuilder
File: SuiteMethod.java
public static Test testFromSuiteMethod(Class<?> klass) throws Throwable {
    Method suiteMethod = null;
    Test suite = null;
    try {
        suiteMethod = klass.getMethod("suite");
        if (!Modifier.isStatic(suiteMethod.getModifiers())) {
            throw new Exception(klass.getName() + ".suite() must be static");
        }
        // static method
        suite = (Test) suiteMethod.invoke(null);
    } catch (InvocationTargetException e) {
        throw e.getCause();
    }
    return suite;
}

58. JSR166TestCase#main()

Project: caffeine
File: JSR166TestCase.java
/**
     * Runs all JSR166 unit tests using junit.textui.TestRunner.
     * Optional command line arg provides the number of iterations to
     * repeat running the tests.
     */
public static void main(String[] args) {
    if (useSecurityManager) {
        System.err.println("Setting a permissive security manager");
        Policy.setPolicy(permissivePolicy());
        System.setSecurityManager(new SecurityManager());
    }
    int iters = (args.length == 0) ? 1 : Integer.parseInt(args[0]);
    Test s = suite();
    for (int i = 0; i < iters; ++i) {
        junit.textui.TestRunner.run(s);
        System.gc();
        System.runFinalization();
    }
    System.exit(0);
}

59. JSR166TestCase#main()

Project: voltdb
File: JSR166TestCase.java
/**
     * Runs all JSR166 unit tests using junit.textui.TestRunner
     */
public static void main(String[] args) {
    if (useSecurityManager) {
        System.err.println("Setting a permissive security manager");
        Policy.setPolicy(permissivePolicy());
        System.setSecurityManager(new SecurityManager());
    }
    int iters = (args.length == 0) ? 1 : Integer.parseInt(args[0]);
    Test s = suite();
    for (int i = 0; i < iters; ++i) {
        junit.textui.TestRunner.run(s);
        System.gc();
        System.runFinalization();
    }
    System.exit(0);
}

60. TestContext#copySuite()

Project: mondrian
File: TestContext.java
/**
     * Makes a copy of a suite, filtering certain tests.
     *
     * @param suite Test suite
     * @param testPattern Regular expression of name of tests to include
     * @return copy of test suite
     */
public static TestSuite copySuite(TestSuite suite, Util.Functor1<Boolean, Test> testPattern) {
    TestSuite newSuite = new TestSuite(suite.getName());
    //noinspection unchecked
    for (Test test : Collections.list((Enumeration<Test>) suite.tests())) {
        if (!testPattern.apply(test)) {
            continue;
        }
        if (test instanceof TestCase) {
            newSuite.addTest(test);
        } else if (test instanceof TestSuite) {
            TestSuite subSuite = copySuite((TestSuite) test, testPattern);
            if (subSuite.countTestCases() > 0) {
                newSuite.addTest(subSuite);
            }
        } else {
            // some other kind of test
            newSuite.addTest(test);
        }
    }
    return newSuite;
}

61. SuiteMethod#testFromSuiteMethod()

Project: junit4
File: SuiteMethod.java
public static Test testFromSuiteMethod(Class<?> klass) throws Throwable {
    Method suiteMethod = null;
    Test suite = null;
    try {
        suiteMethod = klass.getMethod("suite");
        if (!Modifier.isStatic(suiteMethod.getModifiers())) {
            throw new Exception(klass.getName() + ".suite() must be static");
        }
        // static method
        suite = (Test) suiteMethod.invoke(null);
    } catch (InvocationTargetException e) {
        throw e.getCause();
    }
    return suite;
}

62. MissingPermissionsTest#makeTest()

Project: derby
File: MissingPermissionsTest.java
private static Test makeTest(String fixture, String policy) {
    Test t = new MissingPermissionsTest(fixture);
    t = new SecurityManagerSetup(t, policy);
    final Properties props = new Properties();
    props.setProperty("derby.connection.requireAuthentication", "true");
    props.setProperty("derby.database.sqlAuthorization", "true");
    props.setProperty("derby.authentication.provider", "BUILTIN");
    props.setProperty("derby.user.APP", "APPPW");
    t = new SystemPropertyTestSetup(t, props, true);
    t = TestConfiguration.changeUserDecorator(t, "APP", "APPPW");
    t = TestConfiguration.singleUseDatabaseDecorator(t);
    return t;
}

63. TestConfiguration#sqlAuthorizationDecoratorSingleUse()

Project: derby
File: TestConfiguration.java
/**
     * Same as sqlAuthorizationDecoratorSingleUse, except that you can name
     * the database yourself, and you can choose whether or not the decorator
     * should shut down the database before it attempts to drop it.
     *
     * @param test Test to be decorated
     * @param dbName The name of the database to use in the test
     * @param shutdownDatabase Whether or not to shut down the database
     *   before it is dropped
     * @return decorated test.
     *
     * @see TestConfiguration#sqlAuthorizationDecorator(Test test)
     */
public static Test sqlAuthorizationDecoratorSingleUse(Test test, String dbName, boolean shutdownDatabase) {
    // Set the SQL authorization mode as a database property
    // with a modified DatabasePropertyTestSetup that does not
    // reset it.
    final Properties sqlAuth = new Properties();
    sqlAuth.setProperty("derby.database.sqlAuthorization", "true");
    Test setSQLAuthMode = DatabasePropertyTestSetup.getNoTeardownInstance(test, sqlAuth, true);
    setSQLAuthMode = new DropDatabaseSetup(setSQLAuthMode, dbName, shutdownDatabase);
    setSQLAuthMode = new DatabaseChangeSetup(setSQLAuthMode, dbName, dbName, true);
    return changeUserDecorator(setSQLAuthMode, DerbyConstants.TEST_DBO, // DRDA doesn't like empty pw
    "dummy");
}

64. TestConfiguration#sqlAuthorizationDecorator()

Project: derby
File: TestConfiguration.java
/**
     * Decorate a test to use the default database that has
     * was created in SQL authorization mode.
     * The tearDown reverts the configuration to the previous
     * configuration.
     * 
     * The database owner of this default SQL authorization mode
     * database is TEST_DBO. This decorator sets the default user
     * to be TEST_DBO.
     * 
     * Tests can use this in conjunction with
     * DatabasePropertyTestSetup.builtinAuthentication
     * to set up BUILTIN authentication and changeUserDecorator
     * to switch users. The database owner TEST_DBO must be included
     * in the list of users provided to builtinAuthentication.
     * This decorator must be the outer one in this mode.
     * <code>
     * test = DatabasePropertyTestSetup.builtinAuthentication(test,
                new String[] {TEST_DBO,"U1","U2",},
                "nh32ew");
       test = TestConfiguration.sqlAuthorizationDecorator(test);
     * </code>
     * A utility version of sqlAuthorizationDecorator is provided
     * that combines the two setups.
     * 
     * @param test Test to be decorated
     * @return decorated test.
     * 
     * @see DatabasePropertyTestSetup#builtinAuthentication(Test, String[], String)
     */
public static Test sqlAuthorizationDecorator(Test test) {
    // Set the SQL authorization mode as a database property
    // with a modified DatabasePropertyTestSetup that does not
    // reset it.
    final Properties sqlAuth = new Properties();
    sqlAuth.setProperty("derby.database.sqlAuthorization", "true");
    Test setSQLAuthMode = DatabasePropertyTestSetup.getNoTeardownInstance(test, sqlAuth, true);
    return changeUserDecorator(new DatabaseChangeSetup(setSQLAuthMode, DEFAULT_DBNAME_SQL, DEFAULT_DBNAME_SQL, true), DerbyConstants.TEST_DBO, // DRDA doesn't like empty pw
    "dummy");
}

65. TestConfiguration#existingServerDecorator()

Project: derby
File: TestConfiguration.java
/**
    * A variant of defaultServerDecorator allowing 
    * non-default hostname, portnumber and database name.
    */
public static Test existingServerDecorator(Test test, String hostName, int PortNumber, String dbPath) {
    // running in J2ME (JSR169).
    if (!supportsClientServer()) {
        return new BaseTestSuite("empty: no network server support");
    }
    Test r = new ServerSetup(test, hostName, PortNumber);
    ((ServerSetup) r).setJDBCClient(JDBCClient.DERBYNETCLIENT);
    ((ServerSetup) r).setDbPath(dbPath);
    return r;
}

66. TestConfiguration#existingServerDecorator()

Project: derby
File: TestConfiguration.java
/**
    * A variant of defaultServerDecorator allowing 
    * non-default hostname and portnumber.
    */
public static Test existingServerDecorator(Test test, String hostName, int PortNumber) {
    // running in J2ME (JSR169).
    if (!supportsClientServer()) {
        return new BaseTestSuite("empty: no network server support");
    }
    Test r = new ServerSetup(test, hostName, PortNumber);
    ((ServerSetup) r).setJDBCClient(JDBCClient.DERBYNETCLIENT);
    return r;
}

67. TestConfiguration#defaultExistingServerDecorator()

Project: derby
File: TestConfiguration.java
/**
     * Decorate a test to use suite's default host and port, 
     * but assuming the server is already running.
     */
public static Test defaultExistingServerDecorator(Test test) {
    // and not running in J2ME (JSR169).
    if (!(Derby.hasClient()) || JDBC.vmSupportsJSR169()) {
        return new BaseTestSuite("empty: no network server support in JSR169 " + "(or derbyclient.jar missing).");
    }
    Test r = new ServerSetup(test, DEFAULT_HOSTNAME, TestConfiguration.getCurrent().getPort());
    ((ServerSetup) r).setJDBCClient(JDBCClient.DERBYNETCLIENT);
    return r;
}

68. HarnessJavaTest#decorate()

Project: derby
File: HarnessJavaTest.java
/**
     * Decorate a HarnessJavaTest test. Any sub-class must
     * call this decorator when adding a test to a suite.
     * This sets up the ij system properties to setup
     * the default connection to be to the default database.
     * The lock timeouts are also shortened and the test
     * will start in a clean database.
     */
protected static Test decorate(HarnessJavaTest test) {
    Test dtest = new SystemPropertyTestSetup(test, new Properties()) {

        protected void setUp() throws java.lang.Exception {
            TestConfiguration config = TestConfiguration.getCurrent();
            // With JDBC 3 connect using a JDBC URL
            if (JDBC.vmSupportsJDBC3()) {
                newValues.setProperty("ij.database", config.getJDBCUrl());
            }
            super.setUp();
        }
    };
    dtest = DatabasePropertyTestSetup.setLockTimeouts(dtest, 4, 6);
    dtest = new CleanDatabaseTestSetup(dtest);
    return dtest;
}

69. ToolScripts#suite()

Project: derby
File: ToolScripts.java
/**
     * Return the suite that runs all the tool scripts.
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("ToolScripts");
    suite.addTest(getSuite(CLIENT_AND_EMBEDDED_TESTS));
    suite.addTest(getSuite(EMBEDDED_TESTS));
    if (JDBC.vmSupportsJDBC3())
        suite.addTest(getSuite(JDBC3_TESTS));
    suite.addTest(getAuthorizationSuite(SQLAUTHORIZATION_TESTS));
    // Set up the scripts run with the network client
    BaseTestSuite clientTests = new BaseTestSuite("ToolScripts:client");
    clientTests.addTest(getSuite(CLIENT_AND_EMBEDDED_TESTS));
    clientTests.addTest(getAuthorizationSuite(SQLAUTHORIZATION_TESTS));
    clientTests.addTest(getSuite(CLIENT_TESTS));
    Test client = TestConfiguration.clientServerDecorator(clientTests);
    // add those client tests into the top-level suite.
    suite.addTest(client);
    return suite;
}

70. SysinfoLocaleTest#createTest()

Project: derby
File: SysinfoLocaleTest.java
/**
     * Create a single test case.
     *
     * @param loc default locale for the test case
     * @param ui <code>derby.ui.locale</code> for the test case
     * @param german whether output is expected to be German
     */
private static Test createTest(Locale loc, String ui, boolean german) {
    Properties prop = new Properties();
    if (ui != null) {
        prop.setProperty("derby.ui.locale", ui);
    }
    // always set the encoding so that we can reliably read the output
    prop.setProperty("derby.ui.codeset", ENCODING);
    String info = "defaultLocale=" + loc + ",uiLocale=" + ui;
    Test test = new SysinfoLocaleTest(loc, german, info);
    return new SystemPropertyTestSetup(test, prop);
}

71. SysinfoCPCheckTest#suite()

Project: derby
File: SysinfoCPCheckTest.java
public static Test suite() {
    if (!Derby.hasTools())
        return new BaseTestSuite("empty: no tools support");
    // before starting the security manager...
    if (!Derby.hasServer())
        isServer = false;
    if (!Derby.hasClient())
        isClient = false;
    Test suite = new BaseTestSuite(SysinfoCPCheckTest.class, "Sysinfo ClassPath Checker");
    return new LocaleTestSetup(suite, Locale.ENGLISH);
}

72. RollBackWrappingWhenFailOnImportTest#suite()

Project: derby
File: RollBackWrappingWhenFailOnImportTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("RollBackWrappingWhenFailOnImportTest");
    if (!JDBC.vmSupportsJDBC3()) {
        return suite;
    }
    Test test = new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(RollBackWrappingWhenFailOnImportTest.class));
    suite.addTest(test);
    return suite;
}

73. IjSecurityManagerTest#decorateTest()

Project: derby
File: IjSecurityManagerTest.java
private static Test decorateTest() {
    Test test = TestConfiguration.embeddedSuite(IjSecurityManagerTest.class);
    test = new SupportFilesSetup(test, null, new String[] { "functionTests/tests/tools/IjSecurityManagerTest.sql" }, null, new String[] { "IjSecurityManagerTest.sql" });
    return test;
}

74. IjConnNameTest#suite()

Project: derby
File: IjConnNameTest.java
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);
}

75. ij5Test#suite()

Project: derby
File: ij5Test.java
public static Test suite() {
    Properties props = new Properties();
    // return an empty suite (i.e. don't run with JSR 169).
    if (JDBC.vmSupportsJSR169()) {
        return new BaseTestSuite("empty: cannot obtain expected output with JSR169");
    }
    props.setProperty("ij.showNoConnectionsAtStart", "false");
    props.setProperty("ij.showNoCountForSelect", "false");
    Test test = new SystemPropertyTestSetup(new ij5Test("ij5"), props);
    test = new CleanDatabaseTestSetup(test);
    return getIJConfig(test);
}

76. ij3Test#suite()

Project: derby
File: ij3Test.java
public static Test suite() {
    Properties props = new Properties();
    props.setProperty("ij.database", "jdbc:derby:wombat;create=true");
    props.setProperty("ij.showNoConnectionsAtStart", "true");
    props.setProperty("ij.showNoCountForSelect", "true");
    Test test = new SystemPropertyTestSetup(new ij3Test("ij3"), props);
    test = new CleanDatabaseTestSetup(test);
    return getIJConfig(test);
}

77. ConnectWrongSubprotocolTest#suite()

Project: derby
File: ConnectWrongSubprotocolTest.java
public static Test suite() {
    // Test does not run on J2ME
    if (JDBC.vmSupportsJSR169()) {
        return new BaseTestSuite("empty: no support for Driver.sql.Manager with jsr 169");
    }
    if (!Derby.hasTools())
        return new BaseTestSuite("empty: no tools support");
    Properties props = new Properties();
    props.setProperty("ij.connection.wrongSubprotocol", "jdbc:noone:fruitfly;create=true");
    Test test = TestConfiguration.embeddedSuite(ConnectWrongSubprotocolTest.class);
    return new SystemPropertyTestSetup(test, props);
}

78. StoreScriptsTest#suite()

Project: derby
File: StoreScriptsTest.java
public static Test suite() {
    Properties props = new Properties();
    props.setProperty("derby.infolog.append", "true");
    props.setProperty("ij.protocol", "jdbc:derby:");
    props.setProperty("ij.database", "wombat;create=true");
    Test test = new SystemPropertyTestSetup(getSuite(EMBEDDED_TESTS), props);
    // Lock timeout settings that were set for the old harness store tests
    test = DatabasePropertyTestSetup.setLockTimeouts(test, 1, 4);
    BaseTestSuite suite = new BaseTestSuite("StoreScripts");
    suite.addTest(test);
    return getIJConfig(suite);
}

79. SpaceTableTest#suite()

Project: derby
File: SpaceTableTest.java
/**
     * Construct top level suite in this JUnit test
     * The suite is wrapped in a DatabasePropertyTestSetup to set
     * the lock wait timeout.
     *
     * @return A suite containing embedded fixtures
     */
public static Test suite() {
    Test suite = TestConfiguration.embeddedSuite(SpaceTableTest.class);
    return new CleanDatabaseTestSetup(suite) {

        /**
             * Creates the schemas and table used in the test cases.
             *
             * @throws SQLException
             */
        protected void decorateSQL(Statement s) throws SQLException {
            Connection conn = getConnection();
            conn.setAutoCommit(false);
            String createWaitForPostCommit = "CREATE PROCEDURE WAIT_FOR_POST_COMMIT() " + "DYNAMIC RESULT SETS 0 " + "LANGUAGE JAVA EXTERNAL NAME " + "'org.apache.derbyTesting.functionTests.util.T_Access." + "waitForPostCommitToFinish' " + "PARAMETER STYLE JAVA";
            s.executeUpdate(createWaitForPostCommit);
            conn.commit();
            conn.setAutoCommit(true);
        }
    };
}

80. LiveLockTest#suite()

Project: derby
File: LiveLockTest.java
public static Test suite() {
    Test suite = TestConfiguration.embeddedSuite(LiveLockTest.class);
    return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 1, 10)) {

        /**
             * Creates the table used in the test cases.
             * 
             */
        protected void decorateSQL(Statement s) throws SQLException {
            s.executeUpdate("CREATE TABLE T (I INT)");
            s.executeUpdate("INSERT INTO T VALUES(456)");
        }
    };
}

81. IndexSplitDeadlockTest#suite()

Project: derby
File: IndexSplitDeadlockTest.java
public static Test suite() {
    Test test = TestConfiguration.embeddedSuite(IndexSplitDeadlockTest.class);
    // DERBY-4273: Include the lock table in the error message to help
    // debugging in case of lock timeouts.
    test = DatabasePropertyTestSetup.singleProperty(test, "derby.locks.deadlockTrace", "true");
    test = new CleanDatabaseTestSetup(test);
    return test;
}

82. Derby3980DeadlockTest#suite()

Project: derby
File: Derby3980DeadlockTest.java
public static Test suite() {
    Test suite = decorateTest();
    return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 5, 10)) {

        /**
          * Creates the table used in the test cases.
          * 
          */
        protected void decorateSQL(Statement s) throws SQLException {
            s.executeUpdate("CREATE TABLE T (I INT)");
            s.executeUpdate("INSERT INTO T VALUES(456)");
        }
    };
}

83. CryptoCrashRecoveryTest#suite()

Project: derby
File: CryptoCrashRecoveryTest.java
public static Test suite() {
    Test suite;
    if (SanityManager.DEBUG) {
        suite = TestConfiguration.embeddedSuite(CryptoCrashRecoveryTest.class);
    } else {
        suite = new BaseTestSuite("CryptoCrashRecovery disabled due to non-debug build");
        println("CryptoCrashRecoveryTest disabled due to non-debug build");
    }
    return suite;
}

84. ClassLoaderBootTest#suite()

Project: derby
File: ClassLoaderBootTest.java
/**
     * Runs the tests in the default embedded configuration and then
     * the client server configuration.
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite(ClassLoaderBootTest.class);
    Test test = suite;
    TestSetup setup = new CleanDatabaseTestSetup(test) {

        protected void setUp() throws Exception {
            super.setUp();
            //shutdown the database. 
            DataSource ds = JDBCDataSource.getDataSource();
            JDBCDataSource.shutdownDatabase(ds);
        }
    };
    Properties p = new Properties();
    p.setProperty("derby.infolog.append", "true");
    setup = new SystemPropertyTestSetup(setup, p);
    // on. Have to run without security manager for now.
    return SecurityManagerSetup.noSecurityManager(setup);
//return setup;
}

85. BootLockTest#decorateTest()

Project: derby
File: BootLockTest.java
/**
     * Decorate test with singleUseDatabaseDecorator and noSecurityManager.
     *
     * @return the decorated test
     */
private static Test decorateTest() {
    Test test = new BaseTestSuite(BootLockTest.class);
    if (JDBC.vmSupportsJSR169() && !isJ9Platform()) {
        // PhoneME requires forceDatabaseLock
        Properties props = new Properties();
        props.setProperty("derby.database.forceDatabaseLock", "true");
        test = new SystemPropertyTestSetup(test, props, true);
    }
    test = TestConfiguration.singleUseDatabaseDecorator(test, dbName);
    test = SecurityManagerSetup.noSecurityManager(test);
    return test;
}

86. AutomaticIndexStatisticsTest#suite()

Project: derby
File: AutomaticIndexStatisticsTest.java
public static Test suite() {
    Test test = new BaseTestSuite(AutomaticIndexStatisticsTest.class);
    test = new CleanDatabaseTestSetup(test);
    test = TestConfiguration.additionalDatabaseDecorator(test, MASTERDB);
    // TimeZoneTestSetup can probably be removed once DERBY-5974 is fixed.
    return new TimeZoneTestSetup(test, "GMT");
}

87. Test_6661#suite()

Project: derby
File: Test_6661.java
///////////////////////////////////////////////////////////////////////////////////
//
// JUnit BEHAVIOR
//
///////////////////////////////////////////////////////////////////////////////////
public static Test suite() {
    BaseTestSuite baseTest = new BaseTestSuite(Test_6661.class, "Test_6661");
    Test singleUseWrapper = TestConfiguration.singleUseDatabaseDecorator(baseTest);
    Test cleanDatabaseWrapper = new CleanDatabaseTestSetup(singleUseWrapper);
    Test supportFileWrapper = new SupportFilesSetup(cleanDatabaseWrapper);
    Test noSecurityWrapper = SecurityManagerSetup.noSecurityManager(supportFileWrapper);
    return noSecurityWrapper;
}

88. StressMultiTest#suite()

Project: derby
File: StressMultiTest.java
/**
     * Set up the testsuite to run in embedded, client and encryption mode.
     * Default run is 10 threads for 10 minutes in each mode
     */
public static Test suite() {
    Properties dbprops = new Properties();
    dbprops.put("derby.locks.deadlockTimeout", "2");
    dbprops.put("derby.locks.waitTimeout", "3");
    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);
    // make this a singleUseDatabase so the datbase and 
    // transaction log will be preserved.
    embedded = TestConfiguration.singleUseDatabaseDecorator(newCleanDatabase(embedded));
    // SystemPropertyTestSetup for static properties 
    // does not work for client because shutting down the
    // engine causes protocol errors on the client. Run
    // with -Dderby.storage.keepTransactionLog=true if
    // you need to save the transaction log for client.
    Test client = TestConfiguration.clientServerDecorator(new BaseTestSuite(StressMultiTest.class));
    client = newCleanDatabase(new DatabasePropertyTestSetup(client, dbprops));
    Test encrypted = new BaseTestSuite(StressMultiTest.class);
    // SystemPropertyTestSetup for static properties 
    // does not work for encrypted databases because the
    // database has to be rebooted and we don't have access
    // to the boot password (local to Decorator.encryptedDatabase()
    // Run with -Dderby.storage.keepTransactionLog=true if you 
    // need to save the transaction log for encrypted.
    BaseTestSuite unencrypted = new BaseTestSuite("StressMultiTest:unencrypted");
    unencrypted.addTest((embedded));
    unencrypted.addTest((client));
    BaseTestSuite suite = new BaseTestSuite("StressMultiTest, " + THREADS + " Threads " + MINUTES + " Minutes");
    suite.addTest(newCleanDatabase(unencrypted));
    //Encrypted uses a different database so it needs its own newCleanDatabase
    suite.addTest(Decorator.encryptedDatabase(new DatabasePropertyTestSetup(newCleanDatabase(encrypted), dbprops)));
    return suite;
}

89. MBeanTest#suite()

Project: derby
File: MBeanTest.java
protected static Test suite(Class<? extends MBeanTest> testClass, String suiteName) {
    BaseTestSuite outerSuite = new BaseTestSuite(suiteName);
    Test platform = new BaseTestSuite(testClass, suiteName + ":platform");
    // Start the network server to ensure Derby is running and
    // all the MBeans are running.
    platform = TestConfiguration.clientServerDecorator(platform);
    platform = JMXConnectionDecorator.platformMBeanServer(platform);
    // Set of tests that run within the same virtual machine using
    // the platform MBeanServer directly.
    outerSuite.addTest(platform);
    // Create a suite of all "test..." methods in the class.
    Test suite = new BaseTestSuite(testClass, suiteName + ":client");
    // Set up to get JMX connections using remote JMX
    suite = JMXConnectionDecorator.remoteNoSecurity(suite);
    /* Connecting to an MBean server using a URL requires setting up remote
         * JMX in the JVM to which we want to connect. This is usually done by
         * setting a few system properties at JVM startup.
         * A quick solution is to set up a new network server JVM with
         * the required jmx properties.
         * A future improvement could be to fork a new JVM for embedded (?).
         *
         * This requires that the default security policy of the network server
         * includes the permissions required to perform the actions of these 
         * tests. Otherwise, we'd probably have to supply a custom policy file
         * and specify this using additional command line properties at server 
         * startup.
         */
    NetworkServerTestSetup networkServerTestSetup = new NetworkServerTestSetup(// run all tests in this class in the same setup
    suite, // need to set up JMX in JVM
    getCommandLineProperties(false), // no server arguments needed
    new String[0], // wait for the server to start properly
    true);
    /* Since the server will be started in a new process we need "execute" 
         * FilePermission on all files (at least Java executables)...
         * Will run without SecurityManager for now, but could probably add a 
         * JMX specific policy file later. Or use the property trick reported
         * on derby-dev 2008-02-26 and add the permission to the generic 
         * policy.
         * Note that the remote server will be running with a security
         * manager (by default) if testing with jars.
         */
    Test testSetup = SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
    // this decorator makes sure the suite is empty if this configration
    // does not support the network server:
    outerSuite.addTest(TestConfiguration.defaultServerDecorator(testSetup));
    return outerSuite;
}

90. TruncateTableTest#suite()

Project: derby
File: TruncateTableTest.java
public static Test suite() {
    Test cleanTest = TestConfiguration.defaultSuite(TruncateTableTest.class);
    Test authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication(cleanTest, LEGAL_USERS, "");
    Test authorizedTest = TestConfiguration.sqlAuthorizationDecorator(authenticatedTest);
    return authorizedTest;
}

91. LuceneSupportTest#suite()

Project: derby
File: LuceneSupportTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("LuceneSupportTest");
    Test baseTest = TestConfiguration.embeddedSuite(LuceneSupportTest.class);
    Test singleUseTest = TestConfiguration.singleUseDatabaseDecorator(baseTest);
    Test localizedTest = new LocaleTestSetup(singleUseTest, new Locale("en", "US"));
    suite.addTest(SecurityManagerSetup.noSecurityManager(localizedTest));
    return suite;
}

92. SysDiagVTIMappingTest#suite()

Project: derby
File: SysDiagVTIMappingTest.java
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("Diagnostic VTI Table Mappings");
    Test defaultSetup = TestConfiguration.defaultSuite(SysDiagVTIMappingTest.class);
    // turn on statement logging so there will be something in the error log
    // to run these vtis against
    Properties sysprops = new Properties();
    sysprops.put("derby.language.logStatementText", "true");
    Test verboseTest = new SystemPropertyTestSetup(defaultSetup, sysprops);
    suite.addTest(verboseTest);
    /* Some of the VTIs that are tested in this class require a derby.log
         * file.  We have a test log file stored in the tests/lang directory,
         * and since the VTIs are going to try to read it, the test log file
         * must be in a directory for which Derby has read access.  By
         * using a SupportFilesSetup wrapper, we copy the test log file to
         * the "extin" directory, which has the required permissions.
         */
    return SecurityManagerSetup.noSecurityManager(new SupportFilesSetup(suite, new String[] { "functionTests/tests/lang/" + testLogFile }));
}

93. SpillHashTest#suite()

Project: derby
File: SpillHashTest.java
/**
	 * Returns the implemented tests.
	 * 
	 * @return An instance of <code>Test</code> with the implemented tests to
	 *         run.
	 */
public static Test suite() {
    // suite of tests with light load on the tables
    BaseTestSuite light = new BaseTestSuite();
    // suite of tests with heavy load on the tables
    BaseTestSuite heavy = new BaseTestSuite();
    light.addTest(new SpillHashTest("testJoinLight"));
    light.addTest(new SpillHashTest("testDistinctLight"));
    light.addTest(new SpillHashTest("testCursorLight"));
    heavy.addTest(new SpillHashTest("testJoinHeavy"));
    heavy.addTest(new SpillHashTest("testDistinctHeavy"));
    heavy.addTest(new SpillHashTest("testCursorHeavy"));
    Test lightSetup = new BaseJDBCTestSetup(light) {

        protected void setUp() throws Exception {
            super.setUp();
            Statement stmt = getConnection().createStatement();
            PreparedStatement insA = stmt.getConnection().prepareStatement("insert into ta(ca1,ca2) values(?,?)");
            PreparedStatement insB = stmt.getConnection().prepareStatement("insert into tb(cb1,cb2) values(?,?)");
            insertDups(insA, insB, initDupVals);
            getConnection().commit();
            stmt.close();
        //System.out.println("2");
        }
    };
    Test heavySetup = new BaseJDBCTestSetup(heavy) {

        protected void setUp() throws Exception {
            super.setUp();
            Statement stmt = getConnection().createStatement();
            PreparedStatement insA = stmt.getConnection().prepareStatement("insert into ta(ca1,ca2) values(?,?)");
            PreparedStatement insB = stmt.getConnection().prepareStatement("insert into tb(cb1,cb2) values(?,?)");
            for (int i = 1; i <= LOTS_OF_ROWS; i++) {
                insA.setInt(1, i);
                insA.setString(2, ca2Val(i));
                insA.executeUpdate();
                insB.setInt(1, i);
                insB.setString(2, cb2Val(i));
                insB.executeUpdate();
                if ((i & 0xff) == 0)
                    stmt.getConnection().commit();
            }
            insertDups(insA, insB, spillDupVals);
            getConnection().commit();
            stmt.close();
        //System.out.println("3");				
        }
    };
    BaseTestSuite mainSuite = new BaseTestSuite();
    mainSuite.addTest(lightSetup);
    mainSuite.addTest(heavySetup);
    return new CleanDatabaseTestSetup(mainSuite) {

        protected void decorateSQL(Statement stmt) throws SQLException {
            for (int i = 0; i < prep.length; i++) {
                stmt.executeUpdate(prep[i]);
            }
        //System.out.println("1");
        }
    };
}

94. ProcedureInTriggerTest#basesuite()

Project: derby
File: ProcedureInTriggerTest.java
private static Test basesuite() {
    Test basesuite = new BaseTestSuite(ProcedureInTriggerTest.class);
    Test clean = new CleanDatabaseTestSetup(basesuite) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table t1 (i int primary key, b char(15))");
            s.execute("create table t2 (x integer, y integer)");
            s.execute("create procedure proc_no_sql() parameter style java language java NO SQL external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.zeroArg'");
            s.execute("create procedure proc_contains_sql() parameter style java language java CONTAINS SQL external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.getConnectionProc'");
            s.execute("create procedure proc_reads_sql(i integer) parameter style java language java READS SQL DATA external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.selectRows' dynamic result sets 1");
            s.execute("create procedure proc_modifies_sql_insert_op(p1 int, p2 char(10)) parameter style java language java MODIFIES SQL DATA external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.insertRow'");
            s.execute("create procedure proc_modifies_sql_update_op(p1 int) parameter style java language java  MODIFIES SQL DATA  external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.updateRow'");
            s.execute("create procedure proc_modifies_sql_delete_op(p1 int) parameter style java language java MODIFIES SQL DATA external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.deleteRow'");
            s.execute("create procedure alter_table_proc() parameter style java language java external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.alterTable'");
            s.execute("create procedure drop_table_proc() parameter style java language java external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.dropTable'");
            s.execute("create procedure commit_proc() parameter style java dynamic result sets 0 language java contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.doConnCommit'");
            s.execute("create procedure rollback_proc() parameter style java dynamic result sets 0 language java contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.doConnRollback'");
            s.execute("create procedure set_isolation_proc() parameter style java dynamic result sets 0 language java contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.doConnectionSetIsolation'");
            s.execute("create procedure create_index_proc() parameter style java dynamic result sets 0 language java  contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.createIndex'");
            s.execute("create procedure drop_index_proc() parameter style java dynamic result sets 0 language java contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.dropIndex'");
            s.execute("create procedure create_trigger_proc() parameter style java dynamic result sets 0 language java contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.createTrigger'");
            s.execute(" create procedure drop_trigger_proc() parameter style java dynamic result sets 0 language java contains sql external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.dropTrigger'");
            s.execute("create procedure proc_wrongly_defined_as_no_sql(p1 int, p2 char(10)) parameter style java language java NO SQL external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.insertRow'");
            // create a new schema and put a procedure in it.
            s.execute("create schema new_schema");
            s.execute("create procedure new_schema.proc_in_new_schema() parameter style java language java NO SQL external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.zeroArg'");
            // procedure which uses non-existant method
            s.execute("create procedure proc_using_non_existent_method() parameter style java language java NO SQL external name 'org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.nonexistentMethod'");
        }
    };
    return clean;
}

95. NullableUniqueConstraintTest#main()

Project: derby
File: NullableUniqueConstraintTest.java
public static void main(String[] args) {
    TestResult tr = new TestResult();
    Test t = suite();
    t.run(tr);
    System.out.println(tr.errorCount());
    Enumeration e = tr.failures();
    while (e.hasMoreElements()) {
        ((TestFailure) e.nextElement()).thrownException().printStackTrace();
    }
    System.out.println(tr.failureCount());
}

96. DistinctTest#suite()

Project: derby
File: DistinctTest.java
public static Test suite() {
    Test s = new BaseTestSuite(DistinctTest.class);
    Properties p = new Properties();
    p.put("derby.optimizer.noTimeout", "true");
    Test t = new SystemPropertyTestSetup(s, p);
    return new CleanDatabaseTestSetup(t) {

        protected void decorateSQL(Statement s) throws SQLException {
            s.execute("create table t (i int, s smallint, r real, f float, d date, t time, ts timestamp, c char(10), v varchar(20))");
            // for tests from distinctElimination
            s.execute("create table one(c1 int, c2 int, c3 int, c4 int, c5 int)");
            s.execute("create unique index one_c1 on one(c1)");
            s.execute("create table two(c1 int, c2 int, c3 int, c4 int, c5 int)");
            s.execute("create unique index two_c1c3 on two(c1, c3)");
            s.execute("create table three(c1 int, c2 int, c3 int, c4 int, c5 int)");
            s.execute("create unique index three_c1 on three(c1)");
            s.execute("create table four(c1 int, c2 int, c3 int, c4 int, c5 int)");
            s.execute("create unique index four_c1c3 on four(c1, c3)");
            s.execute("CREATE TABLE \"APP\".\"IDEPT\" (\"DISCRIM_DEPT\" VARCHAR(32), \"NO1\" INTEGER NOT NULL, " + "\"NAME\" VARCHAR(50), \"AUDITOR_NO\" INTEGER, \"REPORTTO_NO\" INTEGER, \"HARDWAREASSET\"" + " VARCHAR(15), \"SOFTWAREASSET\" VARCHAR(15))");
            s.execute("ALTER TABLE \"APP\".\"IDEPT\" ADD CONSTRAINT \"PK_IDEPT\" PRIMARY KEY (\"NO1\")");
            s.execute("insert into one values (1, 1, 1, 1, 1)");
            s.execute("insert into one values (2, 1, 1, 1, 1)");
            s.execute("insert into one values (3, 1, 1, 1, 1)");
            s.execute("insert into one values (4, 1, 1, 1, 1)");
            s.execute("insert into one values (5, 1, 1, 1, 1)");
            s.execute("insert into one values (6, 1, 1, 1, 1)");
            s.execute("insert into one values (7, 1, 1, 1, 1)");
            s.execute("insert into one values (8, 1, 1, 1, 1)");
            s.execute("insert into two values (1, 1, 1, 1, 1)");
            s.execute("insert into two values (1, 1, 2, 1, 1)");
            s.execute("insert into two values (1, 1, 3, 1, 1)");
            s.execute("insert into two values (2, 1, 1, 1, 1)");
            s.execute("insert into two values (2, 1, 2, 1, 1)");
            s.execute("insert into two values (2, 1, 3, 1, 1)");
            s.execute("insert into two values (3, 1, 1, 1, 1)");
            s.execute("insert into two values (3, 1, 2, 1, 1)");
            s.execute("insert into two values (3, 1, 3, 1, 1)");
            s.execute("insert into three values (1, 1, 1, 1, 1)");
            s.execute("insert into three values (2, 1, 1, 1, 1)");
            s.execute("insert into three values (3, 1, 1, 1, 1)");
            s.execute("insert into three values (4, 1, 1, 1, 1)");
            s.execute("insert into three values (5, 1, 1, 1, 1)");
            s.execute("insert into three values (6, 1, 1, 1, 1)");
            s.execute("insert into three values (7, 1, 1, 1, 1)");
            s.execute("insert into three values (8, 1, 1, 1, 1)");
            s.execute("insert into four values (1, 1, 1, 1, 1)");
            s.execute("insert into four values (1, 1, 2, 1, 1)");
            s.execute("insert into four values (1, 1, 3, 1, 1)");
            s.execute("insert into four values (2, 1, 1, 1, 1)");
            s.execute("insert into four values (2, 1, 2, 1, 1)");
            s.execute("insert into four values (2, 1, 3, 1, 1)");
            s.execute("insert into four values (3, 1, 1, 1, 1)");
            s.execute("insert into four values (3, 1, 2, 1, 1)");
            s.execute("insert into four values (3, 1, 3, 1, 1)");
            s.execute("insert into idept values ('Dept', 1, 'Department1', null, null, null, null)");
            s.execute("insert into idept values ('HardwareDept', 2, 'Department2', 25, 1, 'hardwareaset2', null)");
            s.execute("insert into idept values ('HardwareDept', 3, 'Department3', 25, 2, 'hardwareaset3', null)");
            s.execute("insert into idept values ('SoftwareDept', 4, 'Department4', 25, 1, null, 'softwareasset4')");
            s.execute("insert into idept values ('SoftwareDept', 5, 'Department5', 30, 4, null, 'softwareasset5')");
        }
    };
}

97. LocalizedDisplayScriptTest#suite()

Project: derby
File: LocalizedDisplayScriptTest.java
/**
     * Return the suite that runs the Localized script.
     */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("LocalizedDisplay");
    // (See DERBY-470).
    if (JDBC.vmSupportsJSR169())
        return suite;
    // test if the encoding is not supported.
    if (!Charset.isSupported(ENCODING)) {
        println("Skip LocalizedDisplayScriptTest because the encoding " + ENCODING + " is not supported");
        return suite;
    }
    BaseTestSuite localizedEmbeddedTests = new BaseTestSuite("LocalizedDisplay:embedded");
    localizedEmbeddedTests.addTest(getSuite());
    Test embeddedrun = TestConfiguration.singleUseDatabaseDecorator(localizedEmbeddedTests);
    // add the client test
    suite.addTest(embeddedrun);
    // It's not working to have both embedded and client run in the same
    // setting as the database doesn't get deleted until after the suite is done.
    // The second run will go against the already created & encoded database,
    // resulting in localized display by default, and thus a diff with the
    // master.
    // Set up the script's run with the network client
    BaseTestSuite localizedTests = new BaseTestSuite("LocalizedDisplay:client");
    localizedTests.addTest(getSuite());
    Test client = TestConfiguration.clientServerDecorator(TestConfiguration.singleUseDatabaseDecorator(localizedTests));
    // add the client test
    suite.addTest(client);
    return suite;
}

98. SSLTest#decorateTest()

Project: derby
File: SSLTest.java
// Test decoration
/**
     * <p>
     * Compose the required decorators to bring up the server in the correct
     * configuration.
     * </p>
     */
private static Test decorateTest(String testName) {
    SSLTest sslTest = new SSLTest(testName);
    String[] startupProperties = getStartupProperties();
    String[] startupArgs = new String[] {};
    NetworkServerTestSetup networkServerTestSetup = new NetworkServerTestSetup(sslTest, startupProperties, startupArgs, true);
    Test testSetup = SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
    testSetup = new SupportFilesSetup(testSetup, null, new String[] { "functionTests/tests/derbynet/SSLTestServerKey.key" }, null, new String[] { "SSLTestServerKey.key" });
    Test test = TestConfiguration.defaultServerDecorator(testSetup);
    test = TestConfiguration.changeSSLDecorator(test, "basic");
    return test;
}

99. SecureServerTest#decorateTest()

Project: derby
File: SecureServerTest.java
///////////////////////////////////////////////////////////////////////////////////
//
// TEST DECORATION
//
///////////////////////////////////////////////////////////////////////////////////
/**
     * <p>
     * Compose the required decorators to bring up the server in the correct
     * configuration.
     * </p>
     */
private static Test decorateTest(boolean unsecureSet, boolean authenticationRequired, String customDerbyProperties, String wildCardHost, Outcome outcome) {
    SecureServerTest secureServerTest = new SecureServerTest(unsecureSet, authenticationRequired, customDerbyProperties, wildCardHost, outcome);
    String[] startupProperties = getStartupProperties(authenticationRequired, customDerbyProperties);
    String[] startupArgs = getStartupArgs(unsecureSet, wildCardHost);
    NetworkServerTestSetup networkServerTestSetup = new NetworkServerTestSetup(secureServerTest, startupProperties, startupArgs, secureServerTest._outcome.serverShouldComeUp());
    secureServerTest.nsTestSetup = networkServerTestSetup;
    Test testSetup = SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
    // if using the custom derby.properties, copy the custom properties to a visible place
    if (customDerbyProperties != null) {
        testSetup = new SupportFilesSetup(testSetup, null, new String[] { "functionTests/tests/derbynet/SecureServerTest.derby.properties" }, null, new String[] { "derby.properties" });
    }
    Test test = TestConfiguration.defaultServerDecorator(testSetup);
    // DERBY-2109: add support for user credentials
    test = TestConfiguration.changeUserDecorator(test, SST_USER_NAME, SST_PASSWORD);
    return test;
}

100. TestCaseTest#testNoArgTestCasePasses()

Project: junit4
File: TestCaseTest.java
public void testNoArgTestCasePasses() {
    Test t = new TestSuite(NoArgTestCaseTest.class);
    TestResult result = new TestResult();
    t.run(result);
    assertTrue(result.runCount() == 1);
    assertTrue(result.failureCount() == 0);
    assertTrue(result.errorCount() == 0);
}