use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class MergeStatementTest method standardDecoration.
/**
* 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);
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class NullIfTest method baseSuite.
public static Test baseSuite(String name) {
BaseTestSuite suite = new BaseTestSuite(name);
suite.addTestSuite(NullIfTest.class);
return new CleanDatabaseTestSetup(suite) {
/**
* Creates the table used in the test cases.
*/
protected void decorateSQL(Statement s) throws SQLException {
SQLUtilities.createAndPopulateAllDataTypesTable(s);
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class LazyDefaultSchemaCreationTest method suite.
public static Test suite() {
BaseTestSuite suite = new BaseTestSuite("LazyDefaultSchemaCreationTest");
BaseTestSuite[] suites = { new BaseTestSuite("LazyDefaultSchemaCreationTest:embedded"), new BaseTestSuite("LazyDefaultSchemaCreationTest:clientServer") };
for (int i = 0; i < 2; i++) {
suites[i].addTest(DatabasePropertyTestSetup.setLockTimeouts(new LazyDefaultSchemaCreationTest("testDerby48testNewSchemaHang"), 2, 1));
suites[i].addTest(DatabasePropertyTestSetup.setLockTimeouts(new LazyDefaultSchemaCreationTest("testDerby48SelfLockingRecovery"), 2, 1));
Properties p = new Properties();
p.setProperty("derby.locks.deadlockTrace", "true");
suites[i].addTest(DatabasePropertyTestSetup.setLockTimeouts(new DatabasePropertyTestSetup(new LazyDefaultSchemaCreationTest("testDerby48SelfLockingRecoveryDeadlockDetectionOn"), p, false), // deadlock timeout
2, // wait timeout
1));
suites[i].addTest(DatabasePropertyTestSetup.setLockTimeouts(new DatabasePropertyTestSetup(new LazyDefaultSchemaCreationTest("testDerby3678"), p, false), // deadlock timeout
2, // wait timeout
1));
suites[i].addTest(new CleanDatabaseTestSetup(new LazyDefaultSchemaCreationTest("testDerby3043CheckConstraint")));
if (i == 0) {
suite.addTest(suites[i]);
} else {
suite.addTest(TestConfiguration.clientServerDecorator(suites[i]));
}
}
return suite;
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class LockTableTest method suite.
/**
* 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();
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class OrderByAndSortAvoidance method makeSuite.
/**
* Construct suite of tests
*
* @return A suite containing the test cases.
*/
private static Test makeSuite() {
return new CleanDatabaseTestSetup(new BaseTestSuite(OrderByAndSortAvoidance.class)) {
protected void decorateSQL(Statement st) throws SQLException {
st.executeUpdate("create table a(col1 int, col2 int)");
st.executeUpdate("insert into a values(1,1),(1,1)");
st.executeUpdate("create table b(col1 int, col2 int)");
st.executeUpdate("insert into b values(2,2),(2,2)");
st.executeUpdate("create table c(col1 int, col2 int)");
st.executeUpdate("insert into c values(3,3),(3,3)");
st.executeUpdate("create TABLE table1 (id BIGINT NOT NULL, PRIMARY KEY(id))");
st.executeUpdate("CREATE INDEX key1 ON table1(id)");
st.executeUpdate("CREATE TABLE table2 (id BIGINT NOT NULL, name " + "VARCHAR(40) NOT NULL, value VARCHAR(1024), PRIMARY " + "KEY(id, name))");
st.executeUpdate("CREATE UNIQUE INDEX key2 ON table2(id, name)");
st.executeUpdate("CREATE INDEX key3 ON table2(value)");
populateTestTables(getConnection());
// Start of tables creation for DERBY-4240 repro
st.executeUpdate("CREATE TABLE test1 (id BIGINT NOT NULL, name VARCHAR(255), " + "PRIMARY KEY (id))");
st.executeUpdate("CREATE TABLE test2 (entity_id BIGINT, rel_id BIGINT)");
st.executeUpdate("CREATE INDEX idx_test2 ON test2 (entity_id)");
st.executeUpdate("INSERT INTO test1 (id, name) VALUES (102, 'Tom')");
st.executeUpdate("INSERT INTO test1 (id, name) VALUES (1, null)");
st.executeUpdate("INSERT INTO test1 (id, name) VALUES (103, 'Jerry')");
st.executeUpdate("INSERT INTO test1 (id, name) VALUES (101, 'Pupy')");
st.executeUpdate("INSERT INTO test2 (entity_id, rel_id) VALUES (1, 102)");
st.executeUpdate("INSERT INTO test2 (entity_id, rel_id) VALUES (1, 101)");
st.executeUpdate("INSERT INTO test2 (entity_id, rel_id) VALUES (1, 103)");
// End of tables creation for DERBY-4240 repro
// Start of tables creation for DERBY-4331 repro
st.executeUpdate("CREATE TABLE REPOSITORIES ( ID INT CONSTRAINT " + "REPOSITORIES_PRIMARY_ID PRIMARY KEY GENERATED ALWAYS " + "AS IDENTITY, " + "PATH VARCHAR(32672) CONSTRAINT REPOSITORIES_PATH " + "UNIQUE NOT NULL)");
st.executeUpdate("CREATE TABLE FILES ( ID INT CONSTRAINT FILES_PRIMARY_ID " + "PRIMARY KEY GENERATED ALWAYS AS IDENTITY, " + "PATH VARCHAR(32672) NOT NULL, REPOSITORY INT NOT NULL " + "REFERENCES REPOSITORIES ON DELETE CASCADE, " + "CONSTRAINT FILES_REPOSITORY_PATH UNIQUE " + "(REPOSITORY, PATH))");
st.executeUpdate("CREATE TABLE AUTHORS ( " + "ID INT CONSTRAINT AUTHORS_PRIMARY_ID PRIMARY KEY " + "GENERATED ALWAYS AS IDENTITY, REPOSITORY INT NOT NULL " + "REFERENCES REPOSITORIES ON DELETE CASCADE, " + "NAME VARCHAR(32672) NOT NULL, " + "CONSTRAINT AUTHORS_REPOSITORY_NAME UNIQUE (REPOSITORY, NAME))");
st.executeUpdate("CREATE TABLE CHANGESETS ( " + "ID INT CONSTRAINT CHANGESETS_PRIMARY_ID PRIMARY KEY " + "GENERATED ALWAYS AS IDENTITY, " + "REPOSITORY INT NOT NULL REFERENCES REPOSITORIES " + "ON DELETE CASCADE, REVISION VARCHAR(1024) NOT NULL, " + "AUTHOR INT NOT NULL REFERENCES AUTHORS ON DELETE CASCADE, " + "TIME TIMESTAMP NOT NULL, MESSAGE VARCHAR(32672) NOT NULL, " + "CONSTRAINT CHANGESETS_REPOSITORY_REVISION UNIQUE " + "(REPOSITORY, REVISION))");
st.executeUpdate("CREATE UNIQUE INDEX IDX_CHANGESETS_ID_DESC ON " + "CHANGESETS(ID DESC)");
st.executeUpdate("CREATE TABLE FILECHANGES ( " + "ID INT CONSTRAINT FILECHANGES_PRIMARY_ID PRIMARY KEY " + "GENERATED ALWAYS AS IDENTITY, FILE INT NOT NULL " + "REFERENCES FILES ON DELETE CASCADE, " + "CHANGESET INT NOT NULL REFERENCES CHANGESETS " + "ON DELETE CASCADE, " + "CONSTRAINT FILECHANGES_FILE_CHANGESET " + "UNIQUE (FILE, CHANGESET))");
st.executeUpdate("insert into repositories(path) values " + "'/var/tmp/source5923202038296723704opengrok/mercurial'");
st.executeUpdate("insert into files(path, repository) values " + "('/mercurial/Makefile', 1), " + "('/mercurial/main.c', 1), " + "('/mercurial/header.h', 1), " + "('/mercurial/.hgignore', 1)");
st.executeUpdate("insert into authors(repository, name) values " + "(1, 'Trond Norbye <trond.norbye@sun.com>')");
st.executeUpdate("insert into changesets(repository, revision, author, " + "time, message) values (1,'0:816b6279ae9c',1," + "'2008-08-12 22:00:00.0','Add .hgignore file')," + "(1,'1:f24a5fd7a85d',1,'2008-08-12 22:03:00.0'," + "'Created a small dummy program')," + "(1,'2:585a1b3f2efb',1,'2008-08-12 22:13:00.0'," + "'Add lint make target and fix lint warnings')");
st.executeUpdate("insert into filechanges(file, changeset) values " + "(4,1),(1,2),(3,2),(2,2),(1,3),(2,3)");
// End of tables creation for DERBY-4331 repro
}
};
}
Aggregations