public final class TestConfiguration
extends java.lang.Object
usedDbNames
property. One of those databases
is supposed to be the default database. A new default database
is added to the pool by singleUseDatabaseDecorator
function.
additionalDatabaseDecorator
function. Each of the additional databases has its logical and physical name.
Physical database name is automatically generated as 'singleUse/oneuseXX'
where 'XX' is unique number. The logical database name is used to establish
a connection to the database using
a TestConfiguration::openConnection(String logicalDatabaseName)
function.
DropDatabaseSetup
.Modifier and Type | Field and Description |
---|---|
private static int |
assignedPortCount |
private static int |
basePort
This is the base port.
|
private static int |
bogusPort |
private java.util.Properties |
connectionAttributes
Extra connection attributes.
|
(package private) Connector |
connector
Indirection for obtaining connections based upon
this configuration.
|
private static java.lang.ThreadLocal<TestConfiguration> |
CURRENT_CONFIG
Current configuration is stored in a ThreadLocal to
allow the potential for multiple tests to be running
concurrently with different configurations.
|
private static TestConfiguration |
DEFAULT_CONFIG
The default configuration.
|
private static java.lang.String |
DEFAULT_DBNAME
Default values for configurations
|
private static java.lang.String |
DEFAULT_DBNAME_SQL |
private static java.lang.String |
DEFAULT_FRAMEWORK |
private static java.lang.String |
DEFAULT_HOSTNAME |
private static int |
DEFAULT_PORT |
private static java.lang.String |
DEFAULT_USER_NAME |
private static java.lang.String |
DEFAULT_USER_PASSWORD |
private java.lang.String |
defaultDbName
The default database name for tests.
|
private boolean |
doTrace |
private java.lang.String |
hostName |
private boolean |
isVerbose |
private JDBCClient |
jdbcClient |
private int |
jmxPort |
private static TestConfiguration |
JUNIT_CONFIG
Default configuration for standalone JUnit tests,
an embedded configuration.
|
private static java.lang.String |
KEY_DBNAME
Keys to use to look up values in properties files.
|
private static java.lang.String |
KEY_FRAMEWORK |
private static java.lang.String |
KEY_HOSTNAME |
private static java.lang.String |
KEY_JMX_PORT |
private static java.lang.String |
KEY_LOGIN_TIMEOUT |
static java.lang.String |
KEY_OMIT_JSON |
static java.lang.String |
KEY_OMIT_LUCENE |
private static java.lang.String |
KEY_PORT |
private static java.lang.String |
KEY_SSL |
private static java.lang.String |
KEY_STOP_AFTER_FIRST_FAIL
derby.tests.stopAfterFirstFail - debugging property to exit after
first failure.
|
private static java.lang.String |
KEY_TRACE |
private static java.lang.String |
KEY_USER_NAME |
private static java.lang.String |
KEY_USER_PASSWORD |
private static java.lang.String |
KEY_VERBOSE |
private static int |
lastAssignedPort |
private static int |
LOCKFILETIMEOUT |
private java.util.HashMap<java.lang.String,java.lang.String> |
logicalDbMapping
Contains the mapping of logical database names to physical database names.
|
private static int |
MAX_PORTS_USED
Maximum number of ports used by Suites.All
If this changes, this constant and the Wiki
page at http://wiki.apache.org/db-derby/DerbyJUnitTesting
need to be updated.
|
private java.lang.String |
passwordToken
Password token used by the builtin authentication decorators.
|
private int |
port |
private static ReleaseRepository |
releaseRepository
Repository of old/previous Derby releases available on the local system.
|
private java.io.FileOutputStream |
serverOutput |
private static int |
SLEEP_TIME
Sleep for 1000 ms before pinging the network server (again)
|
private java.lang.String |
ssl |
private boolean |
stopAfterFirstFail |
private static int |
uniqueDB
Simple count to provide a unique number for database
names.
|
private java.lang.String |
url |
private java.util.ArrayList<java.lang.String> |
usedDbNames
Holds the names of all other databases used in a test to perform a proper cleanup.
|
private java.lang.String |
userName |
private java.lang.String |
userPassword |
Modifier | Constructor and Description |
---|---|
private |
TestConfiguration()
Default embedded configuration
|
private |
TestConfiguration(java.util.Properties props)
This constructor creates a TestConfiguration from a Properties object.
|
(package private) |
TestConfiguration(TestConfiguration copy)
Obtain a new configuration identical to the passed one.
|
(package private) |
TestConfiguration(TestConfiguration copy,
JDBCClient client,
java.lang.String hostName,
int port) |
(package private) |
TestConfiguration(TestConfiguration copy,
JDBCClient client,
java.lang.String hostName,
int port,
java.lang.String dataBasePath) |
(package private) |
TestConfiguration(TestConfiguration copy,
java.lang.String ssl)
Obtains a new configuration identical to the passed in one, except for
the default SSL mode.
|
(package private) |
TestConfiguration(TestConfiguration copy,
java.lang.String logicalDbName,
java.lang.String dbName,
boolean defaultDb)
Obtain a new configuration identical to the passed in
one except for the database name.
|
(package private) |
TestConfiguration(TestConfiguration copy,
java.lang.String user,
java.lang.String password,
java.lang.String passwordToken)
Obtain a new configuration identical to the passed in
one except for the default user and password.
|
Modifier and Type | Method and Description |
---|---|
(package private) TestConfiguration |
addConnectionAttributes(java.util.Properties attrs)
Create a copy of this configuration with some additional connection
attributes.
|
static DatabaseChangeSetup |
additionalDatabaseDecorator(junit.framework.Test test,
java.lang.String logicalDbName)
Decorate a test to use a new database that is created upon the
first connection request to the database and shutdown and deleted at
tearDown.
|
static DatabaseChangeSetup |
additionalDatabaseDecoratorNoShutdown(junit.framework.Test test,
java.lang.String logicalDbName)
Similar to additionalDatabaseDecorator except the database will
not be shutdown, only deleted.
|
static DatabaseChangeSetup |
additionalDatabaseDecoratorNoShutdown(junit.framework.Test test,
java.lang.String logicalDbName,
boolean defaultDB)
Similar to additionalDatabaseDecorator except the database will
not be shutdown, only deleted.
|
static DatabaseChangeSetup |
additionalDatabaseDecoratorNoShutdown(junit.framework.Test test,
java.lang.String logicalDbName,
java.lang.String physicalDbName)
Similar to additionalDatabaseDecorator except the database will
not be shutdown, only deleted.
|
private static junit.framework.Test |
bareClientServerSuite(java.lang.Class testClass)
Create a suite of test cases to run in a client/server environment.
|
static junit.framework.Test |
changeSSLDecorator(junit.framework.Test test,
java.lang.String ssl)
Decorate a test changing the default ssl mode.
|
static junit.framework.Test |
changeUserDecorator(junit.framework.Test test,
java.lang.String user,
java.lang.String password)
Decorate a test changing the default user name and password.
|
static junit.framework.Test |
clientExistingServerSuite(java.lang.Class testClass)
Equivalent to 'clientServerSuite' above, but assumes server is
already running.
|
static junit.framework.Test |
clientExistingServerSuite(java.lang.Class testClass,
java.lang.String hostName,
int portNumber)
Create a suite for the passed test class that includes
all the default fixtures from the class, wrapped in
a existingServerDecorator.
|
static junit.framework.Test |
clientExistingServerSuite(java.lang.Class testClass,
java.lang.String hostName,
int portNumber,
java.lang.String dbPath) |
static junit.framework.Test |
clientServerDecorator(junit.framework.Test suite)
Return a decorator for the passed in tests that sets the
configuration for the client to be Derby's JDBC client
and to start the network server at setUp.
|
static junit.framework.Test |
clientServerDecoratorWithAlternativePort(junit.framework.Test suite)
Wrapper to use the alternative port number.
|
static junit.framework.Test |
clientServerDecoratorWithPort(junit.framework.Test suite,
int port)
Return a decorator for the passed in tests that sets the
configuration for the client to be Derby's JDBC client
and to start the network server at setUp.
|
static junit.framework.Test |
clientServerSuite(java.lang.Class testClass)
Create a suite for the passed test class that includes
all the default fixtures from the class, wrapped in
a derbyClientServerDecorator.
|
static junit.framework.Test |
clientServerSuiteWithAlternativePort(java.lang.Class testClass)
Create a suite for the passed test class that includes
all the default fixtures from the class, wrapped in
a derbyClientServerDecorator with alternative port.
|
static junit.framework.Test |
connectionCPDecorator(junit.framework.Test test)
Return a decorator that changes the configuration to obtain
connections from a ConnectionPoolDataSource using
getPooledConnection().getConnection()
Note that statement pooling is enabled in the data source and in all the
connections created from it. |
static junit.extensions.TestSetup |
connectionDSDecorator(junit.framework.Test test)
Return a decorator that changes the configuration to obtain
connections from a standard DataSource using
getConnection()
The tearDown reverts the configuration to the previous
configuration. |
static junit.framework.Test |
connectionXADecorator(junit.framework.Test test)
Return a decorator that changes the configuration to obtain
connections from an XADataSource using
getXAConnection().getConnection()
The connection is not connected to any global transaction,
thus it is in local connection mode. |
private java.lang.String |
createJDBCUrlWithDatabaseName(java.lang.String name)
Create JDBC connection url, including the name of the database.
|
static junit.framework.Test |
defaultExistingServerDecorator(junit.framework.Test test)
Decorate a test to use suite's default host and port,
but assuming the server is already running.
|
static junit.framework.Test |
defaultExistingServerSuite(java.lang.Class testClass)
Equivalent to "defaultSuite" as defined above, but assumes a server
has already been started.
|
static junit.framework.Test |
defaultExistingServerSuite(java.lang.Class testClass,
boolean cleanDB)
Does the work of "defaultExistingServerSuite" as defined above.
|
(package private) boolean |
defaultSecurityManagerSetup()
Install the default security manager setup,
for the current configuration.
|
static junit.framework.Test |
defaultServerDecorator(junit.framework.Test test)
Decorate a test to use suite's default host and port.
|
static junit.framework.Test |
defaultServerDecoratorWithAlternativePort(junit.framework.Test test)
Decorate a test to use suite's default host and Alternative port.
|
static junit.framework.Test |
defaultSuite(java.lang.Class testClass)
Return a Test suite that contains all the test fixtures
for the passed in class running in embedded and the
default client server configuration.
|
static junit.framework.Test |
defaultSuite(java.lang.Class testClass,
boolean cleanDB)
Does the work of "defaultSuite" as defined above.
|
boolean |
doTrace()
Return JUnit test method trace flag.
|
static junit.framework.Test |
embeddedSuite(java.lang.Class testClass)
Create a suite for the passed test class that includes
all the default fixtures from the class.
|
static junit.framework.Test |
existingServerDecorator(junit.framework.Test test,
java.lang.String hostName,
int PortNumber)
A variant of defaultServerDecorator allowing
non-default hostname and portnumber.
|
static junit.framework.Test |
existingServerDecorator(junit.framework.Test test,
java.lang.String hostName,
int PortNumber,
java.lang.String dbPath)
A variant of defaultServerDecorator allowing
non-default hostname, portnumber and database name.
|
static junit.framework.Test |
existingServerSuite(java.lang.Class testClass,
boolean cleanDB,
java.lang.String hostName,
int portNumber)
Return a Test suite that contains all the test fixtures
for the passed in class running in client server configuration
on an already started server on a given host and port number.
|
static junit.framework.Test |
existingServerSuite(java.lang.Class testClass,
boolean cleanDB,
java.lang.String hostName,
int portNumber,
java.lang.String dbPath) |
static junit.framework.Test |
forceJDBC3Embedded(junit.framework.Test test)
Returns a decorator that forces the JDBC 3 embedded client in
a Java SE 6/JDBC 4 environment.
|
static junit.framework.Test |
forceJDBC3NetClient(junit.framework.Test test)
Returns a decorator that forces the JDBC 3 network client in
a Java SE 6/JDBC 4 environment.
|
static junit.framework.Test |
forceJDBC3Suite(java.lang.Class testClass)
Return a Test suite that contains all the test fixtures
for the passed in class running in embedded and client-
server *JDBC3* configurations.
|
static java.lang.String |
generateUniqueDatabaseName()
Generate the unique database name for single use.
|
private java.lang.String |
getAndVetPhysicalDatabaseName(java.lang.String logicalDatabaseName) |
static int |
getBasePort() |
int |
getBogusPort()
Returns a port number where no Derby network servers are supposed to
be running.
|
java.util.Properties |
getConnectionAttributes()
Return the connection attributes to use in this configuration.
|
(package private) java.lang.String |
getConnectionAttributesString()
Get a flat string representation of the connection attributes.
|
static TestConfiguration |
getCurrent()
Get this Thread's current configuraiton for running
the tests.
|
java.lang.String |
getDatabasePath(java.lang.String physicalDatabaseName) |
java.lang.String |
getDefaultDatabaseName()
Return the default database name.
|
(package private) java.io.File |
getFailureFolder(junit.framework.TestCase test)
Get a folder already created where a test can
write its failure information.
|
java.lang.String |
getHostName()
Return the host name for the network server.
|
JDBCClient |
getJDBCClient()
Get configured JDBCClient object.
|
java.lang.String |
getJDBCUrl()
Return the jdbc url for connecting to the default database.
|
java.lang.String |
getJDBCUrl(java.lang.String databaseName)
Return the jdbc url for a connecting to the database.
|
int |
getJmxPort()
Gets the value of the port number that may be used for "remote"
JMX monitoring and management.
|
int |
getLoginTimeout()
Get the login timeout from the connector
|
int |
getNextAvailablePort()
Get the next available port.
|
java.lang.String |
getPassword(java.lang.String user)
Get the password that is a function of the user
name and the token for the current configuration.
|
(package private) static java.lang.String |
getPassword(java.lang.String user,
java.lang.String token)
Get the password that is a function of the user
name and the passed in token.
|
java.lang.String |
getPhysicalDatabaseName(java.lang.String logicalName)
Return the physical name for a database
given its logical name.
|
int |
getPort()
Get port number for network server.
|
static ReleaseRepository |
getReleaseRepository()
Returns the release repository containing old Derby releases available
on the local system.
|
java.lang.String |
getSsl()
Get ssl mode for network server
|
static java.util.Properties |
getSystemProperties()
Get the system properties in a privileged block.
|
java.lang.String |
getUserName()
Return the user name.
|
java.lang.String |
getUserPassword()
Return the user password.
|
private void |
initConnector(Connector oldConnector)
Initialize the connection factory.
|
static boolean |
isDefaultBasePort()
Return if the base port is default or not.
|
boolean |
isVerbose()
Return verbose flag.
|
static boolean |
loadingFromJars()
Return true if we classes are being loaded from jar files.
|
(package private) java.sql.Connection |
openConnection(java.lang.String logicalDatabaseName)
Open connection to the specified database.
|
java.sql.Connection |
openConnection(java.lang.String logicalDatabaseName,
java.lang.String user,
java.lang.String password)
Open connection to the specified database using the supplied username and password.
|
java.sql.Connection |
openDefaultConnection()
Open connection to the default database.
|
(package private) java.sql.Connection |
openDefaultConnection(java.lang.String user,
java.lang.String password)
Open connection to the default database.
|
java.sql.Connection |
openPhysicalConnection(java.lang.String physicalDatabaseName,
java.lang.String user,
java.lang.String password,
java.util.Properties props)
Open connection to the specified database using the supplied username and password.
|
private void |
println(java.lang.CharSequence msg)
Private method printing debug information to standard out if debugging
is enabled.
|
(package private) static void |
setCurrent(TestConfiguration config)
WORK IN PROGRESS
Set this Thread's current configuration for running tests.
|
void |
setLoginTimeout(int seconds)
Set the login timeout for the connector.
|
void |
setTrace(boolean isChatty)
Set JUnit test method tracing.
|
void |
setVerbosity(boolean isChatty)
Set the verbosity, i.e., whether debug statements print.
|
void |
shutdownDatabase()
Shutdown the database for this configuration
assuming it is booted.
|
void |
shutdownEngine()
Shutdown the engine for this configuration
assuming it is booted.
|
void |
shutdownEngine(boolean deregisterDeriver)
Shutdown the engine for this configuration
assuming it is booted.
|
static junit.extensions.TestSetup |
singleUseDatabaseDecorator(junit.framework.Test test)
Decorate a test to use a new database that is created upon the
first connection request to the database and shutdown and deleted at
tearDown.
|
static junit.extensions.TestSetup |
singleUseDatabaseDecorator(junit.framework.Test test,
java.lang.String dbName)
Decorate a test to use a new database that is created upon the first
connection request to the database and shutdown and deleted at
tearDown.
|
static junit.extensions.TestSetup |
singleUseDatabaseDecoratorNoShutdown(junit.framework.Test test)
Decorate a test to use a new database that is created upon the
first connection request to the database and deleted at
tearDown.
|
static junit.framework.Test |
sqlAuthorizationDecorator(junit.framework.Test test)
Decorate a test to use the default database that has
was created in SQL authorization mode.
|
static junit.framework.Test |
sqlAuthorizationDecorator(junit.framework.Test test,
java.lang.String[] users,
java.lang.String passwordToken)
Utility version of sqlAuthorizationDecorator that also sets
up authentication.
|
static junit.framework.Test |
sqlAuthorizationDecoratorSingleUse(junit.framework.Test test)
Same as sqlAuthorizationDecorator, except that the database is dropped
at teardown and the test is responsible for shutting down the database.
|
static junit.framework.Test |
sqlAuthorizationDecoratorSingleUse(junit.framework.Test test,
java.lang.String dbName,
boolean shutdownDatabase)
Same as sqlAuthorizationDecoratorSingleUse, except that you can name
the database yourself, and you can choose whether or not the decorator
should shut down the database before it attempts to drop it.
|
void |
startNetworkServer()
starts the Networs server for this configuration.
|
boolean |
stopAfterFirstFail() |
void |
stopNetworkServer()
stops the Network server for this configuration.
|
(package private) static java.lang.String |
suiteName(java.lang.Class testClass)
Generate a suite name from a class name, taking
only the last element of the fully qualified class name.
|
private static boolean |
supportsClientServer()
Check if client and server testing is supported in the test environment.
|
void |
waitForShutdownComplete(java.lang.String physicalDatabaseName) |
private static final java.lang.String DEFAULT_DBNAME
private static final java.lang.String DEFAULT_DBNAME_SQL
private static final java.lang.String DEFAULT_USER_NAME
private static final java.lang.String DEFAULT_USER_PASSWORD
private static final int DEFAULT_PORT
private static final java.lang.String DEFAULT_FRAMEWORK
private static final java.lang.String DEFAULT_HOSTNAME
private static final int LOCKFILETIMEOUT
private static final int MAX_PORTS_USED
private static final int basePort
private static int lastAssignedPort
private static final int bogusPort
private static int assignedPortCount
private java.io.FileOutputStream serverOutput
private static final int SLEEP_TIME
private static final java.lang.String KEY_DBNAME
private static final java.lang.String KEY_FRAMEWORK
private static final java.lang.String KEY_USER_PASSWORD
private static final java.lang.String KEY_USER_NAME
private static final java.lang.String KEY_HOSTNAME
private static final java.lang.String KEY_PORT
private static final java.lang.String KEY_VERBOSE
private static final java.lang.String KEY_LOGIN_TIMEOUT
private static final java.lang.String KEY_TRACE
public static final java.lang.String KEY_OMIT_LUCENE
public static final java.lang.String KEY_OMIT_JSON
private static final java.lang.String KEY_STOP_AFTER_FIRST_FAIL
private static final java.lang.String KEY_SSL
private static final java.lang.String KEY_JMX_PORT
private static int uniqueDB
private static ReleaseRepository releaseRepository
private static final TestConfiguration JUNIT_CONFIG
private static final TestConfiguration DEFAULT_CONFIG
private static final java.lang.ThreadLocal<TestConfiguration> CURRENT_CONFIG
private final java.lang.String defaultDbName
private final java.util.ArrayList<java.lang.String> usedDbNames
defaultDbName
is also contained here.private final java.util.HashMap<java.lang.String,java.lang.String> logicalDbMapping
private final java.lang.String url
private final java.lang.String userName
private final java.lang.String userPassword
private final int port
private final java.lang.String hostName
private final JDBCClient jdbcClient
private final int jmxPort
private boolean isVerbose
private boolean doTrace
private boolean stopAfterFirstFail
private java.lang.String ssl
private java.util.Properties connectionAttributes
userName
and userPassword
for those attributes.private java.lang.String passwordToken
Connector connector
private TestConfiguration()
TestConfiguration(TestConfiguration copy)
TestConfiguration(TestConfiguration copy, JDBCClient client, java.lang.String hostName, int port)
TestConfiguration(TestConfiguration copy, JDBCClient client, java.lang.String hostName, int port, java.lang.String dataBasePath)
TestConfiguration(TestConfiguration copy, java.lang.String user, java.lang.String password, java.lang.String passwordToken)
copy
- Configuration to copy.user
- New default userpassword
- New default password.TestConfiguration(TestConfiguration copy, java.lang.String ssl)
The modes supported at the moment are basic and off. The mode peerAuthentication is not yet supported.
copy
- configuration to copyssl
- default SSL modeTestConfiguration(TestConfiguration copy, java.lang.String logicalDbName, java.lang.String dbName, boolean defaultDb)
defaulDb
parameter is true
the new database name is used as a default database.copy
- Configuration to copy.dbName
- New database namedefaultDb
- Indicates that the passed dbName
is supposed
to be used as the default database name.private TestConfiguration(java.util.Properties props) throws java.lang.NumberFormatException
java.lang.NumberFormatException
- if the port specification is not an integer.public static TestConfiguration getCurrent()
public static ReleaseRepository getReleaseRepository()
NOTE: It is your responsibility to keep the repository up to date. This usually involves syncing the local Subversion repository of previous Derby releases with the master repository at Apache.
ReleaseRepository
static void setCurrent(TestConfiguration config)
config
- Configuration to set it to.public static junit.framework.Test defaultSuite(java.lang.Class testClass)
public static junit.framework.Test defaultSuite(java.lang.Class testClass, boolean cleanDB)
public static junit.framework.Test defaultExistingServerSuite(java.lang.Class testClass)
public static junit.framework.Test defaultExistingServerSuite(java.lang.Class testClass, boolean cleanDB)
public static junit.framework.Test existingServerSuite(java.lang.Class testClass, boolean cleanDB, java.lang.String hostName, int portNumber)
public static junit.framework.Test existingServerSuite(java.lang.Class testClass, boolean cleanDB, java.lang.String hostName, int portNumber, java.lang.String dbPath)
public static junit.framework.Test forceJDBC3Suite(java.lang.Class testClass)
static java.lang.String suiteName(java.lang.Class testClass)
public static junit.framework.Test embeddedSuite(java.lang.Class testClass)
public static junit.framework.Test clientServerSuite(java.lang.Class testClass)
public static junit.framework.Test clientServerSuiteWithAlternativePort(java.lang.Class testClass)
public static junit.framework.Test clientExistingServerSuite(java.lang.Class testClass)
public static junit.framework.Test clientExistingServerSuite(java.lang.Class testClass, java.lang.String hostName, int portNumber)
public static junit.framework.Test clientExistingServerSuite(java.lang.Class testClass, java.lang.String hostName, int portNumber, java.lang.String dbPath)
public static junit.framework.Test clientServerDecorator(junit.framework.Test suite)
suite
- the suite to decoratepublic static junit.framework.Test clientServerDecoratorWithPort(junit.framework.Test suite, int port)
suite
- the suite to decoratepublic static junit.framework.Test clientServerDecoratorWithAlternativePort(junit.framework.Test suite)
public static junit.framework.Test defaultExistingServerDecorator(junit.framework.Test test)
public static junit.framework.Test defaultServerDecorator(junit.framework.Test test)
public static junit.framework.Test existingServerDecorator(junit.framework.Test test, java.lang.String hostName, int PortNumber)
public static junit.framework.Test existingServerDecorator(junit.framework.Test test, java.lang.String hostName, int PortNumber, java.lang.String dbPath)
public static junit.framework.Test defaultServerDecoratorWithAlternativePort(junit.framework.Test test)
private static boolean supportsClientServer()
private static junit.framework.Test bareClientServerSuite(java.lang.Class testClass)
testClass
- the class from which to extract the test casestestClass
, or
an empty test suite if client/server is not supported in the test
environmentpublic static java.lang.String generateUniqueDatabaseName()
public static junit.extensions.TestSetup singleUseDatabaseDecorator(junit.framework.Test test)
usedDbNames
and assigned as a default database name.
This decorator expects the database file to be local so it
can be removed.test
- Test to be decoratedpublic static junit.extensions.TestSetup singleUseDatabaseDecorator(junit.framework.Test test, java.lang.String dbName)
usedDbNames
and assigned as a default database
name. This decorator expects the database file to be local so it can be
removed.test
- Test to be decorateddbName
- We sometimes need to know outside to be able to pass it on
to other VMs/processes.public static junit.extensions.TestSetup singleUseDatabaseDecoratorNoShutdown(junit.framework.Test test)
usedDbNames
and assigned as a default database
name. This decorator expects the database file to be local so
it can be removed.test
- Test to be decoratedpublic static DatabaseChangeSetup additionalDatabaseDecorator(junit.framework.Test test, java.lang.String logicalDbName)
usedDbNames
.
This decorator expects the database file to be local so it
can be removed.test
- Test to be decoratedlogicalDbName
- The logical database name. This name is used to identify
the database in openConnection(String logicalDatabaseName) method calls.public static DatabaseChangeSetup additionalDatabaseDecoratorNoShutdown(junit.framework.Test test, java.lang.String logicalDbName)
test
- Test to be decoratedlogicalDbName
- The logical database name. This name is
used to identify the database in
openConnection(String logicalDatabaseName)
method calls.public static DatabaseChangeSetup additionalDatabaseDecoratorNoShutdown(junit.framework.Test test, java.lang.String logicalDbName, boolean defaultDB)
test
- Test to be decoratedlogicalDbName
- The logical database name. This name is
used to identify the database in
openConnection(String logicalDatabaseName)
method calls.defaultDB
- True if the database should store its own name in its TestConfiguration.public static DatabaseChangeSetup additionalDatabaseDecoratorNoShutdown(junit.framework.Test test, java.lang.String logicalDbName, java.lang.String physicalDbName)
test
- Test to be decoratedlogicalDbName
- The logical database name. This name is
used to identify the database in
openConnection(String logicalDatabaseName)
method calls.physicalDbName
- - Real database name on disk.public static junit.framework.Test changeUserDecorator(junit.framework.Test test, java.lang.String user, java.lang.String password)
test
- Test to decorateuser
- New default userpassword
- New passwordDatabasePropertyTestSetup.builtinAuthentication(Test, String[], String)
public static junit.framework.Test sqlAuthorizationDecorator(junit.framework.Test test)
test = DatabasePropertyTestSetup.builtinAuthentication(test,
new String[] {TEST_DBO,"U1","U2",},
"nh32ew");
test = TestConfiguration.sqlAuthorizationDecorator(test);
A utility version of sqlAuthorizationDecorator is provided
that combines the two setups.test
- Test to be decoratedDatabasePropertyTestSetup.builtinAuthentication(Test, String[], String)
public static junit.framework.Test sqlAuthorizationDecoratorSingleUse(junit.framework.Test test)
test
- Test to be decoratedsqlAuthorizationDecorator(Test test)
public static junit.framework.Test sqlAuthorizationDecoratorSingleUse(junit.framework.Test test, java.lang.String dbName, boolean shutdownDatabase)
test
- Test to be decorateddbName
- The name of the database to use in the testshutdownDatabase
- Whether or not to shut down the database
before it is droppedsqlAuthorizationDecorator(Test test)
public static junit.framework.Test sqlAuthorizationDecorator(junit.framework.Test test, java.lang.String[] users, java.lang.String passwordToken)
users
- Set of users excluding the database owner, that will
be added by this decorator.public static junit.framework.Test connectionCPDecorator(junit.framework.Test test)
getPooledConnection().getConnection()
Note that statement pooling is enabled in the data source and in all the connections created from it.
The tearDown reverts the configuration to the previous configuration.
test
- the test/suite to decoratepublic static junit.framework.Test connectionXADecorator(junit.framework.Test test)
getXAConnection().getConnection()
The connection is not connected to any global transaction,
thus it is in local connection mode.
The tearDown reverts the configuration to the previous
configuration.public static junit.extensions.TestSetup connectionDSDecorator(junit.framework.Test test)
getConnection()
The tearDown reverts the configuration to the previous
configuration.public static junit.framework.Test forceJDBC3Embedded(junit.framework.Test test)
test
- public static junit.framework.Test forceJDBC3NetClient(junit.framework.Test test)
test
- Test around which to wrap the JDBC 3 network client
configuration.public static junit.framework.Test changeSSLDecorator(junit.framework.Test test, java.lang.String ssl)
test
- Test to decoratessl
- New ssl modeTestConfiguration addConnectionAttributes(java.util.Properties attrs)
attrs
- the extra connection attributespublic static final java.util.Properties getSystemProperties()
private java.lang.String createJDBCUrlWithDatabaseName(java.lang.String name)
private void initConnector(Connector oldConnector)
public JDBCClient getJDBCClient()
public java.lang.String getJDBCUrl()
Return the jdbc url for connecting to the default database.
The returned URL does not include the connection attributes. These must
either be appended to the URL when connecting, or they must be passed
as a Properties
object to DriverManager.getConnection()
.
public java.lang.String getJDBCUrl(java.lang.String databaseName)
databaseName
- name of database.public java.lang.String getDefaultDatabaseName()
public java.lang.String getPhysicalDatabaseName(java.lang.String logicalName)
public java.lang.String getUserName()
public java.lang.String getUserPassword()
public java.util.Properties getConnectionAttributes()
getUserName()
or getUserPassword()
instead to
retrieve those attributes.null
)java.lang.String getConnectionAttributesString()
null
if there
are no attributes)public java.lang.String getHostName()
public static boolean isDefaultBasePort()
public static int getBasePort()
public int getPort()
public int getNextAvailablePort()
public int getJmxPort()
public int getBogusPort()
public java.lang.String getSsl()
public java.sql.Connection openDefaultConnection() throws java.sql.SQLException
java.sql.SQLException
java.sql.Connection openDefaultConnection(java.lang.String user, java.lang.String password) throws java.sql.SQLException
java.sql.SQLException
java.sql.Connection openConnection(java.lang.String logicalDatabaseName) throws java.sql.SQLException
logicalDatabaseName
- A logical database name as passed
to additionalDatabaseDecorator
function.java.sql.SQLException
private java.lang.String getAndVetPhysicalDatabaseName(java.lang.String logicalDatabaseName) throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection openConnection(java.lang.String logicalDatabaseName, java.lang.String user, java.lang.String password) throws java.sql.SQLException
logicalDatabaseName
- A logical database name as passed
to additionalDatabaseDecorator
function.java.sql.SQLException
public java.sql.Connection openPhysicalConnection(java.lang.String physicalDatabaseName, java.lang.String user, java.lang.String password, java.util.Properties props) throws java.sql.SQLException
physicalDatabaseName
- The real database name to use.user
- name of userpassword
- password of userprops
- extra properties to pass to the connectionjava.sql.SQLException
public void shutdownDatabase()
public void shutdownEngine()
public void shutdownEngine(boolean deregisterDeriver)
deregisterDeriver
- if true, deregister the driverpublic int getLoginTimeout() throws java.sql.SQLException
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
seconds
- the login timeout in secondsjava.sql.SQLException
- if the timeout cannot be setpublic void waitForShutdownComplete(java.lang.String physicalDatabaseName)
public void stopNetworkServer()
public void startNetworkServer() throws java.sql.SQLException
java.sql.SQLException
public void setVerbosity(boolean isChatty)
public void setTrace(boolean isChatty)
public boolean isVerbose()
private void println(java.lang.CharSequence msg)
Note: This method may direct output to a different location than the println method in BaseJDBCTestCase.
public boolean doTrace()
public boolean stopAfterFirstFail()
public static boolean loadingFromJars()
Return true if we classes are being loaded from jar files. For the time being, this simply tests that the JVMInfo class (common to the client and the server) comes out of a jar file.
java.io.File getFailureFolder(junit.framework.TestCase test)
fail/client/testclass/testname
- client - value of JDBCClient.getName() for the test's configuration
- testclass - last element of the class name
- testname - value of test.getName()
boolean defaultSecurityManagerSetup()
java.security.PrivilegedActionException
static final java.lang.String getPassword(java.lang.String user, java.lang.String token)
public final java.lang.String getPassword(java.lang.String user)
public final java.lang.String getDatabasePath(java.lang.String physicalDatabaseName)
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.