Search in sources :

Example 71 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method shouldShowContainerPortMapping.

@Test
public void shouldShowContainerPortMapping() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.port("8080/tcp", "0.0.0.0", "8080").port("8787/tcp", "0.0.0.0", "8787").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    final SWTBotTreeItem containerPorts = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Ports");
    // then
    SWTBotTreeItemAssertions.assertThat(containerPorts).isExpanded().hasChildItems(2);
    SWTBotTreeItemAssertions.assertThat(containerPorts.getNode(0)).hasText("0.0.0.0:8080 -> 8080 (tcp)");
    SWTBotTreeItemAssertions.assertThat(containerPorts.getNode(1)).hasText("0.0.0.0:8787 -> 8787 (tcp)");
}
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 72 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method shouldShowAllImageVariants.

@Test
public void shouldShowAllImageVariants() {
    // given
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.id("1a2b3c4d5e6f7g").name("foo:1.0", "foo:latest", "bar:1.0", "bar:latest").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
    final SWTBotTreeItem imagesTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images");
    // when
    SWTUtils.asyncExec(() -> imagesTreeItem.expand());
    // then 2 images should be displayed
    final SWTBotTreeItem[] images = imagesTreeItem.getItems();
    assertThat(images).hasSize(2);
    assertThat(images[0].getText()).startsWith("bar:1.0, latest");
    assertThat(images[1].getText()).startsWith("foo:1.0, latest");
}
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 73 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method shouldProvideDisabledUnpauseCommandOnMultipleContainersAtOnce.

@Test
public void shouldProvideDisabledUnpauseCommandOnMultipleContainersAtOnce() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Up (Paused)").build()).container(MockContainerFactory.name("angry_bar").status("Running").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // open the context menu on one of the containers
    selectContainersInTreeView("Test", "gentle_foo", "angry_bar");
    final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Unpause");
    // then
    MenuAssertion.assertThat(menuCommand).isVisible().isNotEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) Test(org.junit.Test)

Example 74 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method shouldProvideEnabledRemoveCommandOnMultipleContainersAtOnce.

@Test
public void shouldProvideEnabledRemoveCommandOnMultipleContainersAtOnce() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Stopped").build()).container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // open the context menu on one of the containers
    selectContainersInTreeView("Test", "gentle_foo", "angry_bar");
    final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Remove");
    // then
    MenuAssertion.assertThat(menuCommand).isVisible().isEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) Test(org.junit.Test)

Example 75 with DockerConnection

use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.

the class DockerExplorerViewSWTBotTest method shouldShowSelectedConnectionInPropertiesView.

@Test
public void shouldShowSelectedConnectionInPropertiesView() {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // open the context menu on one the container
    selectConnectionInTreeView("Test");
    // show container info in Properties view
    SWTUtils.getContextMenu(dockerExplorerViewBot.bot().tree(), "Show In", "Properties").click();
    // the properties view should be visible
    assertThat(this.bot.viewById("org.eclipse.ui.views.PropertySheet").isActive()).isEqualTo(true);
    SWTBotView propertiesViewBot = bot.viewById("org.eclipse.ui.views.PropertySheet");
    SWTUtils.getContextMenu(propertiesViewBot.bot().tree().select(1), "Copy").click();
    this.dockerExplorerView = (DockerExplorerView) (dockerExplorerViewBot.getViewReference().getView(true));
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Test(org.junit.Test)

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