public void testDSRequestAuthentication() throws Exception {
// if (usingDerbyNetClient())
// return;
JDBCClient dsclient = getTestConfiguration().getJDBCClient();
String dsName = dsclient.getDataSourceClassName();
DataSource ds = (DataSource) Class.forName(dsName).newInstance();
// DataSource - attributesAsPassword=true");
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.FALSE);
// DataSource - attributesAsPassword=true,
// connectionAttributes=databaseName=kangaroo");
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
JDBCDataSource.setBeanProperty(ds, "connectionAttributes", "databaseName=kangaroo");
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.FALSE);
JDBCDataSource.clearStringBeanProperty(ds, "connectionAttributes");
// Enable Authentication;
setDatabaseProperty("derby.user.fred", "wilma");
setDatabaseProperty("derby.user.APP", "APP");
setDatabaseProperty("derby.authentication.provider", "BUILTIN");
setDatabaseProperty("derby.connection.requireAuthentication", "true");
JDBCDataSource.setBeanProperty(ds, "shutdownDatabase", "shutdown");
try {
ds.getConnection();
fail("shutdown should raise exception");
} catch (SQLException sqle) {
assertSQLState("XJ015", sqle);
}
JDBCDataSource.clearStringBeanProperty(ds, "databaseName");
JDBCDataSource.clearStringBeanProperty(ds, "shutdownDatabase");
// "AUTHENTICATION NOW ENABLED");
// DataSource - attributesAsPassword=true
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.FALSE);
// ensure the DS property password is not treated as a set of
// attributes.
// DataSource - attributesAsPassword=true, user=fred,
// password=databaseName=wombat;password=wilma
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
JDBCDataSource.setBeanProperty(ds, "user", "fred");
JDBCDataSource.setBeanProperty(ds, "password", "databaseName=" + dbName + ";password=wilma");
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.FALSE);
JDBCDataSource.clearStringBeanProperty(ds, "user");
JDBCDataSource.clearStringBeanProperty(ds, "password");
ds = null;
// now with ConnectionPoolDataSource
String cpdsName = dsclient.getConnectionPoolDataSourceClassName();
ConnectionPoolDataSource cpds =
(ConnectionPoolDataSource) Class.forName(cpdsName).newInstance();
// ConnectionPoolDataSource - EMPTY
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ004",
"XJ004","XJ004","XJ004","XJ004","XJ004"},
(ConnectionPoolDataSource)cpds);
// ConnectionPoolDataSource -
// connectionAttributes=databaseName=wombat
JDBCDataSource.setBeanProperty(cpds, "connectionAttributes", "databaseName=" + dbName);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ004",
"XJ004","XJ004","XJ004","XJ004","XJ004"},
(ConnectionPoolDataSource)cpds);
JDBCDataSource.clearStringBeanProperty(cpds, "connectionAttributes");
// ConnectionPoolDataSource - attributesAsPassword=true
JDBCDataSource.setBeanProperty(cpds, "attributesAsPassword", Boolean.TRUE);
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"},
(ConnectionPoolDataSource)cpds);
JDBCDataSource.setBeanProperty(cpds, "attributesAsPassword", Boolean.FALSE);
// ensure the DS property password is not treated as a set of
// attributes.
// ConnectionPoolDataSource - attributesAsPassword=true,
// user=fred, password=databaseName=wombat;password=wilma");
JDBCDataSource.setBeanProperty(cpds, "attributesAsPassword", Boolean.TRUE);
JDBCDataSource.setBeanProperty(cpds, "user", "fred");
JDBCDataSource.setBeanProperty(cpds, "password", "databaseName=" + dbName + ";password=wilma");
dsConnectionRequests(new String[] {
"XJ004","XJ004","XJ004","XJ028",
"XJ028","XJ004","XJ004","XJ004","XJ004"},
(ConnectionPoolDataSource)cpds);
JDBCDataSource.setBeanProperty(cpds, "attributesAsPassword", Boolean.FALSE);
JDBCDataSource.clearStringBeanProperty(cpds, "user");
JDBCDataSource.clearStringBeanProperty(cpds, "password");
cpds = null;
// now with XADataSource
// EmbeddedXADataSource xads = new EmbeddedXADataSource();
String xadsName = dsclient.getXADataSourceClassName();
XADataSource xads =
(XADataSource) Class.forName(xadsName).newInstance();
// XADataSource - EMPTY
dsConnectionRequests(new String[] {