1010 *******************************************************************************/
1111package org .eclipse .jface .text .tests .codemining ;
1212
13- import static org .junit .Assert .assertTrue ;
13+ import static org .junit .jupiter . api . Assertions .assertTrue ;
1414
1515import java .io .ByteArrayInputStream ;
1616import java .text .SimpleDateFormat ;
1717import java .util .Date ;
1818import java .util .HashMap ;
1919import java .util .concurrent .Callable ;
2020
21- import org .junit .After ;
22- import org .junit .AfterClass ;
23- import org .junit .Assert ;
24- import org .junit .BeforeClass ;
25- import org .junit .Test ;
21+ import org .junit .jupiter . api . AfterAll ;
22+ import org .junit .jupiter . api . AfterEach ;
23+ import org .junit .jupiter . api . Assertions ;
24+ import org .junit .jupiter . api . BeforeAll ;
25+ import org .junit .jupiter . api . Test ;
2626
2727import org .eclipse .swt .custom .StyleRange ;
2828import org .eclipse .swt .custom .StyledText ;
@@ -65,20 +65,20 @@ public class CodeMiningTest {
6565
6666 private static IProject project ;
6767
68- @ BeforeClass
69- public static void beforeClass () throws Exception {
68+ @ BeforeAll
69+ static void beforeClass () throws Exception {
7070 hideWelcomePage ();
7171 createProject (PROJECT_NAME );
7272 }
7373
74- @ AfterClass
75- public static void afterClass () throws Exception {
74+ @ AfterAll
75+ static void afterClass () throws Exception {
7676 if (project != null )
7777 project .delete (true , new NullProgressMonitor ());
7878 }
7979
80- @ After
81- public void after () {
80+ @ AfterEach
81+ void after () {
8282 closeAllEditors ();
8383 drainEventQueue ();
8484 CodeMiningTestProvider .provideContentMiningAtOffset = -1 ;
@@ -112,7 +112,7 @@ public void run(IProgressMonitor monitor) throws CoreException {
112112 }
113113
114114 @ Test
115- public void testClearCodeMiningTextEditorDecorationIfInInvisibleArea () throws Exception {
115+ void testClearCodeMiningTextEditorDecorationIfInInvisibleArea () throws Exception {
116116 IFile file = project .getFile ("test.testprojectionviewer" );
117117 if (file .exists ()) {
118118 file .delete (true , new NullProgressMonitor ());
@@ -144,7 +144,7 @@ public Boolean call() throws Exception {
144144 }
145145 });
146146 StyleRange style = styledText .getStyleRangeAtOffset (offsetAtLine95 - 1 );
147- assertTrue (style .metrics .width > 0 );
147+ assertTrue (style != null && style . metrics != null && style .metrics .width > 0 );
148148 // scroll to top so that code minings are not in visible area
149149 viewer .setSelectedRange (0 , 0 );
150150 viewer .revealRange (0 , 1 );
@@ -156,14 +156,14 @@ public Boolean call() throws Exception {
156156 // assert that line vertical height and styleRange was removed after
157157 // deleting the codeminings
158158 for (int i = 0 ; i < 100 ; i ++) {
159- assertTrue ("line vertical indent not zeri at line index " + i , styledText . getLineVerticalIndent ( i ) == 0 );
159+ assertTrue (styledText . getLineVerticalIndent ( i ) == 0 , "line vertical indent not zeri at line index " + i );
160160 }
161161 style = styledText .getStyleRangeAtOffset (offsetAtLine95 - 1 );
162162 assertTrue (style == null );
163163 }
164164
165165 @ Test
166- public void testInlinedAnnotationSupportIsInLinesReturnsValidResultAfterDocumentChange () throws Exception {
166+ void testInlinedAnnotationSupportIsInLinesReturnsValidResultAfterDocumentChange () throws Exception {
167167 IFile file = project .getFile ("test.testprojectionviewer" );
168168 if (file .exists ()) {
169169 file .delete (true , new NullProgressMonitor ());
@@ -185,8 +185,7 @@ public void testInlinedAnnotationSupportIsInLinesReturnsValidResultAfterDocument
185185 additions .put (annot , new Position (0 , source .length ()));
186186 annotationModel .modifyAnnotations (deletionsArray , additions , null );
187187
188- Assert .assertTrue ("Line header code mining above 3rd line not drawn" ,
189- waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
188+ Assertions .assertTrue (waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
190189 @ Override
191190 public Boolean call () throws Exception {
192191 try {
@@ -196,14 +195,13 @@ public Boolean call() throws Exception {
196195 return false ;
197196 }
198197 }
199- }));
198+ }), "Line header code mining above 3rd line not drawn" );
200199
201200 IDocument doc = viewer .getDocument ();
202201 widget .setCaretOffset (offset );
203202 doc .replace (offset , 0 , "\n insert text" );
204203 drainEventQueue ();
205- Assert .assertTrue ("Line header code mining above 4th line after inserting text not drawn" ,
206- waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
204+ Assertions .assertTrue (waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
207205 @ Override
208206 public Boolean call () throws Exception {
209207 try {
@@ -213,11 +211,11 @@ public Boolean call() throws Exception {
213211 return false ;
214212 }
215213 }
216- }));
214+ }), "Line header code mining above 4th line after inserting text not drawn" );
217215 }
218216
219217 @ Test
220- public void testCodeMiningOnEmptyLine () throws Exception {
218+ void testCodeMiningOnEmptyLine () throws Exception {
221219 IFile file = project .getFile ("test.txt" );
222220 if (file .exists ()) {
223221 file .delete (true , new NullProgressMonitor ());
@@ -230,21 +228,19 @@ public void testCodeMiningOnEmptyLine() throws Exception {
230228 drainEventQueue ();
231229 ISourceViewer viewer = (ISourceViewer ) editor .getAdapter (ITextViewer .class );
232230 StyledText widget = viewer .getTextWidget ();
233- Assert .assertTrue ("line content mining not available" ,
234- waitForCondition (widget .getDisplay (), 1000 , new Callable <Boolean >() {
231+ Assertions .assertTrue (waitForCondition (widget .getDisplay (), 1000 , new Callable <Boolean >() {
235232 @ Override
236233 public Boolean call () throws Exception {
237234 return widget .getStyleRangeAtOffset (0 ) != null
238235 && widget .getStyleRangeAtOffset (0 ).metrics != null ;
239236 }
240- }));
237+ }), "line content mining not available" );
241238 drainEventQueue ();
242239
243240 CodeMiningTestProvider .provideHeaderMiningAtLine = 1 ;
244241 ((ISourceViewerExtension5 ) viewer ).updateCodeMinings ();
245242
246- Assert .assertTrue ("Code mining not drawn at empty line after calling updateCodeMinings" ,
247- waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
243+ Assertions .assertTrue (waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
248244 @ Override
249245 public Boolean call () throws Exception {
250246 try {
@@ -254,11 +250,11 @@ public Boolean call() throws Exception {
254250 return false ;
255251 }
256252 }
257- }));
253+ }), "Code mining not drawn at empty line after calling updateCodeMinings" );
258254 }
259255
260256 @ Test
261- public void testCodeMiningAtEndOfLine () throws Exception {
257+ void testCodeMiningAtEndOfLine () throws Exception {
262258 IFile file = project .getFile ("test.txt" );
263259 if (file .exists ()) {
264260 file .delete (true , new NullProgressMonitor ());
@@ -273,21 +269,19 @@ public void testCodeMiningAtEndOfLine() throws Exception {
273269 drainEventQueue ();
274270 ISourceViewer viewer = (ISourceViewer ) editor .getAdapter (ITextViewer .class );
275271 StyledText widget = viewer .getTextWidget ();
276- Assert .assertTrue ("line content mining not available" ,
277- waitForCondition (widget .getDisplay (), 1000 , new Callable <Boolean >() {
272+ Assertions .assertTrue (waitForCondition (widget .getDisplay (), 1000 , new Callable <Boolean >() {
278273 @ Override
279274 public Boolean call () throws Exception {
280275 return widget .getStyleRangeAtOffset (0 ) != null
281276 && widget .getStyleRangeAtOffset (0 ).metrics != null ;
282277 }
283- }));
278+ }), "line content mining not available" );
284279 drainEventQueue ();
285280
286281 CodeMiningTestProvider .provideContentMiningAtOffset = firstPart .length ();
287282 ((ISourceViewerExtension5 ) viewer ).updateCodeMinings ();
288283
289- Assert .assertTrue ("Code mining not drawn at the end of second line after calling updateCodeMinings" ,
290- waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
284+ Assertions .assertTrue (waitForCondition (widget .getDisplay (), 2000 , new Callable <Boolean >() {
291285 @ Override
292286 public Boolean call () throws Exception {
293287 try {
@@ -297,7 +291,7 @@ public Boolean call() throws Exception {
297291 return false ;
298292 }
299293 }
300- }));
294+ }), "Code mining not drawn at the end of second line after calling updateCodeMinings" );
301295 }
302296
303297 private void drainEventQueue () {
@@ -411,4 +405,4 @@ private final boolean waitForCondition(Display display, long timeout, Callable<B
411405 } while (!cond && diff < timeout );
412406 return cond ;
413407 }
414- }
408+ }
0 commit comments