Skip to content

Commit 92eae00

Browse files
author
Gray Watson
committed
cp
1 parent 89d00db commit 92eae00

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

src/test/java/com/j256/simplejmx/client/JmxClientTest.java

+33-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
import static org.junit.Assert.assertNotNull;
55
import static org.junit.Assert.assertNull;
66
import static org.junit.Assert.assertTrue;
7+
import static org.junit.Assert.fail;
78

9+
import java.util.Arrays;
810
import java.util.Date;
11+
import java.util.HashSet;
912
import java.util.Set;
1013

1114
import javax.management.JMException;
@@ -175,11 +178,17 @@ public void testGetAttributeInfoClosed() throws Exception {
175178
public void testGetOperationsInfo() throws Exception {
176179
MBeanOperationInfo[] infos = client.getOperationsInfo(objectName);
177180
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+
}
183192
}
184193

185194
@Test(expected = IllegalArgumentException.class)
@@ -458,66 +467,82 @@ private void testThingtoString(String methodName, String expected, String argStr
458467
@JmxResource(domainName = JMX_DOMAIN)
459468
protected static class JmxClientTestObject {
460469
int x;
470+
461471
@JmxAttributeMethod
462472
public void setX(int x) {
463473
this.x = x;
464474
}
475+
465476
@JmxAttributeMethod
466477
public int getX() {
467478
return x;
468479
}
480+
469481
@JmxAttributeMethod
470482
public String getNull() {
471483
return null;
472484
}
485+
473486
@JmxOperation
474487
public long times(short x1, int x2) {
475488
return x1 * x2;
476489
}
490+
477491
@JmxOperation
478492
public void doThrow() {
479493
throw new RuntimeException("throw away!");
480494
}
495+
481496
@JmxOperation
482497
public Object returnNull() {
483498
return null;
484499
}
500+
485501
@JmxOperation
486502
public Object returnNull(int anotherArg) {
487503
return null;
488504
}
505+
489506
@JmxOperation
490507
public String dateToString(Date date) {
491508
return date.toString();
492509
}
510+
493511
@JmxOperation
494512
public String booleanToString(boolean booleanVal) {
495513
return Boolean.toString(booleanVal);
496514
}
515+
497516
@JmxOperation
498517
public String charToString(char charVal) {
499518
return Character.toString(charVal);
500519
}
520+
501521
@JmxOperation
502522
public String byteToString(byte byteVal) {
503523
return Byte.toString(byteVal);
504524
}
525+
505526
@JmxOperation
506527
public String shortToString(short shortVal) {
507528
return Short.toString(shortVal);
508529
}
530+
509531
@JmxOperation
510532
public String intToString(int intVal) {
511533
return Integer.toString(intVal);
512534
}
535+
513536
@JmxOperation
514537
public String longToString(long longVal) {
515538
return Long.toString(longVal);
516539
}
540+
517541
@JmxOperation
518542
public String floatToString(float floatVal) {
519543
return Float.toString(floatVal);
520544
}
545+
521546
@JmxOperation
522547
public String doubleToString(double doubleVal) {
523548
return Double.toString(doubleVal);
@@ -527,14 +552,17 @@ public String doubleToString(double doubleVal) {
527552
@JmxResource(domainName = JMX_DOMAIN)
528553
protected static class JmxClientTestAnotherObject {
529554
int y;
555+
530556
@JmxAttributeMethod
531557
public int getY() {
532558
return y;
533559
}
560+
534561
@JmxAttributeMethod
535562
public void setY(int y) {
536563
this.y = y;
537564
}
565+
538566
@JmxOperation
539567
public long timesTwo(short y1, int y2) {
540568
return y1 * y2;

0 commit comments

Comments
 (0)