Skip to content

Commit 8a511e3

Browse files
committed
Use convenient IFile.create in genericeditor tests
1 parent 3e0779e commit 8a511e3

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AbstratGenericEditorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static org.eclipse.ui.tests.harness.util.UITestUtil.processEvents;
1919
import static org.eclipse.ui.tests.harness.util.UITestUtil.waitForJobs;
2020

21-
import java.io.ByteArrayInputStream;
2221
import java.nio.charset.StandardCharsets;
2322
import java.util.function.Supplier;
2423

@@ -29,6 +28,7 @@
2928

3029
import org.eclipse.core.resources.IFile;
3130
import org.eclipse.core.resources.IProject;
31+
import org.eclipse.core.resources.IResource;
3232
import org.eclipse.core.resources.ResourcesPlugin;
3333

3434
import org.eclipse.ui.IEditorInput;
@@ -91,7 +91,7 @@ protected void createAndOpenFile(String name, String contents) throws Exception
9191
*/
9292
protected void createAndOpenFile(String name, String contents, Supplier<? extends IEditorInput> inputCreator) throws Exception {
9393
this.file = project.getFile(name);
94-
this.file.create(new ByteArrayInputStream(contents.getBytes(StandardCharsets.UTF_8)), true, null);
94+
this.file.create(contents.getBytes(StandardCharsets.UTF_8), IResource.FORCE, null);
9595
this.file.setCharset(StandardCharsets.UTF_8.name(), null);
9696
this.editor = (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
9797
.getActivePage().openEditor(inputCreator.get(), "org.eclipse.ui.genericeditor.GenericEditor");

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/IconsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import static org.eclipse.ui.tests.harness.util.DisplayHelper.runEventLoop;
1616
import static org.junit.Assert.assertEquals;
1717

18-
import java.io.ByteArrayInputStream;
1918
import java.lang.reflect.Field;
2019

2120
import org.junit.After;
@@ -27,6 +26,7 @@
2726

2827
import org.eclipse.core.resources.IFile;
2928
import org.eclipse.core.resources.IProject;
29+
import org.eclipse.core.resources.IResource;
3030
import org.eclipse.core.resources.ResourcesPlugin;
3131

3232
import org.eclipse.jface.resource.ImageDescriptor;
@@ -51,7 +51,7 @@ public void testEditorIconParentSet() throws Exception {
5151
testProject.open(null);
5252

5353
testFile= testProject.getFile("foobar.txt");
54-
testFile.create(new ByteArrayInputStream("Testing file".getBytes()), true, null);
54+
testFile.create("Testing file".getBytes(), IResource.FORCE, null);
5555

5656
genericEditor= (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
5757
.getActivePage().openEditor(new FileEditorInput(testFile), "org.eclipse.ui.genericeditor.GenericEditor");
@@ -72,7 +72,7 @@ public void testEditorIconChildSet() throws Exception {
7272
testProject.open(null);
7373

7474
testFile= testProject.getFile("foo.txt");
75-
testFile.create(new ByteArrayInputStream("Testing file".getBytes()), true, null);
75+
testFile.create("Testing file".getBytes(), IResource.FORCE, null);
7676

7777
genericEditor= (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
7878
.getActivePage().openEditor(new FileEditorInput(testFile), "org.eclipse.ui.genericeditor.GenericEditor");

tests/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ReconcilerTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
import static org.eclipse.ui.tests.harness.util.DisplayHelper.runEventLoop;
1717
import static org.junit.Assert.assertTrue;
1818

19-
import java.io.ByteArrayInputStream;
20-
2119
import org.junit.Test;
2220

2321
import org.eclipse.core.runtime.NullProgressMonitor;
2422

2523
import org.eclipse.core.resources.IFile;
2624
import org.eclipse.core.resources.IProject;
25+
import org.eclipse.core.resources.IResource;
2726
import org.eclipse.core.resources.ResourcesPlugin;
2827

2928
import org.eclipse.jface.text.BadLocationException;
@@ -68,7 +67,7 @@ public void testMultipleEditors() throws Exception {
6867
secondProject.create(null);
6968
secondProject.open(null);
7069
secondFile= secondProject.getFile("foo.txt");
71-
secondFile.create(new ByteArrayInputStream("bar 'bar'".getBytes()), true, null);
70+
secondFile.create("bar 'bar'".getBytes(), IResource.FORCE, null);
7271
secondEditor = (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
7372
.getActivePage().openEditor(new FileEditorInput(secondFile), "org.eclipse.ui.genericeditor.GenericEditor");
7473
performTestOnEditor(ReconcilerStrategyFirst.SEARCH_TERM, editor, ReconcilerStrategyFirst.REPLACEMENT);
@@ -77,7 +76,7 @@ public void testMultipleEditors() throws Exception {
7776
@Test
7877
public void testMultipleReconcilers() throws Exception {
7978
secondFile = project.getFile("bar.txt");
80-
secondFile.create(new ByteArrayInputStream("".getBytes()), true, null);
79+
secondFile.create("".getBytes(), IResource.FORCE, null);
8180
secondEditor = (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
8281
.getActivePage().openEditor(new FileEditorInput(secondFile), "org.eclipse.ui.genericeditor.GenericEditor");
8382
performTestOnEditor(ReconcilerStrategyFirst.SEARCH_TERM, secondEditor, ReconcilerStrategySecond.REPLACEMENT);

0 commit comments

Comments
 (0)