11/*
2- * Copyright 2013-2019 the original author or authors.
2+ * Copyright 2013-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2424import javax .management .ObjectName ;
2525import javax .management .QueryExp ;
2626
27- import org .junit .Test ;
28- import org .junit .runner .RunWith ;
27+ import org .junit .jupiter .api .Test ;
2928
3029import org .springframework .beans .factory .annotation .Autowired ;
3130import org .springframework .beans .factory .annotation .Qualifier ;
3534import org .springframework .messaging .Message ;
3635import org .springframework .messaging .PollableChannel ;
3736import org .springframework .test .annotation .DirtiesContext ;
38- import org .springframework .test .context .ContextConfiguration ;
39- import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
37+ import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
4038
4139/**
4240 * @author Stuart Williams
4341 * @author Gary Russell
4442 * @author Artem Bilan
4543 *
4644 */
47- @ ContextConfiguration
48- @ RunWith (SpringJUnit4ClassRunner .class )
45+ @ SpringJUnitConfig
4946@ DirtiesContext
5047public class MBeanTreePollingChannelAdapterParserTests {
5148
@@ -103,39 +100,39 @@ public class MBeanTreePollingChannelAdapterParserTests {
103100 private final long testTimeout = 20000L ;
104101
105102 @ Test
106- public void pollDefaultAdapter () throws Exception {
103+ public void pollDefaultAdapter () {
107104 adapterDefault .start ();
108105
109106 Message <?> result = channel1 .receive (testTimeout );
110- assertThat (result ).isNotNull ();
111-
112- assertThat (result .getPayload ().getClass ()).isEqualTo (HashMap .class );
107+ assertThat (result )
108+ .isNotNull ()
109+ .extracting (Message ::getPayload )
110+ .isInstanceOf (HashMap .class );
113111
114112 @ SuppressWarnings ("unchecked" )
115113 Map <String , Object > beans = (Map <String , Object >) result .getPayload ();
116114
117115 // test for a couple of MBeans
118- assertThat (beans .containsKey ("java.lang:type=OperatingSystem" )).isTrue ();
119- assertThat (beans .containsKey ("java.lang:type=Runtime" )).isTrue ();
116+ assertThat (beans ).containsKeys ("java.lang:type=OperatingSystem" , "java.lang:type=Runtime" );
120117
121118 adapterDefault .stop ();
122119 }
123120
124121 @ Test
125- public void pollInnerAdapter () throws Exception {
122+ public void pollInnerAdapter () {
126123 adapterInner .start ();
127124
128125 Message <?> result = channel2 .receive (testTimeout );
129- assertThat (result ).isNotNull ();
130-
131- assertThat (result .getPayload ().getClass ()).isEqualTo (HashMap .class );
126+ assertThat (result )
127+ .isNotNull ()
128+ .extracting (Message ::getPayload )
129+ .isInstanceOf (HashMap .class );
132130
133131 @ SuppressWarnings ("unchecked" )
134132 Map <String , Object > beans = (Map <String , Object >) result .getPayload ();
135133
136134 // test for a couple of MBeans
137- assertThat (beans .containsKey ("java.lang:type=OperatingSystem" )).isTrue ();
138- assertThat (beans .containsKey ("java.lang:type=Runtime" )).isTrue ();
135+ assertThat (beans ).containsKeys ("java.lang:type=OperatingSystem" , "java.lang:type=Runtime" );
139136
140137 adapterInner .stop ();
141138 }
@@ -151,73 +148,80 @@ public void pollQueryNameAdapter() throws Exception {
151148 assertThat (queryExp .apply (new ObjectName ("java.lang:type=Runtime" ))).isTrue ();
152149
153150 Message <?> result = channel3 .receive (testTimeout );
154- assertThat (result ).isNotNull ();
155-
156- assertThat (result .getPayload ().getClass ()).isEqualTo (HashMap .class );
151+ assertThat (result )
152+ .isNotNull ()
153+ .extracting (Message ::getPayload )
154+ .isInstanceOf (HashMap .class );
157155
158156 @ SuppressWarnings ("unchecked" )
159157 Map <String , Object > beans = (Map <String , Object >) result .getPayload ();
160158
161159 // test for a couple of MBeans
162- assertThat (beans .containsKey ("java.lang:type=OperatingSystem" )).isFalse ();
163- assertThat (beans .containsKey ("java.lang:type=Runtime" )).isTrue ();
160+ assertThat (beans )
161+ .containsKey ("java.lang:type=Runtime" )
162+ .doesNotContainKey ("java.lang:type=OperatingSystem" );
164163
165164 adapterQueryName .stop ();
166165 }
167166
168167 @ Test
169- public void pollQueryNameBeanAdapter () throws Exception {
168+ public void pollQueryNameBeanAdapter () {
170169 adapterQueryNameBean .start ();
171170
172171 Message <?> result = channel4 .receive (testTimeout );
173- assertThat (result ).isNotNull ();
174-
175- assertThat (result .getPayload ().getClass ()).isEqualTo (HashMap .class );
172+ assertThat (result )
173+ .isNotNull ()
174+ .extracting (Message ::getPayload )
175+ .isInstanceOf (HashMap .class );
176176
177177 @ SuppressWarnings ("unchecked" )
178178 Map <String , Object > beans = (Map <String , Object >) result .getPayload ();
179179
180180 // test for a couple of MBeans
181- assertThat (beans .containsKey ("java.lang:type=OperatingSystem" )).isTrue ();
182- assertThat (beans .containsKey ("java.lang:type=Runtime" )).isFalse ();
181+ assertThat (beans )
182+ .containsKey ("java.lang:type=OperatingSystem" )
183+ .doesNotContainKey ("java.lang:type=Runtime" );
183184
184185 adapterQueryNameBean .stop ();
185186 }
186187
187188 @ Test
188- public void pollQueryExprBeanAdapter () throws Exception {
189+ public void pollQueryExprBeanAdapter () {
189190 adapterQueryExprBean .start ();
190191
191192 Message <?> result = channel5 .receive (testTimeout );
192- assertThat (result ).isNotNull ();
193-
194- assertThat (result .getPayload ().getClass ()).isEqualTo (HashMap .class );
193+ assertThat (result )
194+ .isNotNull ()
195+ .extracting (Message ::getPayload )
196+ .isInstanceOf (HashMap .class );
195197
196198 @ SuppressWarnings ("unchecked" )
197199 Map <String , Object > beans = (Map <String , Object >) result .getPayload ();
198200
199201 // test for a couple of MBeans
200- assertThat (beans .containsKey ("java.lang:type=OperatingSystem" )).isFalse ();
201- assertThat (beans .containsKey ("java.lang:type=Runtime" )).isTrue ();
202+ assertThat (beans )
203+ .containsKey ("java.lang:type=Runtime" )
204+ .doesNotContainKey ("java.lang:type=OperatingSystem" );
202205
203206 adapterQueryExprBean .stop ();
204207 }
205208
206209 @ Test
207- public void pollConverterAdapter () throws Exception {
210+ public void pollConverterAdapter () {
208211 adapterConverter .start ();
209212
210213 Message <?> result = channel6 .receive (testTimeout );
211- assertThat (result ).isNotNull ();
214+ assertThat (result )
215+ .isNotNull ()
216+ .extracting (Message ::getPayload )
217+ .isInstanceOf (HashMap .class );
212218
213- assertThat (result .getPayload ().getClass ()).isEqualTo (HashMap .class );
214219
215220 @ SuppressWarnings ("unchecked" )
216221 Map <String , Object > beans = (Map <String , Object >) result .getPayload ();
217222
218223 // test for a couple of MBeans
219- assertThat (beans .containsKey ("java.lang:type=OperatingSystem" )).isTrue ();
220- assertThat (beans .containsKey ("java.lang:type=Runtime" )).isTrue ();
224+ assertThat (beans ).containsKeys ("java.lang:type=OperatingSystem" , "java.lang:type=Runtime" );
221225
222226 adapterConverter .stop ();
223227 assertThat (TestUtils .getPropertyValue (adapterConverter , "source.converter" )).isSameAs (converter );
0 commit comments