You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by da...@apache.org on 2012/07/02 22:21:10 UTC
svn commit: r1356457 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Author: dag
Date: Mon Jul 2 20:21:09 2012
New Revision: 1356457
URL: http://svn.apache.org/viewvc?rev=1356457&view=rev
Log:
DERBY-5819 Add logic to BaseTestCase to start subprocesses ready to be attached to from a Java debugger
Adds options to allow this capability for Oracle Java (properties below
ignored for other implementations):
derby.test.debugPortBase=<int> default 8800
derby.test.debugSubProcesses=<boolean> default false
derby.test.debugSuspend=<y|n> default 'y'
If several subprocesses are created, the port for subprocess two will be
debugPortBase + 1 (i.e. 8801 by default) etc.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1356457&r1=1356456&r2=1356457&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Mon Jul 2 20:21:09 2012
@@ -57,7 +57,8 @@ public abstract class BaseTestCase
protected final static String ERRORSTACKTRACEFILE = "error-stacktrace.out";
protected final static String DEFAULT_DB_DIR = "system";
protected final static String DERBY_LOG = "derby.log";
-
+
+ private static int debugPort; // default 8800
/**
* No argument constructor made private to enforce naming of test cases.
* According to JUnit documentation, this constructor is provided for
@@ -603,6 +604,12 @@ public abstract class BaseTestCase
"destfile=" + getJaCoCoOutFile());
}
+ if (isSunJVM() && Boolean.valueOf(
+ getSystemProperty("derby.test.debugSubprocesses")).
+ booleanValue()) {
+ setupForDebuggerAttach(cmdlist);
+ }
+
if (isJarInvocation) {
// If -jar is specified, the Java command will ignore the user's
// classpath, so don't set it. Fail if an explicit classpath has
@@ -1122,4 +1129,29 @@ public abstract class BaseTestCase
return "(net)";
}
}
+
+ private static void setupForDebuggerAttach(ArrayList cmdlist) {
+ if (debugPort == 0) {
+ // lazy initialization
+ String dbp = getSystemProperty("derby.test.debugPortBase");
+ debugPort = 8800; // default
+ if (dbp != null) {
+ try {
+ debugPort = Integer.parseInt(dbp);
+ } catch (NumberFormatException e) {
+ // never mind
+ }
+ }
+ }
+
+ char suspend = 'y'; // default
+ String susp = getSystemProperty("derby.test.debugSuspend");
+ if (susp != null && "n".equals(susp.toLowerCase())) {
+ suspend = 'n';
+ }
+
+ cmdlist.add("-Xdebug");
+ cmdlist.add("-Xrunjdwp:transport=dt_socket,address=" + (debugPort++) +
+ ",server=y,suspend=" + suspend);
+ }
} // End class BaseTestCase