use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class MissingPermissionsTest method makeTest.
private static Test makeTest(String fixture, String policy) {
Test t = new MissingPermissionsTest(fixture);
t = new SecurityManagerSetup(t, policy);
final Properties props = new Properties();
props.setProperty("derby.connection.requireAuthentication", "true");
props.setProperty("derby.database.sqlAuthorization", "true");
props.setProperty("derby.authentication.provider", "BUILTIN");
props.setProperty("derby.user.APP", "APPPW");
t = new SystemPropertyTestSetup(t, props, true);
t = TestConfiguration.changeUserDecorator(t, "APP", "APPPW");
t = TestConfiguration.singleUseDatabaseDecorator(t);
return t;
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup 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.SystemPropertyTestSetup in project derby by apache.
the class AuthenticationTest method setBaseProps.
private static void setBaseProps(BaseTestSuite suite, Test test, Properties extraDbProps) {
// Use DatabasePropertyTestSetup.builtinAuthentication decorator
// to set the user properties required by this test (and shutdown
// the database for the property to take effect).
// DatabasePropertyTestSetup uses SYSCS_SET_DATABASE_PROPERTY
// so that is database level setting.
// Additionally use DatabasePropertyTestSetup to add some
// possibly useful settings
// Finally SystemPropertyTestSetup sets up system level users
Properties props = new Properties();
props.setProperty("derby.infolog.append", "true");
props.setProperty("derby.debug.true", "AuthenticationTrace");
if (extraDbProps != null) {
props.putAll(extraDbProps);
}
Properties sysprops = new Properties();
sysprops.put("derby.user.system", "admin");
sysprops.put("derby.user.mickey", "mouse");
test = DatabasePropertyTestSetup.builtinAuthentication(test, USERS, PASSWORD_SUFFIX);
test = new DatabasePropertyTestSetup(test, props, true);
suite.addTest(new SystemPropertyTestSetup(test, sysprops));
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class LocalizedDisplayScriptTest method getSuite.
/**
* Return a localized test based on the script name.
* The test is surrounded in a decorator that sets up the
* desired properties which is wrapped in a decorator
* which sets up the timezone wrapped in a decorator
* that cleans the database.
*/
private static Test getSuite() {
BaseTestSuite suite = new BaseTestSuite("localized Display");
Properties uiProps = new Properties();
uiProps.put("derby.ui.locale", "es_AR");
uiProps.put("derby.ui.codeset", ENCODING);
suite.addTest(new TimeZoneTestSetup(new SystemPropertyTestSetup(new LocalizedDisplayScriptTest("LocalizedDisplay"), uiProps), "America/Los_Angeles"));
return getIJConfig(suite);
}
use of org.apache.derbyTesting.junit.SystemPropertyTestSetup in project derby by apache.
the class LocalizedAttributeScriptTest method getSuite.
/**
* Return a suite of localized tests based on the
* script name. The test is surrounded in a decorator
* that sets localization properties wrapped in a decorator
* that cleans the database.
*/
private static Test getSuite() {
BaseTestSuite suite = new BaseTestSuite("localized scripts");
Properties uiProps = new Properties();
uiProps.put("derby.ui.locale", "de_DE");
uiProps.put("derby.ui.codeset", "ISO-8859-1");
suite.addTest(new SystemPropertyTestSetup(new LocalizedAttributeScriptTest("LocalizedConnectionAttribute"), uiProps));
return getIJConfig(suite);
}
Aggregations