Subject | Fun with shutdown: Test cases in text |
---|---|
Author | Elias Holman |
Post date | 2004-08-25T15:32:22Z |
It seems to have stripped off my test cases, so here they are in text
form:
public void testOverload() {
Properties p = new Properties();
try {
p.load(new FileInputStream("test.properties"));
for(int i = 0; i < 20; i++) {
System.out.println("Iteration: " + i);
FBConnectionPoolDataSource wds = new FBConnectionPoolDataSource();
wds.setPooling(true);
wds.setDatabase("localhost/3050:/path/to/database");
wds.setUserName(p.getProperty("db.username"));
wds.setPassword(p.getProperty("db.password"));
wds.setPooling(true);
wds.setStatementPooling(true);
wds.setBlockingTimeout(1000);
wds.setMaxPoolSize(Integer.parseInt(p.getProperty("db.connections")));
wds.setMinConnections(Integer.parseInt(p.getProperty("db.connections")));
wds.setMaxStatements(100);
SimpleDataSource sds = new SimpleDataSource(wds);
Connection c = sds.getConnection();
c.close();
c = sds.getConnection();
c.close();
c = sds.getConnection();
c.close();
c = sds.getConnection();
c.close();
wds.shutdown();
}
}
catch(Exception e) {
e.printStackTrace();
}
}
public void testBadShutdown() {
Properties p = new Properties();
try {
p.load(new FileInputStream("test.properties"));
FBConnectionPoolDataSource wds = new FBConnectionPoolDataSource();
wds.setPooling(true);
wds.setDatabase("localhost/3050:/path/to/database");
wds.setUserName(p.getProperty("db.username"));
wds.setPassword(p.getProperty("db.password"));
wds.setPooling(true);
wds.setStatementPooling(true);
wds.setBlockingTimeout(1000);
wds.setMaxPoolSize(Integer.parseInt(p.getProperty("db.connections")));
wds.setMinConnections(Integer.parseInt(p.getProperty("db.connections")));
wds.setMaxStatements(100);
SimpleDataSource sds = new SimpleDataSource(wds);
Connection c = sds.getConnection();
//Comment out this next line to see the effect of having one open
connection on shutdown
c = sds.getConnection();
wds.shutdown();
}
catch(Exception e) {
e.printStackTrace();
}
}
--
Eli
form:
public void testOverload() {
Properties p = new Properties();
try {
p.load(new FileInputStream("test.properties"));
for(int i = 0; i < 20; i++) {
System.out.println("Iteration: " + i);
FBConnectionPoolDataSource wds = new FBConnectionPoolDataSource();
wds.setPooling(true);
wds.setDatabase("localhost/3050:/path/to/database");
wds.setUserName(p.getProperty("db.username"));
wds.setPassword(p.getProperty("db.password"));
wds.setPooling(true);
wds.setStatementPooling(true);
wds.setBlockingTimeout(1000);
wds.setMaxPoolSize(Integer.parseInt(p.getProperty("db.connections")));
wds.setMinConnections(Integer.parseInt(p.getProperty("db.connections")));
wds.setMaxStatements(100);
SimpleDataSource sds = new SimpleDataSource(wds);
Connection c = sds.getConnection();
c.close();
c = sds.getConnection();
c.close();
c = sds.getConnection();
c.close();
c = sds.getConnection();
c.close();
wds.shutdown();
}
}
catch(Exception e) {
e.printStackTrace();
}
}
public void testBadShutdown() {
Properties p = new Properties();
try {
p.load(new FileInputStream("test.properties"));
FBConnectionPoolDataSource wds = new FBConnectionPoolDataSource();
wds.setPooling(true);
wds.setDatabase("localhost/3050:/path/to/database");
wds.setUserName(p.getProperty("db.username"));
wds.setPassword(p.getProperty("db.password"));
wds.setPooling(true);
wds.setStatementPooling(true);
wds.setBlockingTimeout(1000);
wds.setMaxPoolSize(Integer.parseInt(p.getProperty("db.connections")));
wds.setMinConnections(Integer.parseInt(p.getProperty("db.connections")));
wds.setMaxStatements(100);
SimpleDataSource sds = new SimpleDataSource(wds);
Connection c = sds.getConnection();
//Comment out this next line to see the effect of having one open
connection on shutdown
c = sds.getConnection();
wds.shutdown();
}
catch(Exception e) {
e.printStackTrace();
}
}
--
Eli