4
4
import static org .junit .Assert .assertNotNull ;
5
5
import static org .junit .Assert .assertNull ;
6
6
import static org .junit .Assert .assertTrue ;
7
+ import static org .junit .Assert .fail ;
7
8
9
+ import java .util .Arrays ;
8
10
import java .util .Date ;
11
+ import java .util .HashSet ;
9
12
import java .util .Set ;
10
13
11
14
import javax .management .JMException ;
@@ -175,11 +178,17 @@ public void testGetAttributeInfoClosed() throws Exception {
175
178
public void testGetOperationsInfo () throws Exception {
176
179
MBeanOperationInfo [] infos = client .getOperationsInfo (objectName );
177
180
assertEquals (13 , infos .length );
178
- assertEquals ("times" , infos [0 ].getName ());
179
- assertEquals ("shortToString" , infos [1 ].getName ());
180
- assertEquals ("byteToString" , infos [2 ].getName ());
181
- assertEquals ("charToString" , infos [3 ].getName ());
182
- assertEquals ("doThrow" , infos [4 ].getName ());
181
+ Set <String > expectedNames =
182
+ new HashSet <String >(Arrays .asList ("times" , "shortToString" , "byteToString" , "charToString" , "doThrow" ));
183
+
184
+ // orders seem to change
185
+ for (MBeanOperationInfo info : infos ) {
186
+ expectedNames .remove (info .getName ());
187
+ }
188
+
189
+ for (String expectedName : expectedNames ) {
190
+ fail ("should have matched " + expectedName );
191
+ }
183
192
}
184
193
185
194
@ Test (expected = IllegalArgumentException .class )
@@ -458,66 +467,82 @@ private void testThingtoString(String methodName, String expected, String argStr
458
467
@ JmxResource (domainName = JMX_DOMAIN )
459
468
protected static class JmxClientTestObject {
460
469
int x ;
470
+
461
471
@ JmxAttributeMethod
462
472
public void setX (int x ) {
463
473
this .x = x ;
464
474
}
475
+
465
476
@ JmxAttributeMethod
466
477
public int getX () {
467
478
return x ;
468
479
}
480
+
469
481
@ JmxAttributeMethod
470
482
public String getNull () {
471
483
return null ;
472
484
}
485
+
473
486
@ JmxOperation
474
487
public long times (short x1 , int x2 ) {
475
488
return x1 * x2 ;
476
489
}
490
+
477
491
@ JmxOperation
478
492
public void doThrow () {
479
493
throw new RuntimeException ("throw away!" );
480
494
}
495
+
481
496
@ JmxOperation
482
497
public Object returnNull () {
483
498
return null ;
484
499
}
500
+
485
501
@ JmxOperation
486
502
public Object returnNull (int anotherArg ) {
487
503
return null ;
488
504
}
505
+
489
506
@ JmxOperation
490
507
public String dateToString (Date date ) {
491
508
return date .toString ();
492
509
}
510
+
493
511
@ JmxOperation
494
512
public String booleanToString (boolean booleanVal ) {
495
513
return Boolean .toString (booleanVal );
496
514
}
515
+
497
516
@ JmxOperation
498
517
public String charToString (char charVal ) {
499
518
return Character .toString (charVal );
500
519
}
520
+
501
521
@ JmxOperation
502
522
public String byteToString (byte byteVal ) {
503
523
return Byte .toString (byteVal );
504
524
}
525
+
505
526
@ JmxOperation
506
527
public String shortToString (short shortVal ) {
507
528
return Short .toString (shortVal );
508
529
}
530
+
509
531
@ JmxOperation
510
532
public String intToString (int intVal ) {
511
533
return Integer .toString (intVal );
512
534
}
535
+
513
536
@ JmxOperation
514
537
public String longToString (long longVal ) {
515
538
return Long .toString (longVal );
516
539
}
540
+
517
541
@ JmxOperation
518
542
public String floatToString (float floatVal ) {
519
543
return Float .toString (floatVal );
520
544
}
545
+
521
546
@ JmxOperation
522
547
public String doubleToString (double doubleVal ) {
523
548
return Double .toString (doubleVal );
@@ -527,14 +552,17 @@ public String doubleToString(double doubleVal) {
527
552
@ JmxResource (domainName = JMX_DOMAIN )
528
553
protected static class JmxClientTestAnotherObject {
529
554
int y ;
555
+
530
556
@ JmxAttributeMethod
531
557
public int getY () {
532
558
return y ;
533
559
}
560
+
534
561
@ JmxAttributeMethod
535
562
public void setY (int y ) {
536
563
this .y = y ;
537
564
}
565
+
538
566
@ JmxOperation
539
567
public long timesTwo (short y1 , int y2 ) {
540
568
return y1 * y2 ;
0 commit comments