This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: Tests for ObjectName parsing


This adds tests to handle various ObjectNames and their
initial construction.  A separate set of tests is used
for 1.6 format names (with wildcard values).

It also updates the MXBean tests to account for nested
MXBeans.

Changelog:

2007-04-07  Andrew John Hughes  <gnu_andrew@member.fsf.org>

	* gnu/testlet/javax/management/ObjectName/Parsing.java:
	Parse tests for 1.5.
	* gnu/testlet/javax/management/ObjectName/ParsingJDK6.java:
	Parse tests for 1.6.
	* gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.java:
	Add MXBean conversion tests.
	* gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java:
	Likewise.
	* gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.java:
	Likewise.

-- 
Andrew :-)

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.java,v
retrieving revision 1.2
diff -u -3 -p -u -r1.2 MBeanProxy.java
--- gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.java	30 Mar 2007 21:46:38 -0000	1.2
+++ gnu/testlet/javax/management/MBeanServerInvocationHandler/MBeanProxy.java	7 Apr 2007 11:22:23 -0000
@@ -56,11 +56,13 @@ public class MBeanProxy
     ObjectName name = null;
     ObjectName namex = null;
     ObjectName namec = null;
+    ObjectName namecc = null;
     try
       {
 	name = new ObjectName("mauve:test=go");
 	namex = new ObjectName("mauve:test=gox");
 	namec = new ObjectName("mauve:test=goc");
+	namecc = new ObjectName("mauve:test=gocc");
       }
     catch (MalformedObjectNameException e)
       {
@@ -94,7 +96,7 @@ public class MBeanProxy
     h.checkPoint("Calling toString");
     testx.toString();
     h.check(testx.getLastMethodCalled(), "toString");
-    TestCMXBean testc = JMX.newMXBeanProxy(server, namec, TestCMXBean.class);
+    final TestCMXBean testc = JMX.newMXBeanProxy(server, namec, TestCMXBean.class);
     h.checkPoint("Setting id");
     testc.setId(42);
     h.check(testc.getId(), 42, "Getting id");
@@ -142,6 +144,22 @@ public class MBeanProxy
     snumbers.put("Sam",55);
     testc.setSortedPhoneNumbers(snumbers);
     h.check(testc.getSortedPhoneNumbers(), numbers, "Getting sorted phone numbers");
+    h.checkPoint("Creating and setting child");
+    ChildMXBean child = new ChildMXBean() {
+	public TestCMXBean getParent() { return testc; }
+	public void setParent(TestCMXBean bean) { }
+      };
+    try
+      {
+	server.registerMBean(child, namecc);
+      }
+    catch (Exception e)
+      {
+	h.debug(e);
+      }
+    ChildMXBean cproxy = JMX.newMXBeanProxy(server, namecc, ChildMXBean.class);
+    testc.setChild(cproxy);
+    h.check(testc.getChild(), cproxy, "Getting child"); 
   }
 
 }
Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 TestC.java
--- gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java	5 Mar 2007 00:38:21 -0000	1.1
+++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestC.java	7 Apr 2007 11:22:23 -0000
@@ -57,6 +57,8 @@ public class TestC
 
   private SortedMap<String, Integer> sortedNumbers;
 
+  private ChildMXBean child;
+
   public int getId()
   {
     return id;
@@ -156,4 +158,15 @@ public class TestC
   {
     sortedNumbers = numbers;
   }
+
+  public ChildMXBean getChild()
+  {
+    return child;
+  }
+
+  public void setChild(ChildMXBean child)
+  {
+    this.child = child;
+  }
+
 }
Index: gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.java,v
retrieving revision 1.1
diff -u -3 -p -u -r1.1 TestCMXBean.java
--- gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.java	5 Mar 2007 00:38:21 -0000	1.1
+++ gnu/testlet/javax/management/MBeanServerInvocationHandler/TestCMXBean.java	7 Apr 2007 11:22:23 -0000
@@ -75,4 +75,9 @@ public interface TestCMXBean
   SortedMap<String, Integer> getSortedPhoneNumbers();
 
   void setSortedPhoneNumbers(SortedMap<String, Integer> numbers);
+
+  ChildMXBean getChild();
+
+  void setChild(ChildMXBean bean);
+
 }
Index: gnu/testlet/javax/management/ObjectName/Parsing.java
===================================================================
RCS file: gnu/testlet/javax/management/ObjectName/Parsing.java
diff -N gnu/testlet/javax/management/ObjectName/Parsing.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/ObjectName/Parsing.java	7 Apr 2007 11:22:23 -0000
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+// 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.5
+
+package gnu.testlet.javax.management.ObjectName;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import gnu.testlet.Testlet;
+import gnu.testlet.TestHarness;
+
+public class Parsing implements Testlet
+{
+  public void test(TestHarness h)
+  {
+    try
+      {
+	h.checkPoint("Default name");
+	ObjectName name = new ObjectName("*:*");
+	h.check(true);
+	h.checkPoint("Mixed keys and wildcards");
+	name =
+	  new ObjectName("jboss.management.local:j2eeType=ServiceModule,*,name=jbossmq-httpil.sar");
+	h.check(true);
+	h.checkPoint("Match any domain with specific keys");
+	name = new ObjectName("*:library=Classpath,project=GNU");
+	h.check(true);
+	h.checkPoint("Match any domain with specific keys and wildcard at end");
+	name = new ObjectName("*:library=Classpath,project=GNU,*");
+	h.check(true);
+	h.checkPoint("Match the FSF domain with specific keys and wildcard at end");
+	name = new ObjectName("fsf:library=Classpath,project=GNU,*");
+	h.check(true);
+	h.checkPoint("Match the FSF domain with specific keys");
+	name = new ObjectName("fsf:library=Classpath,project=GNU");
+	h.check(true);
+      }
+    catch (MalformedObjectNameException e)
+      {
+	h.debug(e);
+      }
+  }
+}
+
Index: gnu/testlet/javax/management/ObjectName/ParsingJDK6.java
===================================================================
RCS file: gnu/testlet/javax/management/ObjectName/ParsingJDK6.java
diff -N gnu/testlet/javax/management/ObjectName/ParsingJDK6.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/ObjectName/ParsingJDK6.java	7 Apr 2007 11:22:23 -0000
@@ -0,0 +1,52 @@
+// Copyright (C) 2007 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+// 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 ParsingJDK6 implements Testlet
+{
+  public void test(TestHarness h)
+  {
+    try
+      {
+	h.checkPoint("Match the FSF domain with specific keys and ? in value");
+	ObjectName name = new ObjectName("fsf:library=Classpath,project=?NU");
+	h.check(true);
+	h.checkPoint("Match the FSF domain with specific keys and * in value");
+	name = new ObjectName("fsf:library=Classpath,project=*");
+	h.check(true);
+	h.checkPoint("Match the FSF domain with specific keys and quoted * in value");
+	name = new ObjectName("fsf:library=Classpath,project=\"*\"");
+	h.check(true);
+      }
+    catch (MalformedObjectNameException e)
+      {
+	h.debug(e);
+      }
+  }
+}
+

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]