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 km...@apache.org on 2013/08/29 21:07:33 UTC
svn commit: r1518766 - in /db/derby/code/trunk/java:
client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java
testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
Author: kmarsden
Date: Thu Aug 29 19:07:32 2013
New Revision: 1518766
URL: http://svn.apache.org/r1518766
Log:
DERBY-5553 System property for client tracing -Dderby.client.traceDirectory does not work with XADataSource
Modified:
db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java?rev=1518766&r1=1518765&r2=1518766&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java Thu Aug 29 19:07:32 2013
@@ -425,7 +425,7 @@ public abstract class ClientBaseDataSour
Attribute.CLIENT_JVM_PROPERTY_PREFIX +
Attribute.CLIENT_TRACE_DIRECTORY);
- if (traceDirectoryString == null) {
+ if (traceDirectoryString == null && properties != null) {
return properties.getProperty(Attribute.CLIENT_TRACE_DIRECTORY);
} else {
return traceDirectoryString;
@@ -989,12 +989,15 @@ public abstract class ClientBaseDataSour
traceLevelString =
readSystemProperty(Attribute.CLIENT_JVM_PROPERTY_PREFIX +
Attribute.CLIENT_TRACE_LEVEL);
- if (traceLevelString == null) {
+ if (traceLevelString == null && properties != null) {
traceLevelString =
properties.getProperty(Attribute.CLIENT_TRACE_LEVEL);
}
-
- return parseInt(traceLevelString, propertyDefault_traceLevel);
+ if (traceLevelString != null ) {
+ return parseInt(traceLevelString, propertyDefault_traceLevel);
+ } else {
+ return propertyDefault_traceLevel;
+ }
}
synchronized public void setTraceLevel(int traceLevel) {
@@ -1060,6 +1063,22 @@ public abstract class ClientBaseDataSour
private void updateDataSourceValues(Properties prop)
throws SqlException
{
+ // DERBY-5553. System properties derby.client.traceDirectory
+ // and derby.client.traceLevel do not work for ClientXADataSource
+ // or ClientConnectionPoolDataSource
+ // Trace level and trace directory will be read from system
+ // properties if they are not specified in the Properties
+ // argument, so we check for them first to avoid getting cut
+ // off by the (prop == null) check below.
+ String traceDir = getTraceDirectory(prop);
+ if (traceDir != null) {
+ setTraceDirectory(traceDir);
+ }
+
+ int traceLevel = getTraceLevel(prop);
+ if (traceLevel != propertyDefault_traceLevel) {
+ setTraceLevel(traceLevel);
+ }
if (prop == null) {
return;
}
@@ -1073,9 +1092,6 @@ public abstract class ClientBaseDataSour
if (prop.containsKey(Attribute.CLIENT_TRACE_FILE)) {
setTraceFile(getTraceFile(prop));
}
- if (prop.containsKey(Attribute.CLIENT_TRACE_DIRECTORY)) {
- setTraceDirectory(getTraceDirectory(prop));
- }
if (prop.containsKey(Attribute.CLIENT_TRACE_APPEND)) {
setTraceFileAppend(getTraceFileAppend(prop));
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java?rev=1518766&r1=1518765&r2=1518766&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java Thu Aug 29 19:07:32 2013
@@ -23,11 +23,17 @@ package org.apache.derbyTesting.function
import java.io.File;
import java.security.AccessController;
+import java.sql.Connection;
import java.util.Properties;
+import javax.sql.PooledConnection;
+import javax.sql.XAConnection;
+
import junit.framework.Test;
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.J2EEDataSource;
+import org.apache.derbyTesting.junit.JDBCDataSource;
import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
import org.apache.derbyTesting.junit.TestConfiguration;
@@ -38,7 +44,44 @@ public class ClientSideSystemPropertiesT
* because we have set the system properties to enable client side
* tracing. */
public void testConnection() throws Exception {
- getConnection().setAutoCommit(false);
+ Connection conn = openDefaultConnection();
+ conn.setAutoCommit(false);
+ checkTraceFileIsPresent();
+ conn.rollback();
+ conn.close();
+ }
+
+ public void testClientDataSourceConnection() throws Exception {
+ Connection conn = JDBCDataSource.getDataSource().getConnection();
+ conn.setAutoCommit(false);
+ checkTraceFileIsPresent();
+ conn.rollback();
+ conn.close();
+ }
+
+ public void testClientCPDataSourceConnection() throws Exception {
+ PooledConnection pconn = J2EEDataSource.getConnectionPoolDataSource().
+ getPooledConnection();
+ Connection conn = pconn.getConnection();
+ conn.setAutoCommit(false);
+ checkTraceFileIsPresent();
+ conn.rollback();
+ conn.close();
+ pconn.close();
+ }
+
+ public void testClientXADataSourceConnection() throws Exception {
+ XAConnection xaconn = J2EEDataSource.getXADataSource().
+ getXAConnection();
+ Connection conn = xaconn.getConnection();
+ conn.setAutoCommit(false);
+ checkTraceFileIsPresent();
+ conn.close();
+ xaconn.close();
+ }
+
+
+ private void checkTraceFileIsPresent() {
//Make sure the connection above created a trace file. This check is
//made in the privilege block below by looking inside the
//trace Directory and making sure the file count is greater than 0.
@@ -74,7 +117,7 @@ public class ClientSideSystemPropertiesT
File tempFile;
for (;fileCounter<list.length; fileCounter++) {
tempFile = list[fileCounter];
- tempFile.delete();
+ assertTrue(tempFile.delete());
}
}
return null;