Search in sources :

Example 96 with BaseTestSuite

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

the class IndexScanTest method suite.

/**
 * Create a test suite with all the test cases in this class.
 * @return a test suite
 */
public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("IndexScanTest");
    suite.addTest(new IndexScanTest("varchar10", 5000, 4));
    suite.addTest(new IndexScanTest("varchar100", 5000, 4));
    suite.addTest(new IndexScanTest("varchar1000", 5000, 4));
    suite.addTest(new IndexScanTest("varcharAll", 5000, 4));
    suite.addTest(new IndexScanTest("decimal1column", 5000, 4));
    suite.addTest(new IndexScanTest("decimal10columns", 5000, 4));
    return new CleanDatabaseTestSetup(suite) {

        protected void decorateSQL(Statement s) throws SQLException {
            // Create a table with some character data and decimal data
            // that we can use in our tests.
            s.execute("CREATE TABLE T (VC10 VARCHAR(10), " + "VC100 VARCHAR(100), " + "VC1000 VARCHAR(1000), " + "DEC1 DECIMAL(10,10), " + "DEC2 DECIMAL(10,10), " + "DEC3 DECIMAL(10,10), " + "DEC4 DECIMAL(10,10), " + "DEC5 DECIMAL(10,10), " + "DEC6 DECIMAL(10,10), " + "DEC7 DECIMAL(10,10), " + "DEC8 DECIMAL(10,10), " + "DEC9 DECIMAL(10,10), " + "DEC10 DECIMAL(10,10))");
            // Fill the table with 1000 rows containing random data.
            PreparedStatement ps = s.getConnection().prepareStatement("INSERT INTO T(VC10,VC100,VC1000,DEC1,DEC2,DEC3," + "DEC4,DEC5,DEC6,DEC7,DEC8,DEC9,DEC10) VALUES (?,?,?," + "RANDOM(),RANDOM(),RANDOM(),RANDOM(),RANDOM()," + "RANDOM(),RANDOM(),RANDOM(),RANDOM(),RANDOM())");
            char[] chars = new char[1000];
            Random r = new Random();
            for (int i = 0; i < 1000; i++) {
                fillWithRandomChars(r, chars);
                ps.setString(1, new String(chars, 0, 10));
                ps.setString(2, new String(chars, 0, 100));
                ps.setString(3, new String(chars, 0, 1000));
                ps.executeUpdate();
            }
            ps.close();
            // Create various indexes on the table.
            s.execute("CREATE INDEX T_VC10 ON T(VC10)");
            s.execute("CREATE INDEX T_VC100 ON T(VC100)");
            s.execute("CREATE INDEX T_VC1000 ON T(VC1000)");
            s.execute("CREATE INDEX T_VC_ALL ON T(VC10,VC100,VC1000)");
            s.execute("CREATE INDEX T_DEC1 ON T(DEC1)");
            s.execute("CREATE INDEX T_DEC_ALL ON T(DEC1,DEC2,DEC3,DEC4," + "DEC5,DEC6,DEC7,DEC8,DEC9,DEC10)");
        }
    };
}
Also used : Random(java.util.Random) CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) Statement(java.sql.Statement) PreparedStatement(java.sql.PreparedStatement) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) PreparedStatement(java.sql.PreparedStatement)

Example 97 with BaseTestSuite

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

the class ValuesTest method suite.

/**
 * @return Tests that should be run as part of this class.
 */
public static Test suite() {
    int iterations = 100000;
    int repeats = 4;
    BaseTestSuite suite = new BaseTestSuite("ValuesTest");
    // To add embed tests.
    suite.addTest(new ValuesTest("fetchByColumnName", iterations, repeats));
    suite.addTest(new ValuesTest("fetchByColumnNumber", iterations, repeats));
    // To add client tests.
    BaseTestSuite client = new BaseTestSuite("Client_ValuesTest");
    client.addTest(new ValuesTest("fetchByColumnName", iterations, repeats));
    client.addTest(new ValuesTest("fetchByColumnNumber", iterations, repeats));
    suite.addTest(TestConfiguration.clientServerDecorator(client));
    return suite;
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 98 with BaseTestSuite

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

the class SystemPrivilegesPermissionTest method suite.

/**
 * Return a suite with all tests in this class (default suite)
 */
public static Test suite() {
    // this suite cannot be constructed with automatic test extraction
    // (by passing a class argument); instead, the tests need to be added
    // manually since some of them require their own policy file
    BaseTestSuite suite = new BaseTestSuite("SystemPrivilegesPermissionTest");
    // add API tests for the basic security framework classes
    suite.addTest(new SystemPrivilegesPermissionTest("testSystemPrincipal"));
    suite.addTest(new SystemPrivilegesPermissionTest("testSystemPermission"));
    suite.addTest(new SystemPrivilegesPermissionTest("testSystemPermissionCollections"));
    // the DatabasePermission test attempts to canonicalize various
    // directory path names and requires an all-files-read-permission,
    // which is not granted by default derby_tests.policy
    suite.addTest(new SecurityManagerSetup(new SystemPrivilegesPermissionTest("testDatabasePermission"), POLICY_FILE_NAME1));
    // on all JVM platforms
    if (SecurityManagerSetup.JVM_HAS_SUBJECT_AUTHORIZATION) {
        suite.addTest(new SecurityManagerSetup(new SystemPrivilegesPermissionTest("policyTestSystemPermissionGrants"), POLICY_FILE_NAME));
        suite.addTest(new SecurityManagerSetup(new SystemPrivilegesPermissionTest("policyTestDatabasePermissionGrants"), POLICY_FILE_NAME));
    }
    // Only run this test on Java 8.
    if (isJava8()) {
        suite.addTest(SecurityManagerSetup.noSecurityManager(new SystemPrivilegesPermissionTest("testSerialization")));
    }
    return suite;
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup)

Example 99 with BaseTestSuite

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

the class _Suite method suite.

public static Test suite() throws SQLException {
    BaseTestSuite suite = new BaseTestSuite("JUnit unit tests");
    suite.addTest(ArrayInputStreamTest.suite());
    suite.addTest(FormatableBitSetTest.suite());
    suite.addTest(SystemPrivilegesPermissionTest.suite());
    suite.addTest(UTF8UtilTest.suite());
    suite.addTestSuite(CompressedNumberTest.class);
    suite.addTest(AssertFailureTest.suite());
    suite.addTest(InputStreamUtilTest.suite());
    suite.addTest(CharacterStreamDescriptorTest.suite());
    suite.addTest(BlockedByteArrayTest.suite());
    suite.addTest(PathUtilTest.suite());
    suite.addTest(VirtualFileTest.suite());
    suite.addTest(ReaderToUTF8StreamTest.suite());
    suite.addTest(DataInputUtilTest.suite());
    suite.addTest(DerbyVersionTest.suite());
    suite.addTest(MissingPermissionsTest.suite());
    return suite;
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite)

Example 100 with BaseTestSuite

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

the class NetHarnessJavaTest method suite.

public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("derbynet: old harness java tests");
    if (!Derby.hasServer())
        return suite;
    suite.addTest(TestConfiguration.clientServerDecorator(decorate(new NetHarnessJavaTest("executeUpdate"))));
    // which is tested in ProtocolTest.
    return new SupportFilesSetup(suite, new String[] { "functionTests/tests/derbynet/excsat_accsecrd1.inc", "functionTests/tests/derbynet/excsat_accsecrd2.inc", "functionTests/tests/derbynet/excsat_secchk.inc", "functionTests/tests/derbynet/connect.inc", "functionTests/tests/derbynet/values1.inc", "functionTests/tests/derbynet/values64kblksz.inc" });
}
Also used : BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Aggregations

BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)476 Test (junit.framework.Test)136 CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)118 Statement (java.sql.Statement)81 PreparedStatement (java.sql.PreparedStatement)68 SupportFilesSetup (org.apache.derbyTesting.junit.SupportFilesSetup)49 Properties (java.util.Properties)43 SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)34 CallableStatement (java.sql.CallableStatement)19 Connection (java.sql.Connection)14 SecurityManagerSetup (org.apache.derbyTesting.junit.SecurityManagerSetup)13 DatabasePropertyTestSetup (org.apache.derbyTesting.junit.DatabasePropertyTestSetup)11 TestSetup (junit.extensions.TestSetup)10 SQLException (java.sql.SQLException)7 LocaleTestSetup (org.apache.derbyTesting.junit.LocaleTestSetup)7 Method (java.lang.reflect.Method)5 Locale (java.util.Locale)5 BaseJDBCTestSetup (org.apache.derbyTesting.junit.BaseJDBCTestSetup)4 NetworkServerTestSetup (org.apache.derbyTesting.junit.NetworkServerTestSetup)4 ResultSet (java.sql.ResultSet)3