use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class DistinctTest method suite.
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')");
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class DynamicLikeOptimizationTest method suite.
public static Test suite() {
BaseTestSuite tests = new BaseTestSuite("DynamicLikeOptimizationTest");
tests.addTestSuite(DynamicLikeOptimizationTest.class);
tests.addTest(TestConfiguration.clientServerDecorator(new BaseTestSuite(DynamicLikeOptimizationTest.class)));
return new CleanDatabaseTestSetup(tests) {
protected void decorateSQL(Statement stmt) throws SQLException {
stmt.executeUpdate("create table t1(c11 int)");
stmt.executeUpdate("insert into t1 values 1");
stmt.executeUpdate("create table test(id char(10), " + "c10 char(10), vc10 varchar(10))");
PreparedStatement insert = getConnection().prepareStatement("insert into test values (?,?,?)");
String[] values = { "asdf", "asdg", "aasdf", "%foobar", "foo%bar", "foo_bar" };
for (int i = 0; i < values.length; i++) {
for (int j = 1; j <= 3; j++) {
insert.setString(j, values[i]);
}
insert.executeUpdate();
}
insert.setString(1, "V-NULL");
insert.setString(2, null);
insert.setString(3, null);
insert.executeUpdate();
insert.setString(1, "MAX_CHAR");
insert.setString(2, "\uFA2D");
insert.setString(3, "\uFA2D");
insert.executeUpdate();
insert.close();
stmt.executeUpdate("create table likeable(match_me varchar(10), " + "pattern varchar(10), esc varchar(1))");
stmt.executeUpdate("insert into likeable values " + "('foo%bar', 'fooZ%bar', 'Z'), " + "('foo%bar', '%Z%ba_', 'Z')," + "('foo%bar', 'fooZ%baZ', 'Z')");
stmt.executeUpdate("create table cei(id int, name varchar(192) not null, " + "source varchar(252) not null)");
PreparedStatement cei = getConnection().prepareStatement("insert into cei values (?,?,?)");
for (int i = 0; i < CEI_ROWS.length; i++) {
for (int j = 0; j < CEI_ROWS[i].length; j++) {
cei.setObject(j + 1, CEI_ROWS[i][j]);
}
cei.executeUpdate();
}
cei.close();
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class ViewsTest method suite.
public static Test suite() {
BaseTestSuite suite = new BaseTestSuite("views Test");
suite.addTest(TestConfiguration.embeddedSuite(ViewsTest.class));
return new CleanDatabaseTestSetup(suite);
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class Derby5624Test method baseSuite.
protected static Test baseSuite(String name) {
BaseTestSuite suite = new BaseTestSuite(name);
suite.addTestSuite(Derby5624Test.class);
return new CleanDatabaseTestSetup(suite) {
/**
* Creates the tables used in the test cases.
* @exception SQLException if a database error occurs
*/
protected void decorateSQL(Statement stmt) throws SQLException {
Connection conn = stmt.getConnection();
// create table with 1000 columns
StringBuffer create_table_qry = new StringBuffer(10000);
create_table_qry.append("CREATE TABLE TESTBIGTABLE (col0 int");
for (int colnum = 1; colnum < 1000; colnum++) {
create_table_qry.append(", col" + colnum + " int");
}
create_table_qry.append(")");
// CREATE TABLE TESTBIGTABLE (
// col0 int, col1 int, ... , col999 int)
stmt.executeUpdate(create_table_qry.toString());
conn.setAutoCommit(false);
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class Derby6884Test method baseSuite.
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();
}
};
}
Aggregations