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)");
}
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);
}
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());
}
}
}
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);
}
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);
}
Aggregations