Search in sources :

Example 31 with DockerConnection

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

the class EditDockerConnectionSWTBotTest method configureUnixSocketConnection.

private IDockerConnection configureUnixSocketConnection(final String connectionName) {
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from(connectionName, client).withUnixSocketConnectionSettings("/var/run/docker.sock");
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    return dockerConnection;
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient)

Example 32 with DockerConnection

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

the class EditDockerConnectionSWTBotTest method configureTCPConnection.

private IDockerConnection configureTCPConnection(final String connectionName) {
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from(connectionName, client).withTCPConnectionSettings("https://foo:1234", PATH_TO_CERTS);
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    return dockerConnection;
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient)

Example 33 with DockerConnection

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

the class ImagePullSWTBotTest method shouldDisablePullCommandWhenConnectionStateIsUnknown.

@Test
public void shouldDisablePullCommandWhenConnectionStateIsUnknown() {
    // given
    this.client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withState(EnumDockerConnectionState.UNKNOWN);
    assertThat(dockerConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    // when opening the "Push Image..." wizard
    SWTUtils.getTreeItem(dockerExplorerViewBot, "Test").select();
    // then
    MenuAssertion.assertThat(dockerExplorerViewBot.bot().tree().contextMenu("Pull...")).isNotEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Test(org.junit.Test)

Example 34 with DockerConnection

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

the class ImagePullSWTBotTest method shouldEnablePullCommandWhenConnectionIsEstablished.

@Test
public void shouldEnablePullCommandWhenConnectionIsEstablished() {
    // given
    this.client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    // when opening the "Push Image..." wizard
    SWTUtils.getTreeItem(dockerExplorerViewBot, "Test").select();
    // then
    SWTUtils.wait(1, TimeUnit.SECONDS);
    assertThat(dockerConnection.getState()).isEqualTo(EnumDockerConnectionState.ESTABLISHED);
    MenuAssertion.assertThat(dockerExplorerViewBot.bot().tree().contextMenu("Pull...")).isEnabled();
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Test(org.junit.Test)

Example 35 with DockerConnection

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

the class ImageRunSWTBotTest method shouldReportErrorIfContainerWithSameNameExists.

@Test
public void shouldReportErrorIfContainerWithSameNameExists() {
    // given
    final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo:latest").build()).container(MockContainerFactory.name("foo_bar").build()).build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // expand the 'Images' node and select the 'foo' images
    SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images", "foo").select();
    // when opening the "Run Image..." wizard
    final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
    dockerExplorerViewTreeBot.contextMenu("Run...").click();
    // when use an existing container name
    bot.textWithLabel(WizardMessages.getString("ImageRunSelectionPage.containerName")).setText("foo_bar");
    // then
    // wait for https://bugs.eclipse.org/bugs/show_bug.cgi?id=482889 to be
    // able to check the wizard validation message
    // assertThat(bot.text(WizardMessages.getString("ImageRunSelectionPage.containerWithSameName"))).isNotNull();
    ButtonAssertions.assertThat(bot.button("Finish")).isNotEnabled();
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerClient(com.spotify.docker.client.DockerClient) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) 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