use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class cdsXid method suite.
public static Test suite() {
if (JDBC.vmSupportsJSR169()) {
// test uses unsupported classes like DriverManager, XADataSource,
// ConnectionPoolDataSource, ConnectionEvenListenere, as well as
// unsupported methods, like Connection.setTypeMap()...
BaseTestSuite suite = new BaseTestSuite("J2EEDatasourceTest cannot run with JSR169");
return suite;
} else {
BaseTestSuite suite = new BaseTestSuite("J2EEDataSourceTest suite");
// Add tests that will run with both embedded
suite.addTest(baseSuite(":embedded"));
// and network server/client
suite.addTest(TestConfiguration.clientServerDecorator(baseSuite(":client")));
// Add the tests that only run with client
suite.addTest(new SupportFilesSetup(TestConfiguration.clientServerDecorator(getClientSuite())));
// Add the tests that only run with embedded
suite.addTest(getEmbeddedSuite("embedded"));
// Add the tests relying on getting timeouts.
suite.addTest(getTimeoutSuite(":embedded"));
suite.addTest(TestConfiguration.clientServerDecorator(getTimeoutSuite(":client")));
// Note that not all fixtures need (all of) these.
return new CleanDatabaseTestSetup(suite) {
/**
* Create and populate database objects
*
* @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
*/
protected void decorateSQL(Statement s) throws SQLException {
TestRoutines.installRoutines(getConnection());
s.executeUpdate("create table autocommitxastart(i int)");
s.executeUpdate("insert into autocommitxastart values 1,2,3,4,5");
s.executeUpdate("create schema SCHEMA_Patricio");
s.executeUpdate("create table " + "SCHEMA_Patricio.Patricio (id VARCHAR(255), value INTEGER)");
s.executeUpdate("create table intTable(i int)");
s.executeUpdate("create table hold_30 " + "(id int not null primary key, b char(30))");
s.executeUpdate("create procedure checkConn2(in dsname varchar(20)) " + "parameter style java language java modifies SQL DATA " + "external name " + "'org.apache.derbyTesting.functionTests.tests.jdbcapi.J2EEDataSourceTest." + getNestedMethodName() + "'");
s.execute("create table derby3799 (dClob clob)");
s.executeUpdate("insert into derby3799 values (" + "'myLittleTestClob')");
}
};
}
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class LobRsGetterTest method suite.
/**
* Returns a suite with all tests running with both embedded and client.
*/
public static Test suite() {
Test suite = TestConfiguration.defaultSuite(LobRsGetterTest.class, false);
return new CleanDatabaseTestSetup(suite) {
protected void decorateSQL(Statement s) throws SQLException {
Connection con = s.getConnection();
dropTable(con, TABLE);
// NOTE: Do not insert a lot of data into this table, many
// of the tests iterate over all rows in the table.
s.executeUpdate("create table " + TABLE + "(" + "id INT GENERATED ALWAYS AS IDENTITY, " + "dBlob BLOB, dClob CLOB)");
// Insert a few rows with different characteristics:
// multi page LOB, single page LOB, NULL
PreparedStatement ps = con.prepareStatement("insert into " + TABLE + "(dBlob, dClob) values (?,?)");
// 173 KB or KChars
int mpSize = 173 * 1024;
// 300 B or chars
int spSize = 300;
ps.setBinaryStream(1, new LoopingAlphabetStream(mpSize), mpSize);
ps.setCharacterStream(2, new LoopingAlphabetReader(mpSize), mpSize);
ps.executeUpdate();
ps.setBinaryStream(1, new LoopingAlphabetStream(spSize), spSize);
ps.setCharacterStream(2, new LoopingAlphabetReader(spSize), spSize);
ps.executeUpdate();
ps.setNull(1, Types.BLOB);
ps.setNull(2, Types.CLOB);
ps.executeUpdate();
// Make sure there are three rows.
JDBC.assertDrainResults(s.executeQuery("select * from " + TABLE), 3);
ps.close();
s.close();
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class ResultSetMiscTest method baseSuite.
public static Test baseSuite(String name) {
BaseTestSuite suite = new BaseTestSuite(name);
suite.addTestSuite(ResultSetMiscTest.class);
// Some test cases expect lock timeouts, so reduce the timeout to
// make the test go faster.
Test test = DatabasePropertyTestSetup.setLockTimeouts(suite, 1, 3);
return new CleanDatabaseTestSetup(test) {
/**
* Creates the table used in the test cases.
*/
protected void decorateSQL(Statement s) throws SQLException {
s.execute("create table t (i int, s smallint, r real, " + "d double precision, dt date, t time, ts timestamp, " + "c char(10), v varchar(40) not null, dc dec(10,2)," + "bi bigint, cbd char(10) for bit data," + "vbd varchar(10) for bit data,lvbd long varchar for bit data," + "cl clob(2G), bl blob(1G) )");
s.execute("insert into t values(1,2,3.3,4.4,date('1990-05-05')," + "time('12:06:06'),timestamp('1990-07-07 07:07:07.000007')," + "'eight','nine', 10.1, 11," + Utilities.stringToHexLiteral("twelv") + "," + Utilities.stringToHexLiteral("3teen") + "," + Utilities.stringToHexLiteral("4teen") + ", null, null)");
s.execute("CREATE PROCEDURE WAIT_FOR_POST_COMMIT() " + "LANGUAGE JAVA EXTERNAL NAME " + "'org.apache.derbyTesting.functionTests.util." + "T_Access.waitForPostCommitToFinish' " + "PARAMETER STYLE JAVA");
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class SetTransactionIsolationTest method baseSuite.
public static Test baseSuite(String name) {
BaseTestSuite suite = new BaseTestSuite(name);
suite.addTestSuite(SetTransactionIsolationTest.class);
// Some test cases expect lock timeouts, so reduce the timeout to
// make the test go faster.
Test test = DatabasePropertyTestSetup.setLockTimeouts(suite, 1, 3);
return new CleanDatabaseTestSetup(test) {
/**
* Create and populate table
*
* @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
*/
protected void decorateSQL(Statement s) throws SQLException {
Connection conn = getConnection();
/**
* Creates the table used in the test cases.
*/
final int stringLength = 400;
s.executeUpdate("CREATE TABLE TAB1 (c11 int, " + "c12 varchar(" + stringLength + "))");
PreparedStatement insertStmt = conn.prepareStatement("INSERT INTO TAB1 VALUES(?,?)");
// We need to ensure that there is more data in the table than
// the
// client can fetch in one message (about 32K). Otherwise, the
// cursor might be closed on the server and we are not testing
// the
// same thing in embedded mode and client/server mode.
final int rows = 40000 / stringLength;
StringBuffer buff = new StringBuffer(stringLength);
for (int i = 0; i < stringLength; i++) {
buff.append(" ");
}
for (int i = 1; i <= rows; i++) {
insertStmt.setInt(1, i);
insertStmt.setString(2, buff.toString());
insertStmt.executeUpdate();
}
insertStmt.close();
s.execute("create table t1(I int, B char(15))");
s.execute("create table t1copy(I int, B char(15))");
s.executeUpdate("INSERT INTO T1 VALUES(1,'First Hello')");
s.executeUpdate("INSERT INTO T1 VALUES(2,'Second Hello')");
s.executeUpdate("INSERT INTO T1 VALUES(3,'Third Hello')");
s.executeUpdate("create table t3 (i integer)");
}
};
}
use of org.apache.derbyTesting.junit.CleanDatabaseTestSetup in project derby by apache.
the class StatementJdbc20Test method baseSuite.
private static Test baseSuite(String name) {
BaseTestSuite suite = new BaseTestSuite(name);
suite.addTestSuite(StatementJdbc20Test.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 = getConnection();
/**
* Creates the table used in the test cases.
*/
stmt.execute("create table tab1 (i int, s smallint, r real)");
stmt.executeUpdate("insert into tab1 values(1, 2, 3.1)");
stmt.execute("create procedure dynamic_results() " + "language java parameter style java external name '" + StatementJdbc20Test.class.getName() + ".dynamicResults' " + "dynamic result sets 2");
stmt.execute("create table t_autogen( a int generated always as identity, b int )");
}
};
}
Aggregations