use of org.apache.derbyTesting.junit.NetworkServerTestSetup in project derby by apache.
the class RestrictiveFilePermissionsTest method suite.
public static Test suite() throws Exception {
File f = new File("system/testPermissions");
assertTrue(f.mkdirs());
supportsLaxTesting = checkAccessToOwner(f, false, UNKNOWN);
if (!supportsLaxTesting) {
println("warning: testing of lax file permissions in" + "RestrictiveFilePermissionsTest can not take place, " + "use a more liberal runtime default (umask) for the tests");
}
assertDirectoryDeleted(f);
// First collect the tests that check that, if we actually do restrict
// permissions, the files created by Derby actually *are*
// restricted. We test that with an embedded Derby with explicit
// setting of the property derby.storage.useDefaultFilePermissions.
// The extra setup file is for testJarFiles.
BaseTestSuite totalSuite = new BaseTestSuite("RestrictiveFilePermissionsTest");
Properties p = new Properties();
p.put("derby.storage.useDefaultFilePermissions", "false");
p.put("derby.stream.error.file", derbyDotLog);
totalSuite.addTest(new SystemPropertyTestSetup(TestConfiguration.singleUseDatabaseDecorator(new SupportFilesSetup(new BaseTestSuite(RestrictiveFilePermissionsTest.class, "haveWeGotAllCreatedFilesSuite"), new String[] { "functionTests/tests/lang/dcl_id.jar" }), dbName), p, true));
// permissions.
if (Derby.hasServer()) {
totalSuite.addTest(new NetworkServerTestSetup(new RestrictiveFilePermissionsTest("doTestCliServerIsRestrictive"), // system properties
new String[] {}, // non-default start up arguments
new String[] {}, true));
}
//
if (supportsLaxTesting) {
totalSuite.addTest(TestConfiguration.clientServerDecorator(new RestrictiveFilePermissionsTest("doTestNonCliServerIsLax")));
// For embedded, we should see lax permissions also.
//
p = new Properties();
p.put("derby.stream.error.file", derbyDotLog + ".lax");
totalSuite.addTest(new SystemPropertyTestSetup(new RestrictiveFilePermissionsTest("dotestEmbeddedIsLax"), p, true));
}
return totalSuite;
}
use of org.apache.derbyTesting.junit.NetworkServerTestSetup in project derby by apache.
the class LoginTimeoutTest method suite.
// /////////////////////////////////////////////////////////////////////////////////
//
// JUnit MACHINERY
//
// /////////////////////////////////////////////////////////////////////////////////
/**
* Return suite with all tests of the class.
*/
public static Test suite() {
BaseTestSuite suite = new BaseTestSuite();
Test embedded = new BaseTestSuite(LoginTimeoutTest.class, "embedded LoginTimeoutTest");
embedded = TestConfiguration.singleUseDatabaseDecorator(embedded);
embedded = new SystemPropertyTestSetup(embedded, systemProperties());
suite.addTest(embedded);
if (Derby.hasServer() && Derby.hasClient()) {
Test clientServer = new BaseTestSuite(LoginTimeoutTest.class, "client/server LoginTimeoutTest");
clientServer = TestConfiguration.singleUseDatabaseDecorator(clientServer);
clientServer = new JDBCClientSetup(clientServer, JDBCClient.DERBYNETCLIENT);
clientServer = new NetworkServerTestSetup(clientServer, systemPropertiesArray(), new String[] {}, true);
suite.addTest(clientServer);
}
return suite;
}
use of org.apache.derbyTesting.junit.NetworkServerTestSetup in project derby by apache.
the class MBeanTest method suite.
protected static Test suite(Class<? extends MBeanTest> testClass, String suiteName) {
BaseTestSuite outerSuite = new BaseTestSuite(suiteName);
Test platform = new BaseTestSuite(testClass, suiteName + ":platform");
// Start the network server to ensure Derby is running and
// all the MBeans are running.
platform = TestConfiguration.clientServerDecorator(platform);
platform = JMXConnectionDecorator.platformMBeanServer(platform);
// Set of tests that run within the same virtual machine using
// the platform MBeanServer directly.
outerSuite.addTest(platform);
// Create a suite of all "test..." methods in the class.
Test suite = new BaseTestSuite(testClass, suiteName + ":client");
// Set up to get JMX connections using remote JMX
suite = JMXConnectionDecorator.remoteNoSecurity(suite);
/* Connecting to an MBean server using a URL requires setting up remote
* JMX in the JVM to which we want to connect. This is usually done by
* setting a few system properties at JVM startup.
* A quick solution is to set up a new network server JVM with
* the required jmx properties.
* A future improvement could be to fork a new JVM for embedded (?).
*
* This requires that the default security policy of the network server
* includes the permissions required to perform the actions of these
* tests. Otherwise, we'd probably have to supply a custom policy file
* and specify this using additional command line properties at server
* startup.
*/
NetworkServerTestSetup networkServerTestSetup = new NetworkServerTestSetup(// run all tests in this class in the same setup
suite, // need to set up JMX in JVM
getCommandLineProperties(false), // no server arguments needed
new String[0], // wait for the server to start properly
true);
/* Since the server will be started in a new process we need "execute"
* FilePermission on all files (at least Java executables)...
* Will run without SecurityManager for now, but could probably add a
* JMX specific policy file later. Or use the property trick reported
* on derby-dev 2008-02-26 and add the permission to the generic
* policy.
* Note that the remote server will be running with a security
* manager (by default) if testing with jars.
*/
Test testSetup = SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
// this decorator makes sure the suite is empty if this configration
// does not support the network server:
outerSuite.addTest(TestConfiguration.defaultServerDecorator(testSetup));
return outerSuite;
}
use of org.apache.derbyTesting.junit.NetworkServerTestSetup in project derby by apache.
the class SSLTest method decorateTest.
// Test decoration
/**
* <p>
* Compose the required decorators to bring up the server in the correct
* configuration.
* </p>
*/
private static Test decorateTest(String testName) {
SSLTest sslTest = new SSLTest(testName);
String[] startupProperties = getStartupProperties();
String[] startupArgs = new String[] {};
NetworkServerTestSetup networkServerTestSetup = new NetworkServerTestSetup(sslTest, startupProperties, startupArgs, true);
Test testSetup = SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
testSetup = new SupportFilesSetup(testSetup, null, new String[] { "functionTests/tests/derbynet/SSLTestServerKey.key" }, null, new String[] { "SSLTestServerKey.key" });
Test test = TestConfiguration.defaultServerDecorator(testSetup);
test = TestConfiguration.changeSSLDecorator(test, "basic");
return test;
}
use of org.apache.derbyTesting.junit.NetworkServerTestSetup in project derby by apache.
the class SecureServerTest method decorateTest.
// /////////////////////////////////////////////////////////////////////////////////
//
// TEST DECORATION
//
// /////////////////////////////////////////////////////////////////////////////////
/**
* <p>
* Compose the required decorators to bring up the server in the correct
* configuration.
* </p>
*/
private static Test decorateTest(boolean unsecureSet, boolean authenticationRequired, String customDerbyProperties, String wildCardHost, Outcome outcome) {
SecureServerTest secureServerTest = new SecureServerTest(unsecureSet, authenticationRequired, customDerbyProperties, wildCardHost, outcome);
String[] startupProperties = getStartupProperties(authenticationRequired, customDerbyProperties);
String[] startupArgs = getStartupArgs(unsecureSet, wildCardHost);
NetworkServerTestSetup networkServerTestSetup = new NetworkServerTestSetup(secureServerTest, startupProperties, startupArgs, secureServerTest._outcome.serverShouldComeUp());
secureServerTest.nsTestSetup = networkServerTestSetup;
Test testSetup = SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
// if using the custom derby.properties, copy the custom properties to a visible place
if (customDerbyProperties != null) {
testSetup = new SupportFilesSetup(testSetup, null, new String[] { "functionTests/tests/derbynet/SecureServerTest.derby.properties" }, null, new String[] { "derby.properties" });
}
Test test = TestConfiguration.defaultServerDecorator(testSetup);
// DERBY-2109: add support for user credentials
test = TestConfiguration.changeUserDecorator(test, SST_USER_NAME, SST_PASSWORD);
return test;
}
Aggregations