Search in sources :

Example 1 with IDockerConnectionStorageManager

use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.

the class DockerConnectionManagerUtils method configureConnectionManager.

/**
 * Configures the {@link DockerConnectionManager} with the given array of
 * {@link IDockerConnection} (can be mocked) and refreshes the associated
 * {@link DockerExplorerView}.
 *
 * @param connections
 *            the connection to configure in the
 *            {@link DockerConnectionManager} via a mocked
 *            {@link IDockerConnectionStorageManager}
 */
public static void configureConnectionManager(final IDockerConnection... connections) {
    final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connections);
    configureConnectionManager(connectionStorageManager);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)

Example 2 with IDockerConnectionStorageManager

use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenTCPConnectionSettingsChanged.

@Test
public void shouldResetConnectionStateWhenTCPConnectionSettingsChanged() {
    // given
    dockerContainers.close();
    dockerImages.close();
    final IDockerConnection connection = configureTCPConnection("Test");
    final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
    DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // when
    openConnectionEditionWizard("Test");
    bot.text(2).setText("https://foo.bar:1234");
    getFinishButton().click();
    // then
    final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
    assertThat(foundConnection).isNotNull();
    assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
    assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Example 3 with IDockerConnectionStorageManager

use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenNameChanged.

@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenNameChanged() {
    // given
    final IDockerConnection connection = configureTCPConnection("Test");
    final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
    DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // 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(0).setText("foo");
    getFinishButton().click();
    // then
    final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("foo");
    assertThat(foundConnection).isNotNull();
    Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Test(org.junit.Test)

Example 4 with IDockerConnectionStorageManager

use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldResetConnectionStateWhenUnixConnectionSettingsChanged.

@Test
public void shouldResetConnectionStateWhenUnixConnectionSettingsChanged() throws IOException {
    // given
    dockerContainers.close();
    dockerImages.close();
    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");
    assertThat(connection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
    // 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()));
    assertThat(foundConnection.getState()).isEqualTo(EnumDockerConnectionState.UNKNOWN);
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) UnixSocketConnectionSettings(org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) File(java.io.File) Test(org.junit.Test)

Example 5 with IDockerConnectionStorageManager

use of org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager in project linuxtools by eclipse.

the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenTCPConnectionSettingsChanged.

@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenTCPConnectionSettingsChanged() {
    // given
    final IDockerConnection connection = configureTCPConnection("Test");
    final IDockerConnectionStorageManager connectionStorageManager = MockDockerConnectionStorageManagerFactory.providing(connection);
    DockerConnectionManagerUtils.configureConnectionManager(connectionStorageManager);
    final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
    assertThat(connectionTreeItem).isNotNull();
    // 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(2).setText("https://foo.bar:1234");
    getFinishButton().click();
    // then
    final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("Test");
    assertThat(foundConnection).isNotNull();
    assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
    Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
Also used : IDockerConnectionStorageManager(org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) TCPConnectionSettings(org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings) Test(org.junit.Test)

Aggregations

IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)11 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)6 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)6 Test (org.junit.Test)6 TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)3 File (java.io.File)2 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)2