Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Coulon2016-08-16 16:42:38 +0000
committerXavier Coulon2016-08-16 17:14:58 +0000
commit5f9fbca83ff90c2d83824c794694314207bdedf8 (patch)
treefd5d0057e5aaaccee1f57349aa834a2426bd1e23
parentc61be318c2dbbfe6165edf350ed299b80974fb9d (diff)
downloadorg.eclipse.linuxtools-5f9fbca83ff90c2d83824c794694314207bdedf8.tar.gz
org.eclipse.linuxtools-5f9fbca83ff90c2d83824c794694314207bdedf8.tar.xz
org.eclipse.linuxtools-5f9fbca83ff90c2d83824c794694314207bdedf8.zip
Bug 499744 - New connection created with wizard does not appear in the Docker Explorer view
Change-Id: Id0d7f4ed36ee1b78d9e3782e4a4292a70de7060f Signed-off-by: Xavier Coulon <xcoulon@redhat.com> Reviewed-on: https://git.eclipse.org/r/79147 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> Tested-by: Hudson CI
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionSettingsFinder.java25
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushSWTBotTests.java1
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/NewDockerConnectionSWTBotTest.java60
-rw-r--r--containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java6
4 files changed, 62 insertions, 30 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionSettingsFinder.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionSettingsFinder.java
index 68ebda3da0..c2f8a8d2ee 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionSettingsFinder.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/MockDockerConnectionSettingsFinder.java
@@ -11,6 +11,7 @@
package org.eclipse.linuxtools.internal.docker.ui.testutils;
+import java.io.IOException;
import java.util.Collections;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
@@ -38,19 +39,33 @@ public class MockDockerConnectionSettingsFinder {
}
/**
- * Configures the {@link DockerConnectionManager} singleton to being
- * able to detect a <strong>valid Unix Socket</strong> to a Docker daemon.
+ * Configures the {@link DockerConnectionManager} singleton to being able to
+ * detect a <strong>valid Unix Socket</strong> to a Docker daemon.
+ *
+ * @throws IOException
+ */
+ public static void validUnixSocketConnectionAvailable() throws IOException {
+ validUnixSocketConnectionAvailable("mock", "unix:///var/run/docker.sock");
+ }
+
+ /**
+ * Configures the {@link DockerConnectionManager} singleton to being able to
+ * detect a <strong>valid Unix Socket</strong> to a Docker daemon.
+ *
+ * @throws IOException
*/
- public static void validUnixSocketConnectionAvailable() {
+ public static void validUnixSocketConnectionAvailable(final String connectionName, final String unixSocketPath)
+ throws IOException {
final IDockerConnectionSettingsFinder validUnixSocketConnectionAvailable = Mockito
.mock(IDockerConnectionSettingsFinder.class);
- final UnixSocketConnectionSettings unixSocketConnectionSettings = new UnixSocketConnectionSettings("unix://var/run/docker.sock");
+ final UnixSocketConnectionSettings unixSocketConnectionSettings = new UnixSocketConnectionSettings(
+ unixSocketPath);
//unixSocketConnectionSettings.setName("mock");
unixSocketConnectionSettings.setSettingsResolved(true);
Mockito.when(validUnixSocketConnectionAvailable.findDefaultConnectionSettings()).thenReturn(unixSocketConnectionSettings);
Mockito.when(
validUnixSocketConnectionAvailable.resolveConnectionName(Matchers.any(IDockerConnectionSettings.class)))
- .thenReturn("mock");
+ .thenReturn(connectionName);
DockerConnectionManager.getInstance().setConnectionSettingsFinder(validUnixSocketConnectionAvailable);
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushSWTBotTests.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushSWTBotTests.java
index 811d5c37c1..9d1da2dafa 100644
--- a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushSWTBotTests.java
+++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/wizards/ImagePushSWTBotTests.java
@@ -63,6 +63,7 @@ public class ImagePushSWTBotTests {
@Rule
public CloseWizardRule closeWizard = new CloseWizardRule();
+
private RegistryAccountStorageManager defaultRegistryAccountStorageManager;
private DockerClient client;
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 7c50ccafb9..b24f856614 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
@@ -11,12 +11,16 @@
package org.eclipse.linuxtools.internal.docker.ui.wizards;
+import java.io.File;
+import java.io.IOException;
+
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.linuxtools.internal.docker.ui.testutils.MockDockerConnectionSettingsFinder;
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.CloseWizardRule;
import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.RadioAssertion;
+import org.eclipse.linuxtools.internal.docker.ui.testutils.swt.SWTBotTreeItemAssertions;
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;
@@ -38,7 +42,7 @@ import org.junit.runner.RunWith;
/**
* Testing the {@link NewDockerConnection} {@link Wizard}
*/
-@RunWith(SWTBotJunit4ClassRunner.class)
+@RunWith(SWTBotJunit4ClassRunner.class)
public class NewDockerConnectionSWTBotTest {
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
@@ -46,26 +50,26 @@ public class NewDockerConnectionSWTBotTest {
private SWTBotView dockerExplorerViewBot;
@ClassRule
- public static CloseWelcomePageRule closeWelcomePage = new CloseWelcomePageRule();
-
- @Rule
+ public static CloseWelcomePageRule closeWelcomePage = new CloseWelcomePageRule();
+
+ @Rule
public CloseWizardRule closeWizard = new CloseWizardRule();
-
+
@Before
public void lookupDockerExplorerView() throws Exception {
- 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());
- }});
+ 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(DockerContainersView.VIEW_ID)
- || v.getReference().getId().equals(DockerImagesView.VIEW_ID))
- .forEach(v -> v.close());
+ bot.views().stream().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");
}
@@ -75,9 +79,7 @@ public class NewDockerConnectionSWTBotTest {
// given
MockDockerConnectionSettingsFinder.noDockerConnectionAvailable();
// when
- // TODO: should wait until dialog appears after call to click()
addConnectionButton.click();
- //bot.waitUntilWidgetAppears(waitForWidget);
// then
// Empty Connection name
TextAssertion.assertThat(bot.text(0)).isEnabled().isEmpty();
@@ -98,12 +100,11 @@ public class NewDockerConnectionSWTBotTest {
}
@Test
- public void shouldShowDefaultUnixSocketConnectionSettingsWithValidConnectionAvailable() {
+ public void shouldShowDefaultUnixSocketConnectionSettingsWithValidConnectionAvailable() throws IOException {
// given
MockDockerConnectionSettingsFinder.validUnixSocketConnectionAvailable();
// when
addConnectionButton.click();
- // TODO: should wait until dialog appears.
// then
// Connection name
TextAssertion.assertThat(bot.text(0)).isEnabled().textEquals("mock");
@@ -112,7 +113,7 @@ public class NewDockerConnectionSWTBotTest {
// "Unix socket" radio should be disabled and selected
RadioAssertion.assertThat(bot.radio(0)).isNotEnabled().isSelected();
// "Unix socket path" text should be disabled and not empty
- TextAssertion.assertThat(bot.text(1)).isNotEnabled().textEquals("unix://var/run/docker.sock");
+ TextAssertion.assertThat(bot.text(1)).isNotEnabled().textEquals("unix:///var/run/docker.sock");
// "TCP Connection" radio should be unselected and disabled
RadioAssertion.assertThat(bot.radio(1)).isNotEnabled().isNotSelected();
// "URI" should be disabled and empty
@@ -130,7 +131,6 @@ public class NewDockerConnectionSWTBotTest {
// when
addConnectionButton.click();
bot.waitUntil(Conditions.shellIsActive(WizardMessages.getString("NewDockerConnection.title"))); //$NON-NLS-1$
- // TODO: should wait until dialog appears.
// then
// Connection name
TextAssertion.assertThat(bot.text(0)).isEnabled().textEquals("mock");
@@ -150,4 +150,20 @@ public class NewDockerConnectionSWTBotTest {
TextAssertion.assertThat(bot.text(3)).isNotEnabled().textEquals("/path/to/certs");
}
+ @Test
+ public void shouldAddConnectionToDockerExplorerView() throws IOException {
+ // given
+ final File dockerSocketTmpFile = File.createTempFile("docker", ".sock");
+ MockDockerConnectionSettingsFinder.validUnixSocketConnectionAvailable("Mock",
+ "unix://" + dockerSocketTmpFile.getAbsolutePath());
+ // when open wizard
+ addConnectionButton.click();
+ bot.waitUntil(Conditions.shellIsActive(WizardMessages.getString("NewDockerConnection.title"))); //$NON-NLS-1$
+ // when click on "OK"
+ bot.button("Finish").click();
+ // then the Docker Explorer view should have a connection named "Mock"
+ SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(dockerExplorerViewBot.bot().tree(), "Mock"))
+ .isNotNull();
+ }
+
}
diff --git a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java
index 2b7fa437c8..5bd0914a7d 100644
--- a/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java
+++ b/containers/org.eclipse.linuxtools.docker.ui/src/org/eclipse/linuxtools/internal/docker/ui/views/DockerExplorerView.java
@@ -287,9 +287,9 @@ public class DockerExplorerView extends CommonNavigator implements
switch (type) {
case IDockerConnectionManagerListener.ADD_EVENT:
registerListeners(connection);
- // getCommonViewer().refresh();
- // getCommonViewer()
- // .setSelection(new StructuredSelection(connection));
+ getCommonViewer().refresh();
+ getCommonViewer()
+ .setSelection(new StructuredSelection(connection));
break;
case IDockerConnectionManagerListener.RENAME_EVENT:
getCommonViewer().refresh(connection);

Back to the top