1 // Tags: JDK1.5 |
|
2 |
|
3 // Copyright (C) 2007 Andrew John Hughes <gnu_andrew@member.fsf.org> |
|
4 |
|
5 // This file is part of Mauve. |
|
6 |
|
7 // Mauve is free software; you can redistribute it and/or modify |
|
8 // it under the terms of the GNU General Public License as published by |
|
9 // the Free Software Foundation; either version 2, or (at your option) |
|
10 // any later version. |
|
11 |
|
12 // Mauve is distributed in the hope that it will be useful, |
|
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 // GNU General Public License for more details. |
|
16 |
|
17 // You should have received a copy of the GNU General Public License |
|
18 // along with Mauve; see the file COPYING. If not, write to |
|
19 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
20 // Boston, MA 02111-1307, USA. |
|
21 |
|
22 package gnu.testlet.javax.management.openmbean.ArrayType; |
|
23 |
|
24 import gnu.testlet.TestHarness; |
|
25 import gnu.testlet.Testlet; |
|
26 |
|
27 import java.util.HashMap; |
|
28 import java.util.Map; |
|
29 |
|
30 import javax.management.openmbean.ArrayType; |
|
31 import javax.management.openmbean.CompositeData; |
|
32 import javax.management.openmbean.CompositeDataSupport; |
|
33 import javax.management.openmbean.CompositeType; |
|
34 import javax.management.openmbean.OpenDataException; |
|
35 import javax.management.openmbean.OpenType; |
|
36 import javax.management.openmbean.SimpleType; |
|
37 import javax.management.openmbean.TabularData; |
|
38 import javax.management.openmbean.TabularDataSupport; |
|
39 import javax.management.openmbean.TabularType; |
|
40 |
|
41 /** |
|
42 * Tests {@link ArrayType#isValue(Object)}. |
|
43 * |
|
44 * @author <a href="mailto:gnu_andrew@member.fsf.org">Andrew John Hughes</a> |
|
45 */ |
|
46 public class IsValue |
|
47 implements Testlet |
|
48 { |
|
49 |
|
50 public void test(TestHarness h) |
|
51 { |
|
52 ArrayType type = ArrayType.getPrimitiveArrayType(int[].class); |
|
53 h.check(!type.isValue(null), "Null value check"); |
|
54 h.check(!type.isValue(3), "Non-array value check"); |
|
55 h.check(type.isValue(new int[]{3}), "Primitive int array value check"); |
|
56 h.check(!type.isValue(new Integer[]{3}), "Integer array value check"); |
|
57 try |
|
58 { |
|
59 CompositeType ctype = new CompositeType("Test","Test",new String[]{"name"}, |
|
60 new String[]{"Name"}, |
|
61 new OpenType[] { SimpleType.STRING}); |
|
62 Map<String,String> data = new HashMap<String,String>(); |
|
63 data.put("name", "Bob"); |
|
64 CompositeData cdata = new CompositeDataSupport(ctype, data); |
|
65 CompositeData[] cdataarr = new CompositeData[] { cdata }; |
|
66 ArrayType type2 = new ArrayType(1, ctype); |
|
67 h.check(type2.isValue(cdataarr), "Composite data check"); |
|
68 TabularType ttype = new TabularType("Test","Test",ctype,new String[]{"name"}); |
|
69 TabularData tdata = new TabularDataSupport(ttype); |
|
70 tdata.put(cdata); |
|
71 TabularData[] tdataarr = new TabularData[] {tdata}; |
|
72 ArrayType type3 = new ArrayType(1, ttype); |
|
73 h.check(type3.isValue(tdataarr), "Tabular data check"); |
|
74 } |
|
75 catch (OpenDataException e) |
|
76 { |
|
77 h.debug(e); |
|
78 } |
|
79 |
|
80 } |
|
81 |
|
82 |
|
83 } |
|