Search in sources :

Example 56 with DockerConnection

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);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 57 with 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);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 58 with 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);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Example 59 with 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());
}
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)

Example 60 with DockerConnection

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();
    });
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) 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)

Aggregations

DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)108 DockerClient (com.spotify.docker.client.DockerClient)75 Test (org.junit.Test)71 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)31 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)21 DockerException (org.eclipse.linuxtools.docker.core.DockerException)18 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)15 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)9 RunWithProject (org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 Job (org.eclipse.core.runtime.jobs.Job)8 Path (java.nio.file.Path)6 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)6 ProgressHandler (com.spotify.docker.client.ProgressHandler)5 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)5 PropertySheet (org.eclipse.ui.views.properties.PropertySheet)5 TabbedPropertySheetPage (org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)5 Before (org.junit.Before)5 File (java.io.File)4 IOException (java.io.IOException)4