From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5550 invoked by alias); 9 Apr 2007 21:47:27 -0000 Received: (qmail 5539 invoked by uid 22791); 9 Apr 2007 21:47:24 -0000 X-Spam-Check-By: sourceware.org Received: from smtp813.mail.ird.yahoo.com (HELO smtp813.mail.ird.yahoo.com) (217.146.188.73) by sourceware.org (qpsmtpd/0.31) with SMTP; Mon, 09 Apr 2007 22:47:19 +0100 Received: (qmail 51948 invoked from network); 9 Apr 2007 21:47:17 -0000 Received: from unknown (HELO orthanc.middle-earth.co.uk) (hughes2002@btinternet.com@86.141.74.206 with plain) by smtp813.mail.ird.yahoo.com with SMTP; 9 Apr 2007 21:47:16 -0000 X-YMail-OSG: C7h55EsVM1l6cnFs8uEGyh6n7XEGtbmZJzDM05.7miThUEjhR7OR0274vZqjXkx8xVv24BnAwNDTUh8Ng5C8XGDUnzbT.Zqs7Ik9fOvt8TbkNgvdoxHM8CYEUd4- 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 1Hb1h6-0002dQ-NL for mauve-patches@sources.redhat.com; Mon, 09 Apr 2007 22:46:37 +0100 Received: by localhost.localdomain (sSMTP sendmail emulation); Mon, 09 Apr 2007 22:47:11 +0100 From: "Andrew John Hughes" Date: Mon, 09 Apr 2007 21:47:00 -0000 To: mauve-patches@sources.redhat.com Subject: FYI: More ObjectName tests Message-ID: <20070409214710.GA11572@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GID0FwUMdk1T2AWN" 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/msg00022.txt.bz2 --GID0FwUMdk1T2AWN Content-Type: multipart/mixed; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 465 More parsing of 1.5 names and application of 1.6 queries. Changelog: 2007-04-07 Andrew John Hughes * gnu/testlet/javax/management/ObjectName/applyJDK6.java: Application tests for 1.6. * gnu/testlet/javax/management/ObjectName/Parsing.java: More parse tests for 1.5. --=20 Andrew :-) Escape the Java Trap with GNU Classpath! http://www.gnu.org/philosophy/java-trap.html public class gcj extends Freedom implements Java { ... } --xHFwDpU9dbj6ez1V Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="management-05.diff" Content-Transfer-Encoding: quoted-printable Content-length: 15512 Index: gnu/testlet/javax/management/ObjectName/Parsing.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: /cvs/mauve/mauve/gnu/testlet/javax/management/ObjectName/Parsing.= java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Parsing.java --- gnu/testlet/javax/management/ObjectName/Parsing.java 7 Apr 2007 11:31:1= 2 -0000 1.1 +++ gnu/testlet/javax/management/ObjectName/Parsing.java 9 Apr 2007 21:39:0= 4 -0000 @@ -31,32 +31,303 @@ public class Parsing implements Testlet { public void test(TestHarness h) { + ObjectName name; try { h.checkPoint("Default name"); - ObjectName name =3D new ObjectName("*:*"); + name =3D new ObjectName("*:*"); h.check(true); + h.check(name.isDomainPattern(), true); + h.check(name.isPropertyPattern(), true); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "*"); + h.check(name.getKeyPropertyListString(), ""); h.checkPoint("Mixed keys and wildcards"); name =3D new ObjectName("jboss.management.local:j2eeType=3DServiceModule,*,name= =3Djbossmq-httpil.sar"); h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), true); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "jboss.management.local"); + h.check(name.getKeyPropertyListString(), "j2eeType=3DServiceModule,name= =3Djbossmq-httpil.sar"); h.checkPoint("Match any domain with specific keys"); name =3D new ObjectName("*:library=3DClasspath,project=3DGNU"); h.check(true); + h.check(name.isDomainPattern(), true); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "*"); + h.check(name.getCanonicalKeyPropertyListString(), "library=3DClasspath,pr= oject=3DGNU"); + h.check(name.getKeyPropertyListString(), "library=3DClasspath,project=3DG= NU"); h.checkPoint("Match any domain with specific keys and wildcard at end"); name =3D new ObjectName("*:library=3DClasspath,project=3DGNU,*"); h.check(true); + h.check(name.isDomainPattern(), true); + h.check(name.isPropertyPattern(), true); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "*"); + h.check(name.getKeyPropertyListString(), "library=3DClasspath,project=3DG= NU"); + h.checkPoint("Match any domain beginning with 'fs' with specific keys"); + name =3D new ObjectName("fs?:library=3DClasspath,project=3DGNU"); + h.check(true); + h.check(name.isDomainPattern(), true); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "fs?"); + h.check(name.getKeyPropertyListString(), "library=3DClasspath,project=3DG= NU"); + h.checkPoint("Match any domain beginning with 'fs' with specific keys " + + "and wildcard at end"); + name =3D new ObjectName("fs?:library=3DClasspath,project=3DGNU,*"); + h.check(true); + h.check(name.isDomainPattern(), true); + h.check(name.isPropertyPattern(), true); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "fs?"); + h.check(name.getKeyPropertyListString(), "library=3DClasspath,project=3DG= NU"); h.checkPoint("Match the FSF domain with specific keys and wildcard at end= "); name =3D new ObjectName("fsf:library=3DClasspath,project=3DGNU,*"); h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), true); + h.check(name.isPattern(), true); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyPropertyListString(), "library=3DClasspath,project=3DG= NU"); h.checkPoint("Match the FSF domain with specific keys"); name =3D new ObjectName("fsf:library=3DClasspath,project=3DGNU"); h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyPropertyListString(), "library=3DClasspath,project=3DG= NU"); + h.checkPoint("Match the FSF domain with specific keys and quoted values"); + name =3D new ObjectName("fsf:library=3D\"Classpath\",project=3DGNU"); + h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyProperty("library"), "\"Classpath\""); + h.check(name.getKeyPropertyListString(), "library=3D\"Classpath\",project= =3DGNU"); + h.checkPoint("Match the FSF domain with specific keys and quoted values w= ith "+ + "escaped quote"); + name =3D new ObjectName("fsf:library=3D\"Class\\\"path\",project=3DGNU"); + h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyProperty("library"), "\"Class\\\"path\""); + h.check(name.getKeyPropertyListString(), "library=3D\"Class\\\"path\",pro= ject=3DGNU"); + h.checkPoint("Match the FSF domain with specific keys and quoted values w= ith "+ + "escaped newline"); + name =3D new ObjectName("fsf:library=3D\"Class\\npath\",project=3DGNU"); + h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyProperty("library"), "\"Class\\npath\""); + h.check(name.getKeyPropertyListString(), "library=3D\"Class\\npath\",proj= ect=3DGNU"); + h.checkPoint("Match the FSF domain with specific keys and quoted values w= ith "+ + "escaped backslash"); + name =3D new ObjectName("fsf:library=3D\"Class\\\\path\",project=3DGNU"); + h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyProperty("library"), "\"Class\\\\path\""); + h.check(name.getKeyPropertyListString(), "library=3D\"Class\\\\path\",pro= ject=3DGNU"); + h.checkPoint("Match the FSF domain with space preservation"); + name =3D new ObjectName("fsf: library =3D Classpath "); + h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getKeyProperty(" library "), " Classpath "); + h.check(name.getKeyPropertyListString(), " library =3D Classpath "); + h.checkPoint("Key ordering"); + name =3D new ObjectName("fsf:project=3DGNU,library=3DClasspath"); + h.check(true); + h.check(name.isDomainPattern(), false); + h.check(name.isPropertyPattern(), false); + h.check(name.isPattern(), false); + h.check(name.getDomain(), "fsf"); + h.check(name.getCanonicalKeyPropertyListString(), "library=3DClasspath,pr= oject=3DGNU"); + h.check(name.getKeyPropertyListString(), "project=3DGNU,library=3DClasspa= th"); } catch (MalformedObjectNameException e) { h.debug(e); + h.check(false); + } + try + { + name =3D new ObjectName("fsf:lib,rary=3DClasspath,project=3DGNU"); + h.fail("Comma allowed in key name"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Comma in key name caught"); + } + try + { + name =3D new ObjectName("fsf:lib=3Drary=3DClasspath,project=3DGNU"); + h.fail("Equals allowed in key name"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Equals in key name caught"); + } + try + { + name =3D new ObjectName("fsf:lib:rary=3DClasspath,project=3DGNU"); + h.fail("Colon allowed in key name"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Colon in key name caught"); + } + try + { + name =3D new ObjectName("fsf:lib*rary=3DClasspath,project=3DGNU"); + h.fail("Asterisk allowed in key name"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Asterisk in key name caught"); + } + try + { + name =3D new ObjectName("fsf:lib?rary=3DClasspath,project=3DGNU"); + h.fail("Question mark allowed in key name"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Question mark in key name caught"); + } + try + { + name =3D new ObjectName("fsf:library=3DClasspath,library=3DSun,project=3D= GNU"); + h.fail("Duplicate key allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Duplicate key caught"); + } + try + { + name =3D new ObjectName("fsf:library=3DClas,path,project=3DGNU"); + h.fail("Comma allowed in unquoted value"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Comma in unquoted value caught"); + } + try + { + name =3D new ObjectName("fsf:library=3DClas=3Dpath,project=3DGNU"); + h.fail("Equals allowed in unquoted value"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Equals in unquoted value caught"); + } + try + { + name =3D new ObjectName("fsf:library=3DClas:path,project=3DGNU"); + h.fail("Colon allowed in unquoted value"); } + catch (MalformedObjectNameException e) + { + h.check(true, "Colon in unquoted value caught"); + } + try + { + name =3D new ObjectName("fsf:library=3DClas\"path,project=3DGNU"); + h.fail("Quote allowed in unquoted value"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Quote in unquoted value caught"); + } + try + { + name =3D new ObjectName("fsf:library=3D\"Classpath,project=3DGNU"); + h.fail("Unclosed quotes allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Unclosed quotes caught"); + } + try + { + name =3D new ObjectName("fsf:library=3D\"Class\"path\",project=3DGNU"); + h.debug(name.getKeyProperty("library")); + h.fail("Unescaped quote allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Unescaped quote caught"); + } + try + { + name =3D new ObjectName("fsf:"); + h.fail("Non-pattern with no keys allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Non-pattern with no keys caught"); + } + try + { + name =3D new ObjectName("fsf:*,*"); + h.fail("Pattern with multiple asterisks in properties allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Pattern with multiple asterisks in properties caught"); + } + try + { + name =3D new ObjectName("f\nsf:library=3DClasspath"); + h.fail("Domain with newline allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Domain with newline caught"); + } + try + { + name =3D new ObjectName("fsf:lib\nrary=3DClasspath"); + h.fail("Key with newline allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Key with newline caught"); + } + try + { + name =3D new ObjectName("fsf:library=3DClass\npath"); + h.fail("Unquoted value with newline allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Unquoted value with newline caught"); + } + try + { + name =3D new ObjectName("fsf:library=3D\"Class\npath\""); + h.fail("Quoted value with newline allowed"); + } + catch (MalformedObjectNameException e) + { + h.check(true, "Quoted value with newline caught"); + } + } } =20 Index: gnu/testlet/javax/management/ObjectName/applyJDK6.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/ObjectName/applyJDK6.java diff -N gnu/testlet/javax/management/ObjectName/applyJDK6.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/testlet/javax/management/ObjectName/applyJDK6.java 9 Apr 2007 21:39= :04 -0000 @@ -0,0 +1,106 @@ +// Copyright (C) 2007 Red Hat, Inc. +// Written by Gary Benson +// Adapted for additional JDK6 tests. +// 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. + +// Tags: JDK1.6 + +package gnu.testlet.javax.management.ObjectName; + +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + +import gnu.testlet.Testlet; +import gnu.testlet.TestHarness; + +public class applyJDK6 implements Testlet +{ + private String[] domains =3D new String[] { + "mauve", "m?uve", "*ve", "*au*", "m?*e", "mauv?", "m*v*", "*"}; + + private boolean domainMatches(String a, String b) + { + // XXX This is very hacky. The spec says that nothing matches + // a pattern. And all the patterns here match the non-pattern. + return !b.contains("?") && !b.contains("*"); + } + + private String[] properties =3D new String[] { + "foo=3Db?r", "foo=3Db?r,spam=3Deggs", "spam=3Deggs,foo=3Db?r", "foo=3D= b?r,*", + "foo=3Db*", "foo=3Db*,spam=3Deggs", "spam=3Deggs,foo=3Db*", "foo=3Db*,= *", + "foo=3D\"b?r\"", "foo=3D\"b?r\",spam=3Deggs", "spam=3Deggs,foo=3D\"b?r= \"", "foo=3D\"b?r\",*", + "foo=3D\"b*\"", "foo=3D\"b*\",spam=3Deggs", "spam=3Deggs,foo=3D\"b*\""= , "foo=3D\"b*\",*" + }; + + private boolean propertyMatches(String a, String b) + { + // Again, nothing matches a pattern. + if (b.contains("*") || b.contains("?")) + return false; + // All the patterns here match the non-patterns. + if (a.contains("*") || a.contains("?")) + return true; + // If they're the same length then they match (XXX hacky) + return a.length() =3D=3D b.length(); + } + + public void test(TestHarness harness) + { + for (int ida =3D 0; ida < domains.length; ida++) + { + for (int idb =3D 0; idb < domains.length; idb++) + { + for (int ipa =3D 0; ipa < properties.length; ipa++) + { + for (int ipb =3D 0; ipb < properties.length; ipb++) + { + String da =3D domains[ida]; + String db =3D domains[idb]; + boolean dm =3D domainMatches(da, db); + + String pa =3D properties[ipa]; + String pb =3D properties[ipb]; + boolean pm =3D propertyMatches(pa, pb); + + String sa =3D da + ":" + pa; + String sb =3D db + ":" + pb; + boolean expect =3D dm && pm; + + try + { + ObjectName ona =3D new ObjectName(sa); + ObjectName onb =3D new ObjectName(sb); +=09=09=20=20=20=20 + harness.check(ona.apply(onb) =3D=3D expect, + sa + " should" + + (expect ? "" : " not") + + " match " + sb); + } + catch (MalformedObjectNameException e) + { + harness.check(false); + harness.debug(e); + } + } + } + } + } + } +} --xHFwDpU9dbj6ez1V-- --GID0FwUMdk1T2AWN 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) iD8DBQFGGrReAQUyfTZIWfoRAp4bAKCLYx6dN3z4dPoTDPnfF+mjffnBfwCfQiN5 3AaVRHP4Fg1ZAWd6zXZpiE0= =Txch -----END PGP SIGNATURE----- --GID0FwUMdk1T2AWN--