11/*******************************************************************************
2- * Copyright (c) 2000, 2013 IBM Corporation and others.
2+ * Copyright (c) 2000, 2026 IBM Corporation and others.
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
1818import static org .junit .jupiter .api .Assertions .assertNotNull ;
1919import static org .junit .jupiter .api .Assertions .assertNull ;
2020import static org .junit .jupiter .api .Assertions .assertSame ;
21+ import static org .junit .jupiter .api .Assertions .assertThrows ;
2122import static org .junit .jupiter .api .Assertions .assertTrue ;
2223
2324import java .io .File ;
4546import org .eclipse .jface .text .BadLocationException ;
4647import org .eclipse .jface .text .IDocument ;
4748
48-
49-
5049public class FileBufferCreation {
5150
5251 private final static String CONTENT1 = "This is the content of the workspace file." ;
5352 private final static String CONTENT2 = "This is the content of the link target." ;
5453 private final static String CONTENT3 = "This is the content of the external file." ;
5554 private final static String CONTENT4 = "This is the content of a file in a linked folder." ;
5655
57-
5856 private IProject fProject ;
5957
60-
6158 @ BeforeEach
6259 public void setUp () throws Exception {
6360 fProject = ResourceHelper .createProject ("project" );
@@ -166,11 +163,7 @@ public void test2() throws Exception {
166163 assertEquals (CONTENT1 , document2 .get ());
167164 assertSame (buffer2 , manager .getTextFileBuffer (document2 ));
168165
169- try {
170- document1 .replace (0 , document1 .getLength (), CONTENT3 );
171- } catch (BadLocationException x ) {
172- assertTrue (false );
173- }
166+ assertThrows (BadLocationException .class , () -> document1 .replace (0 , document1 .getLength (), CONTENT3 ));
174167
175168 assertEquals (CONTENT3 , document2 .get ());
176169
@@ -198,7 +191,7 @@ public void test3_1() throws Exception {
198191
199192 IDocument document = buffer .getDocument ();
200193 assertNotNull (document );
201- assertTrue (CONTENT2 . equals ( document .get () ));
194+ assertEquals (CONTENT2 , document .get ());
202195 assertSame (buffer , manager .getTextFileBuffer (document ));
203196
204197 manager .disconnect (path , LocationKind .NORMALIZE , null );
@@ -221,7 +214,7 @@ public void test3_2() throws Exception {
221214
222215 IDocument document = buffer .getDocument ();
223216 assertNotNull (document );
224- assertTrue (CONTENT4 . equals ( document .get () ));
217+ assertEquals (CONTENT4 , document .get ());
225218 assertSame (buffer , manager .getTextFileBuffer (document ));
226219
227220 manager .disconnect (path , LocationKind .NORMALIZE , null );
@@ -259,11 +252,7 @@ public void test4() throws Exception {
259252 assertEquals (document1 .get (), document2 .get ());
260253 assertEquals (CONTENT2 , document1 .get ());
261254
262- try {
263- document1 .replace (0 , document1 .getLength (), CONTENT1 );
264- } catch (BadLocationException x ) {
265- assertFalse (false );
266- }
255+ document1 .replace (0 , document1 .getLength (), CONTENT1 );
267256
268257 assertFalse (document1 .get ().equals (document2 .get ()));
269258
@@ -290,7 +279,7 @@ public void test5() throws Exception {
290279
291280 IDocument document = buffer .getDocument ();
292281 assertNotNull (document );
293- assertTrue (CONTENT3 . equals ( document .get () ));
282+ assertEquals (CONTENT3 , document .get ());
294283 assertSame (buffer , manager .getTextFileBuffer (document ));
295284
296285 manager .disconnect (path , LocationKind .NORMALIZE , null );
@@ -330,11 +319,7 @@ public void test6() throws Exception {
330319 assertEquals (document1 .get (), document2 .get ());
331320 assertEquals (CONTENT3 , document1 .get ());
332321
333- try {
334- document1 .replace (0 , document1 .getLength (), CONTENT1 );
335- } catch (BadLocationException x ) {
336- assertFalse (false );
337- }
322+ document1 .replace (0 , document1 .getLength (), CONTENT1 );
338323
339324 assertFalse (document1 .get ().equals (document2 .get ()));
340325
@@ -359,7 +344,7 @@ public void test7() throws Exception {
359344
360345 IDocument document = buffer .getDocument ();
361346 assertNotNull (document );
362- assertTrue ("" . equals ( document .get ()));
347+ assertTrue (document .get (). isEmpty ( ));
363348 assertSame (buffer , manager .getTextFileBuffer (document ));
364349
365350 manager .disconnect (path , LocationKind .NORMALIZE , null );
@@ -428,11 +413,7 @@ public void test2_new() throws Exception {
428413 assertEquals (CONTENT1 , document2 .get ());
429414 assertSame (buffer2 , manager .getTextFileBuffer (document2 ));
430415
431- try {
432- document1 .replace (0 , document1 .getLength (), CONTENT3 );
433- } catch (BadLocationException x ) {
434- assertTrue (false );
435- }
416+ assertThrows (BadLocationException .class , () -> document1 .replace (0 , document1 .getLength (), CONTENT3 ));
436417
437418 assertEquals (CONTENT3 , document2 .get ());
438419
@@ -460,7 +441,7 @@ public void test3_1_IFILE() throws Exception {
460441
461442 IDocument document = buffer .getDocument ();
462443 assertNotNull (document );
463- assertTrue (CONTENT2 . equals ( document .get () ));
444+ assertEquals (CONTENT2 , document .get ());
464445 assertSame (buffer , manager .getTextFileBuffer (document ));
465446
466447 manager .disconnect (path , LocationKind .IFILE , null );
@@ -483,7 +464,7 @@ public void test3_2_new() throws Exception {
483464
484465 IDocument document = buffer .getDocument ();
485466 assertNotNull (document );
486- assertTrue (CONTENT4 . equals ( document .get () ));
467+ assertEquals (CONTENT4 , document .get ());
487468 assertSame (buffer , manager .getTextFileBuffer (document ));
488469
489470 manager .disconnect (path , LocationKind .IFILE , null );
@@ -521,11 +502,7 @@ public void test4_IFILE() throws Exception {
521502 assertEquals (document1 .get (), document2 .get ());
522503 assertEquals (CONTENT2 , document1 .get ());
523504
524- try {
525- document1 .replace (0 , document1 .getLength (), CONTENT1 );
526- } catch (BadLocationException x ) {
527- assertFalse (false );
528- }
505+ document1 .replace (0 , document1 .getLength (), CONTENT1 );
529506
530507 assertFalse (document1 .get ().equals (document2 .get ()));
531508
@@ -552,7 +529,7 @@ public void test5_location() throws Exception {
552529
553530 IDocument document = buffer .getDocument ();
554531 assertNotNull (document );
555- assertTrue (CONTENT3 . equals ( document .get () ));
532+ assertEquals (CONTENT3 , document .get ());
556533 assertSame (buffer , manager .getTextFileBuffer (document ));
557534
558535 manager .disconnect (path , LocationKind .LOCATION , null );
@@ -574,7 +551,7 @@ public void test7_location() throws Exception {
574551
575552 IDocument document = buffer .getDocument ();
576553 assertNotNull (document );
577- assertTrue ("" . equals ( document .get ()));
554+ assertTrue (document .get (). isEmpty ( ));
578555 assertSame (buffer , manager .getTextFileBuffer (document ));
579556
580557 manager .disconnect (path , LocationKind .LOCATION , null );
@@ -597,7 +574,7 @@ public void test7_IFileStore() throws Exception {
597574
598575 IDocument document = buffer .getDocument ();
599576 assertNotNull (document );
600- assertTrue ("" . equals ( document .get ()));
577+ assertTrue (document .get (). isEmpty ( ));
601578 assertSame (buffer , manager .getTextFileBuffer (document ));
602579
603580 manager .disconnectFileStore (fileStore , null );
0 commit comments