use of org.eclipse.linuxtools.docker.core.IDockerConnection in project jbosstools-openshift by jbosstools.
the class CDKDockerUtilityTest method testDockerConnectionExists.
@Test
public void testDockerConnectionExists() throws Exception {
assertFalse(util.dockerConnectionExists(null));
assertFalse(util.dockerConnectionExists("test"));
IDockerConnection existingConnection = mock(IDockerConnection.class);
when(existingConnection.getUri()).thenReturn("https://10.1.2.2:2376");
when(existingConnection.getName()).thenReturn("test");
when(mgr.getConnections()).thenReturn(new IDockerConnection[] { existingConnection });
assertTrue(util.dockerConnectionExists("test"));
IDockerConnection found = util.findDockerConnection("test");
assertEquals(found, existingConnection);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method checkThatNewDockerConnectionsAreReported.
@Test
public void checkThatNewDockerConnectionsAreReported() throws DockerException {
IDockerConnection connection = mock(IDockerConnection.class);
int connectionsSize = model.getDockerConnections().size();
DockerConnectionManager.getInstance().addConnection(connection);
assertThat(model.getDockerConnections()).hasSize(connectionsSize + 1);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project jbosstools-openshift by jbosstools.
the class DeployImageHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Connection connection = null;
IProject project = null;
ISelection selection = HandlerUtil.getCurrentSelection(event);
final IDockerImage image = UIUtils.getFirstElement(selection, IDockerImage.class);
if (image == null || OpenShiftUIUtils.hasOpenShiftExplorerSelection()) {
selection = OpenShiftUIUtils.getOpenShiftExplorerSelection();
project = ResourceUtils.getProject(UIUtils.getFirstElement(selection, IResource.class));
if (project != null) {
connection = ConnectionsRegistryUtil.getConnectionFor(project);
} else {
connection = UIUtils.getFirstElement(selection, Connection.class);
}
}
if (connection == null) {
connection = OpenShiftUIUtils.getExplorerDefaultConnection(Connection.class);
}
IDockerConnection dockerConnection = null;
if (image != null) {
dockerConnection = image.getConnection();
} else if (OpenShiftUIUtils.hasDockerExplorerSelection()) {
ISelection dockerSelection = OpenShiftUIUtils.getDockerExplorerSelection();
dockerConnection = UIUtils.getFirstElement(dockerSelection, IDockerConnection.class);
if (dockerConnection == null) {
// Action is originated from OpenShift Explorer, do the best to pick up Docker connection from the current selection in Docker Explorer.
IDockerImage selectedImage = UIUtils.getFirstElement(dockerSelection, IDockerImage.class);
if (selectedImage != null) {
dockerConnection = selectedImage.getConnection();
}
}
}
runWizard(HandlerUtil.getActiveWorkbenchWindow(event).getShell(), dockerConnection, image, project, connection);
return null;
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldSaveConnectionWhenNameAndTCPConnectionSettingsChanged.
@SuppressWarnings("unchecked")
@Test
public void shouldSaveConnectionWhenNameAndTCPConnectionSettingsChanged() {
// 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");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
// then
final IDockerConnection foundConnection = DockerConnectionManager.getInstance().findConnection("foo");
assertThat(foundConnection).isNotNull();
assertThat(foundConnection.getSettings()).isNotNull().isEqualTo(new TCPConnectionSettings("https://foo.bar:1234", PATH_TO_CERTS));
Mockito.verify(connectionStorageManager).saveConnections(Matchers.anyList());
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class EditDockerConnectionSWTBotTest method shouldRefreshDockerExplorerViewWhenTCPConnectionSettingsChanged.
@Test
public void shouldRefreshDockerExplorerViewWhenTCPConnectionSettingsChanged() {
// given
dockerContainers.close();
dockerImages.close();
final IDockerConnection connection = configureTCPConnection("Test");
final SWTBotTreeItem connectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(connectionTreeItem).isNotNull();
// when
openConnectionEditionWizard("Test");
bot.text(2).setText("https://foo.bar:1234");
getFinishButton().click();
SWTUtils.wait(2, TimeUnit.SECONDS);
// then
final SWTBotTreeItem updatedConnectionTreeItem = SWTUtils.getTreeItem(dockerExplorer.bot(), "Test");
assertThat(updatedConnectionTreeItem).isNotNull();
assertThat(updatedConnectionTreeItem.getText()).contains("https://foo.bar:1234");
// 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);
}
Aggregations