Skip to content

Commit

Permalink
Fix another batch of tests and patches for 2022-09 eclipse. fixes ecl…
Browse files Browse the repository at this point in the history
…ipse-archived#2156

Signed-off-by: Ondrej Dockal <[email protected]>
  • Loading branch information
odockal committed Sep 6, 2022
1 parent 6f4f3ce commit ac823d0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
*******************************************************************************/
package org.eclipse.reddeer.eclipse.jdt.ui.wizards;

import org.eclipse.reddeer.core.exception.CoreLayerException;
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.eclipse.reddeer.swt.impl.button.LabeledCheckBox;
import org.eclipse.reddeer.swt.impl.button.RadioButton;
import org.eclipse.reddeer.swt.impl.text.LabeledText;

/**
Expand Down Expand Up @@ -81,7 +82,11 @@ public boolean getFinalModifierCheckboxState() {
* @param toggle final modifier checkbox
*/
public NewClassWizardPage toggleFinalModifierCheckbox(boolean toggle) {
new CheckBox(this, "final").toggle(toggle);
try {
new CheckBox(this, "final").toggle(toggle);
} catch (CoreLayerException exc) {
new RadioButton(this, "final").toggle(toggle);
}
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,6 @@ public void testAddingAndRemovingNonexistingAndNotFullySpecifiedInterfaces() {
new PushButton("Cancel").click();
}

// try to add an extended interface, that is not fully specified by its name
try {
classPage.addExtendedInterface("Acl");
fail("RedDeer exception was not thrown when trying to add an extended interface, that is not fully specified by its name.");
} catch (RedDeerException e) {
new PushButton("Cancel").click();
}

// try to remove an extended interface, that is not on the list
try {
classPage.removeExtendedInterface("javax.accessibility.AccessibleAction");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
import java.util.List;

import org.eclipse.reddeer.common.exception.RedDeerException;
import org.eclipse.reddeer.common.matcher.RegexMatcher;
import org.eclipse.reddeer.common.wait.TimePeriod;
import org.eclipse.reddeer.common.wait.WaitUntil;
import org.eclipse.reddeer.common.wait.WaitWhile;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.JavaProjectWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard;
import org.eclipse.reddeer.eclipse.jdt.ui.wizards.NewInterfaceCreationWizardPage;
Expand All @@ -29,6 +32,7 @@
import org.eclipse.reddeer.eclipse.ui.perspectives.JavaPerspective;
import org.eclipse.reddeer.junit.runner.RedDeerSuite;
import org.eclipse.reddeer.requirements.openperspective.OpenPerspectiveRequirement.OpenPerspective;
import org.eclipse.reddeer.swt.condition.ShellIsAvailable;
import org.eclipse.reddeer.swt.impl.button.PushButton;
import org.eclipse.reddeer.workbench.condition.EditorWithTitleIsActive;
import org.eclipse.reddeer.workbench.handler.EditorHandler;
Expand Down Expand Up @@ -62,6 +66,11 @@ public static void setup() {

@After
public void closeAllEditors() {
ShellIsAvailable shell = new ShellIsAvailable(new WithTextMatcher(new RegexMatcher("[Extended|Implemented].*Interfaces Selection")));
new WaitWhile(shell, TimePeriod.SHORT, false);
if (shell.getResult() != null) {
shell.getResult().close();
}
EditorHandler.getInstance().closeAll(true);
}

Expand Down Expand Up @@ -226,14 +235,6 @@ public void testAddingAndRemovingNonexistingAndNotFullySpecifiedInterfaces() {
new PushButton("Cancel").click();
}

// try to add an extended interface, that is not fully specified by its name
try {
interfacePage.addExtendedInterface("Acl");
fail("RedDeer exception was not thrown when trying to add an extended interface, that is not fully specified by its name.");
} catch (RedDeerException e) {
new PushButton("Cancel").click();
}

// try to remove an extended interface, that is not on the list
try {
interfacePage.removeExtendedInterface("javax.accessibility.AccessibleAction");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public void setup() {

@Test
public void testBrowserPreferencePage() {
assertEquals("1", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY));
page.toggleExternalBrowser();
page.apply();
assertEquals("1", Preferences.get(BROWSER_PLUGIN, BROWSER_KEY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.List;

import org.eclipse.reddeer.eclipse.core.resources.DefaultProject;
Expand Down Expand Up @@ -71,12 +73,14 @@ public void addAll_removeTwo(){
ModifyModulesPage page = new ModifyModulesPage(dialog);
page.addAll();
dialog.finish();
List<String> expectedBefore = Arrays.asList(PROJECT_1, PROJECT_2, PROJECT_3);

List<ServerModule> modules = server.getModules();
assertThat(modules.size(), is(3));
assertThat(modules.get(0).getLabel().getName(), is(PROJECT_1));
assertThat(modules.get(1).getLabel().getName(), is(PROJECT_2));
assertThat(modules.get(2).getLabel().getName(), is(PROJECT_3));

modules.stream().forEach(mod -> {
assertTrue(expectedBefore.contains(mod.getLabel().getName()));
});

dialog = server.addAndRemoveModules();
page = new ModifyModulesPage(dialog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.List;

import org.eclipse.reddeer.eclipse.wst.server.ui.cnf.Server;
Expand Down Expand Up @@ -76,19 +78,24 @@ public void removeServerModule() {
ModifyModulesPage page = new ModifyModulesPage(dialog);
page.addAll();
dialog.finish();
List<String> expectedBefore = Arrays.asList(PROJECT_1, PROJECT_2, PROJECT_3);
List<String> expectedAfter = Arrays.asList(PROJECT_1, PROJECT_3);

List<ServerModule> modules = server.getModules();
assertThat(modules.size(), is(3));
assertThat(modules.get(0).getLabel().getName(), is(PROJECT_1));
assertThat(modules.get(1).getLabel().getName(), is(PROJECT_2));
assertThat(modules.get(2).getLabel().getName(), is(PROJECT_3));
modules.stream().forEach(mod -> {
assertTrue(expectedBefore.contains(mod.getLabel().getName()));
});

modules.get(0).remove();
ServerModule module = modules.stream().filter(item -> item.getLabel().getName().equals(PROJECT_2)).findFirst().orElse(null);
assertNotNull(module);
module.remove();

modules = server.getModules();
assertThat(modules.size(), is(2));
assertThat(modules.get(0).getLabel().getName(), is(PROJECT_2));
assertThat(modules.get(1).getLabel().getName(), is(PROJECT_3));
modules.stream().forEach(mod -> {
assertTrue(expectedAfter.contains(mod.getLabel().getName()));
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected static void createServer(String name) {

NewServerWizardPage newServerPage = new NewServerWizardPage(wizardDialog);
newServerPage.selectType("Basic", TestServer.NAME);
newServerPage.setName(name);
newServerPage.setName(name);

wizardDialog.finish();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,4 @@ public void stopModule(IModule[] module, IProgressMonitor monitor) throws CoreEx
AbstractWait.sleep(TimePeriod.SHORT);
setModuleState(module, IServer.STATE_STOPPED);
}


}

0 comments on commit ac823d0

Please sign in to comment.