1717 *******************************************************************************/
1818package org .eclipse .ui .internal .monitoring ;
1919
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertNotNull ;
22- import static org .junit .Assert .assertTrue ;
20+
21+ import static org .junit .jupiter .api .Assertions .assertEquals ;
22+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
23+ import static org .junit .jupiter .api .Assertions .assertTrue ;
2324
2425import java .lang .management .ManagementFactory ;
2526import java .lang .management .ThreadMXBean ;
3536import org .eclipse .jface .preference .IPreferenceStore ;
3637import org .eclipse .swt .widgets .Display ;
3738import org .eclipse .ui .monitoring .PreferenceConstants ;
38- import org .junit .After ;
39- import org .junit .Before ;
40- import org .junit .Test ;
39+ import org .junit .jupiter . api . AfterEach ;
40+ import org .junit .jupiter . api . BeforeEach ;
41+ import org .junit .jupiter . api . Test ;
4142
4243/**
4344 * A test that measures performance overhead of {@link EventLoopMonitorThread}.
@@ -111,12 +112,12 @@ public class EventLoopMonitorThreadManualTests {
111112 */
112113 protected static final long PN63_GENERATOR_POLY = (3L << 62 ) | 1 ;
113114
114- @ Before
115+ @ BeforeEach
115116 public void setUp () {
116117 MonitoringPlugin .getPreferenceStore ().setValue (PreferenceConstants .MONITORING_ENABLED , false );
117118 }
118119
119- @ After
120+ @ AfterEach
120121 public void tearDown () {
121122 MonitoringPlugin .getPreferenceStore ().setToDefault (PreferenceConstants .MONITORING_ENABLED );
122123 }
@@ -163,7 +164,7 @@ protected static long doWork(long pnSeqeuence, long iterations) {
163164 @ Test
164165 public void testFixedWork () throws Exception {
165166 final Display display = Display .getDefault ();
166- assertNotNull ("No SWT Display available." , display );
167+ assertNotNull (display , "No SWT Display available." );
167168
168169 final MockUiFreezeEventLogger logger = new MockUiFreezeEventLogger ();
169170 final CountDownLatch backgroundJobsDone = new CountDownLatch (1 );
@@ -246,13 +247,18 @@ public void testFixedWork() throws Exception{
246247 maxRelativeIncreaseOneStackAllowed * 100 ));
247248 }
248249 assertTrue (
249- String .format ("""
250- Relative overhead of monitoring surpassed threshold for
251- measurement %d of %d. It took %.3fs with a relative increase of %.3f%%
252- (allowed < %.3f%%).""" ,
253- i , NUM_UI_STACK_MEASUREMENTS , tWork [0 ] / 1e9 , relativeDiffOneThread * 100 ,
254- maxRelativeIncreaseOneStackAllowed * 100 ),
255- relativeDiffOneThread <= maxRelativeIncreaseOneStackAllowed );
250+ relativeDiffOneThread <= maxRelativeIncreaseOneStackAllowed ,
251+ String .format ("""
252+ Relative overhead of monitoring surpassed threshold for \
253+ measurement %d of %d. It took %.3fs with a relative increase of %.3f%% \
254+ (allowed < %.3f%%).""" ,
255+ i ,
256+ NUM_UI_STACK_MEASUREMENTS ,
257+ tWork [0 ] / 1e9 ,
258+ relativeDiffOneThread * 100 ,
259+ maxRelativeIncreaseOneStackAllowed * 100 )
260+ );
261+
256262 }
257263 killMonitorThread (monitor1 , display );
258264
@@ -277,13 +283,19 @@ public void testFixedWork() throws Exception{
277283 i , NUM_ALL_STACKS_MEASUREMENTS , tWork [0 ] / 1e9 , relativeDiffAllThreads * 100 ,
278284 maxRelativeIncreaseAllStacksAllowed * 100 ));
279285 }
280- assertTrue (String .format ("""
281- Relative overhead of monitoring with stack traces of all threads
282- surpassed threshold for measurement %d of %d. It took %.3fs with a relative
283- increase of %.3f%% (allowed < %.3f%%).""" ,
284- i , NUM_ALL_STACKS_MEASUREMENTS , tWork [0 ] / 1e9 , relativeDiffAllThreads * 100 ,
285- maxRelativeIncreaseAllStacksAllowed * 100 ),
286- relativeDiffAllThreads <= maxRelativeIncreaseAllStacksAllowed );
286+ assertTrue (
287+ relativeDiffAllThreads <= maxRelativeIncreaseAllStacksAllowed ,
288+ String .format ("""
289+ Relative overhead of monitoring with stack traces of all threads \
290+ surpassed threshold for measurement %d of %d. It took %.3fs with a relative \
291+ increase of %.3f%% (allowed < %.3f%%).""" ,
292+ i ,
293+ NUM_ALL_STACKS_MEASUREMENTS ,
294+ tWork [0 ] / 1e9 ,
295+ relativeDiffAllThreads * 100 ,
296+ maxRelativeIncreaseAllStacksAllowed * 100 )
297+ );
298+
287299 }
288300 killMonitorThread (monitor2 , display );
289301
@@ -376,22 +388,30 @@ public void testFixedWork() throws Exception{
376388 threads .offer (t ); // Retry.
377389 }
378390 }
379-
380- assertEquals ("Did not log expected number of freeze events," ,
391+ assertEquals (
381392 NUM_UI_STACK_MEASUREMENTS + NUM_ALL_STACKS_MEASUREMENTS ,
382- logger .getLoggedEvents ().size ());
383- assertTrue (String .format ("""
384- Relative overhead of monitoring with stack traces of the UI
385- thread was %.3f%% (allowed < %.3f%%).""" ,
386- worstRelativeDiffOneThread * 100 ,
387- maxRelativeIncreaseOneStackAllowed * 100 ),
388- worstRelativeDiffOneThread <= maxRelativeIncreaseOneStackAllowed );
389- assertTrue (String .format ("""
390- Relative overhead of monitoring with stack traces of all
391- threads was %.3f%% (allowed < %.3f%%).""" ,
392- worstRelativeDiffAllThreads * 100 ,
393- maxRelativeIncreaseAllStacksAllowed * 100 ),
394- worstRelativeDiffAllThreads <= maxRelativeIncreaseAllStacksAllowed );
393+ logger .getLoggedEvents ().size (),
394+ "Did not log expected number of freeze events."
395+ );
396+
397+ assertTrue (
398+ worstRelativeDiffOneThread <= maxRelativeIncreaseOneStackAllowed ,
399+ String .format ("""
400+ Relative overhead of monitoring with stack traces of the UI \
401+ thread was %.3f%% (allowed < %.3f%%).""" ,
402+ worstRelativeDiffOneThread * 100 ,
403+ maxRelativeIncreaseOneStackAllowed * 100 )
404+ );
405+
406+ assertTrue (
407+ worstRelativeDiffAllThreads <= maxRelativeIncreaseAllStacksAllowed ,
408+ String .format ("""
409+ Relative overhead of monitoring with stack traces of all \
410+ threads was %.3f%% (allowed < %.3f%%).""" ,
411+ worstRelativeDiffAllThreads * 100 ,
412+ maxRelativeIncreaseAllStacksAllowed * 100 )
413+ );
414+
395415 }
396416
397417 private Thread createAndStartMonitoringThread (Display display , boolean dumpAll ) throws Exception {
0 commit comments