use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class NativeAuthenticationServiceTest method decorate.
/**
* <p>
* Wrap base test with standard decorators in order to setup system
* properties and allow for the creation of multiple databases with
* stored properties that can't be removed at tearDown time.
* </p>
*/
private Test decorate(boolean clientServer) throws Exception {
String credentialsDBPhysicalName = TestConfiguration.generateUniqueDatabaseName();
Test result = this;
//
if (clientServer) {
result = TestConfiguration.clientServerDecorator(result);
}
//
// Turn on the property which enables NATIVE authentication. This will trigger
// an engine shutdown at the end of the test. We want to shutdown the engine
// before deleting the physical databases. This is because we need one of the
// databases (the credentials db) in order to authenticate engine shutdown.
//
Properties systemProperties = null;
try {
systemProperties = systemProperties(credentialsDBPhysicalName);
} catch (Exception e) {
printStackTrace(e);
}
println(nameOfTest());
println(" NativeAuthenticationServiceTest.decorate() systemProperties = " + systemProperties);
result = new SystemPropertyTestSetup(result, systemProperties, true);
//
if (enableSubprotocolTests()) {
// Add a jar file to the classpath so that we can test the classpath subprotocol.
URL nast2Jar = SupportFilesSetup.getReadOnlyURL(NAST2_JAR_FILE);
result = new ClasspathSetup(result, nast2Jar);
// Add the jar files needed for testing jar and classpath subprotocols.
result = new SupportFilesSetup(result, SUPPORT_FILES_SOURCE, null, SUPPORT_FILES_TARGET, null);
}
//
// Register temporary databases, where the test will do its work.
// We can't use the default, re-usable database because NATIVE authentication stores
// persistent properties which cannot be turned off.
//
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, CREDENTIALS_DB, credentialsDBPhysicalName);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, SECOND_DB);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, THIRD_DB);
result = _fourthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FOURTH_DB, true);
result = _fifthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FIFTH_DB, true);
result = _sixthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, SIXTH_DB, true);
result = _seventhDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, SEVENTH_DB, true);
result = _eighthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, EIGHTH_DB, true);
result = _ninthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, NINTH_DB, true);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, TENTH_DB);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, ELEVENTH_DB);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, TWELTH_DB);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, THIRTEENTH_DB);
result = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FOURTEENTH_DB);
result = _fifteenthDBSetup = TestConfiguration.additionalDatabaseDecoratorNoShutdown(result, FIFTEENTH_DB, true);
result = TestConfiguration.changeUserDecorator(result, DBO, getPassword(DBO));
return result;
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class PredicatePushdownTest method suite.
public static Test suite() {
Properties systemProperties = new Properties();
systemProperties.setProperty("derby.optimizer.noTimeout", "true");
BaseTestSuite suite = new BaseTestSuite("predicatePushdown Test");
suite.addTest(new SystemPropertyTestSetup(new CleanDatabaseTestSetup(TestConfiguration.embeddedSuite(PredicatePushdownTest.class)), systemProperties));
return suite;
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class KeepDisposableStatsPropertyTest method suite.
/**
* Returns a suite where the test is run without specifying the property
* (use the default value), explicitly setting it to {@code true}, and
* explicitly setting it to {@code false}.
*/
public static Test suite() {
String property = "derby.storage.indexStats.debug.keepDisposableStats";
BaseTestSuite suite = new BaseTestSuite("KeepDisposableStatsPropertyTestSuite");
// Test the default (expected to be false).
suite.addTest(new KeepDisposableStatsPropertyTest("testPropertyDefault"));
// Test setting the property explicitly to true.
Properties propsOn = new Properties();
propsOn.setProperty(property, "true");
BaseTestSuite suiteOn = new BaseTestSuite("Do KeepDisposableStats");
suiteOn.addTest(new KeepDisposableStatsPropertyTest("testPropertyTrue"));
suite.addTest(new SystemPropertyTestSetup(suiteOn, propsOn, true));
// Test setting the property explicitly to false.
Properties propsOff = new Properties();
propsOff.setProperty(property, "false");
BaseTestSuite suiteOff = new BaseTestSuite("Don't KeepDisposableStats");
suiteOff.addTest(new KeepDisposableStatsPropertyTest("testPropertyFalse"));
suite.addTest(new SystemPropertyTestSetup(suiteOff, propsOff, true));
return suite;
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class StreamingColumnTest method suite.
/**
* Runs the test fixtures in embedded and client.
*
* @return test suite
*/
public static Test suite() {
Properties strColProperties = new Properties();
strColProperties.setProperty("derby.storage.sortBufferMax", "5");
strColProperties.setProperty("derby.debug.true", "testSort");
BaseTestSuite suite = new BaseTestSuite("StreamingColumnTest");
suite.addTest(baseSuite("StreamingColumnTest:embedded"));
suite.addTest(TestConfiguration.clientServerDecorator(baseSuite("StreamingColumnTest:client")));
return new SystemPropertyTestSetup(suite, strColProperties);
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class HoldCursorExternalSortJDBC30Test method suite.
public static Test suite() {
Properties sysProps = new Properties();
sysProps.put("derby.storage.sortBufferMax", "5");
sysProps.put("derby.debug.true", "testSort");
Test suite = TestConfiguration.embeddedSuite(HoldCursorExternalSortJDBC30Test.class);
return new CleanDatabaseTestSetup(new SystemPropertyTestSetup(suite, sysProps, true)) {
/**
* Creates the table used in the test cases.
*/
protected void decorateSQL(Statement s) throws SQLException {
Connection conn = s.getConnection();
conn.setAutoCommit(false);
/* This table is used by testOrder_Hold and testOrder_NoHold */
s.executeUpdate("create table foo (a int, data varchar(2000))");
/* This one is specific for testOrderWithMultipleLevel since
* it requires some more records to be inserted */
s.executeUpdate("create table bar (a int, data varchar(2000))");
PreparedStatement ps = conn.prepareStatement("insert into foo values(?,?), (?,?), (?,?), (?,?), (?,?), " + "(?,?), (?,?), (?,?), (?,?), (?,?)");
for (int i = 0; i <= 9; i++) {
ps.setInt(i * 2 + 1, i + 1);
ps.setString(i * 2 + 2, Formatters.padString("" + (i + 1), 2000));
}
ps.executeUpdate();
ps.close();
s.execute("INSERT INTO bar SELECT * FROM foo");
}
};
}
Aggregations