Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-01-19 10:28:14 +0000
committerJeff Johnston2016-01-21 22:39:48 +0000
commitc898d6287508ef68fcb78f8a633f1e2fb7154f66 (patch)
tree144e2e736e193b7f0cd446abd08d86710891212b
parent0a191f677d6a8e61bb9b1e1c97566568f72c9972 (diff)
downloadorg.eclipse.linuxtools-c898d6287508ef68fcb78f8a633f1e2fb7154f66.tar.gz
org.eclipse.linuxtools-c898d6287508ef68fcb78f8a633f1e2fb7154f66.tar.xz
org.eclipse.linuxtools-c898d6287508ef68fcb78f8a633f1e2fb7154f66.zip
Bug 485973 - clicking test connection does not behave as expected
Removing the part of code that blocks until the Docker daemon responded to the 'ping' request (or time out occurred) Also, fixed side problem where the client is null when creating the connection, so the ping would fail immediatly o_O Also fixed problems in SWTBot tests where the Docker Explorer view was closed during some previous tests, leading to an error. Change-Id: I18331aa5cdd9aa09d095fc15dc2bb256f507fc7d Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/64635 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> (cherry picked from commit f6004ac2bd042404323afeac9b83c108f3864932) Reviewed-on: https://git.eclipse.org/r/64924
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java8
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionSWTBotTest.java19
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java95
3 files changed, 66 insertions, 56 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java
index 28101ffa9e..d7876ea71f 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerViewSWTBotTest.java
@@ -73,16 +73,16 @@ public class DockerExplorerViewSWTBotTest {
this.bot = new SWTWorkbenchBot();
SWTUtils.asyncExec(() -> {try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .showView("org.eclipse.linuxtools.docker.ui.dockerExplorerView");
+ .showView(DockerExplorerView.VIEW_ID);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
}});
- this.dockerExplorerViewBot = bot.viewById("org.eclipse.linuxtools.docker.ui.dockerExplorerView");
+ this.dockerExplorerViewBot = bot.viewById(DockerExplorerView.VIEW_ID);
this.dockerExplorerView = (DockerExplorerView) (dockerExplorerViewBot.getViewReference().getView(true));
this.bot.views().stream()
- .filter(v -> v.getReference().getId().equals("org.eclipse.linuxtools.docker.ui.dockerContainersView")
- || v.getReference().getId().equals("org.eclipse.linuxtools.docker.ui.dockerImagesView")
+ .filter(v -> v.getReference().getId().equals(DockerContainersView.VIEW_ID)
+ || v.getReference().getId().equals(DockerImagesView.VIEW_ID)
|| v.getReference().getId().equals("org.eclipse.ui.views.PropertySheet"))
.forEach(v -> v.close());
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionSWTBotTest.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionSWTBotTest.java
index ba401cf1f4..139d8554fb 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionSWTBotTest.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionSWTBotTest.java
@@ -18,13 +18,19 @@ import org.eclipse.linuxtools.internal.docker.ui.testutils.MockDockerConnectionS
import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.CheckBoxAssertion;
import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.CloseWelcomePageRule;
import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.RadioAssertion;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTUtils;
import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.TextAssertion;
+import org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView;
+import org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView;
+import org.eclipse.linuxtools.internal.docker.ui.views.DockerImagesView;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.eclipse.ui.PlatformUI;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
@@ -45,11 +51,18 @@ public class NewDockerConnectionSWTBotTest {
@Before
public void lookupDockerExplorerView() throws Exception {
- dockerExplorerViewBot = bot.viewById("org.eclipse.linuxtools.docker.ui.dockerExplorerView");
+ SWTUtils.asyncExec(() -> {try {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .showView(DockerExplorerView.VIEW_ID);
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
+ }});
+ dockerExplorerViewBot = bot.viewById(DockerExplorerView.VIEW_ID);
dockerExplorerViewBot.show();
bot.views().stream()
- .filter(v -> v.getReference().getId().equals("org.eclipse.linuxtools.docker.ui.dockerContainersView")
- || v.getReference().getId().equals("org.eclipse.linuxtools.docker.ui.dockerImagesView"))
+ .filter(v -> v.getReference().getId().equals(DockerContainersView.VIEW_ID)
+ || v.getReference().getId().equals(DockerImagesView.VIEW_ID))
.forEach(v -> v.close());
dockerExplorerViewBot.setFocus();
this.addConnectionButton = dockerExplorerViewBot.toolbarButton("&Add Connection");
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java
index b2d36174a1..81ccbe26d1 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionPage.java
@@ -21,8 +21,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.TimeUnit;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeanProperties;
@@ -92,6 +90,9 @@ public class NewDockerConnectionPage extends WizardPage {
private final NewDockerConnectionPageModel model;
+ /**
+ * Constructor.
+ */
public NewDockerConnectionPage() {
super("NewDockerConnectionPage", //$NON-NLS-1$
WizardMessages.getString("NewDockerConnectionPage.title"), //$NON-NLS-1$
@@ -561,8 +562,6 @@ public class NewDockerConnectionPage extends WizardPage {
@Override
public void widgetSelected(SelectionEvent e) {
- final ArrayBlockingQueue<Boolean> resultQueue = new ArrayBlockingQueue<>(
- 1);
try {
getWizard().getContainer().run(true, false,
new IRunnableWithProgress() {
@@ -574,65 +573,63 @@ public class NewDockerConnectionPage extends WizardPage {
IProgressMonitor.UNKNOWN);
try {
final DockerConnection dockerConnection = getDockerConnection();
- if (dockerConnection.getClient() != null) {
- dockerConnection.open(false);
- dockerConnection.ping();
- dockerConnection.close();
- resultQueue.add(true);
- } else {
- resultQueue.add(false);
- }
+ dockerConnection.open(false);
+ dockerConnection.ping();
+ dockerConnection.close();
+ // ping succeeded
+ displaySuccessDialog();
} catch (DockerException e) {
// only log if there's an underlying cause.
if (e.getCause() != null) {
Activator.log(e);
}
- resultQueue.add(false);
+ displayErrorDialog();
}
}
+
});
} catch (InvocationTargetException | InterruptedException o_O) {
Activator.log(o_O);
}
- try {
- final Boolean result = resultQueue.poll(5000,
- TimeUnit.MILLISECONDS);
- if (result != null && result) {
- new MessageDialog(Display.getDefault().getActiveShell(),
- WizardMessages.getString(
- "NewDockerConnectionPage.success"), //$NON-NLS-1$
- null,
- WizardMessages.getString(
- "NewDockerConnectionPage.pingSuccess"), //$NON-NLS-1$
- SWT.ICON_INFORMATION,
- new String[] { WizardMessages.getString(
- "NewDockerConnectionPage.ok") }, //$NON-NLS-1$
- 0).open();
- } else {
+ }
+
+ private void displaySuccessDialog() {
+ displayDialog(
+ WizardMessages
+ .getString("NewDockerConnectionPage.success"), //$NON-NLS-1$
+ WizardMessages.getString(
+ "NewDockerConnectionPage.pingSuccess"), //$NON-NLS-1$
+ SWT.ICON_INFORMATION,
+ new String[] { WizardMessages
+ .getString("NewDockerConnectionPage.ok") } //$NON-NLS-1$
+ );
+ }
+
+ private void displayErrorDialog() {
+ displayDialog(
+ WizardMessages
+ .getString("NewDockerConnectionPage.failure"), //$NON-NLS-1$
+ WizardMessages.getString(
+ "NewDockerConnectionPage.pingFailure"), //$NON-NLS-1$
+ SWT.ICON_ERROR,
+ new String[] { WizardMessages
+ .getString("NewDockerConnectionPage.ok") } //$NON-NLS-1$
+ );
+ }
+
+ private void displayDialog(final String dialogTitle,
+ final String dialogMessage, final int icon,
+ final String[] buttonLabels) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
new MessageDialog(Display.getDefault().getActiveShell(),
- WizardMessages.getString(
- "NewDockerConnectionPage.failure"), //$NON-NLS-1$
- null,
- WizardMessages.getString(
- "NewDockerConnectionPage.pingFailure"), //$NON-NLS-1$
- SWT.ICON_ERROR,
- new String[] { WizardMessages.getString(
- "NewDockerConnectionPage.ok") }, //$NON-NLS-1$
- 0).open();
+ dialogTitle, null, dialogMessage, icon,
+ buttonLabels, 0).open();
}
- } catch (InterruptedException o_O) {
- new MessageDialog(Display.getDefault().getActiveShell(),
- WizardMessages.getString(
- "NewDockerConnectionPage.failure"), //$NON-NLS-1$
- null,
- WizardMessages.getString(
- "NewDockerConnectionPage.pingFailure"), //$NON-NLS-1$
- SWT.ICON_ERROR,
- new String[] { WizardMessages
- .getString("NewDockerConnectionPage.ok") }, //$NON-NLS-1$
- 0).open();
- }
+ });
}
};

Back to the top