use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainerPortsCategory.
@Test
public void shouldRetrieveConnectionFromSelectedContainerPortsCategory() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.port("8080/tcp", "0.0.0.0", "8080").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem ports = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Ports");
// when selecting the port
ports.select();
// then current connection should be found
Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedContainer.
@Test
public void shouldRetrieveConnectionFromSelectedContainer() {
// given
final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem container = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar");
// when selecting the container
container.select();
// then current connection should be found
Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class CommandUtilsSWTBotTest method shouldRetrieveConnectionFromSelectedImagesCategory.
@Test
public void shouldRetrieveConnectionFromSelectedImagesCategory() {
// given
final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final SWTBotTreeItem images = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Images");
// when selecting the images category
images.select();
// then current connection should be found
Assertions.assertThat(CommandUtils.getCurrentConnection(dockerExplorerView)).isEqualTo(dockerConnection);
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class BuildDockerImageShortcutSWTBotTest method shouldBuildDockerImageImmediatelyOnSecondCall.
@Test
@RunWithProject("foo")
public void shouldBuildDockerImageImmediatelyOnSecondCall() throws InterruptedException, com.spotify.docker.client.exceptions.DockerException, IOException {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when
SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
// then expect a dialog, fill the "repository" text field and click "Ok"
assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
// when launching the build
SWTUtils.syncExec(() -> {
bot.button("OK").click();
});
// then the 'DockerConnection#buildImage(...) method should have been
// called within the specified timeout
Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(1)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
// when trying to call again, there should be no dialog
SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
// then a second call should have been done
Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(3)).times(2)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class BuildDockerImageShortcutSWTBotTest method shouldNotBuildDockerImageOnSecondCallWhenDockerfileWasRemoved.
@Test
@RunWithProject("foo")
public void shouldNotBuildDockerImageOnSecondCallWhenDockerfileWasRemoved() throws InterruptedException, com.spotify.docker.client.exceptions.DockerException, IOException, CoreException {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when
SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
// then expect a dialog, fill the "repository" text field and click "Ok"
assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
// when launching the build
SWTUtils.syncExec(() -> {
bot.button("OK").click();
});
// then the 'DockerConnection#buildImage(...) method should have been
// called within the specified timeout
Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(30)).times(1)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
// when trying to call again after file was removed, there should
// be an error dialog
projectInit.getProject().findMember("Dockerfile").delete(true, new NullProgressMonitor());
bot.toolbarDropDownButtonWithTooltip("Run").menuItem("1 foo_bar [latest]").click();
// $NON-NLS-1$
final SWTBotShell shell = bot.shell(JobMessages.getString("BuildImageJob.title"));
assertThat(shell).isNotNull();
// closing the dialog
SWTUtils.syncExec(() -> {
shell.bot().button(IDialogConstants.OK_LABEL).click();
});
}
Aggregations