use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldUpdateLaunchConfigurationWhenConnectionNameChanged.
@Test
public void shouldUpdateLaunchConfigurationWhenConnectionNameChanged() throws CoreException {
// given
final IDockerConnection connection = configureTCPConnection("Test");
final String buildImageLaunchConfigurationName = configureBuildImageLaunchConfiguration(connection);
final ILaunchConfiguration buildDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, buildImageLaunchConfigurationName);
assertThat(buildDockerImageLaunchConfig).isNotNull();
assertThat(buildDockerImageLaunchConfig.getAttribute(IDockerImageBuildOptions.DOCKER_CONNECTION, "")).isEqualTo("Test");
final String runImageLaunchConfigurationName = configureRunImageLaunchConfiguration(connection, "bridge");
final ILaunchConfiguration runDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
assertThat(runDockerImageLaunchConfig).isNotNull();
assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("Test");
assertThat(runDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("bridge");
// when
openConnectionEditionWizard("Test");
bot.text(0).setText("foo");
getFinishButton().click();
// then
final ILaunchConfiguration updatedBuildDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, buildImageLaunchConfigurationName);
assertThat(updatedBuildDockerImageLaunchConfig).isNotNull();
assertThat(updatedBuildDockerImageLaunchConfig.getAttribute(IDockerImageBuildOptions.DOCKER_CONNECTION, "")).isEqualTo("foo");
final ILaunchConfiguration updatedRunDockerImageLaunchConfig = LaunchConfigurationUtils.getLaunchConfigurationByName(IRunDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, runImageLaunchConfigurationName);
assertThat(updatedRunDockerImageLaunchConfig).isNotNull();
assertThat(updatedRunDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONNECTION_NAME, "")).isEqualTo("foo");
assertThat(updatedRunDockerImageLaunchConfig.getAttribute(IRunDockerImageLaunchConfigurationConstants.NETWORK_MODE, "")).isEqualTo("bridge");
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenUnixSockerConnectionSettingsChanged.
@Test
public void shouldRefreshDockerExplorerViewWhenUnixSockerConnectionSettingsChanged() throws IOException {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureUnixSocketConnection("Test");
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
final File tmpDockerSocketFile = folder.newFile("docker.sock");
// when
openConnectionEditionWizard("Test");
bot.text(1).setText(tmpDockerSocketFile.getAbsolutePath());
getFinishButton().click();
SWTUtils.wait(2, TimeUnit.SECONDS);
// then
final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(updatedConnectionTreeItem).isNotNull();
assertThat(updatedConnectionTreeItem.getText()).contains(tmpDockerSocketFile.getAbsolutePath());
// list of containers and images should have been refreshed
Mockito.verify(connection, Mockito.times(0)).getContainers(true);
Mockito.verify(connection, Mockito.times(0)).getImages(true);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenConnectionNameChanged.
@Test
public void shouldRefreshDockerExplorerViewWhenConnectionNameChanged() {
// given
final IDockerConnection connection = configureTCPConnection("Test");
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// when
openConnectionEditionWizard("Test");
bot.text(0).setText("foo");
getFinishButton().click();
SWTUtils.wait(2, TimeUnit.SECONDS);
// then
final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "foo");
assertThat(updatedConnectionTreeItem).isNotNull();
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection 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;
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenUnixSocketConnectionSettingsChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenUnixSocketConnectionSettingsChanged() throws IOException {
// given
final IDockerConnection connection = configureUnixSocketConnection("Test");
final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
final File tmpDockerSocketFile = folder.newFile("docker.sock");
// let's ignore the connection savings that may have occurred when
// adding elements from the extension points
Mockito.reset(connectionStorageManager);
// when
openConnectionEditionWizard("Test");
bot.text(1).setText(tmpDockerSocketFile.getAbsolutePath());
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new UnixSocketConnectionSettings(tmpDockerSocketFile.getAbsolutePath()));
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
Aggregations