-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add features to JRE preference page (fixes #2026)
- update eclipse orbit update site to 2019-09 M3 - add setDefault configuration to JRERequirement - add java.target.version property to pom.xml as an option for compilation against different java version Signed-off-by: Ondrej Dockal <odockal@redhat.com>
- Loading branch information
Showing
6 changed files
with
235 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...e.test/src/org/eclipse/reddeer/eclipse/test/jdt/debug/ui/jres/JREsPreferencePageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2019 Red Hat, Inc and others. | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.reddeer.eclipse.test.jdt.debug.ui.jres; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
import org.eclipse.reddeer.core.exception.CoreLayerException; | ||
import org.eclipse.reddeer.eclipse.exception.EclipseLayerException; | ||
import org.eclipse.reddeer.eclipse.jdt.debug.ui.jres.JREsPreferencePage; | ||
import org.eclipse.reddeer.eclipse.jdt.ui.preferences.JREItem; | ||
import org.eclipse.reddeer.junit.runner.RedDeerSuite; | ||
import org.eclipse.reddeer.requirements.property.RequirementPropertyExpandor; | ||
import org.eclipse.reddeer.swt.api.TableItem; | ||
import org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Tests preference page for manipulation of JREs. | ||
* @author odockal | ||
* | ||
*/ | ||
@RunWith(RedDeerSuite.class) | ||
public class JREsPreferencePageTest { | ||
|
||
private WorkbenchPreferenceDialog dialog; | ||
private JREsPreferencePage page; | ||
|
||
@Before | ||
public void setup() { | ||
preferenceIsOpen(); | ||
} | ||
|
||
@Test | ||
public void testAddingJRE() { | ||
addJRE(false); | ||
TableItem jre = getJRETableItem(); | ||
assertFalse(jre.isChecked()); | ||
assertFalse(page.getJREItem(getName()).isDefault()); | ||
} | ||
|
||
@Test | ||
public void testAddingDefaultJRE() { | ||
addJRE(true); | ||
assertEquals(getName() + " (default)", page.getJREItem(getName()).getName()); | ||
assertTrue(page.getJRETableItem(getName()).isChecked()); | ||
} | ||
|
||
@Test(expected=CoreLayerException.class) | ||
public void testJRENotFound() { | ||
page.getJREItem("RandomJRE"); | ||
} | ||
|
||
@Test(expected=EclipseLayerException.class) | ||
public void testOneDefaultJRE() { | ||
for(JREItem item : page.getJREs()) { | ||
page.toggleJRE(item.getName(), false); | ||
} | ||
} | ||
|
||
@After | ||
public void clean() { | ||
preferenceIsOpen(); | ||
for (JREItem item : page.getJREs()) { | ||
if (item.getName().equals(getName())) { | ||
page.deleteJRE(getName()); | ||
} | ||
} | ||
dialog.cancel(); | ||
} | ||
|
||
private TableItem getJRETableItem() { | ||
try { | ||
return page.getJRETableItem(getName()); | ||
} catch (CoreLayerException e) { | ||
fail("Cannot select non existing JRE: " + getName() + ". Only existing JREs are: " + | ||
page.getJREs().stream().map(item -> item.getName()).collect(Collectors.joining(", "))); | ||
} | ||
return null; | ||
} | ||
|
||
public static void addJRE(boolean setDefault) { | ||
WorkbenchPreferenceDialog dialog = new WorkbenchPreferenceDialog(); | ||
dialog.open(); | ||
JREsPreferencePage page = new JREsPreferencePage(dialog); | ||
dialog.select(page); | ||
page.addJRE(getPath(), getName()); | ||
if (setDefault) { | ||
page.setDefaultJRE(getName()); | ||
} | ||
} | ||
|
||
public static String getName() { | ||
return "jre.test"; | ||
} | ||
|
||
public static String getPath() { | ||
return RequirementPropertyExpandor.getProperty("${java.home}"); | ||
} | ||
|
||
private void preferenceIsOpen() { | ||
if (dialog == null || !dialog.isOpen()) { | ||
dialog = new WorkbenchPreferenceDialog(); | ||
dialog.open(); | ||
page = new JREsPreferencePage(dialog); | ||
dialog.select(page); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters