001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package test.javax.management;
010:
011: import java.util.Arrays;
012: import java.util.Set;
013: import javax.management.MBeanServer;
014: import javax.management.MBeanServerFactory;
015: import javax.management.ObjectInstance;
016: import javax.management.ObjectName;
017: import javax.management.Query;
018: import javax.management.ValueExp;
019:
020: import junit.framework.TestCase;
021: import test.javax.management.support.QuerySupport;
022:
023: /**
024: * Class QueryTest, tests the query service
025: *
026: * @version $Revision: 1.10 $
027: */
028: public class QueryTest extends TestCase {
029: public QueryTest(String name) {
030: super (name);
031: }
032:
033: public void testQueryEmpty() throws Exception {
034: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
035:
036: int count = server.getMBeanCount().intValue();
037: QuerySupport.Test bean1 = new QuerySupport.Test(null, null,
038: null);
039: server.registerMBean(bean1, new ObjectName("Query:name=bean1"));
040: QuerySupport.Test bean2 = new QuerySupport.Test(null, null,
041: null);
042: server.registerMBean(bean2, new ObjectName("Query:name=bean2"));
043: QuerySupport.Test bean3 = new QuerySupport.Test(null, null,
044: null);
045: server.registerMBean(bean3, new ObjectName("Query:name=bean3"));
046: Set result = server.queryMBeans(null, null);
047: assertNotNull(result);
048: assertEquals(count + 3, result.size());
049: result = server.queryNames(null, null);
050: assertEquals(count + 3, result.size());
051: assertNotNull(result);
052: assertTrue(result.contains(new ObjectName("Query:name=bean1")));
053: assertTrue(result.contains(new ObjectName("Query:name=bean2")));
054: assertTrue(result.contains(new ObjectName("Query:name=bean3")));
055: }
056:
057: public void testStringMatch() throws Exception {
058: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
059:
060: ObjectName name1 = new ObjectName("StringMatch:name=test1");
061: ObjectName name2 = new ObjectName("StringMatch:name=test2");
062: ObjectName name3 = new ObjectName("StringMatch:name=test3");
063:
064: QuerySupport.Test a = new QuerySupport.Test("trial", null, null);
065: QuerySupport.Test b = new QuerySupport.Test("arial", null, null);
066: QuerySupport.Test c = new QuerySupport.Test("trial2", null,
067: null);
068: server.registerMBean(a, name1);
069: server.registerMBean(b, name2);
070: server.registerMBean(c, name3);
071: Set result = server.queryMBeans(null, Query.match(Query
072: .attr("Str"), Query.value("*rial")));
073: assertEquals(2, result.size());
074: result = server.queryMBeans(null, Query.match(
075: Query.attr("Str"), Query.value("[at]rial")));
076: assertEquals(1, result.size());
077: result = server.queryMBeans(null, Query.match(
078: Query.attr("Str"), Query.value("[a-z]rial")));
079: assertEquals(2, result.size());
080: result = server.queryMBeans(null, Query.match(
081: Query.attr("Str"), Query.value("[b-z]rial?")));
082: assertEquals(1, result.size());
083: }
084:
085: public void testArray() throws Exception {
086: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
087:
088: QuerySupport.Test bean1 = new QuerySupport.Test("a",
089: new Integer(0), null);
090: server.registerMBean(bean1, new ObjectName("Query:name=bean1"));
091: QuerySupport.Test bean2 = new QuerySupport.Test("b",
092: new Integer(1), null);
093: server.registerMBean(bean2, new ObjectName("Query:name=bean2"));
094: QuerySupport.Test bean3 = new QuerySupport.Test("c",
095: new Integer(2), null);
096: server.registerMBean(bean3, new ObjectName("Query:name=bean3"));
097: Set result = server.queryMBeans(null, Query.in(Query
098: .attr("Number"), new ValueExp[] { Query.value(0),
099: Query.value(1) }));
100: assertEquals(2, result.size());
101: result = server.queryMBeans(null, Query.in(Query.attr("Str"),
102: new ValueExp[] { Query.value("a"), Query.value("d") }));
103: assertEquals(1, result.size());
104: }
105:
106: public void testFinalSubString() throws Exception {
107: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
108:
109: ObjectName name1 = new ObjectName("StringMatch:name=test1");
110: ObjectName name2 = new ObjectName("StringMatch:name=test2");
111: ObjectName name3 = new ObjectName("StringMatch:name=test3");
112:
113: QuerySupport.Test a = new QuerySupport.Test("trial", null, null);
114: QuerySupport.Test b = new QuerySupport.Test("arial", null, null);
115: QuerySupport.Test c = new QuerySupport.Test("tria2l", null,
116: null);
117: server.registerMBean(a, name1);
118: server.registerMBean(b, name2);
119: server.registerMBean(c, name3);
120: Set result = server.queryMBeans(null, Query.finalSubString(
121: Query.attr("Str"), Query.value("l")));
122: assertEquals(3, result.size());
123: result = server.queryMBeans(null, Query.finalSubString(Query
124: .attr("Str"), Query.value("rial")));
125: assertEquals(2, result.size());
126: result = server.queryMBeans(null, Query.finalSubString(Query
127: .attr("Str"), Query.value("nothing")));
128: assertEquals(0, result.size());
129: }
130:
131: public void testInitialString() throws Exception {
132: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
133:
134: ObjectName name1 = new ObjectName("StringMatch:name=test1");
135: ObjectName name2 = new ObjectName("StringMatch:name=test2");
136: ObjectName name3 = new ObjectName("StringMatch:name=test3");
137:
138: QuerySupport.Test a = new QuerySupport.Test("trial", null, null);
139: QuerySupport.Test b = new QuerySupport.Test("arial", null, null);
140: QuerySupport.Test c = new QuerySupport.Test("trial2", null,
141: null);
142: server.registerMBean(a, name1);
143: server.registerMBean(b, name2);
144: server.registerMBean(c, name3);
145: Set result = server.queryMBeans(null, Query.initialSubString(
146: Query.attr("Str"), Query.value("t")));
147: assertEquals(2, result.size());
148: result = server.queryMBeans(null, Query.initialSubString(Query
149: .attr("Str"), Query.value("tr")));
150: assertEquals(2, result.size());
151: result = server.queryMBeans(null, Query.initialSubString(Query
152: .attr("Str"), Query.value("tri")));
153: assertEquals(2, result.size());
154: result = server.queryMBeans(null, Query.initialSubString(Query
155: .attr("Str"), Query.value("nothing")));
156: assertEquals(0, result.size());
157: }
158:
159: public void testMathOperations() throws Exception {
160: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
161:
162: ObjectName name1 = new ObjectName("StringMatch:name=test1");
163: ObjectName name2 = new ObjectName("StringMatch:name=test2");
164: ObjectName name3 = new ObjectName("StringMatch:name=test3");
165:
166: QuerySupport.Test a = new QuerySupport.Test(null,
167: new Integer(1), null);
168: QuerySupport.Test b = new QuerySupport.Test(null,
169: new Integer(2), null);
170: QuerySupport.Test c = new QuerySupport.Test(null,
171: new Integer(3), null);
172: server.registerMBean(a, name1);
173: server.registerMBean(b, name2);
174: server.registerMBean(c, name3);
175: Set result = server.queryMBeans(null, Query.eq(Query.value(3),
176: Query.plus(Query.attr("Number"), Query.value(1))));
177: assertEquals(1, result.size());
178: result = server.queryMBeans(null, Query.eq(Query.value(0),
179: Query.minus(Query.attr("Number"), Query.value(2))));
180: assertEquals(1, result.size());
181: result = server.queryMBeans(null, Query.eq(Query.value(0),
182: Query.times(Query.attr("Number"), Query.value(0))));
183: assertEquals(3, result.size());
184: result = server.queryMBeans(null, Query.eq(Query.value(1),
185: Query.div(Query.attr("Number"), Query.value(3))));
186: assertEquals(1, result.size());
187: }
188:
189: public void testAttribute() throws Exception {
190: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
191:
192: ObjectName name1 = new ObjectName("StringMatch:name=test1");
193: ObjectName name2 = new ObjectName("StringMatch:name=test2");
194: ObjectName name3 = new ObjectName("StringMatch:name=test3");
195:
196: QuerySupport.Test a = new QuerySupport.Test(null,
197: new Integer(1), null);
198: QuerySupport.Test b = new QuerySupport.Test(null,
199: new Integer(2), null);
200: QuerySupport.Test c = new QuerySupport.Test(null,
201: new Integer(2), null);
202: server.registerMBean(a, name1);
203: server.registerMBean(b, name2);
204: server.registerMBean(c, name3);
205: Set result = server.queryMBeans(null, Query.eq(Query.value(2),
206: Query.attr("Number")));
207: assertEquals(2, result.size());
208: result = server
209: .queryMBeans(
210: null,
211: Query
212: .eq(
213: Query.classattr(),
214: Query
215: .value("test.javax.management.support.QuerySupport$Test")));
216: assertEquals(3, result.size());
217: }
218:
219: public void testBetween() throws Exception {
220: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
221:
222: ObjectName name1 = new ObjectName("StringMatch:name=test1");
223: ObjectName name2 = new ObjectName("StringMatch:name=test2");
224: ObjectName name3 = new ObjectName("StringMatch:name=test3");
225:
226: QuerySupport.Test a = new QuerySupport.Test("a",
227: new Integer(1), null);
228: QuerySupport.Test b = new QuerySupport.Test("b",
229: new Integer(2), null);
230: QuerySupport.Test c = new QuerySupport.Test("c",
231: new Integer(5), null);
232: server.registerMBean(a, name1);
233: server.registerMBean(b, name2);
234: server.registerMBean(c, name3);
235: Set result = server.queryMBeans(null, Query.between(Query
236: .attr("Number"), Query.value(2), Query.value(3)));
237: assertEquals(1, result.size());
238: result = server.queryMBeans(null, Query.between(Query
239: .attr("Number"), Query.value(1), Query.value(3)));
240: assertEquals(2, result.size());
241: result = server.queryMBeans(null, Query.between(Query
242: .attr("Number"), Query.value(1), Query.value(5)));
243: assertEquals(3, result.size());
244: /*
245: result =
246: server.queryMBeans(null,
247: Query.between(Query.attr("Str"),
248: Query.value("a"),
249: Query.value("b")));
250: assertEquals(2, result.size());
251: result =
252: server.queryMBeans(null,
253: Query.between(Query.attr("Str"),
254: Query.value("a"),
255: Query.value("z")));
256: assertEquals(3, result.size());
257: */
258: }
259:
260: public void testRelation() throws Exception {
261: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
262:
263: ObjectName name1 = new ObjectName("StringMatch:name=test1");
264: ObjectName name2 = new ObjectName("StringMatch:name=test2");
265: ObjectName name3 = new ObjectName("StringMatch:name=test3");
266: ObjectName name4 = new ObjectName("BigNumber:name=test4");
267: ObjectName name5 = new ObjectName("BigNumber:name=test5");
268: ObjectName name6 = new ObjectName("LittleNumber:name=test6");
269:
270: QuerySupport.Test a = new QuerySupport.Test("a",
271: new Integer(1), null);
272: QuerySupport.Test b = new QuerySupport.Test("b",
273: new Integer(2), null);
274: QuerySupport.Test c = new QuerySupport.Test("c",
275: new Integer(5), null);
276: QuerySupport.Test d = new QuerySupport.Test("d", new Integer(
277: 112), null);
278: QuerySupport.DynamicTest e = new QuerySupport.DynamicTest("e",
279: 119L, null);
280: QuerySupport.DynamicTest f = new QuerySupport.DynamicTest("f",
281: 8L, null);
282:
283: server.registerMBean(a, name1);
284: server.registerMBean(b, name2);
285: server.registerMBean(c, name3);
286: server.registerMBean(d, name4);
287: server.registerMBean(e, name5);
288: server.registerMBean(f, name6);
289:
290: Set result = server.queryMBeans(null, Query.lt(Query
291: .attr("Number"), Query.value(3)));
292: assertEquals(2, result.size());
293: result = server.queryMBeans(null, Query.leq(Query
294: .attr("Number"), Query.value(5)));
295: assertEquals(3, result.size());
296: result = server.queryMBeans(new ObjectName("StringMatch:*"),
297: Query.eq(Query.attr("Str"), Query.value("a")));
298: assertEquals(1, result.size());
299: result = server.queryMBeans(new ObjectName("StringMatch:*"),
300: Query.gt(Query.attr("Number"), Query.value(2)));
301: assertEquals(1, result.size());
302: result = server.queryMBeans(null, Query.gt(Query
303: .attr("Boolean"), Query.value(2)));
304: assertEquals(0, result.size());
305: result = server.queryMBeans(new ObjectName("StringMatch:*"),
306: Query.geq(Query.attr("Number"), Query.value(2)));
307: assertEquals(2, result.size());
308: result = server.queryMBeans(new ObjectName("StringMatch:*"),
309: Query.geq(Query.attr("Str"), Query.value("a")));
310: assertEquals(3, result.size());
311: result = server.queryMBeans(null, Query.gt(
312: Query.attr("Number"), Query.value(2)));
313: assertEquals(4, result.size());
314: result = server.queryMBeans(new ObjectName("*Number:*"), Query
315: .gt(Query.attr("Number"), Query.value(100)));
316: assertEquals(2, result.size());
317: }
318:
319: public void testAnyString() throws Exception {
320: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
321:
322: ObjectName name1 = new ObjectName("StringMatch:name=test1");
323: ObjectName name2 = new ObjectName("StringMatch:name=test2");
324: ObjectName name3 = new ObjectName("StringMatch:name=test3");
325:
326: QuerySupport.Test a = new QuerySupport.Test("trial", null, null);
327: QuerySupport.Test b = new QuerySupport.Test("arial", null, null);
328: QuerySupport.Test c = new QuerySupport.Test("trial2", null,
329: null);
330: server.registerMBean(a, name1);
331: server.registerMBean(b, name2);
332: server.registerMBean(c, name3);
333: Set result = server.queryMBeans(null, Query.anySubString(Query
334: .attr("Str"), Query.value("trial")));
335: assertEquals(2, result.size());
336: result = server.queryMBeans(null, Query.anySubString(Query
337: .attr("Str"), Query.value("rial")));
338: assertEquals(3, result.size());
339: result = server.queryMBeans(null, Query.anySubString(Query
340: .attr("Str"), Query.value("tri")));
341: assertEquals(2, result.size());
342: result = server.queryMBeans(null, Query.anySubString(Query
343: .attr("Str"), Query.value("ri")));
344: assertEquals(3, result.size());
345: result = server.queryMBeans(null, Query.anySubString(Query
346: .attr("Str"), Query.value("no")));
347: assertEquals(0, result.size());
348: }
349:
350: public void testNotOperation() throws Exception {
351: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
352:
353: ObjectName name1 = new ObjectName("StringMatch:name=test1");
354:
355: QuerySupport.Test a = new QuerySupport.Test(null, null,
356: Boolean.TRUE);
357: server.registerMBean(a, name1);
358: Set result = server.queryMBeans(null, Query.not(Query.eq(Query
359: .value(false), Query.attr("Boolean"))));
360: assertEquals(1, result.size());
361: }
362:
363: public void testLogical() throws Exception {
364: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
365:
366: ObjectName name1 = new ObjectName("StringMatch:name=test1");
367: ObjectName name2 = new ObjectName("StringMatch:name=test2");
368: ObjectName name3 = new ObjectName("StringMatch:name=test3");
369:
370: QuerySupport.Test a = new QuerySupport.Test("a",
371: new Integer(1), Boolean.TRUE);
372: QuerySupport.Test b = new QuerySupport.Test("b",
373: new Integer(2), Boolean.FALSE);
374: QuerySupport.Test c = new QuerySupport.Test("c",
375: new Integer(5), Boolean.TRUE);
376: server.registerMBean(a, name1);
377: server.registerMBean(b, name2);
378: server.registerMBean(c, name3);
379: Set result = server.queryMBeans(null, Query.and(Query.eq(Query
380: .attr("Boolean"), Query.value(true)), Query.lt(Query
381: .attr("Number"), Query.value(3))));
382: assertEquals(1, result.size());
383: result = server.queryMBeans(null, Query.or(Query.eq(Query
384: .attr("Boolean"), Query.value(true)), Query.eq(Query
385: .attr("Str"), Query.value("a"))));
386: assertEquals(2, result.size());
387: result = server.queryMBeans(null, Query.or(Query.eq(Query
388: .attr("Boolean"), Query.value(true)), Query.geq(Query
389: .attr("Str"), Query.value("a"))));
390: assertEquals(3, result.size());
391: }
392:
393: public void testQualifiedAttributeName() throws Exception {
394: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
395:
396: ObjectName name1 = new ObjectName("StringMatch:name=test1");
397: ObjectName name2 = new ObjectName("StringMatch:name=test2");
398: ObjectName name3 = new ObjectName("StringMatch:name=test3");
399:
400: QuerySupport.Test a = new QuerySupport.Test("a",
401: new Integer(1), Boolean.TRUE);
402: QuerySupport.Test b = new QuerySupport.Test("b",
403: new Integer(2), Boolean.FALSE);
404: QuerySupport.Test c = new QuerySupport.Test("c",
405: new Integer(5), Boolean.TRUE);
406: server.registerMBean(a, name1);
407: server.registerMBean(b, name2);
408: server.registerMBean(c, name3);
409: Set result = server.queryMBeans(null, Query.eq(Query.attr(
410: "test.javax.management.support.QuerySupport$Test",
411: "Number"), Query.value(2)));
412: assertEquals(1, result.size());
413: result = server.queryMBeans(null, Query.eq(Query.attr(
414: "test.javax.management.support.QuerySupport.Test2",
415: "Number"), Query.value(2)));
416: assertEquals(0, result.size());
417: }
418:
419: public void testQueryScope() throws Exception {
420: MBeanServer server = MBeanServerFactory.newMBeanServer("query");
421:
422: ObjectName name1 = new ObjectName("Scope:name0=test0");
423: ObjectName name2 = new ObjectName("Scope2:name0=test0");
424: ObjectName name3 = new ObjectName("Scope:name1=test1");
425: ObjectName name4 = new ObjectName(
426: "Scope:name1=test1,name2=test2");
427: ObjectName name5 = new ObjectName(
428: "Scope:name0=test0,name1=test1,name2=test2");
429:
430: QuerySupport.Test a = new QuerySupport.Test("a",
431: new Integer(1), Boolean.TRUE);
432: QuerySupport.Test b = new QuerySupport.Test("b",
433: new Integer(2), Boolean.TRUE);
434: QuerySupport.Test c = new QuerySupport.Test("c",
435: new Integer(3), Boolean.TRUE);
436: QuerySupport.Test d = new QuerySupport.Test("d",
437: new Integer(4), Boolean.TRUE);
438: QuerySupport.Test e = new QuerySupport.Test("e",
439: new Integer(5), Boolean.TRUE);
440: server.registerMBean(a, name1);
441: server.registerMBean(b, name2);
442: server.registerMBean(c, name3);
443: server.registerMBean(d, name4);
444: server.registerMBean(e, name5);
445:
446: ObjectName scope = new ObjectName("*:*");
447:
448: int count = server.getMBeanCount().intValue();
449: Set result = server.queryMBeans(scope, null);
450: assertEquals(count, result.size());
451:
452: scope = new ObjectName("*:name0=test0");
453: result = server.queryMBeans(scope, null);
454: assertEquals(2, result.size());
455:
456: scope = new ObjectName("*:name0=test0,*");
457: result = server.queryMBeans(scope, null);
458: assertEquals(3, result.size());
459:
460: scope = new ObjectName("*:name1=test1");
461: result = server.queryMBeans(scope, null);
462: assertEquals(1, result.size());
463:
464: scope = new ObjectName("*:*,name1=test1");
465: result = server.queryMBeans(scope, null);
466: assertEquals(3, result.size());
467:
468: scope = new ObjectName("*:name1=test1,*");
469: result = server.queryMBeans(scope, null);
470: assertEquals(3, result.size());
471:
472: scope = new ObjectName("*:name2=test2");
473: result = server.queryMBeans(scope, null);
474: assertEquals(0, result.size());
475:
476: scope = new ObjectName("*:name2=test2,*");
477: result = server.queryMBeans(scope, null);
478: assertEquals(2, result.size());
479:
480: scope = new ObjectName("*:name0=test0,name2=test2");
481: result = server.queryMBeans(scope, null);
482: assertEquals(0, result.size());
483:
484: scope = new ObjectName("*:name0=test0,name2=test2,*");
485: result = server.queryMBeans(scope, null);
486: assertEquals(1, result.size());
487:
488: ObjectName[] xpnames = new ObjectName[] { name1, name2 };
489: scope = new ObjectName("S*:name0=test0");
490: result = server.queryNames(scope, null);
491: assertTrue(Arrays.asList(xpnames).containsAll(result));
492: ObjectInstance[] xpinstances = new ObjectInstance[] {
493: new ObjectInstance(name1, QuerySupport.Test.class
494: .getName()),
495: new ObjectInstance(name2, QuerySupport.Test.class
496: .getName()) };
497: result = server.queryMBeans(scope, null);
498: assertTrue(Arrays.asList(xpinstances).containsAll(result)
499: && result.size() == xpinstances.length);
500: assertEquals(2, result.size());
501:
502: scope = new ObjectName("S*:*");
503: xpnames = new ObjectName[] { name1, name2, name3, name4, name5 };
504: result = server.queryNames(scope, null);
505: assertTrue(Arrays.asList(xpnames).containsAll(result)
506: && result.size() == xpnames.length);
507: result = server.queryMBeans(scope, null);
508: xpinstances = new ObjectInstance[] {
509: new ObjectInstance(name1, QuerySupport.Test.class
510: .getName()),
511: new ObjectInstance(name2, QuerySupport.Test.class
512: .getName()),
513: new ObjectInstance(name3, QuerySupport.Test.class
514: .getName()),
515: new ObjectInstance(name4, QuerySupport.Test.class
516: .getName()),
517: new ObjectInstance(name5, QuerySupport.Test.class
518: .getName()) };
519: assertTrue(Arrays.asList(xpinstances).containsAll(result)
520: && result.size() == xpinstances.length);
521: assertEquals(5, result.size());
522:
523: scope = new ObjectName("Scope?:*");
524: xpnames = new ObjectName[] { name2 };
525: result = server.queryNames(scope, null);
526: assertTrue(Arrays.asList(xpnames).containsAll(result)
527: && result.size() == xpnames.length);
528: result = server.queryMBeans(scope, null);
529: xpinstances = new ObjectInstance[] { new ObjectInstance(name2,
530: QuerySupport.Test.class.getName()) };
531: assertTrue(Arrays.asList(xpinstances).containsAll(result)
532: && result.size() == xpinstances.length);
533: assertEquals(1, result.size());
534:
535: scope = new ObjectName("S?o?e?:*");
536: xpnames = new ObjectName[] { name2 };
537: result = server.queryNames(scope, null);
538: assertTrue(Arrays.asList(xpnames).containsAll(result)
539: && result.size() == xpnames.length);
540: result = server.queryMBeans(scope, null);
541: xpinstances = new ObjectInstance[] { new ObjectInstance(name2,
542: QuerySupport.Test.class.getName()) };
543: assertTrue(Arrays.asList(xpinstances).containsAll(result)
544: && result.size() == xpinstances.length);
545: assertEquals(1, result.size());
546:
547: scope = new ObjectName("?c*e?:*");
548: xpnames = new ObjectName[] { name2 };
549: result = server.queryNames(scope, null);
550: assertTrue(Arrays.asList(xpnames).containsAll(result)
551: && result.size() == xpnames.length);
552: result = server.queryMBeans(scope, null);
553: xpinstances = new ObjectInstance[] { new ObjectInstance(name2,
554: QuerySupport.Test.class.getName()) };
555: assertTrue(Arrays.asList(xpinstances).containsAll(result)
556: && result.size() == xpinstances.length);
557: assertEquals(1, result.size());
558: }
559:
560: public void testExceptionPropagation() throws Exception {
561: MBeanServer server = MBeanServerFactory.createMBeanServer();
562: ObjectName objname = new ObjectName(
563: "querytest:name=testExceptionPropagation");
564: QuerySupport.DynamicTest mbean = new QuerySupport.DynamicTest(
565: "xyzzy", 42L, Boolean.TRUE);
566: server.registerMBean(mbean, objname);
567: Set result = server.queryNames(null, Query.match(Query
568: .attr("Str"), Query.value("x*y")));
569: assertEquals(0, result.size());
570: result = server.queryMBeans(new ObjectName("query*:*"), Query
571: .match(Query.attr("Str"), Query.value("x*y")));
572: assertEquals(0, result.size());
573: }
574: }
|