diff options
author | Xavier Coulon | 2015-11-24 08:21:42 +0000 |
---|---|---|
committer | Xavier Coulon | 2015-11-25 15:46:04 +0000 |
commit | 22ec078ee9b1257ccda419b0187d011838a63ac6 (patch) | |
tree | 987948c9ef694f639618156011c6469194ec7a84 /containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearConnectionManagerRule.java | |
parent | db8dd4400d77b4a5583656f0dd13598d95b87f14 (diff) | |
download | org.eclipse.linuxtools-22ec078ee9b1257ccda419b0187d011838a63ac6.tar.gz org.eclipse.linuxtools-22ec078ee9b1257ccda419b0187d011838a63ac6.tar.xz org.eclipse.linuxtools-22ec078ee9b1257ccda419b0187d011838a63ac6.zip |
Bug 481219 - Validate container name in "Image Run" wizard
Raise an error message when a container with the same name exists.
Also added checks to avoid NPE when initializing ContainerInfo and
ImageInfo
Refactored some SWT utility classes used to setup the mock connection
and moved some reusable blocks in JUnit rules.
Change-Id: Ie8363fb4af6e8e5d210734c7f9028b27ac70548a
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Reviewed-on: https://git.eclipse.org/r/61113
Tested-by: Hudson CI
Diffstat (limited to 'containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearConnectionManagerRule.java')
-rw-r--r-- | containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearConnectionManagerRule.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearConnectionManagerRule.java b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearConnectionManagerRule.java new file mode 100644 index 0000000000..b448362689 --- /dev/null +++ b/containers/org.eclipse.linuxtools.docker.ui.tests/src/org/eclipse/linuxtools/internal/docker/ui/testutils/swt/ClearConnectionManagerRule.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2015 Red Hat. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial Contribution + *******************************************************************************/ + +package org.eclipse.linuxtools.internal.docker.ui.testutils.swt; + +import java.util.stream.Stream; + +import org.eclipse.linuxtools.docker.core.DockerConnectionManager; +import org.eclipse.linuxtools.internal.docker.core.DefaultDockerConnectionSettingsFinder; +import org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerView; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; +import org.junit.rules.ExternalResource; + +/** + * Clears the connection manager after each test. + */ +public class ClearConnectionManagerRule extends ExternalResource { + + @Override + protected void after() { + final SWTWorkbenchBot bot = new SWTWorkbenchBot(); + final SWTBotView dockerExplorerViewBot = bot.viewById("org.eclipse.linuxtools.docker.ui.dockerExplorerView"); + final DockerExplorerView dockerExplorerView = (DockerExplorerView) (dockerExplorerViewBot.getViewReference() + .getView(true)); + SWTUtils.syncExec(() -> { + Stream.of(DockerConnectionManager.getInstance().getConnections()) + .forEach(c -> DockerConnectionManager.getInstance().removeConnection(c)); + dockerExplorerView.getCommonViewer().refresh(true); + dockerExplorerView.showConnectionsOrExplanations(); + }); + DockerConnectionManager.getInstance().setConnectionSettingsFinder(new DefaultDockerConnectionSettingsFinder()); + } +} |