db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r678858 - in /db/derby/code/trunk: java/shared/ java/shared/org/apache/derby/shared/common/sanity/ java/testing/org/apache/derbyTesting/functionTests/util/ java/testing/org/apache/derbyTesting/unitTests/junit/ tools/jar/
Date Tue, 22 Jul 2008 18:43:28 GMT
Author: kmarsden
Date: Tue Jul 22 11:43:27 2008
New Revision: 678858

URL: http://svn.apache.org/viewvc?rev=678858&view=rev
Log:
DERBY-3618 Perform thread dump with ASSERTS with jdk 1.5 or higher

Contributed by Erlend Birkenes


Added:
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/ThreadDump.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy
  (with props)
Modified:
    db/derby/code/trunk/java/shared/build.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java
    db/derby/code/trunk/tools/jar/dnc.properties
    db/derby/code/trunk/tools/jar/extraDBMSclasses.properties

Modified: db/derby/code/trunk/java/shared/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/build.xml?rev=678858&r1=678857&r2=678858&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/build.xml (original)
+++ db/derby/code/trunk/java/shared/build.xml Tue Jul 22 11:43:27 2008
@@ -51,7 +51,7 @@
 
 <!-- compile classes  -->
   <target name="compile">
-    <javac
+  	<javac
       source="1.4"
       target="1.4"
       bootclasspath="${empty}"
@@ -69,7 +69,27 @@
           <pathelement path="${java14compile.classpath}"/>
       </classpath>
       <include name="org/apache/derby/shared/**"/>
+  	  <exclude name="org/apache/derby/shared/common/sanity/ThreadDump.java"/>
     </javac>
+  	
+  	<javac
+  	      source="1.5"
+  	      target="1.5"
+  	      bootclasspath="${empty}"
+  	      nowarn="on"
+  	      debug="${debug}"
+  	      depend="${depend}"
+  	      deprecation="${deprecation}"
+  	      optimize="${optimize}"
+  	      proceed="${proceed}"
+  	      verbose="${verbose}"
+  	      srcdir="${derby.shared.src.dir}"
+  	      destdir="${out.dir}">
+  	      <classpath>
+  	        <pathelement path="${java15compile.classpath}"/>
+  	      </classpath>
+  	    <include name="org/apache/derby/shared/common/sanity/ThreadDump.java"/>
+  	    </javac>
 </target>
   
 

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java?rev=678858&r1=678857&r2=678858&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/AssertFailure.java
Tue Jul 22 11:43:27 2008
@@ -21,19 +21,39 @@
 
 package org.apache.derby.shared.common.sanity;
 
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 /**
- * AssertFailure is raised when an ASSERT check fails.
- * Because assertions are not used in production code,
- * are never expected to fail, and recovering from their
- * failure is expected to be hard, they are under
- * RuntimeException so that no one needs to list them
- * in their throws clauses.  An AssertFailure at the
+ * AssertFailure is raised when an ASSERT check fails. Because assertions are
+ * not used in production code, are never expected to fail, and recovering from
+ * their failure is expected to be hard, they are under RuntimeException so that
+ * no one needs to list them in their throws clauses. An AssertFailure at the
  * outermost system level will result in system shutdown.
- **/
-public class AssertFailure extends RuntimeException
-{
+ * 
+ * An AssertFailure also contains a string representation of a full thread dump 
+ * for all the live threads at the moment it was thrown if the JVM supports it 
+ * and we have the right permissions. 
+ * 
+ * If the JVM doesn't have the method Thread.getAllStackTraces i.e, we are on a
+ * JVM < 1.5, or if we don't have the permissions java.lang.RuntimePermission
+ * "getStackTrace" and "modifyThreadGroup", a message saying so is stored
+ * instead.
+ * 
+ * The thread dump string is printed to System.err after the normal stack trace 
+ * when the error is thrown, and it is also directly available by getThreadDump().
+ */
+public class AssertFailure extends RuntimeException {
+    
+    private String threadDump;
+    
 	/**
 	 * This constructor takes the pieces of information
 	 * expected for each error.
@@ -47,16 +67,134 @@
 	 * the most sever error; inner errors should be providing
 	 * additional information about what went wrong.
 	 **/
-	public AssertFailure(String message, Throwable nestedError)
-	{
+	public AssertFailure(String message, Throwable nestedError) {   
 		super(message, nestedError);
+		threadDump = dumpThreads();
 	}
-
+	
+	/**
+     * This constructor takes the just the message for this error.
+     *
+     * @param message the message associated with the error.
+     **/
+	public AssertFailure(String message) {
+        super(message);
+        threadDump = dumpThreads();
+    }
+	
 	/**
 	 * This constructor expects no arguments or nested error.
 	 **/
-	public AssertFailure(String message)
-	{
-		super(message);
+	public AssertFailure() {
+		super();
+		threadDump = dumpThreads();
+	}
+	
+	/**
+	 * Returns the thread dump stored in this AssertFailure as a string.
+	 * 
+	 * @return - thread dump string.
+	 */
+	public String getThreadDump() {
+	    return threadDump;
+	}
+	
+	/**
+	 * Overrides printStackTrace() in java.lang.Throwable to include
+	 * the thread dump after the normal stack trace. 
+	 */
+	
+	public void printStackTrace() {
+	    printStackTrace(System.err);
+	}
+	
+	/**
+     * Overrides printStackTrace(PrintStream s) in java.lang.Throwable 
+     * to include the thread dump after the normal stack trace. 
+     */
+	public void printStackTrace(PrintStream s) {
+	    super.printStackTrace(s);
+	    s.println(threadDump);
+    }
+	
+	/**
+     * Overrides printStackTrace(PrintWriter s) in java.lang.Throwable 
+     * to include the thread dump after the normal stack trace. 
+     */
+	public void printStackTrace(PrintWriter s) { 
+	    super.printStackTrace(s);
+        s.println(threadDump);
+	}
+	
+	/**
+	 * Dumps stack traces for all the threads if the JVM supports it.
+	 * The result is returned as a string, ready to print.
+	 * 
+	 * If the JVM doesn't have the method Thread.getAllStackTraces 
+	 * i.e, we are on a JVM < 1.5, or  if we don't have the permissions: 
+	 * java.lang.RuntimePermission "getStackTrace" and "modifyThreadGroup",
+	 * a message saying so is returned instead. 
+	 * 
+	 * @return stack traces for all live threads as a string or an error message.
+	 */
+	private String dumpThreads() {
+	    PrintWriter p;
+	    ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+	    p = new PrintWriter(out, true);
+	    
+	    //Try to get a thread dump and deal with various situations.
+	    try {
+	        try {
+	            //This checks that we are on a jvm >= 1.5 where we 
+	            //can actually do threaddumps.
+	            Class c = Class.forName("java.lang.Thread");
+	            c.getMethod("getAllStackTraces", new Class[] {});
+	            
+	            //Then get the thread dump.
+	            c = Class.forName("org.apache.derby.shared.common.sanity.ThreadDump");
+                final Method m = c.getMethod("getStackDumpString",new Class[] {});
+                
+                String dump;
+                try {
+                    dump = (String) AccessController.doPrivileged
+                        (new PrivilegedExceptionAction(){
+                                public Object run() throws 
+                                    IllegalArgumentException, 
+                                    IllegalAccessException, 
+                                    InvocationTargetException{
+                                    return m.invoke(null, null);
+                                }
+                            }
+                         );
+                } catch (PrivilegedActionException e) {
+                    throw  e.getException();
+                }
+                //Print the dump to the message string. That went OK.
+                p.print("---------------\nStack traces for all " +
+                "live threads:");
+                p.println("\n" + dump);
+                p.println("---------------");
+	        
+	        } catch (NoSuchMethodException e) {
+	            p.println("(Skipping thread dump because it is not " +
+	            		"supported on JVM 1.4)");
+	        }
+	    } catch (Exception e){ 
+            if (e instanceof InvocationTargetException) {
+            	if (((InvocationTargetException) e).getTargetException() 
+            			instanceof AccessControlException) {
+            		p.println("(Skipping thread dump " +
+            				"because of insufficient permissions:\n" 
+            		        + e.getCause() + ")\n" );
+            	} else 
+            		((InvocationTargetException) e).getTargetException().
+            		printStackTrace(p);
+            } else {
+            	p.println("Error trying to dump thread stack traces:");
+                e.printStackTrace(p);
+            }
+        }
+	    return out.toString();
 	}
 }

Added: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/ThreadDump.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/ThreadDump.java?rev=678858&view=auto
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/ThreadDump.java
(added)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/ThreadDump.java
Tue Jul 22 11:43:27 2008
@@ -0,0 +1,50 @@
+/*
+
+   Derby - Class org.apache.derby.iapi.services.sanity.ThreadDump
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derby.shared.common.sanity;
+
+import java.util.Map;
+
+public class ThreadDump {
+
+    /**
+     * 
+     * @return A string representation of a full thread dump
+     */
+    public static String getStackDumpString() {
+        StringBuffer sb = new StringBuffer();
+        Map<Thread, StackTraceElement[]> st = Thread.getAllStackTraces();
+        for (Map.Entry<Thread, StackTraceElement[]> e : st.entrySet()) {
+            StackTraceElement[] lines = e.getValue();
+            Thread t = e.getKey();
+            sb.append("Thread name=" + t.getName() + " id=" + t.getId()
+                    + " priority=" + t.getPriority() + " state=" + t.getState()
+                    + " isdaemon=" + t.isDaemon() + "\n");
+            for (int i = 0; i < lines.length; i++) {
+                sb.append("\t" + lines[i] + "\n");
+
+            }
+            sb.append("\n");
+        }
+        return sb.toString();
+    }
+
+}

Propchange: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/sanity/ThreadDump.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=678858&r1=678857&r2=678858&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Tue Jul 22 11:43:27 2008
@@ -119,6 +119,11 @@
   permission java.util.PropertyPermission "${emma.active}user.dir", "read";
   permission java.io.FilePermission "${emma.active}${user.dir}${/}coverage.ec", "read, write";
   permission java.lang.RuntimePermission "${emma.active}writeFileDescriptor";
+  
+  // These permissions are needed by AssertFailure to dump the thread stack
+  // traces upon failure.
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
 };
 
 //
@@ -159,6 +164,11 @@
   // to create the trace files in that directory.
   permission java.util.PropertyPermission "user.dir", "read";
   permission java.io.FilePermission "${user.dir}${/}-", "read, write"; 
+  
+  // These permissions are needed by AssertFailure to dump the thread stack
+  // traces upon failure.
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
 
 };
 
@@ -204,7 +214,7 @@
   permission java.security.SecurityPermission "getPolicy";
   permission java.lang.RuntimePermission "setIO";  
 
-  // These permissions are needed by stress.multi to dump the thread stack
+  // These permissions are needed to dump the thread stack
   // traces upon failure.
   permission java.lang.RuntimePermission "getStackTrace";
   permission java.lang.RuntimePermission "modifyThreadGroup";

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java?rev=678858&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
Tue Jul 22 11:43:27 2008
@@ -0,0 +1,126 @@
+/*
+
+   Derby - Class
+   org.apache.derbyTesting.unitTests.junit.AssertFailureTest
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+package org.apache.derbyTesting.unitTests.junit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derby.iapi.services.info.JVMInfo;
+import org.apache.derby.shared.common.sanity.AssertFailure;
+import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+/**
+ * Testcase that test that AssertFailure's message string is correct when we
+ * have permisssion to do thread dumps and when we don't. Depends on the
+ * policyfiles AssertFailureTest.policy and AssertFailureTest1.policy where only
+ * the former grants this permission.
+ */
+public class AssertFailureTest extends BaseTestCase {
+
+    /**
+     * Security policy file that allows thread dumps.
+     */
+    private static String POLICY_FILENAME =
+        "org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy";
+
+    /**
+     * Security policy file that DOESN'T allow thread dumps.
+     */
+    private static String NO_DUMP_POLICY_FILENAME =
+        "org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy";
+
+    public AssertFailureTest(String name) {
+        super(name);
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("AssertFailureTest");
+
+        // Run with thread dump permissions
+        suite.addTest(new SecurityManagerSetup(new AssertFailureTest(
+            "testAssertFailureThreadDump"), POLICY_FILENAME));
+
+        // Run WITHOUT thread dump permissions
+        suite.addTest(new SecurityManagerSetup(new AssertFailureTest(
+            "testAssertFailureNoThreadDump"), NO_DUMP_POLICY_FILENAME));
+
+        return suite;
+    }
+
+    /**
+     * Test that AssertFailure's message string is correct when we have
+     * permisssion to do thread dumps. Must be run with correct permissions, ie.
+     * with java.lang.RuntimePermission "getStackTrace" and
+     * java.lang.RuntimePermission "modifyThreadGroup".
+     */
+    public void testAssertFailureThreadDump() {
+
+        String s = new AssertFailure("AssertFailureTest").getThreadDump();
+        //System.out.println(s);    //Debug failures
+
+        // Assert that the string is correct, by checking that
+        // it starts the right way.
+        if (JVMInfo.JDK_ID >= 6) {
+            String expected = "---------------\n" + 
+            		"Stack traces for all live threads:\nThread name=";
+            
+            assertTrue("String not correct. Expected to start with:\n<" 
+                + expected + ">...\nWas:\n<" + s + ">.\n" , 
+                s.startsWith(expected));
+            
+        } else {
+            String expected = "(Skipping thread dump because it is not " +
+            		"supported on JVM 1.4)";
+                        
+            assertTrue("String not correct.", s.startsWith(expected));
+        }
+    }
+
+    /**
+     * Test that AssertFailure's log entry is correct when we DON'T have
+     * permisssion to to thread dumps. Must be run with correct permissions, ie.
+     * WITHOUT java.lang.RuntimePermission "getStackTrace" and
+     * java.lang.RuntimePermission "modifyThreadGroup";
+     */
+    public void testAssertFailureNoThreadDump() {
+
+        String s = new AssertFailure("AssertFailureTest").getThreadDump();
+        //System.out.println(s);    //Debug failures.
+        
+        // Assert that the string is correct, by checking that is starts 
+        // the right way.
+        if (JVMInfo.JDK_ID >= 6) {
+            String expected = "(Skipping thread dump because of insufficient " +
+            		"permissions:";
+        
+            assertTrue("String not correct. Expected: <" + expected + 
+                ">\nWas:\n<" + s + ">", s.startsWith(expected));
+            
+        } else {
+            String expected = "(Skipping thread dump because it is not " +
+                "supported on JVM 1.4)";
+            
+            assertTrue("String not correct.", s.startsWith(expected));
+        }
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy?rev=678858&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy
Tue Jul 22 11:43:27 2008
@@ -0,0 +1,92 @@
+// Policy file with minimal set of permissions to run unit test for
+// AssertFailureTest with ThreadDump permissions.
+
+
+// The test harness sets up four variables used by this policy file
+//
+// derbyTesting.codejar - URL to the jar files when they are in the classpath
+// derbyTesting.codeclasses - URL to the classes directory when it is in the classpath
+//
+// Only one of derbyTesting.codejar and derbyTesting.codeclasses will be valid, the
+// other will be set to a bogus URL like file://unused
+//
+// derbyTesting.codedir - File location of either derbyTesting.codejar or derbyTesting.codeclasses.
+// Only required due to a BUG (see below for more info).
+//
+// derbyTesting.jaxpjar - URL to the jar file containing the JAXP implementation
+//     for XML-based tests (ex. lang/XMLBindingTest.java).
+//
+// derbyTesting.serverhost - Host name or ip where network server is started 
+// derbyTesting.clienthost - specifies the clients ip address/hostName. 
+//     when testing with networkserver on a remote host, this needs to be passed in 
+//     with the NetworkServerControl start command
+
+
+//
+// Permissions for the tests (derbyTesting.jar)
+//
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
+  // Allow tests to install and uninstall the security manager and
+  // to refresh the policy
+  permission java.util.PropertyPermission "java.security.policy", "read,write";
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.security.SecurityPermission "getPolicy";
+  
+  // derbyTesting.junit.TestConfiguration... modifies System properties
+  permission java.util.PropertyPermission "*", "read,write";
+
+  //needs to run "doAsPrivileged"
+  permission javax.security.auth.AuthPermission "doAsPrivileged";
+  
+};
+
+
+//
+// Permissions for running the test on the class files
+//
+grant codeBase "${derbyTesting.codeclasses}" {
+  // Allow tests to install and uninstall the security manager and
+  // to refresh the policy
+  permission java.util.PropertyPermission "java.security.policy", "read,write";
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.security.SecurityPermission "getPolicy";
+
+  // derbyTesting.junit.TestConfiguration... modifies System properties
+  permission java.util.PropertyPermission "*", "read,write";
+
+//These are the ones that matters:
+//-----------------------------------------------------------------------------
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
+//-----------------------------------------------------------------------------
+};
+
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+    permission java.lang.RuntimePermission "setIO";
+    
+    // This permission is needed when running the tests using ant 1.7
+    permission java.io.FilePermission "${user.dir}${/}*", "write";
+};
+
+
+grant codeBase "${derbyTesting.codejar}derby.jar" {
+//These are the ones that matters:
+//-----------------------------------------------------------------------------
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
+//-----------------------------------------------------------------------------
+};
+
+
+grant codeBase "${derbyTesting.codejar}derbyclient.jar" {
+//These are the ones that matters:
+//-----------------------------------------------------------------------------
+  permission java.lang.RuntimePermission "getStackTrace";
+  permission java.lang.RuntimePermission "modifyThreadGroup";
+//-----------------------------------------------------------------------------
+};
\ No newline at end of file

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest.policy
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy?rev=678858&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy
Tue Jul 22 11:43:27 2008
@@ -0,0 +1,69 @@
+// Policy file with minimal set of permissions to run unit test for
+// AssertFailureTest with ThreadDump permissions.
+
+
+// The test harness sets up four variables used by this policy file
+//
+// derbyTesting.codejar - URL to the jar files when they are in the classpath
+// derbyTesting.codeclasses - URL to the classes directory when it is in the classpath
+//
+// Only one of derbyTesting.codejar and derbyTesting.codeclasses will be valid, the
+// other will be set to a bogus URL like file://unused
+//
+// derbyTesting.codedir - File location of either derbyTesting.codejar or derbyTesting.codeclasses.
+// Only required due to a BUG (see below for more info).
+//
+// derbyTesting.jaxpjar - URL to the jar file containing the JAXP implementation
+//     for XML-based tests (ex. lang/XMLBindingTest.java).
+//
+// derbyTesting.serverhost - Host name or ip where network server is started 
+// derbyTesting.clienthost - specifies the clients ip address/hostName. 
+//     when testing with networkserver on a remote host, this needs to be passed in 
+//     with the NetworkServerControl start command
+
+
+//
+// Permissions for the tests (derbyTesting.jar)
+//
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
+  // Allow tests to install and uninstall the security manager and
+  // to refresh the policy
+  permission java.util.PropertyPermission "java.security.policy", "read,write";
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.security.SecurityPermission "getPolicy";
+  
+  // derbyTesting.junit.TestConfiguration... modifies System properties
+  permission java.util.PropertyPermission "*", "read,write";
+
+  //needs to run "doAsPrivileged"
+  permission javax.security.auth.AuthPermission "doAsPrivileged";
+  
+};
+
+
+//
+// Permissions for running the test on the class files
+//
+grant codeBase "${derbyTesting.codeclasses}" {
+  // Allow tests to install and uninstall the security manager and
+  // to refresh the policy
+  permission java.util.PropertyPermission "java.security.policy", "read,write";
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.security.SecurityPermission "getPolicy";
+
+  // derbyTesting.junit.TestConfiguration... modifies System properties
+  permission java.util.PropertyPermission "*", "read,write";
+
+};
+
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+    permission java.lang.RuntimePermission "setIO";
+    
+    // This permission is needed when running the tests using ant 1.7
+    permission java.io.FilePermission "${user.dir}${/}*", "write";
+};

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/AssertFailureTest1.policy
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java?rev=678858&r1=678857&r2=678858&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java Tue
Jul 22 11:43:27 2008
@@ -24,6 +24,7 @@
 import java.sql.SQLException;
 
 import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -33,7 +34,7 @@
  * org.apache.derbyTesting.unitTests.junit
  *
  */
-public class _Suite extends BaseTestCase  {
+public class _Suite extends BaseTestCase {
 
     /**
      * Use suite method instead.
@@ -51,6 +52,7 @@
         suite.addTest(SystemPrivilegesPermissionTest.suite());
         suite.addTest(UTF8UtilTest.suite());
         suite.addTestSuite(CompressedNumberTest.class);
+        suite.addTest(AssertFailureTest.suite());
 
         return suite;
     }

Modified: db/derby/code/trunk/tools/jar/dnc.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/dnc.properties?rev=678858&r1=678857&r2=678858&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/dnc.properties (original)
+++ db/derby/code/trunk/tools/jar/dnc.properties Tue Jul 22 11:43:27 2008
@@ -24,3 +24,5 @@
 #jdbc4_optional_derby.module.client.40cp=org.apache.derby.client.ClientPooledConnection40
 #jdbc4_optional_derby.module.client.40nc=org.apache.derby.client.net.NetConnection40
 #jdbc4_optional_derby.module.client.40cjof=org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40
+
+derby.module.shared.threaddump=org.apache.derby.shared.common.sanity.ThreadDump
\ No newline at end of file

Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=678858&r1=678857&r2=678858&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original)
+++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Tue Jul 22 11:43:27 2008
@@ -98,3 +98,5 @@
 derby.module.store.cpf=org.apache.derby.impl.io.CPFile
 
 derby.module.xml.sqlxmle=org.apache.derby.impl.sql.execute.SqlXmlExecutor
+
+derby.module.shared.threaddump=org.apache.derby.shared.common.sanity.ThreadDump



Mime
View raw message