use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject 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();
});
}
use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.
the class BuildDockerImageShortcutSWTBotTest method shouldPromptDialogThenBuildDockerImageOnFirstCall.
@Test
@RunWithProject("foo")
public void shouldPromptDialogThenBuildDockerImageOnFirstCall() 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());
}
use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.
the class DockerComposeSWTBotTest method shouldStartDockerComposeWithExistingLaunchConfiguration.
@Test
@RunWithProject("foo")
public void shouldStartDockerComposeWithExistingLaunchConfiguration() throws CoreException {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
final IFile dockerComposeScript = projectInit.getProject().getFile("docker-compose.yml");
LaunchConfigurationUtils.createDockerComposeUpLaunchConfiguration(dockerConnection, dockerComposeScript);
// when
SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
// then confirm the connection
final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
}
use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.
the class DockerComposeSWTBotTest method shouldStartDockerComposeFromScratch.
@Test
@RunWithProject("foo")
public void shouldStartDockerComposeFromScratch() throws CoreException {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when
SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
// then confirm the connection
bot.button("OK").click();
// wait for the job to run
SWTUtils.waitForJobsToComplete();
// then expect the console to be displayed
assertThat(SWTUtils.isConsoleViewVisible(this.bot)).isTrue();
// expect the 'stop' button to be enabled
final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
// verify that the launch configuration was saved
final ILaunchConfiguration launchConfiguration = LaunchConfigurationUtils.getLaunchConfigurationByName(IDockerComposeLaunchConfigurationConstants.CONFIG_TYPE_ID, "Docker Compose [foo]");
assertThat(launchConfiguration).isNotNull();
// verify the latch
assertThat(latch.getCount()).isEqualTo(1);
}
use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.
the class DockerComposeSWTBotTest method shouldRestartDockerCompose.
@Test
@RunWithProject("foo")
public void shouldRestartDockerCompose() throws InterruptedException, DockerException {
// given
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when starting without launch config
SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
bot.button("OK").click();
// wait for the job to run
SWTUtils.waitForJobsToComplete();
// when stopping
final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
consoleToolbarStopButton.click();
// redo the setup to get a new mock process
setupMockedProcessLauncher();
// when restarting
SWTUtils.asyncExec(() -> getRunAsDockerComposeContextMenu("foo", "docker-compose.yml").click());
// wait for the job to run
SWTUtils.waitForJobsToComplete();
// then
ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
}
Aggregations