Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 14756 invoked from network); 13 Mar 2008 18:33:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Mar 2008 18:33:23 -0000 Received: (qmail 50215 invoked by uid 500); 13 Mar 2008 18:33:20 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 50198 invoked by uid 500); 13 Mar 2008 18:33:20 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 50187 invoked by uid 99); 13 Mar 2008 18:33:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Mar 2008 11:33:20 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Mar 2008 18:32:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6113B1A9832; Thu, 13 Mar 2008 11:32:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r636824 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit: SystemPrivilegesPermissionTest.java _Suite.java Date: Thu, 13 Mar 2008 18:32:58 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080313183259.6113B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djd Date: Thu Mar 13 11:32:56 2008 New Revision: 636824 URL: http://svn.apache.org/viewvc?rev=636824&view=rev Log: Add the SystemPrivilegesPermissionTest to junit._Suite to gain coverage of the SystemPermission class. Minor refactor of the class to have seperate fixtures for the various tests, it was really already coded that way but the sub-methods were run as a single fixture. Commented out code related to DatabasePermission for two reasons: 1) DERBY-3531 DatabasePermission uses methods not in J2ME/CDC/Foundation 2) Since DatabasePermission is not used it would fail with the jar tests since it is correctly not included in any jar file. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java?rev=636824&r1=636823&r2=636824&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java Thu Mar 13 11:32:56 2008 @@ -40,7 +40,7 @@ import org.apache.derby.authentication.SystemPrincipal; import org.apache.derby.security.SystemPermission; -import org.apache.derby.security.DatabasePermission; +//import org.apache.derby.security.DatabasePermission; import org.apache.derby.iapi.util.IdUtil; import org.apache.derby.iapi.error.StandardException; @@ -135,18 +135,6 @@ { false, false, false, false, false, false, true, false }, { false, false, false, false, false, false, false, true } }; - - /** - * Add decorators to a test run to establish a security manager - * with this test's policy file. - */ - static private Test decorateTest(String method) { - final Test undecorated = new SystemPrivilegesPermissionTest(method); - - // install a security manager using this test's policy file - return new SecurityManagerSetup(undecorated, POLICY_FILE_NAME); - } - /** * Create a test with the given name. @@ -163,38 +151,24 @@ * @throws Exception */ public static Test suite() { - //final TestSuite ts - // = new TestSuite("SystemPrivilegesPermissionTest suite"); - //ts.addTest(decorateTest("testSystemPrivileges")); - //return ts; - return decorateTest("testSystemPrivileges"); + TestSuite suite = new TestSuite( + SystemPrivilegesPermissionTest.class, + "SystemPrivilegesPermissionTest"); + return new SecurityManagerSetup(suite, POLICY_FILE_NAME); } /** * Test case that does a check of the XXX */ - public void testSystemPrivileges() throws IOException { - println(""); - println("testing System Privileges ..."); + public void testIsSecurityManager() { assertSecurityManager(); - execute(); - println("testing System Privileges: done."); - println(""); - } + } - /** - * Tests SystemPermissions. - */ - public void execute() throws IOException { - checkSystemPrincipal(); - checkSystemPermission(); - checkDatabasePermission(); - } /** * Tests SystemPrincipal. */ - private void checkSystemPrincipal() throws IOException { + public void testSystemPrincipal() { // test SystemPrincipal with null name argument try { new SystemPrincipal(null); @@ -215,7 +189,7 @@ /** * Tests SystemPermission. */ - private void checkSystemPermission() throws IOException { + public void testSystemPermission() { // test SystemPermission with null name argument try { new SystemPermission(null, null); @@ -278,7 +252,9 @@ /** * Tests DatabasePermission. */ - private void checkDatabasePermission() throws IOException { + + public void XXtestDatabasePermission() throws IOException { + /********************************************* // test DatabasePermission with null url try { new DatabasePermission(null, DatabasePermission.CREATE); @@ -302,7 +278,8 @@ } catch (IllegalArgumentException ex) { // expected exception } - +***********************************************/ + // this test's commented out because it's platform-dependent // (no reliable way to make it pass on Unix) // test DatabasePermission with non-canonicalizable URL @@ -315,7 +292,7 @@ //} catch (IOException ex) { // // expected exception //} - +/********************************************** // test DatabasePermission with null actions try { new DatabasePermission("directory:dir", null); @@ -462,6 +439,7 @@ DatabasePermission.CREATE); execute(anyUser, new CreateDatabaseAction(dbPerm), true); +***********************************************/ } /** @@ -493,6 +471,7 @@ /** * Tests DatabasePermission.getName() and .getActions(). */ +/************88 private void checkNameAndActions(DatabasePermission[] dbperm, String[] dbpath) throws IOException { @@ -505,18 +484,19 @@ DatabasePermission.CREATE, dbp.getActions()); } } +***************/ /** * Tests DatabasePermission.hashCode() and .equals(). */ - private void checkHashCodeAndEquals(DatabasePermission[] dbp0, - DatabasePermission[] dbp1) + private void checkHashCodeAndEquals(Permission[] dbp0, + Permission[] dbp1) throws IOException { //assert(dbp0.length == dbp1.length) for (int i = 0; i < dbp0.length; i++) { - final DatabasePermission p0 = dbp0[i]; + final Permission p0 = dbp0[i]; for (int j = 0; j < dbp0.length; j++) { - final DatabasePermission p1 = dbp1[j]; + final Permission p1 = dbp1[j]; if (i == j) { assertTrue(p0.hashCode() == p1.hashCode()); assertTrue(p0.equals(p1)); @@ -531,14 +511,14 @@ /** * Tests DatabasePermission.implies(). */ - private void checkImplies(DatabasePermission[] dbp0, - DatabasePermission[] dbp1, + private void checkImplies(Permission[] dbp0, + Permission[] dbp1, boolean[][] impls) throws IOException { for (int i = 0; i < dbp0.length; i++) { - final DatabasePermission p0 = dbp0[i]; + final Permission p0 = dbp0[i]; for (int j = 0; j < dbp1.length; j++) { - final DatabasePermission p1 = dbp1[j]; + final Permission p1 = dbp1[j]; assertEquals("test: " + p0 + ".implies" + p1, impls[i][j], p0.implies(p1)); //assertEquals("test: " + p1 + ".implies" + p0, 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=636824&r1=636823&r2=636824&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 Thu Mar 13 11:32:56 2008 @@ -47,7 +47,7 @@ TestSuite suite = new TestSuite("JUnit unit tests"); suite.addTest(FormatableBitSetTest.suite()); - //suite.addTest(SystemPrivilegesPermissionTest.suite()); + suite.addTest(SystemPrivilegesPermissionTest.suite()); suite.addTest(UTF8UtilTest.suite()); return suite;