Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2015-01-07 11:25:09 -0500
committerTobias Oberlies2015-01-08 04:34:38 -0500
commit3e1ee0a24a2946e1acc975c39a687c559262c4de (patch)
tree6cb850af65a235b2948ef41b65beff1326f34989
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
-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
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java2
4 files changed, 22 insertions, 8 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();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
index b07f491bf..255bef63e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
@@ -24,7 +24,6 @@ import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import org.eclipse.swt.widgets.Shell;
/**
* Utility methods for manipulating model elements.
@@ -34,7 +33,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public class ElementUtils {
- public static void updateRepositoryUsingElements(final ProvisioningUI ui, final MetadataRepositoryElement[] elements, final Shell shell) {
+ public static void updateRepositoryUsingElements(final ProvisioningUI ui, final MetadataRepositoryElement[] elements) {
ui.signalRepositoryOperationStart();
IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
IArtifactRepositoryManager artManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
index 914f56c2d..6d0391c86 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
@@ -543,7 +543,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
*/
public boolean performOk() {
if (changed)
- ElementUtils.updateRepositoryUsingElements(ui, getElements(), getShell());
+ ElementUtils.updateRepositoryUsingElements(ui, getElements());
originalNameCache.clear();
originalURICache.clear();
return super.performOk();

Back to the top