Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2015-01-07 16:25:09 +0000
committerTobias Oberlies2015-01-08 09:34:38 +0000
commit3e1ee0a24a2946e1acc975c39a687c559262c4de (patch)
tree6cb850af65a235b2948ef41b65beff1326f34989 /bundles/org.eclipse.equinox.p2.tests.ui/src/org
parent75d234230a8cee01748555881d1950d3b084d2fe (diff)
downloadrt.equinox.p2-3e1ee0a24a2946e1acc975c39a687c559262c4de.tar.gz
rt.equinox.p2-3e1ee0a24a2946e1acc975c39a687c559262c4de.tar.xz
rt.equinox.p2-3e1ee0a24a2946e1acc975c39a687c559262c4de.zip
456940 Work around NPE in getActiveWorkbenchWindow in tests on Hudson
- Remove unused parameter in ElementUtils, which would require calling the problematic getActiveWorkbenchWindow in the test. - Do an extra call to getActiveWorkbenchWindow() and ignore potential exceptions before the first time the method is needed in the IUPropertyPagesTest. Bug: 456940 Change-Id: Ie3a38c2576ebc96e831ff2eb685a8c595c3ae5ff
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests.ui/src/org')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java22
2 files changed, 20 insertions, 5 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
index 258c1f5f4..c597e9e0b 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/actions/ElementUtilsTest.java
@@ -20,7 +20,6 @@ import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
-import org.eclipse.ui.PlatformUI;
/**
* @since 3.5
@@ -86,7 +85,7 @@ public class ElementUtilsTest extends ProfileModificationActionTest {
// We expect uri3 to get removed (as if it had been removed from a pref page)
// System repos shouldn't be touched
- ElementUtils.updateRepositoryUsingElements(getProvisioningUI(), elements, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ ElementUtils.updateRepositoryUsingElements(getProvisioningUI(), elements);
URI[] enabled = getMetadataRepositoryManager().getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
URI[] disabled = getMetadataRepositoryManager().getKnownRepositories(IRepositoryManager.REPOSITORIES_DISABLED);
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java
index d076d3cd1..b4a0b779b 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/IUPropertyPagesTest.java
@@ -10,12 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.dialogs;
-import org.eclipse.equinox.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.tests.ui.AbstractProvisioningUITest;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.dialogs.PropertyDialog;
@@ -29,7 +27,23 @@ public class IUPropertyPagesTest extends AbstractProvisioningUITest {
private static final String COPYRIGHT = "org.eclipse.equinox.p2.ui.sdk.IUCopyrightPropertyPage";
private static final String LICENSE = "org.eclipse.equinox.p2.ui.sdk.IULicensePropertyPage";
+ private static boolean initialized;
+
+ public static void init() {
+ if (!initialized) {
+ // workaround for bug 456940
+ try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ } catch (Exception e) {
+ System.err.println("Bug 456940: First invocation of getActiveWorkbenchWindow() threw an Exception:");
+ e.printStackTrace();
+ }
+ initialized = true;
+ }
+ }
+
public void testGeneralPage() throws URISyntaxException {
+ init();
PropertyDialog dialog = PropertyDialog.createDialogOn(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), GENERAL, getIU());
dialog.setBlockOnOpen(false);
dialog.open();
@@ -41,6 +55,7 @@ public class IUPropertyPagesTest extends AbstractProvisioningUITest {
}
public void testCopyrightPage() throws URISyntaxException {
+ init();
PropertyDialog dialog = PropertyDialog.createDialogOn(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), COPYRIGHT, getIU());
dialog.setBlockOnOpen(false);
dialog.open();
@@ -52,6 +67,7 @@ public class IUPropertyPagesTest extends AbstractProvisioningUITest {
}
public void testLicensePage() throws URISyntaxException {
+ init();
PropertyDialog dialog = PropertyDialog.createDialogOn(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), LICENSE, getIU());
dialog.setBlockOnOpen(false);
dialog.open();

Back to the top