From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18186 invoked by alias); 20 Feb 2006 12:34:15 -0000 Received: (qmail 18176 invoked by uid 22791); 20 Feb 2006 12:34:14 -0000 X-Spam-Check-By: sourceware.org Received: from gbenson.demon.co.uk (HELO gbenson.demon.co.uk) (80.177.220.214) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 20 Feb 2006 12:34:13 +0000 Received: from slippy.wire.rat ([192.168.1.1]) by gbenson.demon.co.uk with esmtp (Exim 3.36 #1) id 1FBAF0-0006s2-00 for mauve-patches@sources.redhat.com; Mon, 20 Feb 2006 12:34:10 +0000 Received: from slippy.wire.rat (localhost.localdomain [127.0.0.1]) by slippy.wire.rat (8.13.1/8.13.1) with ESMTP id k1KCYA4s006349 for ; Mon, 20 Feb 2006 12:34:10 GMT Received: (from gary@localhost) by slippy.wire.rat (8.13.1/8.13.1/Submit) id k1KCYA8f006348 for mauve-patches@sources.redhat.com; Mon, 20 Feb 2006 12:34:10 GMT Date: Mon, 20 Feb 2006 12:34:00 -0000 From: Gary Benson To: mauve-patches@sources.redhat.com Subject: FYI: java.lang.ThreadGroup throwpoint tests Message-ID: <20060220123408.GF5477@redhat.com> Mail-Followup-To: mauve-patches@sources.redhat.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OgqxwSJOaUobr8KG" Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2006/txt/msg00155.txt.bz2 --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 85 Hi all, This commit adds throwpoint checks for java.lang.ThreadGroup. Cheers, Gary --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-length: 7957 Index: ChangeLog =================================================================== RCS file: /cvs/mauve/mauve/ChangeLog,v retrieving revision 1.1487 diff -u -r1.1487 ChangeLog --- ChangeLog 20 Feb 2006 11:30:23 -0000 1.1487 +++ ChangeLog 20 Feb 2006 11:55:23 -0000 @@ -1,3 +1,7 @@ +2006-02-20 Gary Benson + + * gnu/testlet/java/lang/ThreadGroup/security.java: New test. + 2006-02-20 Robert Schuster * gnu/testlet/javax/swing/text/PlainDocument/remove.java: Index: gnu/testlet/java/lang/ThreadGroup/security.java =================================================================== RCS file: gnu/testlet/java/lang/ThreadGroup/security.java diff -N gnu/testlet/java/lang/ThreadGroup/security.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/java/lang/ThreadGroup/security.java 20 Feb 2006 11:55:23 -0000 @@ -0,0 +1,249 @@ +// Copyright (C) 2006 Red Hat, Inc. +// Written by Gary Benson + +// This file is part of Mauve. + +// Mauve is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2, or (at your option) +// any later version. + +// Mauve is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Mauve; see the file COPYING. If not, write to +// the Free Software Foundation, 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + +package gnu.testlet.java.lang.ThreadGroup; + +import java.security.Permission; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; +import gnu.testlet.TestSecurityManager2; + +public class security implements Testlet +{ + public void test(TestHarness harness) + { + try { + harness.checkPoint("setup"); + + ThreadGroup testGroup = Thread.currentThread().getThreadGroup(); + if (testGroup.getParent() == null) + testGroup = new ThreadGroup(testGroup, "test group"); + harness.check(testGroup.getParent() != null); + + Permission[] modifyThreadGroup = new Permission[] { + new RuntimePermission("modifyThreadGroup")}; + + Permission[] modifyThread = new Permission[] { + new RuntimePermission("modifyThread")}; + + Permission[] stopThread = new Permission[] { + new RuntimePermission("modifyThread"), + new RuntimePermission("stopThread")}; + + TestSecurityManager2 sm = new TestSecurityManager2(harness); + try { + sm.install(); + + // throwpoint: java.lang.ThreadGroup-ThreadGroup(String) + harness.checkPoint("ThreadGroup(String)"); + try { + sm.prepareChecks(modifyThreadGroup); + new ThreadGroup("test"); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-ThreadGroup(ThreadGroup, String) + harness.checkPoint("ThreadGroup(ThreadGroup, String)"); + try { + sm.prepareChecks(modifyThreadGroup); + new ThreadGroup(testGroup, "test"); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-checkAccess + harness.checkPoint("checkAccess"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.checkAccess(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-enumerate(Thread[]) + harness.checkPoint("enumerate(Thread[])"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.enumerate(new Thread[0]); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-enumerate(Thread[], boolean) + harness.checkPoint("enumerate(Thread[], boolean)"); + for (int i = 0; i <= 1; i++) { + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.enumerate(new Thread[0], i == 1); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + } + + // throwpoint: java.lang.ThreadGroup-enumerate(ThreadGroup[]) + harness.checkPoint("enumerate(ThreadGroup[])"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.enumerate(new ThreadGroup[0]); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-enumerate(ThreadGroup[], boolean) + harness.checkPoint("enumerate(ThreadGroup[], boolean)"); + for (int i = 0; i <= 1; i++) { + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.enumerate(new ThreadGroup[0], i == 1); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + } + + // throwpoint: java.lang.ThreadGroup-getParent + harness.checkPoint("getParent"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.getParent(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-setDaemon + harness.checkPoint("setDaemon"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.setDaemon(false); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-setMaxPriority + harness.checkPoint("setMaxPriority"); + try { + int priority = testGroup.getMaxPriority(); + sm.prepareChecks(modifyThreadGroup); + testGroup.setMaxPriority(priority); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-suspend + harness.checkPoint("suspend"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.suspend(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-resume + harness.checkPoint("resume"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.resume(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-destroy + harness.checkPoint("destroy"); + try { + sm.prepareChecks(modifyThreadGroup); + testGroup.destroy(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-interrupt + harness.checkPoint("interrupt"); + try { + sm.prepareChecks(modifyThreadGroup, modifyThread); + testGroup.interrupt(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + + // throwpoint: java.lang.ThreadGroup-stop + harness.checkPoint("stop"); + try { + sm.prepareChecks(modifyThreadGroup, stopThread); + testGroup.stop(); + sm.checkAllChecked(harness); + } + catch (SecurityException ex) { + harness.debug(ex); + harness.check(false, "unexpected check"); + } + } + finally { + sm.uninstall(); + } + } + catch (Throwable ex) { + harness.debug(ex); + harness.check(false, "Unexpected exception"); + } + } +} --OgqxwSJOaUobr8KG--