use of org.apache.derbyTesting.junit.TestConfiguration in project derby by apache.
the class ProtocolTest method createSocket.
/**
* Initializes a socket to the server.
*
* @return A socket connected to the server.
* @throws IOException if reading/writing to the socket fails
* @throws UnknownHostException if the server host cannot be resolved
*/
private static Socket createSocket() throws IOException, UnknownHostException {
Socket socket = null;
final TestConfiguration cfg = TestConfiguration.getCurrent();
try {
socket = AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Socket>() {
public Socket run() throws IOException, UnknownHostException {
return new Socket(cfg.getHostName(), cfg.getPort());
}
});
} catch (PrivilegedActionException pae) {
if (pae.getCause() instanceof IOException) {
throw (IOException) pae.getCause();
} else if (pae.getCause() instanceof UnknownHostException) {
throw (UnknownHostException) pae.getCause();
}
fail("Unhandled exception", pae);
}
return socket;
}
use of org.apache.derbyTesting.junit.TestConfiguration in project derby by apache.
the class SecureServerTest method connectToServer.
private void connectToServer() throws Exception {
final TestConfiguration config = getTestConfiguration();
String url = ("jdbc:derby://localhost:" + config.getPort() + "/" + "wombat;create=true" + ";user=" + config.getUserName() + ";password=" + config.getUserPassword());
println("XXX in connectToServer(). url = " + url);
// just try to get a connection
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn = DriverManager.getConnection(url);
assertNotNull("Connection should not be null...", conn);
conn.close();
}
use of org.apache.derbyTesting.junit.TestConfiguration in project derby by apache.
the class _Suite method suite.
/**
* Returns the default set of compatibility tests, intended to be run
* as part of suites.All.
*
* @return A default suite of compatibility tests.
*/
public static Test suite() {
// run off of UNC paths (network drives).
if (suffersFromDerby5889()) {
String msg = ("tests.compatibility disabled on Windows " + "with UNC paths, see DERBY-5889");
println(msg);
return new BaseTestSuite(msg);
}
// from VersionCombinationConfigurator.getJarDirectoryOf
if (!TestConfiguration.loadingFromJars())
return new BaseTestSuite("Compatibility tests skipped becasue " + "they need to run from jars");
if (!Derby.hasClient() || !Derby.hasServer()) {
return new BaseTestSuite("Compatibility tests skipped because " + "client or server is missing");
}
BaseTestSuite suite = new BaseTestSuite();
addVersionCombinations(suite);
TestConfiguration config = TestConfiguration.getCurrent();
return new SecurityManagerSetup(new ServerSetup(suite, "localhost", config.getPort()), // to put on the classpath for the spawned process(es).
VersionCombinationConfigurator.class.getName().replaceAll("\\.", "/") + ".policy", true);
}
use of org.apache.derbyTesting.junit.TestConfiguration in project derby by apache.
the class ReadMeFilesTest method testReadMeFilesExist.
public void testReadMeFilesExist() throws IOException, SQLException {
getConnection();
TestConfiguration currentConfig = TestConfiguration.getCurrent();
String dbPath = currentConfig.getDatabasePath(currentConfig.getDefaultDatabaseName());
lookForReadmeFile(dbPath);
lookForReadmeFile(dbPath + File.separator + "seg0");
String logDevice = currentConfig.getConnectionAttributes().getProperty("logDevice");
if (logDevice != null) {
lookForReadmeFile(logDir + File.separator + "log");
} else {
lookForReadmeFile(dbPath + File.separator + "log");
}
}
use of org.apache.derbyTesting.junit.TestConfiguration in project derby by apache.
the class DecryptDatabaseTest method setUp.
/**
* Makes sure that the database is encrypted.
*/
public void setUp() throws Exception {
super.setUp();
// Connect.
try {
connect(false, BOOTPW, null).close();
} catch (SQLException sqle) {
assertSQLState("Did you change the boot password?", "XJ004", sqle);
// Create the database and save the encryption algorithm.
getConnection();
saveEncryptionAlgorithm();
}
// Make sure the database is (still) encrypted.
TestConfiguration tc = getTestConfiguration();
tc.shutdownDatabase();
try {
connect(false, null, null);
tc.shutdownDatabase();
// Database has been decrypted. Encrypt it again.
println("encrypting database (" + encryptionAlgorithm + ")");
connect(false, BOOTPW, "dataEncryption=true;encryptionAlgorithm=" + encryptionAlgorithm);
tc.shutdownDatabase();
connect(false, null, null);
fail("database encryption failed");
} catch (SQLException sqle) {
assertSQLState("XBM06", sqle);
}
}
Aggregations