From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27871 invoked by alias); 5 Mar 2007 00:38:11 -0000 Received: (qmail 27852 invoked by uid 22791); 5 Mar 2007 00:38:05 -0000 X-Spam-Check-By: sourceware.org Received: from smtp801.mail.ird.yahoo.com (HELO smtp801.mail.ird.yahoo.com) (217.146.188.61) by sourceware.org (qpsmtpd/0.31) with SMTP; Mon, 05 Mar 2007 00:37:56 +0000 Received: (qmail 27823 invoked from network); 5 Mar 2007 00:37:54 -0000 Received: from unknown (HELO orthanc.middle-earth.co.uk) (hughes2002@btinternet.com@86.141.74.206 with plain) by smtp801.mail.ird.yahoo.com with SMTP; 5 Mar 2007 00:37:53 -0000 X-YMail-OSG: PMUQB.0VM1kwDU3F4qpAH6Y.IA__7WYR8X3I5LnOrSs80fzBFgQxVEDFchBS5h4uskcavCOblJv9WbKtapjdxyXXMvly1HwP5623MrB8kWz1YbVDXBSoFvOc4hmTIbm509j..6KxLNNMwYOjhz795aHjhCwC.df0 Received: from rivendell.middle-earth.co.uk ([192.168.0.1] helo=localhost.localdomain ident=gandalf) by orthanc.middle-earth.co.uk with smtp (Exim 4.63) (envelope-from ) id 1HO1Cd-000281-2o for mauve-patches@sources.redhat.com; Mon, 05 Mar 2007 00:37:24 +0000 Received: by localhost.localdomain (sSMTP sendmail emulation); Mon, 05 Mar 2007 00:37:50 +0000 From: "Andrew John Hughes" Date: Mon, 05 Mar 2007 00:38:00 -0000 To: mauve-patches@sources.redhat.com Subject: FYI: MBeanServerInvocationHandler and MBeanPermission tests Message-ID: <20070305003750.GA4407@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CUfgB8w4ZwR/yMy5" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes Mailing-List: contact mauve-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-patches-owner@sourceware.org X-SW-Source: 2007/txt/msg00014.txt.bz2 --CUfgB8w4ZwR/yMy5 Content-Type: multipart/mixed; boundary="tThc/1wpZn/ma/RB" Content-Disposition: inline --tThc/1wpZn/ma/RB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1303 This patch adds tests for MBeanServerInvocationHandler and MBeanServerPermission. Changelog: 2007-03-05 Andrew John Hughes * gnu/testlet/javax/management/MBeanServerInvocationHandler/Colour.java: Test enumeration. * gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.jav= a: Test for proxying. * gnu/testlet/javax/management/MBeanServerInvocationHandler/Test.java: Implementation of TestMBean. * gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java: Implementation of TestCMXBean. * gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.ja= va: Interface for an MXBean for conversion testing.=09 * gnu/testlet/javax/management/MBeanServerInvocationHandler/TestMBean.java: Interface for a test bean. * gnu/testlet/javax/management/MBeanServerInvocationHandler/TestX.java: Implementation of TestXMBean. * gnu/testlet/javax/management/MBeanServerInvocationHandler/TestXMBean.jav= a: Interface for a test bean that extends Object's methods. * gnu/testlet/javax/management/MBeanServerPermission/Constructor.java: Test for MBeanServerPermission. --=20 Andrew :-) Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... } --tThc/1wpZn/ma/RB Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="management-01.diff" Content-Transfer-Encoding: quoted-printable Content-length: 26823 Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/Colour.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/Colour.= java diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/Colour.ja= va --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/Colour.java 5= Mar 2007 00:31:51 -0000 @@ -0,0 +1,27 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +public enum Colour +{ + RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET; +} Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanPr= oxy.java diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProx= y.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.ja= va 5 Mar 2007 00:31:51 -0000 @@ -0,0 +1,149 @@ +// Tags: JDK1.5 + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +import gnu.testlet.TestHarness; +import gnu.testlet.Testlet; + +import java.lang.management.ManagementFactory; + +import java.lang.reflect.Proxy; + +import javax.management.JMX; +import javax.management.MalformedObjectNameException; +import javax.management.MBeanServer; +import javax.management.ObjectName; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +/** + * Tests {@link MBeanServerInvocationHandler} + * for MBeans. + * + * @author Andrew John Hughes= + */ +public class MBeanProxy + implements Testlet +{ +=20=20 + public void test(TestHarness h) + { + ObjectName name =3D null; + ObjectName namex =3D null; + ObjectName namec =3D null; + try + { + name =3D new ObjectName("mauve:test=3Dgo"); + namex =3D new ObjectName("mauve:test=3Dgox"); + namec =3D new ObjectName("mauve:test=3Dgoc"); + } + catch (MalformedObjectNameException e) + { + h.debug(e); + } + MBeanServer server =3D ManagementFactory.getPlatformMBeanServer(); + try + { + server.registerMBean(new Test("GNU Classpath"), name); + server.registerMBean(new TestX("GNU Classpath"), namex); + server.registerMBean(new TestC(), namec); + } + catch (Exception e) + { + h.debug(e); + } + TestMBean test =3D JMX.newMBeanProxy(server, name, TestMBean.class); + h.check(test.getName(), "GNU Classpath", "Name test"); + h.check(test.isEdible(), false, "Edible test"); + h.checkPoint("Mutator test"); + test.setName("Mauve"); + h.check(test.getName(), "Mauve", "Name test after change"); + h.check(test.equals(test), "Proxy equivalence reflection test"); + TestXMBean testx =3D JMX.newMBeanProxy(server, namex, TestXMBean.class= ); + h.checkPoint("Calling equals"); + testx.equals(null); + h.check(testx.getLastMethodCalled(), "equals"); + h.checkPoint("Calling hashCode"); + testx.hashCode(); + h.check(testx.getLastMethodCalled(), "hashCode"); + h.checkPoint("Calling toString"); + testx.toString(); + h.check(testx.getLastMethodCalled(), "toString"); + TestCMXBean testc =3D JMX.newMXBeanProxy(server, namec, TestCMXBean.cl= ass); + h.checkPoint("Setting id"); + testc.setId(42); + h.check(testc.getId(), 42, "Getting id"); + h.checkPoint("Setting size"); + testc.setSize(5); + h.check(testc.getSize() =3D=3D 5, "Getting size"); + h.checkPoint("Setting name"); + testc.setName(namec); + h.check(testc.getName(), namec, "Getting name"); + h.checkPoint("Setting weights"); + float[] weights =3D new float[] { 0.5f, -0.7f }; + testc.setWeights(weights); + h.check(testc.getWeights(), weights, "Getting weights"); + h.checkPoint("Setting names"); + String[] names =3D new String[] { "Bob", "Jim", "Jake" }; + testc.setNames(names); + h.check(testc.getNames(), names, "Getting names"); + h.checkPoint("Setting ages"); + Set ages =3D new HashSet(); + ages.add(45); + ages.add(24); + testc.setAges(ages); + h.check(testc.getAges(), ages, "Getting ages"); + h.checkPoint("Setting biscuits"); + SortedSet biscuits =3D new TreeSet(); + biscuits.add("Chocolate"); + biscuits.add("Ginger"); + biscuits.add("Plain"); + testc.setBiscuits(biscuits); + h.check(testc.getBiscuits(), biscuits, "Getting biscuits"); + h.checkPoint("Setting colour"); + testc.setColour(Colour.RED); + h.check(testc.getColour(), Colour.RED, "Getting colour"); + h.checkPoint("Setting phone numbers"); + Map numbers =3D new HashMap(); + numbers.put("Bob",999); + numbers.put("Jim",111); + numbers.put("Sam",55); + testc.setPhoneNumbers(numbers); + h.check(testc.getPhoneNumbers(), numbers, "Getting phone numbers"); + h.checkPoint("Setting sorted phone numbers"); + SortedMap snumbers =3D new TreeMap(); + snumbers.put("Bob",999); + snumbers.put("Jim",111); + snumbers.put("Sam",55); + testc.setSortedPhoneNumbers(snumbers); + h.check(testc.getSortedPhoneNumbers(), numbers, "Getting sorted phone = numbers"); + } + +} + Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/Test.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/Test.ja= va diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/Test.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/Test.java 5 M= ar 2007 00:31:51 -0000 @@ -0,0 +1,55 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +/** + * Test bean implementation for proxying. + * + * @author Andrew John Hughes= + */ +public class Test + implements TestMBean +{ +=20=20 + private String name; + + public Test(String name) + { + setName(name); + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name =3D name; + } + + public boolean isEdible() + { + return false; + } + +} Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.j= ava diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java 5 = Mar 2007 00:31:51 -0000 @@ -0,0 +1,159 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +import javax.management.ObjectName; + +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; + +/** + * Test {@link javax.management.MXBean} implementation for proxying. + * + * @author Andrew John Hughes= + */ +public class TestC + implements TestCMXBean +{ +=20=20 + private int id; + + private Integer size; + + private ObjectName name; + + private float[] weights; + + private String[] names; + + private Set ages; + + private SortedSet biscuits; + + private Colour colour; + + private Map numbers; + + private SortedMap sortedNumbers; + + public int getId() + { + return id; + } + + public void setId(int id) + { + this.id =3D id; + } + + public Integer getSize() + { + return size; + } + + public void setSize(Integer size) + { + this.size =3D size; + } + + public ObjectName getName() + { + return name; + } + + public void setName(ObjectName name) + { + this.name =3D name; + } +=20=20 + public float[] getWeights() + { + return weights; + } + + public void setWeights(float[] weights) + { + this.weights =3D weights; + } + + public String[] getNames() + { + return names; + } + + public void setNames(String[] names) + { + this.names =3D names; + } + + public Set getAges() + { + return ages; + } + + public void setAges(Set ages) + { + this.ages =3D ages; + } + + public SortedSet getBiscuits() + { + return biscuits; + } + + public void setBiscuits(SortedSet biscuits) + { + this.biscuits =3D biscuits; + } + + public Colour getColour() + { + return colour; + } + + public void setColour(Colour colour) + { + this.colour =3D colour; + } + + public Map getPhoneNumbers() + { + return numbers; + } + + public void setPhoneNumbers(Map numbers) + { + this.numbers =3D numbers; + } + + public SortedMap getSortedPhoneNumbers() + { + return sortedNumbers; + } + + public void setSortedPhoneNumbers(SortedMap numbers) + { + sortedNumbers =3D numbers; + } +} Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBea= n.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMX= Bean.java diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBe= an.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.j= ava 5 Mar 2007 00:31:51 -0000 @@ -0,0 +1,78 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +import javax.management.ObjectName; + +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; + +/** + * Test {@link javax.management.MXBean} for proxying. + * + * @author Andrew John Hughes= + */ +public interface TestCMXBean +{ +=20=20 + int getId(); + + void setId(int id); + + Integer getSize(); + + void setSize(Integer size); + + ObjectName getName(); + + void setName(ObjectName name); +=20=20 + float[] getWeights(); + + void setWeights(float[] weights); + + String[] getNames(); + + void setNames(String[] names); + + Set getAges(); + + void setAges(Set ages); + + SortedSet getBiscuits(); + + void setBiscuits(SortedSet biscuits); + + Colour getColour(); + + void setColour(Colour colour); + + Map getPhoneNumbers(); + + void setPhoneNumbers(Map numbers); + + SortedMap getSortedPhoneNumbers(); + + void setSortedPhoneNumbers(SortedMap numbers); +} Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestMBean.= java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestMBe= an.java diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/TestMBean= .java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestMBean.jav= a 5 Mar 2007 00:31:52 -0000 @@ -0,0 +1,40 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +import javax.management.MBeanServerInvocationHandler; + +/** + * Test bean for proxying. + * + * @author Andrew John Hughes= + */ +public interface TestMBean +{ +=20=20 + String getName(); + + void setName(String name); + + boolean isEdible(); + +} Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestX.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestX.j= ava diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/TestX.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestX.java 5 = Mar 2007 00:31:52 -0000 @@ -0,0 +1,69 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +/** + * Test bean implementation for proxying. + * + * @author Andrew John Hughes= + */ +public class TestX + extends Test + implements TestXMBean +{ + + private String lastMethodCalled; + + public TestX(String name) + { + super(name); + } + + public boolean equals(Object obj) + { + lastMethodCalled =3D "equals"; + return false; + } + + public int hashCode() + { + lastMethodCalled =3D "hashCode"; + return 42; + } + + public String getLastMethodCalled() + { + return lastMethodCalled; + } + + public String toString() + { + lastMethodCalled =3D "toString"; + return getClass().getName() + + "[name=3D" + getName() + + ",isEdible=3D" + isEdible() + + ",lastMethodCalled=3D" + lastMethodCalled + + "]"; + } +=20=20=20=20 + +} Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestXMBean= .java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestXMB= ean.java diff -N gnu/testlet/javax/management/MBeanServerInvocationHandler/TestXMBea= n.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestXMBean.ja= va 5 Mar 2007 00:31:52 -0000 @@ -0,0 +1,43 @@ +// Tags: not-a-test + +// Copyright (C) 2007 Andrew John Hughes + +// 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.javax.management.MBeanServerInvocationHandler; + +import javax.management.MBeanServerInvocationHandler; + +/** + * Test bean for proxying. + * + * @author Andrew John Hughes= + */ +public interface TestXMBean + extends TestMBean +{ +=20=20 + boolean equals(Object obj); + + int hashCode(); + + String getLastMethodCalled(); + + String toString(); + +} Index: gnu/testlet/javax/management/MBeanServerPermission/Constructor.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: gnu/testlet/javax/management/MBeanServerPermission/Constructor.ja= va diff -N gnu/testlet/javax/management/MBeanServerPermission/Constructor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/MBeanServerPermission/Constructor.java 5 M= ar 2007 00:31:52 -0000 @@ -0,0 +1,177 @@ +// Tags: JDK1.5 + +// Copyright (C) 2006 Andrew John Hughes + +// 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.javax.management.MBeanServerPermission; + +import gnu.testlet.TestHarness; +import gnu.testlet.Testlet; + +import javax.management.MBeanServerPermission; + +/** + * Tests creation of an + * {@link MBeanServerPermission}. + * + * @author Andrew John Hughes= + */ +public class Constructor + implements Testlet +{ +=20=20 + public void test(TestHarness h) + { + Exception caught =3D null; + + // Check null name throws NullPointerException + try + { + new MBeanServerPermission(null); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught instanceof NullPointerException, "Null name"); +=20=20=20 + caught =3D null; + // Check "*" is a valid name + try + { + new MBeanServerPermission("*"); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught, null, "* is valid"); +=20=20=20=20 + // Check valid values are allowed + String[] valid =3D new String[] { "createMBeanServer", "newMBeanServer= ", + "findMBeanServer", "releaseMBeanServer" }; + // 1 + for (int a =3D 0; a < valid.length; ++a) + { + caught =3D null; + try + { + new MBeanServerPermission(valid[a]); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught, null, valid[a] + " is valid"); + }=20 + // 2 + for (int a =3D 0; a < valid.length; ++a) + for (int b =3D 0; b < valid.length; ++b) + { + caught =3D null; + String permit =3D valid[a] + "," + valid[b]; + try + { + new MBeanServerPermission(permit); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught, null, permit + " is valid"); + }=20 + // 3 + for (int a =3D 0; a < valid.length; ++a) + for (int b =3D 0; b < valid.length; ++b) + for (int c =3D 0; c < valid.length; ++c) + { + caught =3D null; + String permit =3D valid[a] + "," + valid[b] + "," + valid[c]; + try + { + new MBeanServerPermission(permit); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught, null, permit + " is valid"); + }=20 + // 4 + for (int a =3D 0; a < valid.length; ++a) + for (int b =3D 0; b < valid.length; ++b) + for (int c =3D 0; c < valid.length; ++c) + for (int d =3D 0; d < valid.length; ++d) + { + caught =3D null; + String permit =3D valid[a] + "," + valid[b] + "," + valid[c] + + "," + valid[d]; + try + { + new MBeanServerPermission(permit); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught, null, permit + " is valid"); + } +=20=20=20=20 + caught =3D null; + // Check with spaces + try + { + new MBeanServerPermission(" createMBeanServer , newMBeanServer "); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught, null, "spaces are valid"); + + caught =3D null; + // Check random stuff gets thrown out + try + { + new MBeanServerPermission("fjafjlskjflka"); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught instanceof IllegalArgumentException, + "other names are invalid"); +=20=20=20=20 + caught =3D null; + // Check non-null non-empty actions are caught + try + { + new MBeanServerPermission("*","fishcakes"); + } + catch (Exception ex) + { + caught =3D ex; + } + h.check(caught instanceof IllegalArgumentException, + "non-null non-empty actions are invalid"); + + } + +} + --tThc/1wpZn/ma/RB-- --CUfgB8w4ZwR/yMy5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline Content-length: 189 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFF62ZeAQUyfTZIWfoRArLUAJ9YDcVCW5ON3gTupJ+2cD/G4rT5UQCePavT u0fHVCaoJ1J0qlFazciE130= =3UsA -----END PGP SIGNATURE----- --CUfgB8w4ZwR/yMy5--