Search in sources :

Example 6 with SupportFilesSetup

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

Example 7 with SupportFilesSetup

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

the class ProtocolTest method suite.

/**
 * Creates a suite of tests dynamically from a file describing protocol
 * tests.
 *
 * @return A suite of tests.
 * @throws Exception if creating the suite fails for some reason
 */
public static Test suite() throws Exception {
    BaseTestSuite suite = new BaseTestSuite("Derby DRDA protocol tests");
    // Process the list of files and create test cases for the sub-tests.
    // NOTE: We cannot assume anything about the order in which the tests
    // are executed.
    final String testFile = PREFIX + "protocol.tests";
    final URL testFileURL = BaseTestCase.getTestResource(testFile);
    BufferedReader bIn = new BufferedReader(new InputStreamReader(openTestResource(testFileURL), Charset.forName("UTF-8")));
    // Split the tests into individual tests.
    final String END_TEST = ProtocolTestGrammar.END_TEST.toCmdString();
    int currentLine = 1;
    // First line is line number one.
    int startLine = 1;
    ArrayList<String> cmdLines = new ArrayList<String>();
    StringBuilder str = new StringBuilder();
    String line;
    // Iterate until the end of test token is reached.
    while ((line = bIn.readLine()) != null) {
        cmdLines.add(line);
        str.append(line).append(NL);
        if (line.toLowerCase(Locale.ENGLISH).startsWith(END_TEST)) {
            // Create a new test case.
            suite.addTest(new ProtocolTest("protocol.tests", str.toString(), startLine, currentLine - startLine));
            cmdLines.clear();
            str.setLength(0);
            startLine = currentLine + 1;
        }
        currentLine++;
    }
    bIn.close();
    // Install a security policy and copy the required include files.
    final String resourcePath = "functionTests/tests/derbynet";
    return new SecurityManagerSetup(TestConfiguration.clientServerDecorator(new SupportFilesSetup(suite, new String[] { resourcePath + "/connect.inc", resourcePath + "/excsat_accsecrd1.inc", resourcePath + "/excsat_accsecrd2.inc", resourcePath + "/excsat_accsecrd_nordb.inc", resourcePath + "/excsat_secchk_nordbonaccsec.inc", resourcePath + "/excsat_secchk.inc", resourcePath + "/values1.inc", resourcePath + "/values64kblksz.inc" })), PREFIX + "ProtocolTest.policy", true);
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SecurityManagerSetup(org.apache.derbyTesting.junit.SecurityManagerSetup) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup) URL(java.net.URL)

Example 8 with SupportFilesSetup

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

the class CheckToursDBTest method basesuite.

public static Test basesuite(String name) {
    BaseTestSuite suite = new BaseTestSuite(CheckToursDBTest.class, name);
    Test test = new SupportFilesSetup(suite, new String[] { "functionTests/tests/demo/cupisle.gif", "functionTests/tests/demo/smallisle.gif", "functionTests/tests/demo/witchisle.gif" });
    return test;
}
Also used : Test(junit.framework.Test) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Example 9 with SupportFilesSetup

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

the class RestrictiveFilePermissionsTest method suite.

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

Example 10 with SupportFilesSetup

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

the class I18NImportExport method suite.

public static Test suite() {
    BaseTestSuite suite = new BaseTestSuite("I18NImportExport");
    suite.addTest(new CleanDatabaseTestSetup(new I18NImportExport("I18NImportExport")));
    return getIJConfig(new SupportFilesSetup(suite, new String[] { "functionTests/tests/i18n/data/Tab1_fr.ctrl", "functionTests/tests/i18n/data/Tab1_il.ctrl", "functionTests/tests/i18n/data/Tab1_jp.ctrl" }));
}
Also used : CleanDatabaseTestSetup(org.apache.derbyTesting.junit.CleanDatabaseTestSetup) BaseTestSuite(org.apache.derbyTesting.junit.BaseTestSuite) SupportFilesSetup(org.apache.derbyTesting.junit.SupportFilesSetup)

Aggregations

SupportFilesSetup (org.apache.derbyTesting.junit.SupportFilesSetup)58 BaseTestSuite (org.apache.derbyTesting.junit.BaseTestSuite)49 Test (junit.framework.Test)34 CleanDatabaseTestSetup (org.apache.derbyTesting.junit.CleanDatabaseTestSetup)19 Statement (java.sql.Statement)13 PreparedStatement (java.sql.PreparedStatement)11 Properties (java.util.Properties)9 SystemPropertyTestSetup (org.apache.derbyTesting.junit.SystemPropertyTestSetup)8 SecurityManagerSetup (org.apache.derbyTesting.junit.SecurityManagerSetup)4 CallableStatement (java.sql.CallableStatement)3 LocaleTestSetup (org.apache.derbyTesting.junit.LocaleTestSetup)3 NetworkServerTestSetup (org.apache.derbyTesting.junit.NetworkServerTestSetup)3 URL (java.net.URL)2 Locale (java.util.Locale)2 ClasspathSetup (org.apache.derbyTesting.junit.ClasspathSetup)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1