1818 */
1919package groovy.jmx.builder
2020
21+ import org.junit.jupiter.api.Assumptions
2122import org.junit.jupiter.api.BeforeEach
2223import org.junit.jupiter.api.Test
2324
24- class JmxBeansFactoryTest {
25- def builder
25+ final class JmxBeansFactoryTest {
26+
27+ private JmxBuilder builder
2628
2729 @BeforeEach
2830 void setUp () {
2931 builder = new JmxBuilder ()
30- builder. registerFactory(" beans" , new JmxBeansFactory ())
32+ builder. registerFactory(' beans' , new JmxBeansFactory ())
33+ try {
34+ builder. getMBeanServer()
35+ } catch (e) {
36+ Assumptions . abort(e. getMessage())
37+ }
3138 }
3239
3340 @Test
@@ -45,35 +52,38 @@ class JmxBeansFactoryTest {
4552
4653 def attribs = map. attributes
4754 assert attribs.Something
48- assert attribs.Something . type == " java.lang.String"
55+ assert attribs.Something . type == ' java.lang.String'
4956
5057 assert attribs.SomethingElse
51- assert attribs.SomethingElse . type == " int"
58+ assert attribs.SomethingElse . type == ' int'
5259
5360 assert attribs.Available
54- assert attribs.Available . type == " boolean"
61+ assert attribs.Available . type == ' boolean'
5562
56- // test MockEmbeddedObject map
63+ // test BaseEmbeddedClass map
5764 map = maps[1 ]
5865 assert map. attributes
5966 assert map.attributes.Id
60- assert map.attributes.Id . type == " int"
67+ assert map.attributes.Id . type == ' int'
6168
6269 assert map.attributes.Name
63- assert map.attributes.Name . type == " java.lang.String"
70+ assert map.attributes.Name . type == ' java.lang.String'
6471
6572 assert map.attributes.Location
66- assert map.attributes.Location . type == " java.lang.Object"
73+ assert map.attributes.Location . type == ' java.lang.Object'
6774
6875 assert map.attributes.Available
69- assert map.attributes.Available . type == " boolean"
76+ assert map.attributes.Available . type == ' boolean'
7077 }
7178
7279 @Test
7380 void testMBeanClass () {
7481 def object = new MockSimpleObject ()
7582 def maps = builder. beans([object])
83+
7684 assert maps
85+ assert maps. size() == 1
86+
7787 def map = maps[0 ]
7888 assert map. isMBean
7989 assert map. target
@@ -83,4 +93,3 @@ class JmxBeansFactoryTest {
8393 assert ! map. operations
8494 }
8595}
86-
0 commit comments