Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ Automatic-Module-Name: org.eclipse.ui.workbench.texteditor.tests
Import-Package: org.mockito,
org.mockito.stubbing;version="5.5.0",
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)"
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)",
org.opentest4j;version="[1.3.0,2.0.0)"
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
Expand All @@ -33,9 +33,9 @@

import java.util.function.Predicate;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -86,14 +86,14 @@ private void setFindAndReplaceString(IFindReplaceLogic findReplaceLogic, String
findReplaceLogic.setReplaceString(replaceString);
}

@After
@AfterEach
public void disposeShell() {
if (parentShell != null) {
parentShell.dispose();
}
}

@Before
@BeforeEach
public void setupShell() {
parentShell= new Shell();
}
Expand Down Expand Up @@ -252,8 +252,8 @@ public void testPerformSelectAndReplaceRegEx() {
expectStatusEmpty(findReplaceLogic);

status= findReplaceLogic.performSelectAndReplace();
assertEquals("Status wasn't correctly returned", false, status);
assertEquals("Text shouldn't have been changed", "Hello World !", textViewer.getDocument().get());
assertEquals(false, status, "Status wasn't correctly returned");
assertEquals("Hello World !", textViewer.getDocument().get(), "Text shouldn't have been changed");
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);
}

Expand Down Expand Up @@ -288,12 +288,12 @@ public void testPerformSelectAndReplaceRegExWithLinebreaks() {
expectStatusEmpty(findReplaceLogic);

setFindAndReplaceString(findReplaceLogic, """
""", " ");
""", " ");
status= findReplaceLogic.performSelectAndReplace();
assertEquals("Status wasn't correctly returned", false, status);
assertEquals("Text shouldn't have been changed", """
assertEquals(false, status, "Status wasn't correctly returned");
assertEquals("""
Hello!
World!""", textViewer.getDocument().get());
World!""", textViewer.getDocument().get(), "Text shouldn't have been changed");
}

@Test
Expand Down Expand Up @@ -324,8 +324,8 @@ public void testPerformSelectAndReplaceWithConfigurationChanges() {
expectStatusEmpty(findReplaceLogic);

status= findReplaceLogic.performSelectAndReplace();
assertEquals("Status wasn't correctly returned", false, status);
assertEquals("Text shouldn't have been changed", "Hello World ! !", textViewer.getDocument().get());
assertEquals(false, status, "Status wasn't correctly returned");
assertEquals("Hello World ! !", textViewer.getDocument().get(), "Text shouldn't have been changed");
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);
}

Expand Down Expand Up @@ -355,20 +355,20 @@ public void testPerformReplaceAndFind_caseInsensitive() {
setFindAndReplaceString(findReplaceLogic, "<Replace>", " ");

boolean status= findReplaceLogic.performReplaceAndFind();
assertTrue("replace should have been performed", status);
assertTrue(status, "replace should have been performed");
assertThat(textViewer.getDocument().get(), equalTo("Hello World<replace>!"));
assertThat(findReplaceLogic.getTarget().getSelectionText(), equalTo("<replace>"));
expectStatusEmpty(findReplaceLogic);

setFindAndReplaceString(findReplaceLogic, "<replace>", " ");
status= findReplaceLogic.performReplaceAndFind();
assertTrue("replace should have been performed", status);
assertTrue(status, "replace should have been performed");
assertThat(textViewer.getDocument().get(), equalTo("Hello World !"));
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);

status= findReplaceLogic.performReplaceAndFind();
assertFalse("replace should not have been performed", status);
assertEquals("Text shouldn't have been changed", "Hello World !", textViewer.getDocument().get());
assertFalse(status, "replace should not have been performed");
assertEquals("Hello World !", textViewer.getDocument().get(), "Text shouldn't have been changed");
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);
}

Expand All @@ -381,12 +381,12 @@ public void testPerformReplaceAndFind_caseSensitive() {
setFindAndReplaceString(findReplaceLogic, "<replace>", " ");

boolean status= findReplaceLogic.performReplaceAndFind();
assertTrue("replace should have been performed", status);
assertTrue(status, "replace should have been performed");
assertThat(textViewer.getDocument().get(), equalTo("Hello<Replace>World !"));
assertThat(findReplaceLogic.getTarget().getSelectionText(), equalTo(" "));

status= findReplaceLogic.performReplaceAndFind();
assertFalse("replace should not have been performed", status);
assertFalse(status, "replace should not have been performed");
assertThat(textViewer.getDocument().get(), equalTo("Hello<Replace>World !"));
assertThat(findReplaceLogic.getTarget().getSelectionText(), equalTo(" "));
}
Expand All @@ -400,20 +400,20 @@ public void testPerformReplaceAndFind_caseSensitiveAndIncremental() {
setFindAndReplaceString(findReplaceLogic, "<Replace>", " ");

boolean status= findReplaceLogic.performReplaceAndFind();
assertTrue("replace should have been performed", status);
assertTrue(status, "replace should have been performed");
assertThat(textViewer.getDocument().get(), equalTo("Hello World<replace>!"));
assertThat(findReplaceLogic.getTarget().getSelectionText(), equalTo("<replace>"));
expectStatusEmpty(findReplaceLogic);

setFindAndReplaceString(findReplaceLogic, "<replace>", " ");
status= findReplaceLogic.performReplaceAndFind();
assertTrue("replace should have been performed", status);
assertTrue(status, "replace should have been performed");
assertThat(textViewer.getDocument().get(), equalTo("Hello World !"));
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);

status= findReplaceLogic.performReplaceAndFind();
assertFalse("replace should not have been performed", status);
assertEquals("Text shouldn't have been changed", "Hello World !", textViewer.getDocument().get());
assertFalse(status, "replace should not have been performed");
assertEquals("Hello World !", textViewer.getDocument().get(), "Text shouldn't have been changed");
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);
}

Expand Down Expand Up @@ -484,8 +484,8 @@ private void executeReplaceAndFindRegExTest(TextViewer textViewer, IFindReplaceL

setFindAndReplaceString(findReplaceLogic, "<(\\w*)>", " ");
status= findReplaceLogic.performReplaceAndFind();
assertEquals("Status wasn't correctly returned", false, status);
assertEquals("Text shouldn't have been changed", "Hello World ! !", textViewer.getDocument().get());
assertEquals(false, status, "Status wasn't correctly returned");
assertEquals("Hello World ! !", textViewer.getDocument().get(), "Text shouldn't have been changed");
expectStatusIsCode(findReplaceLogic, FindStatus.StatusCode.NO_MATCH);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.fail;

import java.util.function.Supplier;

Expand Down Expand Up @@ -60,4 +60,4 @@ public static void waitForFocus(Supplier<Boolean> hasFocusValidator, String test
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
******************************************************************************/
package org.eclipse.ui.internal.findandreplace;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ResourceBundle;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

import org.eclipse.swt.SWT;

Expand All @@ -37,17 +36,18 @@
import org.eclipse.ui.texteditor.FindReplaceAction;

public abstract class FindReplaceUITest<AccessType extends IFindReplaceUIAccess> {
@Rule
public TestName testName= new TestName();

protected TestInfo testInfo;

private TextViewer fTextViewer;

private FindReplaceAction findReplaceAction;

private AccessType dialog;

@Before
public final void ensureWorkbenchWindowIsActive() {
@BeforeEach
public final void ensureWorkbenchWindowIsActive(TestInfo info) {
this.testInfo = info;
PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().forceActive();
}

Expand Down Expand Up @@ -80,7 +80,7 @@ protected void reopenFindReplaceUIForTextViewer() {

protected abstract AccessType openUIFromTextViewer(TextViewer viewer);

@After
@AfterEach
public void tearDown() throws Exception {
if (dialog != null) {
dialog.closeAndRestore();
Expand Down Expand Up @@ -388,4 +388,4 @@ protected final IFindReplaceTarget getFindReplaceTarget() {
return fTextViewer.getFindReplaceTarget();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import static org.eclipse.ui.internal.findandreplace.FindReplaceTestUtil.waitForFocus;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.swt.graphics.Point;

Expand Down Expand Up @@ -48,7 +48,7 @@ public OverlayAccess openUIFromTextViewer(TextViewer viewer) {
actionAccessor.invoke("showOverlayInEditor");
FindReplaceOverlay overlay= (FindReplaceOverlay) actionAccessor.get("overlay");
OverlayAccess uiAccess= new OverlayAccess(getFindReplaceTarget(), overlay);
waitForFocus(uiAccess::hasFocus, testName.getMethodName());
waitForFocus(uiAccess::hasFocus, testInfo.getTestMethod().get().getName());
return uiAccess;
}

Expand Down Expand Up @@ -177,7 +177,7 @@ public void testDisableOverlayViaPreference() {
boolean useOverlayPreference= preferences.getBoolean(USE_FIND_REPLACE_OVERLAY, true);
try {
preferences.putBoolean(USE_FIND_REPLACE_OVERLAY, false);
assertFalse("dialog should be closed after changing preference", getDialog().isShown());
assertFalse(getDialog().isShown(), "dialog should be closed after changing preference");
} finally {
preferences.putBoolean(USE_FIND_REPLACE_OVERLAY, useOverlayPreference);
reopenFindReplaceUIForTextViewer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.workbench.texteditor.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.swt.widgets.Composite;

Expand Down Expand Up @@ -231,4 +231,4 @@ public Object getSelectedPage() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
package org.eclipse.ui.workbench.texteditor.tests;

import static org.eclipse.jface.text.DocumentRewriteSessionType.SEQUENTIAL;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
Expand Down Expand Up @@ -169,4 +169,4 @@ public void nonSuspendedLineDifferStaysNonSuspendedAfterDocumentRewriteSession()
assertFalse(fLineDiffer.isSuspended());
}

}
}
Loading
Loading