use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class LobSortTest method suite.
public static Test suite() {
Properties props = new Properties();
// Adjust sort buffer size to trigger the bug situation with less data.
props.setProperty("derby.storage.sortBufferMax", "4");
BaseTestSuite suite = new BaseTestSuite(LobSortTest.class, "LobSortTestEmbedded");
return new CleanDatabaseTestSetup(new SystemPropertyTestSetup(suite, props, true)) {
/**
* Generates a table with Blob and Clobs of mixed size.
*/
protected void decorateSQL(Statement s) throws SQLException {
Random rnd = new Random(SEED);
Connection con = s.getConnection();
con.setAutoCommit(false);
s.executeUpdate("create table MIXED_LOBS (" + "c clob, clen int, b blob, blen int, rnd int)");
PreparedStatement ps = con.prepareStatement("insert into MIXED_LOBS values (?,?,?,?,?)");
// Make sure we get at least one zero-length CLOB and BLOB.
ps.setString(1, "");
ps.setInt(2, 0);
ps.setBytes(3, new byte[0]);
ps.setInt(4, 0);
ps.setInt(5, rnd.nextInt());
ps.executeUpdate();
for (int i = 0; i < 100; i++) {
CharAlphabet ca = getCharAlphabet(1 + rnd.nextInt(3));
int length = (int) (rnd.nextDouble() * 64.0 * 1024.0);
if (rnd.nextInt(1000) < 500) {
// Specify the length.
ps.setCharacterStream(1, new LoopingAlphabetReader(length, ca), length);
} else {
// Don't specify the length.
ps.setCharacterStream(1, new LoopingAlphabetReader(length, ca));
}
ps.setInt(2, length);
length = (int) (rnd.nextDouble() * 64.0 * 1024.0);
if (rnd.nextInt(1000) < 500) {
// Specify the length.
ps.setBinaryStream(3, new LoopingAlphabetStream(length), length);
} else {
// Don't specify the length.
ps.setBinaryStream(3, new LoopingAlphabetStream(length));
}
ps.setInt(4, length);
ps.setInt(5, rnd.nextInt());
ps.executeUpdate();
}
con.commit();
ps.close();
}
/**
* Returns a character alphabet.
*/
private CharAlphabet getCharAlphabet(int i) {
switch(i) {
case 1:
return CharAlphabet.modernLatinLowercase();
case 2:
return CharAlphabet.tamil();
case 3:
return CharAlphabet.cjkSubset();
default:
fail("Unknown alphabet identifier: " + i);
}
// Will never be reached.
return null;
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class ConnectionMethodsTest method baseSuite.
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 )");
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class Derby3650Test method baseSuite.
protected static Test baseSuite(String name) {
BaseTestSuite suite = new BaseTestSuite(name);
suite.addTestSuite(Derby3650Test.class);
return new CleanDatabaseTestSetup(DatabasePropertyTestSetup.setLockTimeouts(suite, 2, 4)) {
/**
* Creates the tables used in the test cases.
* @exception SQLException if a database error occurs
*/
protected void decorateSQL(Statement stmt) throws SQLException {
try {
initializeClobTables(stmt);
initializeBlobTables(stmt);
} catch (IOException ioe) {
fail("Unexpected I/O exception during setup: " + ioe);
}
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class UrlLocaleTest method suite.
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;
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class AbortTest method baseSuite.
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);
}
}
Aggregations