1515package org .eclipse .swt .tests .junit ;
1616
1717import static org .eclipse .swt .tests .junit .SwtTestUtil .assertSWTProblem ;
18- import static org .junit .Assert .assertEquals ;
19- import static org .junit .Assert .assertFalse ;
20- import static org .junit .Assert .assertNotNull ;
21- import static org .junit .Assert .assertNull ;
22- import static org .junit .Assert .assertSame ;
23- import static org .junit .Assert .assertTrue ;
24- import static org .junit .Assert .fail ;
18+ import static org .junit .jupiter . api . Assertions .assertEquals ;
19+ import static org .junit .jupiter . api . Assertions .assertFalse ;
20+ import static org .junit .jupiter . api . Assertions .assertNotNull ;
21+ import static org .junit .jupiter . api . Assertions .assertNull ;
22+ import static org .junit .jupiter . api . Assertions .assertSame ;
23+ import static org .junit .jupiter . api . Assertions .assertTrue ;
24+ import static org .junit .jupiter . api . Assertions .fail ;
2525
2626import java .io .IOException ;
2727import java .util .concurrent .CompletableFuture ;
@@ -144,16 +144,16 @@ else if (e.type == SWT.Dispose)
144144 } finally {
145145 display .close ();
146146 }
147- assertFalse (":a:" , callbackReceived [CLOSE_CALLBACK ]);
148- assertTrue (":b:" , callbackReceived [DISPOSE_CALLBACK ]);
147+ assertFalse (callbackReceived [CLOSE_CALLBACK ]);
148+ assertTrue (callbackReceived [DISPOSE_CALLBACK ]);
149149
150150 display = new Display ();
151151 try {
152152 display .addListener (SWT .Close , listener );
153153 } finally {
154154 display .close ();
155155 }
156- assertTrue (":c:" , callbackReceived [CLOSE_CALLBACK ]);
156+ assertTrue (callbackReceived [CLOSE_CALLBACK ]);
157157}
158158
159159@ Test
@@ -250,10 +250,10 @@ public void test_disposeExecLjava_lang_Runnable() {
250250 Display testDisplay = new Display ();
251251 disposeExecRan = false ;
252252 testDisplay .disposeExec (() -> disposeExecRan = true );
253- assertEquals ( "Display should not be disposed" , false , testDisplay . isDisposed () );
253+ assertFalse ( testDisplay . isDisposed (), "Display should not be disposed" );
254254 testDisplay .dispose ();
255- assertTrue ("Display should be disposed" , testDisplay . isDisposed () );
256- assertTrue ("DisposeExec Runnable did not run" , disposeExecRan );
255+ assertTrue (testDisplay . isDisposed (), "Display should be disposed" );
256+ assertTrue (disposeExecRan , "DisposeExec Runnable did not run" );
257257}
258258
259259@ Test
@@ -372,8 +372,7 @@ public void test_getDismissalAlignment() {
372372 Display display = new Display ();
373373 try {
374374 int alignment = display .getDismissalAlignment ();
375- assertTrue ("getDismissalAlignment should return SWT.LEFT or SWT.RIGHT" ,
376- alignment == SWT .LEFT || alignment == SWT .RIGHT );
375+ assertTrue (alignment == SWT .LEFT || alignment == SWT .RIGHT , "getDismissalAlignment should return SWT.LEFT or SWT.RIGHT" );
377376 } finally {
378377 display .dispose ();
379378 }
@@ -416,9 +415,9 @@ public void test_getMonitors() {
416415 Display display = new Display ();
417416 Monitor [] monitors = display .getMonitors ();
418417 assertNotNull (monitors );
419- assertTrue ("at least one monitor should be returned" , monitors . length >= 1 );
418+ assertTrue (monitors . length >= 1 , "at least one monitor should be returned" );
420419 for (int i = 0 ; i < monitors .length ; i ++)
421- assertNotNull ("monitor at index " +i +" should not be null" , monitors [ i ] );
420+ assertNotNull (monitors [ i ], "monitor at index " +i +" should not be null" );
422421 display .dispose ();
423422}
424423
@@ -1103,7 +1102,7 @@ public void test_postLorg_eclipse_swt_widgets_Event() {
11031102 event = new Event ();
11041103 event .type = SWT .KeyDown ;
11051104 event .keyCode = -1 ; // bogus key code; default 0 character
1106- assertTrue ("Display#post failed, probably because screen is not rendered (bug 407862)" , display . post ( event ) ); //$NON-NLS-1$
1105+ assertTrue (display . post ( event ), "Display#post failed, probably because screen is not rendered (bug 407862)" ); //$NON-NLS-1$
11071106 // don't test KeyDown/KeyUp with a character to avoid sending to
11081107 // random window if test shell looses focus
11091108
@@ -1469,7 +1468,7 @@ public void test_syncCall_RuntimeException() {
14691468 final Display display = new Display ();
14701469 try {
14711470 int depth =display .syncCall (() -> {throw new IllegalArgumentException ("42" );});
1472- assertFalse ("should not be reached " +depth , true );
1471+ fail ("should not be reached " +depth );
14731472 } catch (RuntimeException e ) {
14741473 assertEquals ("42" , e .getMessage ());
14751474 } finally {
@@ -1481,7 +1480,7 @@ public void test_syncCall_Exception() {
14811480 final Display display = new Display ();
14821481 try {
14831482 int depth =display .syncCall (() -> {throw new IOException ("42" );});
1484- assertFalse ("should not be reached " +depth , true );
1483+ fail ("should not be reached " +depth );
14851484 } catch (IOException e ) {
14861485 assertEquals ("42" , e .getMessage ());
14871486 } finally {
@@ -1494,20 +1493,18 @@ public void test_syncCall_SWTException() {
14941493 display .dispose ();
14951494 try {
14961495 int magic =display .syncCall (() -> {display .dispose (); return 42 ;});
1497- assertFalse ("should not be reached " +magic , true );
1496+ fail ("should not be reached " +magic );
14981497 } catch (SWTException e ) {
14991498 assertEquals ("Device is disposed" , e .getMessage ());
15001499 }
15011500}
15021501@ Test
1503- public void test_syncCall_concurrentCallable () {
1502+ public void test_syncCall_concurrentCallable () throws Exception {
15041503 final Display display = new Display ();
15051504 try {
15061505 java .util .concurrent .Callable <Integer > c =() -> {return 42 ;};
15071506 int magic =display .syncCall (c ::call );
15081507 assertEquals (42 , magic );
1509- } catch (Exception e ) {
1510- assertFalse ("should not be reached " , true );
15111508 } finally {
15121509 display .dispose ();
15131510 }
@@ -1518,7 +1515,7 @@ public void test_syncCall_concurrentCallable_Exception() {
15181515 try {
15191516 java .util .concurrent .Callable <Integer > c =() -> {throw new IOException ("42" );};
15201517 int depth =display .syncCall (c ::call );
1521- assertFalse ("should not be reached " +depth , true );
1518+ fail ("should not be reached " +depth );
15221519 } catch (Exception e ) {
15231520 assertEquals ("42" , e .getMessage ());
15241521 } finally {
@@ -1560,7 +1557,7 @@ public void test_timerExecILjava_lang_Runnable() {
15601557 }
15611558
15621559 // Verify the timerExec with less than zero milliseconds didn't execute.
1563- assertFalse ("< 0 ms timer did execute" , timerExecRan [ 0 ] );
1560+ assertFalse (timerExecRan [ 0 ], "< 0 ms timer did execute" );
15641561 } finally {
15651562 display .dispose ();
15661563 }
@@ -1589,8 +1586,8 @@ public void test_getDPI() {
15891586 Display display = new Display ();
15901587 try {
15911588 Point p = display .getDPI ();
1592- assertTrue ("horizontal DPI not greater than zero" , p . x > 0 );
1593- assertTrue ("vertical DPI not greater than zero" , p . y > 0 );
1589+ assertTrue (p . x > 0 , "horizontal DPI not greater than zero" );
1590+ assertTrue (p . y > 0 , "vertical DPI not greater than zero" );
15941591 } finally {
15951592 display .dispose ();
15961593 }
@@ -1601,7 +1598,7 @@ public void test_getDepth() {
16011598 Display display = new Display ();
16021599 try {
16031600 int d = display .getDepth ();
1604- assertTrue ("depth not greater than zero" , d > 0 );
1601+ assertTrue (d > 0 , "depth not greater than zero" );
16051602 } finally {
16061603 display .dispose ();
16071604 }
@@ -1612,7 +1609,7 @@ public void test_getFontListLjava_lang_StringZ() {
16121609 try {
16131610 FontData [] scalable = display .getFontList (null , true );
16141611 FontData [] non_scalable = display .getFontList (null , false );
1615- assertTrue ("no fonts detected" , (scalable .length + non_scalable .length ) > 0 );
1612+ assertTrue ((scalable .length + non_scalable .length ) > 0 , "no fonts detected" );
16161613 } finally {
16171614 display .dispose ();
16181615 }
0 commit comments