Search in sources :

Example 56 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem 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());
}
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 57 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem 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);
}
Also used : SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Test(org.junit.Test)

Example 58 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class ImagePushSWTBotTests method openPushWizard.

private void openPushWizard() {
    SWTUtils.syncExec(() -> dockerExplorerView.getCommonViewer().expandAll());
    final SWTBotTreeItem imageTreeItem = SWTUtils.getTreeItem(dockerExplorerViewBot, "Test", "Images", "foo/bar");
    // when opening the "Push Image..." wizard
    final SWTBotTree dockerExplorerViewTreeBot = dockerExplorerViewBot.bot().tree();
    dockerExplorerViewTreeBot.select(imageTreeItem);
    SWTUtils.getContextMenu(dockerExplorerViewTreeBot, "Push...").click();
}
Also used : SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 59 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class ProjectExplorer method getProjectItem.

/**
 * @param projectItem The tree item corresponding to the project.
 * @param name
 *             name of an item
 * @return the project item pertaining to the project
 */
public static SWTBotTreeItem getProjectItem(SWTBotTreeItem projectItem, String file) {
    for (SWTBotTreeItem item : projectItem.getItems()) {
        String itemText = item.getText();
        if (itemText.contains(file)) {
            if (itemText.contains(" ")) {
                StringTokenizer tok = new StringTokenizer(itemText, " ");
                String name = tok.nextToken();
                if (file.equals(name))
                    return item;
            } else if (itemText.equals(file)) {
                return item;
            }
        }
    }
    return null;
}
Also used : StringTokenizer(java.util.StringTokenizer) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)

Example 60 with SWTBotTreeItem

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem in project linuxtools by eclipse.

the class SVNProject method checkoutProject.

/**
 * Use File => Import => SVN to create a svn-backed project.
 */
public IProject checkoutProject() throws IllegalStateException {
    if (repoURL == null || projectName == null) {
        // need to have url and project set
        throw new IllegalStateException();
    }
    bot.menu("File").menu("Import...").click();
    SWTBotShell shell = bot.shell("Import");
    shell.activate();
    bot.tree().expandNode("SVN").select("Checkout Projects from SVN");
    bot.button("Next >").click();
    // create new repo
    shell = bot.shell("Checkout from SVN");
    shell.activate();
    bot.button("Next >").click();
    shell = bot.shell("Checkout from SVN");
    shell.activate();
    // Enter url
    bot.comboBoxWithLabelInGroup("Url:", "Location").setText(repoURL);
    bot.button("Next >").click();
    // the next few operation can take quite a while, adjust
    // timout accordingly.
    long oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    shell = bot.shell("Progress Information").activate();
    bot.waitUntil(Conditions.shellCloses(shell));
    shell = bot.shell("Checkout from SVN").activate();
    bot.waitUntil(new TreeItemAppearsCondition(repoURL, projectName));
    SWTBotTreeItem projectTree = bot.tree().expandNode(repoURL);
    projectTree.expandNode(projectName).select();
    bot.button("Finish").click();
    // Wait for import operation to finish
    bot.waitUntil(Conditions.shellCloses(shell));
    SWTBotShell svnCheckoutPopup = bot.shell("SVN Checkout").activate();
    bot.waitUntil(Conditions.shellCloses(svnCheckoutPopup));
    // need a little delay
    bot.waitUntil(new SVNProjectCreatedCondition(projectName));
    // Set timout back what it was.
    SWTBotPreferences.TIMEOUT = oldTimeout;
    // A quick sanity check
    IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject changelogTestsProject = (IProject) wsRoot.findMember(new Path(projectName));
    assertNotNull(changelogTestsProject);
    try {
        changelogTestsProject.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    IResource manifest = changelogTestsProject.findMember(new Path("/META-INF/MANIFEST.MF"));
    assertNotNull(manifest);
    return changelogTestsProject;
}
Also used : Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Aggregations

SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)63 Test (org.junit.Test)38 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)20 DockerClient (com.spotify.docker.client.DockerClient)19 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)9 Path (org.eclipse.core.runtime.Path)7 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)7 IDockerConnectionStorageManager (org.eclipse.linuxtools.docker.core.IDockerConnectionStorageManager)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 IEditorReference (org.eclipse.ui.IEditorReference)5 Ignore (org.junit.Ignore)5 IResource (org.eclipse.core.resources.IResource)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 TCPConnectionSettings (org.eclipse.linuxtools.internal.docker.core.TCPConnectionSettings)3 UnixSocketConnectionSettings (org.eclipse.linuxtools.internal.docker.core.UnixSocketConnectionSettings)2