* FYI: ArrayType tests
@ 2007-03-11 22:22 Andrew John Hughes
0 siblings, 0 replies; only message in thread
From: Andrew John Hughes @ 2007-03-11 22:22 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1.1: Type: text/plain, Size: 1141 bytes --]
This adds a set of tests for ArrayType.
Changelog:
2007-03-11 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/testlet/javax/management/openmbean/ArrayType/Constructor1.java:
New test for the first constructor.
* gnu/testlet/javax/management/openmbean/ArrayType/Constructor2.java:
New test for the second constructor.
* gnu/testlet/javax/management/openmbean/ArrayType/Equals.java:
New test for equals(Object).
* gnu/testlet/javax/management/openmbean/ArrayType/GetArrayType.java:
New test for getArrayType(OpenType).
* gnu/testlet/javax/management/openmbean/ArrayType/GetPrimitiveArrayType.java:
New test for getPrimitiveArrayType(Class).
* gnu/testlet/javax/management/openmbean/ArrayType/HashCode.java:
New test for hashCode().
* gnu/testlet/javax/management/openmbean/ArrayType/IsPrimitiveArray.java:
New test for isPrimitiveArray().
* gnu/testlet/javax/management/openmbean/ArrayType/IsValue.java:
New test for isValue().
--
Andrew :-)
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
[-- Attachment #1.2: management-02.diff --]
[-- Type: text/x-diff, Size: 27974 bytes --]
Index: gnu/testlet/javax/management/openmbean/ArrayType/Constructor1.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/Constructor1.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/Constructor1.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/Constructor1.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,155 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularType;
+
+/**
+ * Tests {@link ArrayType(int,javax.management.openmbean.OpenType} constructor.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class Constructor1
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ try
+ {
+ ArrayType type = new ArrayType(0, SimpleType.INTEGER);
+ h.fail("Didn't catch dimensions < 1");
+ }
+ catch (IllegalArgumentException e)
+ {
+ h.check(true, "Threw exception for dimensions of 0");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ try
+ {
+ ArrayType type = new ArrayType(-1, SimpleType.INTEGER);
+ h.fail("Didn't catch dimensions < 1");
+ }
+ catch (IllegalArgumentException e)
+ {
+ h.check(true, "Threw exception for dimensions of -1");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ try
+ {
+ h.checkPoint("1-dimensional String array");
+ ArrayType type = new ArrayType(1, SimpleType.STRING);
+ h.check(type.getClassName(), "[Ljava.lang.String;");
+ h.check(type.getTypeName(), "[Ljava.lang.String;");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.String");
+ h.check(type.getDescription(), "1-dimension array of java.lang.String");
+ h.checkPoint("2-dimensional String array");
+ ArrayType type2 = new ArrayType(2, SimpleType.STRING);
+ h.check(type2.getClassName(), "[[Ljava.lang.String;");
+ h.check(type2.getTypeName(), "[[Ljava.lang.String;");
+ h.check(type2.getElementOpenType().getClassName(), "java.lang.String");
+ h.check(type2.getDescription(), "2-dimension array of java.lang.String");
+ h.checkPoint("4-dimensional String array (one constructor)");
+ ArrayType type3 = new ArrayType(4, SimpleType.STRING);
+ h.check(type3.getClassName(), "[[[[Ljava.lang.String;");
+ h.check(type3.getTypeName(), "[[[[Ljava.lang.String;");
+ h.check(type3.getElementOpenType().getClassName(), "java.lang.String");
+ h.check(type3.getDescription(), "4-dimension array of java.lang.String");
+ h.checkPoint("4-dimensional String array (two constructors)");
+ ArrayType type4 = new ArrayType(2, type2);
+ h.check(type4.getClassName(), "[[[[Ljava.lang.String;");
+ h.check(type4.getTypeName(), "[[[[Ljava.lang.String;");
+ h.check(type4.getElementOpenType().getClassName(), "java.lang.String");
+ h.check(type4.getDescription(), "4-dimension array of java.lang.String");
+ h.checkPoint("Composite Type Array");
+ CompositeType ctype = new CompositeType("Test","Test",new String[]{"name"},
+ new String[]{"Name"},
+ new OpenType[] { SimpleType.STRING});
+ ArrayType type5 = new ArrayType(1, ctype);
+ String className = CompositeData.class.getName();
+ h.check(type5.getClassName(), "[L" + className + ";");
+ h.check(type5.getTypeName(), "[L" + className + ";");
+ h.check(type5.getElementOpenType().getClassName(), className);
+ h.check(type5.getDescription(), "1-dimension array of " + className);
+ h.checkPoint("Tabular Type Array");
+ TabularType ttype = new TabularType("Test","Test",ctype,new String[]{"name"});
+ ArrayType type6 = new ArrayType(1, ttype);
+ className = TabularData.class.getName();
+ h.check(type6.getClassName(), "[L" + className + ";");
+ h.check(type6.getTypeName(), "[L" + className + ";");
+ h.check(type6.getElementOpenType().getClassName(), className);
+ h.check(type6.getDescription(), "1-dimension array of " + className);
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ try
+ {
+ ArrayType type = new ArrayType(-1, new OpenType("Mauve","Mauve","Mauve")
+ {
+ public boolean equals(Object obj)
+ {
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return 42;
+ }
+
+ public boolean isValue(Object obj)
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return "Mauve";
+ }
+ });
+ h.fail("Didn't catch our own OpenType");
+ }
+ catch (OpenDataException e)
+ {
+ h.check(true, "Threw exception for invalid OpenType");
+ }
+
+ }
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/Constructor2.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/Constructor2.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/Constructor2.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/Constructor2.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,82 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Tests {@link ArrayType} constructor
+ * for 1-dimensional simple arrays.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class Constructor2
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ try
+ {
+ ArrayType type = new ArrayType(SimpleType.STRING, true);
+ h.fail("Non-primitive type allowed.");
+ }
+ catch (OpenDataException e)
+ {
+ h.check(true, "Exception thrown for primitive array with non-primitive type");
+ }
+ try
+ {
+ h.checkPoint("Primitive integer array");
+ ArrayType type = new ArrayType(SimpleType.INTEGER, true);
+ h.check(type.getClassName(), "[I");
+ h.check(type.getTypeName(), "[I");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "1-dimension array of int");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ try
+ {
+ h.checkPoint("String array");
+ ArrayType type = new ArrayType(SimpleType.STRING, false);
+ h.check(type.getClassName(), "[Ljava.lang.String;");
+ h.check(type.getTypeName(), "[Ljava.lang.String;");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.String");
+ h.check(type.getDescription(), "1-dimension array of java.lang.String");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+
+ }
+
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/Equals.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/Equals.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/Equals.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/Equals.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,63 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Tests {@link ArrayType#equals(Object)}.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class Equals
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ArrayType type = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(type.equals(type), "Reflection test");
+ h.check(type.equals(type), "Consistency test");
+ ArrayType type2 = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(type.equals(type2), "Equality over creation test");
+ h.check(type2.equals(type), "Symmetric test");
+ ArrayType type3 = null;
+ try
+ {
+ type3 = new ArrayType(SimpleType.INTEGER, true);
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ h.check(type2.equals(type3), "Equality over different creation test");
+ h.check(type.equals(type3), "Transitivity test");
+ h.check(!type.equals(null), "Null test");
+ }
+
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/GetArrayType.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/GetArrayType.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/GetArrayType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/GetArrayType.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,87 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Tests {@link ArrayType#getArrayType(OpenType)}
+ * for 1-dimensional simple arrays.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class GetArrayType
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ArrayType type = null;
+ try
+ {
+ h.checkPoint("1-dimensional integer array");
+ type = ArrayType.getArrayType(SimpleType.INTEGER);
+ h.check(type.getClassName(), "[Ljava.lang.Integer;");
+ h.check(type.getTypeName(), "[Ljava.lang.Integer;");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "1-dimension array of java.lang.Integer");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ try
+ {
+ h.checkPoint("2-dimensional integer array");
+ type = ArrayType.getArrayType(type);
+ h.check(type.getClassName(), "[[Ljava.lang.Integer;");
+ h.check(type.getTypeName(), "[[Ljava.lang.Integer;");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "2-dimension array of java.lang.Integer");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ try
+ {
+ h.checkPoint("3-dimensional integer array");
+ type = ArrayType.getArrayType(type);
+ h.check(type.getClassName(), "[[[Ljava.lang.Integer;");
+ h.check(type.getTypeName(), "[[[Ljava.lang.Integer;");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "3-dimension array of java.lang.Integer");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+
+ }
+
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/GetPrimitiveArrayType.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/GetPrimitiveArrayType.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/GetPrimitiveArrayType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/GetPrimitiveArrayType.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,84 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Tests {@link ArrayType#getPrimitiveArrayType(OpenType)}
+ * for 1-dimensional simple arrays.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class GetPrimitiveArrayType
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ArrayType type = null;
+ h.checkPoint("1-dimensional integer array");
+ type = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(type.getClassName(), "[I");
+ h.check(type.getTypeName(), "[I");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "1-dimension array of int");
+ h.checkPoint("2-dimensional integer array");
+ type = ArrayType.getPrimitiveArrayType(int[][].class);
+ h.check(type.getClassName(), "[[I");
+ h.check(type.getTypeName(), "[[I");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "2-dimension array of int");
+ h.checkPoint("3-dimensional integer array");
+ type = ArrayType.getPrimitiveArrayType(int[][][].class);
+ h.check(type.getClassName(), "[[[I");
+ h.check(type.getTypeName(), "[[[I");
+ h.check(type.getElementOpenType().getClassName(), "java.lang.Integer");
+ h.check(type.getDescription(), "3-dimension array of int");
+ try
+ {
+ ArrayType.getPrimitiveArrayType(int.class);
+ h.fail("int.class allowed.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ h.check(true, "Exception thrown for int.class");
+ }
+ try
+ {
+ ArrayType.getPrimitiveArrayType(String.class);
+ h.fail("String.class allowed.");
+ }
+ catch (IllegalArgumentException e)
+ {
+ h.check(true, "Exception thrown for String.class");
+ }
+
+ }
+
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/HashCode.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/HashCode.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/HashCode.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/HashCode.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,61 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.SimpleType;
+
+/**
+ * Tests {@link ArrayType#hashCode()}.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class HashCode
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ArrayType type = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(type.hashCode(), type.hashCode(), "Reflection test");
+ h.check(type.hashCode(), type.hashCode(), "Consistency test");
+ ArrayType type2 = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(type.hashCode(), type2.hashCode(), "Equality over creation test");
+ ArrayType type3 = null;
+ try
+ {
+ type3 = new ArrayType(SimpleType.INTEGER, true);
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ h.check(type3.hashCode(), type2.hashCode(), "Equality over different creation test");
+ h.check(type.hashCode(), type3.hashCode(), "Transitivity test");
+ }
+
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/IsPrimitiveArray.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/IsPrimitiveArray.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/IsPrimitiveArray.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/IsPrimitiveArray.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,80 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularType;
+
+/**
+ * Tests {@link ArrayType#isPrimitiveArray()}.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class IsPrimitiveArray
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ArrayType type1 = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(type1.isPrimitiveArray(), "int[] true check");
+ try
+ {
+ ArrayType type2 = new ArrayType(SimpleType.INTEGER, true);
+ h.check(type2.isPrimitiveArray(), "Wrapped masked true check");
+ ArrayType type3 = new ArrayType(SimpleType.INTEGER, false);
+ h.check(!type3.isPrimitiveArray(), "Wrapped not masked false check");
+ ArrayType type4 = new ArrayType(1, SimpleType.INTEGER);
+ h.check(!type4.isPrimitiveArray(), "Normal wrapped false check");
+ ArrayType type5 = new ArrayType(1, SimpleType.STRING);
+ h.check(!type5.isPrimitiveArray(), "String false check");
+ CompositeType ctype = new CompositeType("Test","Test",new String[]{"name"},
+ new String[]{"Name"},
+ new OpenType[] { SimpleType.STRING});
+ ArrayType type6 = new ArrayType(1, ctype);
+ h.check(!type6.isPrimitiveArray(), "Composite type false check");
+ TabularType ttype = new TabularType("Test","Test",ctype,new String[]{"name"});
+ ArrayType type7 = new ArrayType(1, ttype);
+ h.check(!type7.isPrimitiveArray(), "Tabular type false check");
+ ArrayType type8 = new ArrayType(1, type1);
+ h.check(type8.isPrimitiveArray(), "Carry through true check");
+ ArrayType type9 = new ArrayType(1, type2);
+ h.check(type9.isPrimitiveArray());
+ ArrayType type10 = new ArrayType(1, type3);
+ h.check(!type10.isPrimitiveArray(), "Carry through false check");
+
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+ }
+
+
+}
Index: gnu/testlet/javax/management/openmbean/ArrayType/IsValue.java
===================================================================
RCS file: gnu/testlet/javax/management/openmbean/ArrayType/IsValue.java
diff -N gnu/testlet/javax/management/openmbean/ArrayType/IsValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/management/openmbean/ArrayType/IsValue.java 11 Mar 2007 22:17:19 -0000
@@ -0,0 +1,83 @@
+// Tags: JDK1.5
+
+// 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.
+
+package gnu.testlet.javax.management.openmbean.ArrayType;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+/**
+ * Tests {@link ArrayType#isValue(Object)}.
+ *
+ * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a>
+ */
+public class IsValue
+ implements Testlet
+{
+
+ public void test(TestHarness h)
+ {
+ ArrayType type = ArrayType.getPrimitiveArrayType(int[].class);
+ h.check(!type.isValue(null), "Null value check");
+ h.check(!type.isValue(3), "Non-array value check");
+ h.check(type.isValue(new int[]{3}), "Primitive int array value check");
+ h.check(!type.isValue(new Integer[]{3}), "Integer array value check");
+ try
+ {
+ CompositeType ctype = new CompositeType("Test","Test",new String[]{"name"},
+ new String[]{"Name"},
+ new OpenType[] { SimpleType.STRING});
+ Map<String,String> data = new HashMap<String,String>();
+ data.put("name", "Bob");
+ CompositeData cdata = new CompositeDataSupport(ctype, data);
+ CompositeData[] cdataarr = new CompositeData[] { cdata };
+ ArrayType type2 = new ArrayType(1, ctype);
+ h.check(type2.isValue(cdataarr), "Composite data check");
+ TabularType ttype = new TabularType("Test","Test",ctype,new String[]{"name"});
+ TabularData tdata = new TabularDataSupport(ttype);
+ tdata.put(cdata);
+ TabularData[] tdataarr = new TabularData[] {tdata};
+ ArrayType type3 = new ArrayType(1, ttype);
+ h.check(type3.isValue(tdataarr), "Tabular data check");
+ }
+ catch (OpenDataException e)
+ {
+ h.debug(e);
+ }
+
+ }
+
+
+}
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-03-11 22:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-11 22:22 FYI: ArrayType tests Andrew John Hughes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).