Search in sources :

Example 1 with RunWithProject

use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.

the class BuildDockerImageShortcutSWTBotTest method shouldPromptForAnotherConnectionWhenBuildingDockerImageOnSecondCallAfterConnectionWasReplaced.

@RunWithProject("foo")
public void shouldPromptForAnotherConnectionWhenBuildingDockerImageOnSecondCallAfterConnectionWasReplaced() 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 after connection was replaced, there should
    // be an error dialog
    final DockerConnection dockerConnection2 = MockDockerConnectionFactory.from("Test 2", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection2);
    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(2)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) DockerClient(com.spotify.docker.client.DockerClient) ProgressHandler(com.spotify.docker.client.ProgressHandler) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 2 with RunWithProject

use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.

the class BuildDockerImageShortcutSWTBotTest method shouldNotBuildDockerImageOnSecondCallWhenAllConnectionWereRemoved.

@Test
@RunWithProject("foo")
public void shouldNotBuildDockerImageOnSecondCallWhenAllConnectionWereRemoved() 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(30)).times(1)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
    // when trying to call again after connection was removed, there should
    // be an error dialog
    DockerConnectionManager.getInstance().removeConnection(dockerConnection);
    SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click(), false);
    final SWTBotShell shell = bot.shell("Edit Configuration");
    assertThat(shell).isNotNull();
    assertThat(shell.bot().button("Run").isEnabled()).isFalse();
    // closing the wizard
    SWTUtils.asyncExec(() -> {
        shell.bot().button(IDialogConstants.CLOSE_LABEL).click();
    }, false);
    // do not save the config while closing
    SWTUtils.syncExec(() -> {
        bot.button(IDialogConstants.NO_LABEL).click();
    });
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) DockerClient(com.spotify.docker.client.DockerClient) ProgressHandler(com.spotify.docker.client.ProgressHandler) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 3 with RunWithProject

use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.

the class DockerComposeSWTBotTest method shouldStopDockerCompose.

@Test
@RunWithProject("foo")
public void shouldStopDockerCompose() throws CoreException {
    // given
    shouldStartDockerComposeFromScratch();
    // when
    final SWTBotToolbarButton consoleToolbarStopButton = SWTUtils.getConsoleToolbarButtonWithTooltipText(bot, ConsoleMessages.getString("DockerComposeStopAction.tooltip"));
    ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isEnabled();
    consoleToolbarStopButton.click();
    // then
    // verify the latch is down
    assertThat(latch.getCount()).isEqualTo(0);
    // verify the stop button is disabled
    ToolbarButtonAssertions.assertThat(consoleToolbarStopButton).isNotEnabled();
}
Also used : SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 4 with RunWithProject

use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject in project linuxtools by eclipse.

the class DockerComposeSWTBotTest method shouldValidateLaunchConfiguration.

@Test
@RunWithProject("foo")
// ignored for now because the "Run" menu from the toolbar remains
@Ignore
public // found.
void shouldValidateLaunchConfiguration() 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
    bot.toolbarDropDownButtonWithTooltip("Run").menuItem("Run Configurations...").click();
    final SWTBotTreeItem dockerComposeTreeItem = SWTUtils.expand(bot.tree(), "Docker Compose");
    SWTUtils.select(dockerComposeTreeItem, "Docker Compose [foo]");
    // verify that the config is set and the form can be closed with the
    // "OK" button
    ComboAssertions.assertThat(bot.comboBox(0)).isEnabled().itemSelected("Test");
    TextAssertions.assertThat(bot.text(2)).isEnabled().textEquals("/foo");
    ButtonAssertions.assertThat(bot.button("Run")).isEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) IFile(org.eclipse.core.resources.IFile) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Ignore(org.junit.Ignore) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 5 with RunWithProject

use of org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject 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());
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) DockerClient(com.spotify.docker.client.DockerClient) ProgressHandler(com.spotify.docker.client.ProgressHandler) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Aggregations

RunWithProject (org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)10 DockerClient (com.spotify.docker.client.DockerClient)9 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)9 Test (org.junit.Test)9 ProgressHandler (com.spotify.docker.client.ProgressHandler)5 Path (java.nio.file.Path)5 SWTBotToolbarButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)4 IFile (org.eclipse.core.resources.IFile)2 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)1 Ignore (org.junit.Ignore)1