Search in sources :

Example 11 with DockerConnection

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

the class DockerContainersViewSWTBotTest method shouldOpenImageHierarchyView.

@Test
public void shouldOpenImageHierarchyView() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // make sure the hierarchy view is closed.
    SWTUtils.closeView(this.bot, DockerImageHierarchyView.VIEW_ID);
    // open the context menu on one of the containers
    selectContainerInTable("angry_bar");
    SWTUtils.getContextMenu(dockerContainersViewBot.bot().table(), "Open Image Hierarchy").click();
    // wait 1sec
    SWTUtils.wait(1, TimeUnit.SECONDS);
    DockerImageHierarchyViewAssertions.assertThat(SWTUtils.getView(bot, DockerImageHierarchyView.VIEW_ID)).isNotNull();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 12 with DockerConnection

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

the class DockerContainersViewSWTBotTest method setup.

@Before
public void setup() {
    this.bot = new SWTWorkbenchBot();
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("defaultcon").status("Running").build()).image(MockImageFactory.id("987654321abcde").name("default:1").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Default", client).withDefaultTCPConnectionSettings();
    dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.asyncExec(() -> {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerContainersView.VIEW_ID);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail("Failed to open Docker Explorer view: " + e.getMessage());
        }
    });
    this.dockerContainersViewBot = bot.viewById(DockerContainersView.VIEW_ID);
    this.dockerContainersView = (DockerContainersView) (dockerContainersViewBot.getViewReference().getView(true));
    this.dockerExplorerBotView = bot.viewById(DockerExplorerView.VIEW_ID);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) DockerClient(com.spotify.docker.client.DockerClient) Before(org.junit.Before)

Example 13 with DockerConnection

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

the class DockerContainersViewSWTBotTest method shouldNotRemoveListenersWhenNoSelectedConnectionBeforeClosingView.

@Test
public void shouldNotRemoveListenersWhenNoSelectedConnectionBeforeClosingView() {
    // given
    dockerExplorerBotView.close();
    final DockerClient client = MockDockerClientFactory.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());
    assertThat(dockerConnection.getContainerListeners()).hasSize(0);
    // close the Docker Containers View
    dockerContainersViewBot.close();
    // there should be one listener left: DockerExplorerView
    assertThat(dockerConnection.getContainerListeners()).hasSize(0);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 14 with DockerConnection

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

the class DockerContainersViewSWTBotTest method shouldProvideEnabledRestartOnMultipleContainers.

@Test
public void shouldProvideEnabledRestartOnMultipleContainers() {
    // 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);
    // make sure the hierarchy view is closed.
    SWTUtils.closeView(this.bot, DockerImageHierarchyView.VIEW_ID);
    // open the context menu on one of the containers
    selectContainersInTable("gentle_foo", "bold_eagle", "angry_bar");
    final SWTBotMenu menuCommand = dockerContainersViewBot.bot().table().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)

Example 15 with DockerConnection

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

the class DockerContainersViewSWTBotTest method shouldShowSelectedContainerInPropertiesView.

@Test
public void shouldShowSelectedContainerInPropertiesView() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build(), MockContainerInfoFactory.networkMode("host").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    final PropertySheet propertySheet = SWTUtils.syncExec(() -> SWTUtils.getView(bot, "org.eclipse.ui.views.PropertySheet", true));
    this.dockerContainersView.setFocus();
    // select the container in the table
    selectContainerInTable("angry_bar");
    // then the properties view should have a selected tab with container
    // info
    assertThat(propertySheet.getCurrentPage()).isInstanceOf(TabbedPropertySheetPage.class);
    final TabbedPropertySheetPage currentPage = (TabbedPropertySheetPage) propertySheet.getCurrentPage();
    TabDescriptorAssertions.assertThat(currentPage.getSelectedTab()).isNotNull().hasId("org.eclipse.linuxtools.docker.ui.properties.container.info");
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) 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