Search in sources :

Example 26 with DockerConnection

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

the class DockerExplorerViewSWTBotTest method shouldShowContainerVolumes.

@Test
public void shouldShowContainerVolumes() {
    // given
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("foo_bar").build(), MockContainerInfoFactory.volume("/path/to/container").volume("/path/to/host:/path/to/container").volume("/path/to/host:/path/to/container:Z,ro").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.asyncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
    // when
    final SWTBotTreeItem volumesTreeItem = SWTUtils.expand(dockerExplorerViewBot.bot().tree(), "Test", "Containers", "foo_bar", "Volumes");
    // then
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem).isExpanded().hasChildItems(3);
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(0)).hasText("/path/to/container");
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(1)).hasText("/path/to/host -> /path/to/container");
    SWTBotTreeItemAssertions.assertThat(volumesTreeItem.getNode(2)).hasText("/path/to/host -> /path/to/container (Z,ro)");
}
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 27 with DockerConnection

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

the class DockerImagesViewSWTBotTest method shouldRemoveListenersWhenClosingView.

@Test
public void shouldRemoveListenersWhenClosingView() {
    // 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);
    SWTUtils.getTreeItem(dockerExplorerBotView, "Test").select();
    // remove the DockerContainerRefreshManager
    dockerConnection.removeContainerListener(DockerContainerRefreshManager.getInstance());
    // DockerExplorerView inner classes
    assertThat(dockerConnection.getImageListeners()).hasSize(2);
    // close the Docker Images View
    dockerImagesBotView.close();
    // there should be one listener left: DockerExplorerView
    assertThat(dockerConnection.getImageListeners()).hasSize(1);
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) Test(org.junit.Test)

Example 28 with DockerConnection

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

the class DockerImagesViewSWTBotTest method verifyBuildAndPullActionEnablement.

@Test
public void verifyBuildAndPullActionEnablement() {
    // given
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("angry_bar").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.syncExec(() -> SWTUtils.getView(bot, "org.eclipse.ui.views.PropertySheet", true));
    this.dockerImagesView.setFocus();
    // select the container in the table
    selectImageInTable("angry_bar");
    List<SWTBotToolbarButton> buttons = this.dockerImagesBotView.getToolbarButtons();
    for (SWTBotToolbarButton button : buttons) {
        if (button.getText().equals("Build Image")) {
            assertThat(button.isEnabled());
        } else if (button.getText().equals("Pull...")) {
            assertThat(button.isEnabled());
        }
    }
    unselectImages();
    buttons = this.dockerImagesBotView.getToolbarButtons();
    for (SWTBotToolbarButton button : buttons) {
        if (button.getText().equals("Build Image")) {
            assertThat(button.isEnabled());
        } else if (button.getText().equals("Pull...")) {
            assertThat(button.isEnabled());
        }
    }
    unselectConnections();
    buttons = this.dockerImagesBotView.getToolbarButtons();
    for (SWTBotToolbarButton button : buttons) {
        if (button.getText().equals("Build Image")) {
            assertThat(!button.isEnabled());
        } else if (button.getText().equals("Pull...")) {
            assertThat(!button.isEnabled());
        }
    }
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton) Test(org.junit.Test)

Example 29 with DockerConnection

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

the class DockerImagesViewSWTBotTest method setup.

@Before
public void setup() {
    this.bot = new SWTWorkbenchBot();
    final DockerClient client = MockDockerClientFactory.container(MockContainerFactory.name("angry_bar").status("Stopped").build()).image(MockImageFactory.id("987654321abcde").name("default:1").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Default", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    SWTUtils.asyncExec(() -> {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerExplorerView.VIEW_ID);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerImagesView.VIEW_ID);
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail("Failed to open Docker Images view: " + e.getMessage());
        }
    });
    this.dockerImagesBotView = bot.viewById("org.eclipse.linuxtools.docker.ui.dockerImagesView");
    this.dockerImagesView = (DockerImagesView) (dockerImagesBotView.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 30 with DockerConnection

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

the class DockerImagesViewSWTBotTest 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.getImageListeners()).hasSize(0);
    // close the Docker Images View
    dockerImagesBotView.close();
    // there should be one listener left: DockerExplorerView
    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)

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