db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r669243 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apache/derbyTesting/functionTests/util/
Date Wed, 18 Jun 2008 18:11:49 GMT
Author: kmarsden
Date: Wed Jun 18 11:11:49 2008
New Revision: 669243

URL: http://svn.apache.org/viewvc?rev=669243&view=rev
Log:
DERBY-3708 setting tracedirectory from the command line does not work


Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=669243&r1=669242&r2=669243&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Wed Jun 18 11:11:49 2008
@@ -2155,8 +2155,9 @@
 					break;
 				}
 			case COMMAND_TRACEDIRECTORY:
-				setTraceDirectory((String) commandArgs.elementAt(0));
-				consolePropertyMessage("DRDA_TraceDirectoryChange.I", traceDirectory);
+				String directory = (String) commandArgs.elementAt(0);
+				sendSetTraceDirectory(directory);
+				consolePropertyMessage("DRDA_TraceDirectoryChange.I", directory);
 				break;
 			case COMMAND_TESTCONNECTION:
 				ping();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java?rev=669243&r1=669242&r2=669243&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SecureServerTest.java
Wed Jun 18 11:11:49 2008
@@ -21,6 +21,7 @@
 
 package org.apache.derbyTesting.functionTests.tests.derbynet;
 
+import java.io.File;
 import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -45,6 +46,7 @@
 import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.functionTests.util.PrivilegedFileOpsForTests;
 
 import org.apache.derby.drda.NetworkServerControl;
 
@@ -353,6 +355,36 @@
         //
         runsysinfo();
         enableTracing();
+        setTraceDirectory();
+        disableTracing();
+        
+        
+    }
+
+    private void disableTracing() throws Exception {
+
+        String traceOffOutput = runServerCommand( "trace off" );
+
+        println( "Output for trace off command:\n\n" + traceOffOutput );
+
+        if ( traceOffOutput.indexOf( "Trace turned off for all sessions." ) < 0 )
+        { fail( "Failed to turn trace off:\n\n:" + traceOffOutput ); }
+    }
+
+    private void setTraceDirectory() throws Exception {
+
+        String  traceDirectoryOutput = runServerCommand( "tracedirectory trace" );
+        println( "Output for tracedirectory trace command:\n\n" + traceDirectoryOutput );
+
+        if ( traceDirectoryOutput.indexOf( "Trace directory changed to trace." ) < 0 )
+        { fail( "Unexpected output in setting trace directory:" + traceDirectoryOutput );
}
+
+        String pingOutput = runServerCommand( "ping" );
+
+        if (pingOutput.indexOf("Connection obtained for host:") < 0)
+        { fail ("Failed ping after changing trace directory: " + pingOutput);}
+        assertTrue("directory trace does not exist",
+                PrivilegedFileOpsForTests.exists(new File("trace")));
     }
 
     private void    connectToServer()

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java?rev=669243&r1=669242&r2=669243&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/PrivilegedFileOpsForTests.java
Wed Jun 18 11:11:49 2008
@@ -82,4 +82,28 @@
         }
     }
 
+    /**
+     * Check if the file exists.
+     *
+     * @return <code>true</code> if file exists, <code>false</code>
otherwise
+     * @throws SecurityException if the required permissions to read the file,
+     *      or the path it is in, are missing
+     * @see File#exists
+     */
+    public static boolean exists(final File file)
+            throws SecurityException {
+        if (file == null) {
+            throw new IllegalArgumentException("file cannot be <null>");
+        }
+        try {
+            return ((Boolean)AccessController.doPrivileged(
+                        new PrivilegedExceptionAction() {
+                            public Object run() throws SecurityException {
+                                return new Boolean(file.exists());
+                            }
+                        })).booleanValue();
+        } catch (PrivilegedActionException pae) {
+            throw (SecurityException)pae.getException();
+        }
+    }
 }



Mime
View raw message