Search in sources :

Example 76 with DockerConnection

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

the class DockerExplorerViewSWTBotTest method shouldProvideEnabledPauseCommandOnMultipleContainersAtOnce.

@Test
public void shouldProvideEnabledPauseCommandOnMultipleContainersAtOnce() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Running").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("Pause");
    // 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 77 with DockerConnection

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

the class DockerExplorerViewSWTBotTest method shouldRemoveListenersWhenClosingView.

@Test
public void shouldRemoveListenersWhenClosingView() {
    // given
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("angry_bar").build()).container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // remove the DockerContainerRefreshManager
    dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
    // DockerExplorerView inner classes
    assertThat(dockerConnection.getContainerListeners()).hasSize(1);
    assertThat(dockerConnection.getImageListeners()).hasSize(1);
    // close the Docker Explorer View
    dockerExplorerViewBot.close();
    // there should be no listener left
    assertThat(dockerConnection.getContainerListeners()).hasSize(0);
    assertThat(dockerConnection.getImageListeners()).hasSize(0);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 78 with DockerConnection

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

the class DockerExplorerViewSWTBotTest method shouldProvideDisabledStartCommandOnMultipleContainersAtOnce.

@Test
public void shouldProvideDisabledStartCommandOnMultipleContainersAtOnce() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Stopped").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("Start");
    // 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 79 with DockerConnection

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

the class DockerExplorerViewSWTBotTest method shouldRemainExpandedAfterRefreshOnContainersCategory.

@Test
public void shouldRemainExpandedAfterRefreshOnContainersCategory() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/container").port("8080/tcp", "0.0.0.0", "8080").link("/foo:/bar/foo").volume("/path/to/host:/path/to/container:Z,ro").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final SWTBotTreeItem containers = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers");
    final SWTBotTreeItem containerLinks = SWTUtils.expand(containers, "foo_bar", "Links");
    final SWTBotTreeItem containerPorts = SWTUtils.expand(containers, "foo_bar", "Ports");
    final SWTBotTreeItem containerVolumes = SWTUtils.expand(containers, "foo_bar", "Volumes");
    // ensure items are actually expanded before calling the 'refresh'
    // command
    SWTBotTreeItemAssertions.assertThat(containerLinks).isExpanded();
    SWTBotTreeItemAssertions.assertThat(containerPorts).isExpanded();
    SWTBotTreeItemAssertions.assertThat(containerVolumes).isExpanded();
    // when refreshing the container
    dockerExplorerViewBot.bot().tree().select(containers);
    dockerExplorerViewBot.bot().tree().contextMenu("Refresh").click();
    SWTUtils.asyncExec(() -> containers.expand());
    // then all items should remain expanded (after they were reloaded)
    SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(containers, "foo_bar", "Links")).isExpanded();
    SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(containers, "foo_bar", "Ports")).isExpanded();
    SWTBotTreeItemAssertions.assertThat(SWTUtils.getTreeItem(containers, "foo_bar", "Volumes")).isExpanded();
}
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 80 with DockerConnection

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

the class DockerExplorerViewSWTBotTest method shouldProvideEnabledRestartCommandOnMultipleContainersAtOnce.

@Test
public void shouldProvideEnabledRestartCommandOnMultipleContainersAtOnce() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("gentle_foo").status("Running").build()).container(MockContainerFactory.name("bold_eagle").status("Stopped").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", "bold_eagle", "angry_bar");
    final SWTBotMenu menuCommand = dockerExplorerViewBot.bot().tree().contextMenu("Restart");
    // 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)

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