1717import static org .eclipse .ui .genericeditor .tests .contributions .LongRunningBarContentAssistProcessor .LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL ;
1818import static org .hamcrest .CoreMatchers .endsWith ;
1919import static org .hamcrest .MatcherAssert .assertThat ;
20- import static org .junit .Assert .assertEquals ;
21- import static org .junit .Assert .assertFalse ;
22- import static org .junit .Assert .assertNotNull ;
23- import static org .junit .Assert .assertNull ;
24- import static org .junit .Assert .assertTrue ;
25- import static org .junit .Assert .fail ;
26- import static org .junit .Assume .assumeFalse ;
20+ import static org .junit .jupiter .api .Assertions .assertEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
23+ import static org .junit .jupiter .api .Assertions .assertNull ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
25+ import static org .junit .jupiter .api .Assertions .fail ;
2726
2827import java .util .ArrayList ;
2928import java .util .Arrays ;
3635import java .util .function .BooleanSupplier ;
3736import java .util .stream .Collectors ;
3837
39- import org .junit .After ;
40- import org .junit .Test ;
38+ import org .junit .jupiter .api .AfterEach ;
39+ import org .junit .jupiter .api .Test ;
40+ import org .junit .jupiter .api .condition .DisabledOnOs ;
41+ import org .junit .jupiter .api .condition .OS ;
4142import org .osgi .framework .Bundle ;
4243import org .osgi .framework .BundleContext ;
4344import org .osgi .framework .FrameworkUtil ;
6061import org .eclipse .core .runtime .IStatus ;
6162import org .eclipse .core .runtime .Platform ;
6263
63- import org .eclipse .jface .util .Util ;
64-
6564import org .eclipse .jface .text .ITextSelection ;
6665import org .eclipse .jface .text .ITextViewer ;
6766import org .eclipse .jface .text .contentassist .ICompletionProposal ;
@@ -85,14 +84,16 @@ public class CompletionTest extends AbstratGenericEditorTest {
8584 private Shell completionShell ;
8685
8786 @ Test
87+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
8888 public void testCompletion () throws Exception {
89- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
9089 editor .selectAndReveal (3 , 0 );
91- this .completionShell = openConentAssist ();
90+ this .completionShell = openConentAssist ();
9291 final Table completionProposalList = findCompletionSelectionControl (completionShell );
9392 checkCompletionContent (completionProposalList );
94- // TODO find a way to actually trigger completion and verify result against Editor content
95- // Assert.assertEquals("Completion didn't complete", "bars are good for a beer.", ((StyledText)editor.getAdapter(Control.class)).getText());
93+ // TODO find a way to actually trigger completion and verify result against
94+ // Editor content
95+ // Assert.assertEquals("Completion didn't complete", "bars are good for a
96+ // beer.", ((StyledText)editor.getAdapter(Control.class)).getText());
9697 }
9798
9899 @ Test
@@ -103,13 +104,13 @@ public void testDefaultContentAssistBug570488() throws Exception {
103104 createAndOpenFile ("Bug570488.txt" , "bar 'bar'" );
104105 openConentAssist (false );
105106 DisplayHelper .runEventLoop (Display .getCurrent (), 0 );
106- assertFalse ("There are errors in the log" , listener .messages .stream ().anyMatch (s -> s .matches (IStatus .ERROR )));
107+ assertFalse (listener .messages .stream ().anyMatch (s -> s .matches (IStatus .ERROR )), "There are errors in the log" );
107108 log .removeLogListener (listener );
108109 }
109110
110111 @ Test
112+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
111113 public void testCompletionService () throws Exception {
112- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
113114 Bundle bundle = FrameworkUtil .getBundle (CompletionTest .class );
114115 assertNotNull (bundle );
115116 BundleContext bundleContext = bundle .getBundleContext ();
@@ -122,13 +123,13 @@ public void testCompletionService() throws Exception {
122123 this .completionShell = openConentAssist ();
123124 final Table completionProposalList = findCompletionSelectionControl (completionShell );
124125 checkCompletionContent (completionProposalList );
125- assertTrue ("Service was not called!" , service . called );
126+ assertTrue (service . called , "Service was not called!" );
126127 registration .unregister ();
127128 }
128129
129130 @ Test
131+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
130132 public void testCompletionUsingViewerSelection () throws Exception {
131- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
132133 editor .getDocumentProvider ().getDocument (editor .getEditorInput ()).set ("abc" );
133134 editor .selectAndReveal (0 , 3 );
134135 this .completionShell = openConentAssist ();
@@ -138,13 +139,10 @@ public void testCompletionUsingViewerSelection() throws Exception {
138139 }
139140
140141 private static void waitForProposalRelatedCondition (String errorMessage , Table completionProposalList , BooleanSupplier condition , int timeoutInMsec ) {
141- assertTrue (errorMessage , new DisplayHelper () {
142- @ Override
143- protected boolean condition () {
144- assertFalse ("Completion proposal list was unexpectedly disposed" , completionProposalList .isDisposed ());
145- return condition .getAsBoolean ();
146- }
147- }.waitForCondition (completionProposalList .getDisplay (), timeoutInMsec ));
142+ assertTrue (DisplayHelper .waitForCondition (completionProposalList .getDisplay (), timeoutInMsec , () -> {
143+ assertFalse (completionProposalList .isDisposed (), "Completion proposal list was unexpectedly disposed" );
144+ return condition .getAsBoolean ();
145+ }), errorMessage );
148146 }
149147
150148 @ Test
@@ -153,7 +151,7 @@ public void testEnabledWhenCompletion() throws Exception {
153151 EnabledPropertyTester .setEnabled (false );
154152 createAndOpenFile ("enabledWhen.txt" , "bar 'bar'" );
155153 editor .selectAndReveal (3 , 0 );
156- assertNull ("A new shell was found" , openConentAssist ( false ) );
154+ assertNull (openConentAssist ( false ), "A new shell was found" );
157155 cleanFileAndEditor ();
158156
159157 // Confirm that when enabled, a completion shell is present
@@ -187,8 +185,8 @@ private void checkCompletionContent(final Table completionProposalList) {
187185 // should be instantaneous, but happens to go asynchronous on CI so let's allow a wait
188186 waitForProposalRelatedCondition ("Proposal list did not show two initial items" , completionProposalList ,
189187 () -> completionProposalList .getItemCount () == 2 , 200 );
190- assertTrue ("Missing computing info entry" , isComputingInfoEntry (completionProposalList .getItem (0 )));
191- assertTrue ("Missing computing info entry in proposal list" , isComputingInfoEntry ( completionProposalList . getItem ( 0 )) );
188+ assertTrue (isComputingInfoEntry (completionProposalList .getItem (0 )), "Missing computing info entry" );
189+ assertTrue (isComputingInfoEntry ( completionProposalList . getItem ( 0 )), "Missing computing info entry in proposal list" );
192190 final TableItem initialProposalItem = completionProposalList .getItem (1 );
193191 final String initialProposalString = ((ICompletionProposal )initialProposalItem .getData ()).getDisplayString ();
194192 assertThat ("Unexpected initial proposal item" ,
@@ -205,7 +203,7 @@ private void checkCompletionContent(final Table completionProposalList) {
205203 assertThat ("Unexpected first proposal item" , BAR_CONTENT_ASSIST_PROPOSAL , endsWith (firstCompletionProposalText ));
206204 assertThat ("Unexpected second proposal item" , LONG_RUNNING_BAR_CONTENT_ASSIST_PROPOSAL , endsWith (secondCompletionProposalText ));
207205 String selectedProposalString = ((ICompletionProposal )completionProposalList .getSelection ()[0 ].getData ()).getDisplayString ();
208- assertEquals ("Addition of completion proposal should keep selection" , initialProposalString , selectedProposalString );
206+ assertEquals (initialProposalString , selectedProposalString , "Addition of completion proposal should keep selection" );
209207 }
210208
211209 private static boolean isComputingInfoEntry (TableItem item ) {
@@ -218,33 +216,33 @@ public static Shell findNewShell(Set<Shell> beforeShells, Display display, boole
218216 .filter (shell -> !beforeShells .contains (shell ))
219217 .toArray (Shell []::new );
220218 if (expectShell ) {
221- assertEquals ("No new shell found" , 1 , afterShells . length );
219+ assertEquals (1 , afterShells . length , "No new shell found" );
222220 }
223221 return afterShells .length > 0 ? afterShells [0 ] : null ;
224222 }
225223
226224 @ Test
225+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
227226 public void testCompletionFreeze_bug521484 () throws Exception {
228- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
229227 editor .selectAndReveal (3 , 0 );
230228 this .completionShell =openConentAssist ();
231229 final Table completionProposalList = findCompletionSelectionControl (this .completionShell );
232230 // should be instantaneous, but happens to go asynchronous on CI so let's allow a wait
233231 waitForProposalRelatedCondition ("Proposal list did not show two items" , completionProposalList ,
234232 () -> completionProposalList .getItemCount () == 2 , 200 );
235- assertTrue ("Missing computing info entry" , isComputingInfoEntry (completionProposalList .getItem (0 )));
233+ assertTrue (isComputingInfoEntry (completionProposalList .getItem (0 )), "Missing computing info entry" );
236234 // Some processors are long running, moving cursor can cause freeze (bug 521484)
237235 // asynchronous
238236 long timestamp = System .currentTimeMillis ();
239237 emulatePressLeftArrowKey ();
240238 DisplayHelper .sleep (editor .getSite ().getShell ().getDisplay (), 200 ); //give time to process events
241239 long processingDuration = System .currentTimeMillis () - timestamp ;
242- assertTrue ("UI Thread frozen for " + processingDuration + "ms" , processingDuration < LongRunningBarContentAssistProcessor . DELAY );
240+ assertTrue (processingDuration < LongRunningBarContentAssistProcessor . DELAY , "UI Thread frozen for " + processingDuration + "ms" );
243241 }
244242
245243 @ Test
244+ @ DisabledOnOs (value = OS .MAC , disabledReason = "test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" )
246245 public void testMoveCaretBackUsesAllProcessors_bug522255 () throws Exception {
247- assumeFalse ("test fails on Mac, see https://github.com/eclipse-platform/eclipse.platform.ui/issues/906" , Util .isMac ());
248246 testCompletion ();
249247 emulatePressLeftArrowKey ();
250248 final Set <Shell > beforeShells = Arrays .stream (editor .getSite ().getShell ().getDisplay ().getShells ()).filter (Shell ::isVisible ).collect (Collectors .toSet ());
@@ -280,7 +278,7 @@ public static Table findCompletionSelectionControl(Widget control) {
280278 return null ;
281279 }
282280
283- @ After
281+ @ AfterEach
284282 public void closeShell () {
285283 if (this .completionShell != null && !completionShell .isDisposed ()) {
286284 completionShell .close ();
0 commit comments