use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class ImageRunSWTBotTest method testNetworkModeDefault.
@Test
public void testNetworkModeDefault() throws CoreException {
final DockerClient client = MockDockerClientFactory.image(MockImageFactory.name("foo:latest").build()).container(MockContainerFactory.name("foo_bar").build()).build();
final DockerConnection connection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
final String runImageLaunchConfigurationName = configureRunImageLaunchConfiguration(connection, "");
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("");
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class ImageSearchSWTBotTest method shouldAllowForDefaultLatestTag.
@Test
public void shouldAllowForDefaultLatestTag() {
// given
final DockerClient client = MockDockerClientFactory.onSearch("foo", MockImageSearchResultFactory.name("foo").build()).build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
// when opening the "Pull..." wizard
SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images").select();
dockerExplorerViewBot.bot().tree().contextMenu("Pull...").click();
// when specifying a term
bot.textWithLabel(WizardMessages.getString("ImagePullPushPage.name.label")).setText("foo");
// when clicking on the "Search..." button
bot.button(WizardMessages.getString("ImagePull.search.label")).click();
// then the search should have been triggered and results should be
// available
assertThat(bot.table().rowCount()).isEqualTo(1);
assertThat(bot.button("Next >").isEnabled()).isTrue();
assertThat(bot.button("Finish").isEnabled()).isTrue();
bot.button("Finish").click();
// when back to Pull wizard, the Image name field should be filled
assertThat(bot.textWithLabel(WizardMessages.getString("ImagePullPushPage.name.label")).getText()).isEqualTo("foo:latest");
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class NewDockerConnectionSWTBotTest method configureUnixSocketConnection.
private IDockerConnection configureUnixSocketConnection(final String connectionName, final String pathToSocket) {
final DockerClient client = MockDockerClientFactory.build();
final DockerConnection dockerConnection = MockDockerConnectionFactory.from(connectionName, client).withUnixSocketConnectionSettings(pathToSocket);
DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
return dockerConnection;
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class NewDockerConnectionPage method onTestConnectionButtonSelection.
/**
* Verifies that the given connection settings work by trying to connect to
* the target Docker daemon
*
* @return
*/
private SelectionListener onTestConnectionButtonSelection() {
return new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
try {
getWizard().getContainer().run(true, false, monitor -> {
monitor.beginTask(WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.pingTask"), IProgressMonitor.UNKNOWN);
try {
final DockerConnection dockerConnection = getDockerConnection();
dockerConnection.open(false);
dockerConnection.ping();
dockerConnection.close();
// ping succeeded
displaySuccessDialog();
} catch (DockerException e) {
// in Eclipse.org AERI
if (e.getCause() != null) {
displayErrorDialog(e.getCause());
} else {
displayErrorDialog(e);
}
}
});
} catch (InvocationTargetException | InterruptedException o_O) {
Activator.log(o_O);
}
}
private void displaySuccessDialog() {
displayDialog(WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.success"), WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.pingSuccess"), SWT.ICON_INFORMATION, new String[] { WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.ok") });
}
private void displayErrorDialog(final Throwable cause) {
displayDialog(WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.failure"), WizardMessages.getFormattedString(// $NON-NLS-1$
"DockerConnectionPage.pingFailure", cause.getMessage()), SWT.ICON_ERROR, new String[] { WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.ok") });
}
private void displayDialog(final String dialogTitle, final String dialogMessage, final int icon, final String[] buttonLabels) {
Display.getDefault().syncExec(() -> new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, icon, buttonLabels, 0).open());
}
};
}
use of org.eclipse.linuxtools.internal.docker.core.DockerConnection in project linuxtools by eclipse.
the class ContainerVMInstall method getInstallLocation.
@Override
public File getInstallLocation() {
if (installLocation == null) {
DockerConnection conn = getConnection();
ImageQuery q = new ImageQuery(conn, image.id());
installLocation = q.getDefaultJVMInstallLocation();
q.destroy();
}
return installLocation;
}
Aggregations