Skip to content

Commit

Permalink
Add more tests and hints on variations of tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
swaldman committed Feb 15, 2024
1 parent f6b1ce9 commit d792689
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 28 deletions.
37 changes: 33 additions & 4 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,43 @@ object c3p0 extends RootModule with JavaModule with PublishModule {
override def ivyDeps = T{
super.ivyDeps() ++ Agg(Dependency.JUnit,Dependency.PgJdbc)
}

override def forkArgs = T {
"-Dc3p0.jdbcUrl=jdbc:postgresql://localhost:5432/c3p0" :: Nil
"-Dc3p0.jdbcUrl=jdbc:postgresql://localhost:5432/c3p0" ::
//"-Dcom.sun.management.jmxremote.port=38383" ::
//"-Dcom.sun.management.jmxremote.authenticate=false" ::
//"-Dcom.sun.management.jmxremote.ssl=false" ::
//"-server" ::
//"-Xrunhprof:cpu=times,file=/tmp/java.hprof,doe=y,format=a" ::
//"-Xprof" ::
//"-Xrunhprof:file=/tmp/java.hprof,doe=y,format=b" ::
//"-verbose:class"
//"-ea" ::
Nil
}

def c3p0BenchmarkApp = T {
def c3p0Benchmark = T {
this.runMain("com.mchange.v2.c3p0.test.C3P0BenchmarkApp")()
}
def c3p0Stats = T {
this.runMain("com.mchange.v2.c3p0.test.StatsTest")()
}
def c3p0Proxywrapper = T {
this.runMain("com.mchange.v2.c3p0.test.ProxyWrappersTest")()
}
def c3p0RawConnectionOp = T {
this.runMain("com.mchange.v2.c3p0.test.RawConnectionOpTest")()
}
def c3p0Load = T {
this.runMain("com.mchange.v2.c3p0.test.LoadPoolBackedDataSource")()
}
def c3p0PSLoad = T {
this.runMain("com.mchange.v2.c3p0.test.PSLoadPoolBackedDataSource")()
}
def c3p0InterruptedBatch = T {
this.runMain("com.mchange.v2.c3p0.test.InterruptedBatchTest")()
}
def c3p0Dispersion = T {
this.runMain("com.mchange.v2.c3p0.test.ConnectionDispersionTest")()
}
}

override def artifactName = T{"c3p0"}
Expand Down
15 changes: 10 additions & 5 deletions test/src/com/mchange/v2/c3p0/test/ConnectionDispersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private static synchronized boolean shouldGo()

public static void main(String[] argv)
{
/*
String jdbc_url = null;
String username = null;
String password = null;
Expand All @@ -104,16 +105,20 @@ else if (argv.length == 1)
}
else
usage();
if (! jdbc_url.startsWith("jdbc:") )
usage();

*/

try
{
ComboPooledDataSource ds = new ComboPooledDataSource();
ds.setJdbcUrl( jdbc_url );
ds.setUser( username );
ds.setPassword( password );

// expect this stuff through sysprops or c3p0.properties or whatnot
// ds.setJdbcUrl( jdbc_url );
// ds.setUser( username );
// ds.setPassword( password );

setDataSource( ds );

// get the DataSource initialized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public static void main(String[] argv)
{
System.err.println( LoadPoolBackedDataSource.class.getName() +
" now requires no args. Please set everything in standard c3p0 config files.");
return;
return;
}
String jdbc_url = null;
String username = null;
String password = null;

/*
/*
if (argv.length == 3)
{
jdbc_url = argv[0];
Expand Down
11 changes: 7 additions & 4 deletions test/src/com/mchange/v2/c3p0/test/ProxyWrappersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ public static void main(String[] argv)
try
{
cpds = new ComboPooledDataSource();
cpds.setDriverClass( "org.postgresql.Driver" );
cpds.setJdbcUrl( "jdbc:postgresql://localhost/c3p0-test" );
cpds.setUser("swaldman");
cpds.setPassword("test");

// let system properties or c3p0.properties set this stuff up
// cpds.setDriverClass( "org.postgresql.Driver" );
// cpds.setJdbcUrl( "jdbc:postgresql://localhost/c3p0-test" );
// cpds.setUser("swaldman");
// cpds.setPassword("test");

cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);
Expand Down
24 changes: 14 additions & 10 deletions test/src/com/mchange/v2/c3p0/test/RawConnectionOpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ public static void main(String[] argv)
ComboPooledDataSource cpds = null;
try
{
/*
String jdbc_url = null;
String username = null;
String password = null;
if (argv.length == 3)
{
jdbc_url = argv[0];
Expand All @@ -67,17 +68,20 @@ else if (argv.length == 1)
}
else
usage();
if (! jdbc_url.startsWith("jdbc:") )
usage();

*/

cpds = new ComboPooledDataSource();
cpds.setJdbcUrl( jdbc_url );
cpds.setUser( username );
cpds.setPassword( password );

// let system properties or c3p0.properties set this stuff up for now
// cpds.setJdbcUrl( jdbc_url );
// cpds.setUser( username );
// cpds.setPassword( password );
cpds.setMaxPoolSize( 10 );
// cpds.setUsesTraditionalReflectiveProxies( true );

C3P0ProxyConnection conn = (C3P0ProxyConnection) cpds.getConnection();
Method toStringMethod = Object.class.getMethod("toString", new Class[]{});
Method identityHashCodeMethod = System.class.getMethod("identityHashCode", new Class[] {Object.class});
Expand All @@ -92,7 +96,7 @@ else if (argv.length == 1)
Integer ihc2 = (Integer) stmt.rawStatementOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyStatement.RAW_STATEMENT});
System.out.println("System.identityHashCode( rawStatement ) -> " + Integer.toHexString( ihc2.intValue() ));

conn.close();
conn.close();

for (int i = 0; i < 10; ++i)
{
Expand All @@ -116,8 +120,8 @@ else if (argv.length == 1)
private static void usage()
{
System.err.println("java " + RawConnectionOpTest.class.getName() + " \\");
System.err.println("\t<jdbc_driver_class> \\");
System.err.println("\t<jdbc_url> [<username> <password>]");
//System.err.println("\t<jdbc_driver_class> \\");
//System.err.println("\t<jdbc_url> [<username> <password>]");
System.exit(-1);
}
}
9 changes: 6 additions & 3 deletions test/src/com/mchange/v2/c3p0/test/StatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ public static void main(String[] argv)
try
{
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setJdbcUrl( argv[0] );
cpds.setUser( argv[1] );
cpds.setPassword( argv[2] );

//we'll let sysprops of c3p0.properties set-up this stuff for now
//cpds.setJdbcUrl( argv[0] );
//cpds.setUser( argv[1] );
//cpds.setPassword( argv[2] );

cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);
Expand Down

0 comments on commit d792689

Please sign in to comment.