Beispiel #1
0
  public void confirmShellShareProjectFiles(String project, String[] files, JID[] jids) {
    SWTBot bot = new SWTBot();
    SWTBotShell shell = bot.shell(SHELL_SHARE_PROJECT);
    shell.activate();

    // wait for tree update
    bot.sleep(500);

    SWTBotTree tree = shell.bot().tree();

    selectProjectFiles(tree, project, files);

    shell.bot().button(NEXT).click();

    // wait for tree update
    bot.sleep(500);

    tree = shell.bot().tree();

    for (SWTBotTreeItem item : tree.getAllItems()) while (item.isChecked()) item.uncheck();

    for (JID jid : jids)
      WidgetUtil.getTreeItemWithRegex(tree, Pattern.quote(jid.getBase()) + ".*").check();

    shell.bot().button(FINISH).click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }
  @Test
  @Ignore // workspace model dosn't show non-workspace files ... yet ;)
  public void shouldShowCompareEditorForNonWorkspaceFileFromSynchronization() throws Exception {
    // given
    String content = "file content";
    String name = "non-workspace.txt";
    File root = new File(getTestDirectory(), REPO1);
    File nonWorkspace = new File(root, name);
    BufferedWriter writer = new BufferedWriter(new FileWriter(nonWorkspace));
    writer.append(content);
    writer.close();

    // when
    launchSynchronization(INITIAL_TAG, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem workingTree = syncViewTree.expandNode(PROJ1);
    assertEquals(1, syncViewTree.getAllItems().length);
    workingTree.expand().getNode(name).doubleClick();

    SWTBotEditor editor = bot.editorByTitle(name);
    editor.setFocus();

    // the WidgetNotFoundException will be thrown when widget with given content cannot be not found
    SWTBotStyledText left = editor.bot().styledText(content);
    SWTBotStyledText right = editor.bot().styledText("");
    // to be complete sure assert that both sides are not the same
    assertNotSame(left, right);
  }
  @Test
  public void testLinkWithSelectionNavigator() throws Exception {
    deleteAllProjects();
    shareProjects(repositoryFile);
    SWTBotTree tree = getOrOpenView().bot().tree();
    myRepoViewUtil.getRootItem(tree, repositoryFile).select();
    // the selection should be root
    assertTrue(tree.selection().get(0, 0).startsWith(REPO1));

    SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
    getProjectItem(projectExplorerTree, PROJ1).select();

    // the selection should be still be root
    assertTrue(tree.selection().get(0, 0).startsWith(REPO1));

    // activate the link with selection
    toggleLinkWithSelection();

    // the selection should be still be root
    assertTrue(tree.selection().get(0, 0).startsWith(REPO1));

    // select again the project
    projectExplorerTree = TestUtil.getExplorerTree();
    getProjectItem(projectExplorerTree, PROJ1).select();

    // the selection should be project
    assertTrue(tree.selection().get(0, 0).equals(PROJ1));

    // deactivate the link with selection
    toggleLinkWithSelection();
  }
  private SWTBotTreeItem getEntry(String ViewTitle, String... path) throws Exception {

    SWTBotTree browserTree = getTree(ViewTitle);
    List<String> pathList = new ArrayList<String>(Arrays.asList(path));
    SWTBotTreeItem entry = null;

    while (!pathList.isEmpty()) {
      String node = pathList.remove(0);

      if (entry == null) {
        node = adjustNodeName(browserTree, node);
        entry = browserTree.getTreeItem(node);
      } else {
        // adjust current path, because the label is decorated with the
        // number of children
        node = adjustNodeName(entry, node);
        entry = entry.getNode(node);
      }

      if (!pathList.isEmpty()) {
        // expand entry and wait till
        // - children are displayed
        // - next child is visible
        final String nextNode = !pathList.isEmpty() ? pathList.get(0) : null;
        expand(entry, true, nextNode);
      }
    }

    return entry;
  }
  @Test
  public void shouldRefreshSyncResultAfterRepositoryChange() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    changeFilesInProject();
    launchSynchronization(HEAD, HEAD, true);

    // preconditions - sync result should contain two uncommitted changes
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem[] syncItems = syncViewTree.getAllItems();
    assertTrue(syncItems[0].getText().contains(PROJ1));
    syncItems[0].expand();
    syncItems[0].getItems()[0].expand();
    assertEquals(2, syncItems[0].getItems()[0].getItems().length);

    // when
    commit(PROJ1);

    // then - synchronize view should be empty
    SWTBot viewBot = bot.viewByTitle("Synchronize").bot();
    @SuppressWarnings("unchecked")
    Matcher matcher = allOf(widgetOfType(Label.class), withRegex("No changes in .*"));

    @SuppressWarnings("unchecked")
    SWTBotLabel l = new SWTBotLabel((Label) viewBot.widget(matcher));
    assertNotNull(l);
  }
 @Test
 public void testPropertiesContextMenu() throws Exception {
   openDialog();
   // use index 1 since first tree is property page navigation tree
   SWTBotTree tree = mBot.tree(1);
   ContextMenuHelper.clickContextMenu(tree, "Add");
   new NewPropertyInputDialogTestFixture("keyx", "valuex").inputData();
   ContextMenuHelper.clickContextMenu(tree, "Add");
   new NewPropertyInputDialogTestFixture("keyz", "valuez").inputData();
   tree.getTreeItem("keyz").select();
   ContextMenuHelper.clickContextMenu(tree, "Delete");
   tree.unselect();
   // delete should not show up when the selection is empty
   assertThat(SWTTestUtil.getMenuItems(tree).get("Delete"), nullValue());
   mBot.button("OK").click();
   Thread.sleep(WAIT_TIME);
   AbstractUIRunner.syncRun(
       new ThrowableRunnable() {
         @Override
         public void run() throws Throwable {
           assertDeployedStrategy(
               mStrategy,
               mEngine,
               StrategyState.STOPPED,
               "Strategy1",
               "Claz",
               "Lang",
               "c:\\path",
               true,
               ImmutableMap.of("keyx", "valuex"));
         }
       });
 }
  public void testCancelTagLibDefenition() {
    openPage();
    openPalette();
    // Test open import dialog
    bot.viewByTitle(ActionItem.View.GeneralPalette.LABEL.getName()).setFocus(); // $NON-NLS-1$
    new PaletteView().getToolbarButtonWitTooltip("Import").click();
    bot.shell("Import Tags from TLD File").activate(); // $NON-NLS-1$

    // Test open edit TLD dialog

    bot.button("Browse...").click(); // $NON-NLS-1$
    bot.shell("Edit TLD").activate(); // $NON-NLS-1$
    delay();
    // Test cancel TLD
    SWTBotTree tree = bot.tree();
    delay();
    SWTBotTreeItem item = tree.expandNode(JBT_TEST_PROJECT_NAME);
    delay();
    item.getNode("html_basic.tld [h]").select(); // $NON-NLS-1$ //$NON-NLS-2$
    delay();
    bot.button("Cancel").click(); // $NON-NLS-1$

    // Test check fields

    bot.shell("Import Tags from TLD File").activate(); // $NON-NLS-1$
    assertEquals("", bot.textWithLabel("TLD File:*").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("", bot.textWithLabel("Name:*").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("", bot.textWithLabel("Default Prefix:").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("", bot.textWithLabel("Library URI:").getText()); // $NON-NLS-1$ //$NON-NLS-2$
    bot.button("Cancel").click(); // $NON-NLS-1$
  }
Beispiel #8
0
 private SWTBotTreeItem selectInProjectExplorer(String path) {
   final SWTBotTree wizardTree = viewByTitle(UIConstants.PACKAGE_EXPLORER_VIEW_NAME).bot().tree();
   final String[] split = path.split("/");
   SWTBotTreeItem treeItem = wizardTree.expandNode(split[0]).select();
   for (int i = 1; i < split.length; i++) {
     treeItem = treeItem.expandNode(split[i]).select();
   }
   return treeItem;
 }
Beispiel #9
0
 protected static boolean isProjectCreated(final String name) {
   try {
     final SWTBotView packageExplorer = getNavigator();
     final SWTBotTree tree = packageExplorer.bot().tree();
     tree.getTreeItem(name);
     return true;
   } catch (final WidgetNotFoundException e) {
     return false;
   }
 }
  /** Import a gzip trace */
  @Test
  public void testGzipImport() {
    final String traceType = "Test trace : TMF Tests";
    final String tracesNode = "Traces [1]";

    /*
     * Actual importing
     */
    openImportWizard();
    selectImportFromArchive(fGzipTrace.getAbsolutePath());
    selectFolder(ROOT_FOLDER);
    SWTBotCheckBox checkBox = fBot.checkBox(Messages.ImportTraceWizard_CreateLinksInWorkspace);
    assertFalse(checkBox.isEnabled());
    SWTBotCombo comboBox = fBot.comboBoxWithLabel(Messages.ImportTraceWizard_TraceType);
    comboBox.setSelection(traceType);
    importFinish();
    /*
     * Remove .gz extension
     */
    assertNotNull(fGzipTrace);
    String name = fGzipTrace.getName();
    assertNotNull(name);
    assertTrue(name.length() > 3);
    String traceName = name.substring(0, name.length() - 3);
    assertNotNull(traceName);
    assertFalse(traceName.isEmpty());

    /*
     * Open trace
     */
    SWTBotView projectExplorer = fBot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectExplorer.setFocus();
    final SWTBotTree tree = projectExplorer.bot().tree();
    /*
     * This appears to be problematic due to the length of the file name and
     * the resolution in our CI.
     */
    tree.expandNode(PROJECT_NAME, true);
    SWTBotTreeItem treeItem = tree.getTreeItem(PROJECT_NAME);
    fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(tracesNode, treeItem));
    treeItem = treeItem.getNode(tracesNode);
    fBot.waitUntil(ConditionHelpers.IsTreeChildNodeAvailable(traceName, treeItem));
    treeItem = treeItem.getNode(traceName);
    treeItem.doubleClick();
    SWTBotUtils.waitForJobs();
    /*
     * Check results
     */
    SWTBotTable editor = fBot.activeEditor().bot().table();
    String c22 = editor.cell(2, 2);
    String c10 = editor.cell(1, 0);
    assertEquals("Type-1", c22);
    assertEquals("", c10);
  }
 private void findSelectEnterpriseRuntimeLibrary(SWTBotExt bot) throws Exception {
   SWTBotTree libraryTree = bot.tree(1);
   boolean libraryFound = false;
   for (SWTBotTreeItem libraryItem : libraryTree.getAllItems()) {
     if (libraryItem.getText().contains("JBoss Enterprise Application Platform")) {
       libraryTree.select(libraryItem);
       libraryFound = true;
       break;
     }
   }
   if (!libraryFound) throw new RuntimeException("No runtime library has been found");
 }
  @Test
  public void shouldCompareBranchAgainstTag() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    makeChangesAndCommit(PROJ1);

    // when
    launchSynchronization(INITIAL_TAG, HEAD, false);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    assertEquals(2, syncViewTree.getAllItems().length);
  }
  @Test
  public void shouldReturnListOfChanges() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    changeFilesInProject();

    // when
    launchSynchronization(HEAD, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem[] syncItems = syncViewTree.getAllItems();
    assertTrue(syncItems[0].getText().contains(PROJ1));
  }
Beispiel #14
0
  /** Open the properties view. */
  public void openPropertiesView() {
    menu(UIConstants.WINDOW_MENU)
        .menu(UIConstants.SHOW_VIEW_MENU)
        .menu(UIConstants.OTHER_MENU)
        .click();

    final SWTBotShell shell = shell(UIConstants.SHOW_VIEW_MENU);
    activateShell(shell);

    final SWTBotTree viewSelectionTree = tree();
    viewSelectionTree.expandNode(UIConstants.GENERAL_MENU).select(UIConstants.PROPERTIES_VIEW_NAME);
    button(UIConstants.OK_BUTTON).click();
    waitUntil(Conditions.shellCloses(shell));
  }
  /**
   * Selects an entry in the given tree and optionally expands the selected entry. Takes care that
   * all attributes and child entries are initialized so that there are no pending background
   * actions and event notifications. This is necessary to avoid race conditions.
   *
   * @param bot the SWT bot
   * @param tree the given tree
   * @param expandChild true to expand the child entry
   * @param path the path to the entry
   * @return the selected entry as SWTBotTreeItem
   * @throws Exception the exception
   */
  public static SWTBotTreeItem selectEntry(
      final SWTWorkbenchBot bot,
      final SWTBotTree tree,
      final boolean expandChild,
      final String... path) {
    List<String> pathList = new ArrayList<String>(Arrays.asList(path));
    SWTBotTreeItem entry = null;

    while (!pathList.isEmpty()) {
      String currentPath = pathList.remove(0);

      if (entry == null) {
        currentPath = adjustNodeName(tree, currentPath);
        entry = tree.getTreeItem(currentPath);
      } else {
        // adjust current path, because the label is decorated with the
        // number of children
        currentPath = adjustNodeName(entry, currentPath);
        entry = entry.getNode(currentPath);
      }
      entry.click();

      if (!pathList.isEmpty() || expandChild) {
        // expand entry and wait till
        // - children are displayed
        // - next child is visible
        final String nextName = !pathList.isEmpty() ? pathList.get(0) : null;
        expandEntry(bot, entry, nextName);
      }

      entry.select();
    }
    return entry;
  }
  /**
   * Delete Project from workspace
   *
   * @param projectName
   */
  public void deleteProject(String projectName) {

    removeProjectFromServers(projectName);

    SWTBot packageExplorer = eclipse.showView(ViewType.PACKAGE_EXPLORER);
    delay();
    SWTBotTree tree = packageExplorer.tree();
    delay();

    ContextMenuHelper.prepareTreeItemForContextMenu(tree, tree.getTreeItem(projectName));
    new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.DELETE, false)).click();
    bot.shell(IDELabel.Shell.DELETE_RESOURCES).activate();
    bot.button(IDELabel.Button.OK).click();

    new SWTUtilExt(bot).waitForNonIgnoredJobs();
  }
  /**
   * Remove Project from all Servers
   *
   * @param projectName
   * @param stringToContain
   */
  public void removeProjectFromServers(String projectName, String stringToContain) {

    eclipse.showView(ViewType.SERVERS);

    delay();

    try {
      SWTBotTree serverTree = bot.viewByTitle(IDELabel.View.SERVERS).bot().tree();

      delay();

      // Expand All
      for (SWTBotTreeItem serverTreeItem : serverTree.getAllItems()) {
        serverTreeItem.expand();
        // if JSF Test Project is deployed to server remove it
        SWTBotTreeItem[] serverTreeItemChildren = serverTreeItem.getItems();
        if (serverTreeItemChildren != null && serverTreeItemChildren.length > 0) {
          int itemIndex = 0;
          boolean found = false;
          String treeItemlabel = null;
          do {
            treeItemlabel = serverTreeItemChildren[itemIndex].getText();
            found =
                treeItemlabel.startsWith(projectName)
                    && (stringToContain == null || treeItemlabel.indexOf(stringToContain) >= 0);
          } while (!found && ++itemIndex < serverTreeItemChildren.length);
          // Server Tree Item has Child with Text equal to JSF TEst Project
          if (found) {
            log.info("Found project to be removed from server: " + treeItemlabel);
            ContextMenuHelper.prepareTreeItemForContextMenu(
                serverTree, serverTreeItemChildren[itemIndex]);
            new SWTBotMenu(
                    ContextMenuHelper.getContextMenu(serverTree, IDELabel.Menu.REMOVE, false))
                .click();
            bot.shell("Server").activate();
            bot.button(IDELabel.Button.OK).click();
            log.info("Removed project from server: " + treeItemlabel);
            bot.sleep(10 * 1000L);
          }
        }
      }
      delay();

    } catch (WidgetNotFoundException wnfe) {
      // do nothing it means there is no server defined
    }
  }
Beispiel #18
0
  @Override
  public void confirmShellAddProjectsToSession(String... projectNames) throws RemoteException {

    SWTBot bot = new SWTBot();
    SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS_TO_SESSION);
    shell.activate();

    // wait for tree update
    bot.sleep(500);

    SWTBotTree tree = shell.bot().tree();

    for (String projectName : projectNames) tree.getTreeItem(projectName).check();

    shell.bot().button(FINISH).click();
    bot.waitUntil(Conditions.shellCloses(shell));
  }
 private SWTBotTreeItem getProjectTreeItem(SWTBotTree projectsTree, String projectName) {
   for (SWTBotTreeItem item : projectsTree.getAllItems()) {
     if (projectName.equals(getProjectLabel(item.getText()))) {
       return item;
     }
   }
   throw new IllegalStateException("Project " + projectName + " not available");
 }
  @Test
  public void testCreateNewDawnEditorSelectFolder() throws Exception {
    {
      CDOSession session = openSession();
      ResourceSet resourceSet = new ResourceSetImpl();
      CDOTransaction transaction = session.openTransaction(resourceSet);

      final URI uri = URI.createURI("cdo:/folder/dummy");
      resourceSet.createResource(uri);
      transaction.commit();
    }

    getBot().menu("File").menu("New").menu("Other...").click();

    SWTBotShell shell = getBot().shell("New");
    shell.activate();
    getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF);
    getBot().button("Next >").click();

    shell = getBot().shell("New");
    shell.activate();

    SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel);
    fileNameLabel.setText("test.acore");

    SWTBotTree tree = getBot().tree(0);

    selectFolder(tree.getAllItems(), "folder", false);

    getBot().button("Next >").click();

    SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0);
    comboBox.setFocus();
    comboBox.setSelection("ACore Root");

    getBot().button("Finish").click();

    SWTBotEditor editor = getBot().editorByTitle("test.acore");
    assertNotNull(editor);
    editor.close();

    {
      assertEquals(true, resourceExists("/folder/test.acore"));
    }
  }
 private static String adjustNodeName(SWTBotTree tree, String nodeName) {
   SWTBotTreeItem[] allItems = tree.getAllItems();
   for (SWTBotTreeItem item : allItems) {
     String node = item.getText();
     if (node.toUpperCase().startsWith(nodeName.toUpperCase())) {
       return node;
     }
   }
   return null;
 }
  private void testClient() {
    Assert.assertTrue("service must exist", servicePassed);
    clientHelper.createClient(
        deploymentHelper.getWSDLUrl(getWsProjectName(), getWsName()),
        WebServiceRuntime.JBOSS_WS,
        getWsClientProjectName(),
        getEarProjectName(),
        SliderLevel.DEVELOP,
        getWsClientPackage());
    IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(getWsClientProjectName());
    String pkg = "org/jboss/wsclient";
    String cls = "src/" + pkg + "/AreaService.java";
    Assert.assertTrue(p.getFile(cls).exists());
    cls = "src/" + pkg + "/clientsample/ClientSample.java";
    IFile f = p.getFile(cls);
    Assert.assertTrue(f.exists());
    replaceContent(f, "/resources/jbossws/clientsample.java.ws");

    /*
     * workaround for https://issues.jboss.org/browse/JBIDE-9817
     */
    projectExplorer.selectProject(getWsClientProjectName());
    SWTBotTree tree = projectExplorer.bot().tree();
    SWTBotTreeItem item = tree.getTreeItem(getWsClientProjectName());
    item.expand();
    removeRuntimeLibrary(tree, item, bot, util);

    /* workaround problems with generated code that require JAX-WS API 2.2 */
    jaxWsApi22RequirementWorkaround(getWsClientProjectName(), getWsClientPackage());

    eclipse.runJavaApplication(
        getWsClientProjectName(), "org.jboss.wsclient.clientsample.ClientSample", null);
    util.waitForNonIgnoredJobs();

    // wait until the client ends (prints the last line)
    new WaitUntil(new ConsoleHasText("Call Over!"), TimePeriod.NORMAL);

    ConsoleView cw = new ConsoleView();
    String consoleOutput = cw.getConsoleText();
    LOGGER.info(consoleOutput);
    Assert.assertTrue(consoleOutput, consoleOutput.contains("Server said: 37.5"));
    Assert.assertTrue(consoleOutput.contains("Server said: 3512.3699"));
  }
  @Test
  @Ignore // workspace model dosn't show non-workspace files ... yet ;)
  public void shouldShowNonWorkspaceFileInSynchronization() throws Exception {
    // given
    String name = "non-workspace.txt";
    File root = new File(getTestDirectory(), REPO1);
    File nonWorkspace = new File(root, name);
    BufferedWriter writer = new BufferedWriter(new FileWriter(nonWorkspace));
    writer.append("file content");
    writer.close();

    // when
    launchSynchronization(INITIAL_TAG, HEAD, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem workingTree = syncViewTree.expandNode(PROJ1);
    assertEquals(1, syncViewTree.getAllItems().length);
    assertEquals(1, workingTree.getNodes(name).size());
  }
 @Test
 // (Test Cases for 1.8) test case 5
 public void testInvalidCacheSizeOKToLeave() throws Exception {
   Utility.createProject(Messages.projCache);
   SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1);
   wabot.checkBox().select();
   /*
    * To avoid missing storage account error,
    * type some value. Requires typeText only.
    */
   wabot.textWithLabel(Messages.keyLbl).typeText("a");
   wabot.textWithLabel(Messages.nameLbl).typeText("a");
   // Cache size = 0
   wabot.textWithLabel(Messages.cachScaleLbl).setText("");
   wabot.textWithLabel(Messages.cachScaleLbl).typeText("0");
   SWTBotTree properties = propShell.bot().tree();
   properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select();
   SWTBotShell errorShell =
       wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate();
   Boolean zeroErr =
       errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " "));
   wabot.button("OK").click();
   // Cache size < 0 i.e. Negative
   wabot.textWithLabel(Messages.cachScaleLbl).setText("");
   wabot.textWithLabel(Messages.cachScaleLbl).typeText("-2");
   properties = propShell.bot().tree();
   properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select();
   errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate();
   Boolean negErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " "));
   wabot.button("OK").click();
   // Cache size > 100
   wabot.textWithLabel(Messages.cachScaleLbl).setText("");
   wabot.textWithLabel(Messages.cachScaleLbl).typeText("105%");
   properties = propShell.bot().tree();
   properties.getTreeItem(Messages.roleTreeRoot).getNode(Messages.endptPage).select();
   errorShell = wabot.shell(String.format("%s%s", Messages.okToLeaveTtl, " ")).activate();
   Boolean grtErr = errorShell.getText().equals(String.format("%s%s", Messages.okToLeaveTtl, " "));
   wabot.button("OK").click();
   assertTrue("testInvalidCacheSizeOKToLeave", zeroErr && negErr && grtErr);
   propShell.close();
 }
  @Test
  public void shouldSynchronizeInEmptyRepository() throws Exception {
    // given
    createEmptyRepository();

    // when
    launchSynchronization(EMPTY_PROJECT, "", "", true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, EMPTY_PROJECT);
    assertEquals(1, syncViewTree.getAllItems().length);

    SWTBotTreeItem folderTree = waitForNodeWithText(projectTree, FOLDER);
    assertEquals(2, folderTree.getItems().length);

    SWTBotTreeItem fileTree = folderTree.getItems()[0];
    assertEquals(FILE1, fileTree.getText());
    fileTree = folderTree.getItems()[1];
    assertEquals(FILE2, fileTree.getText());
  }
Beispiel #26
0
  /** Test create new Struts Project */
  @Test
  public void testCreateNewStrutsProject() {
    eclipse.createNew(EntityType.STRUTS_PROJECT);
    bot.shell(IDELabel.Shell.NEW_STRUTS_PROJECT).activate();
    bot.textWithLabel(IDELabel.NewStrutsProjectDialog.NAME)
        .setText(StrutsAllBotTests.STRUTS_PROJECT_NAME);
    bot.comboBoxWithLabel(IDELabel.NewStrutsProjectDialog.TEMPLATE)
        .setSelection(IDELabel.NewStrutsProjectDialog.TEMPLATE_KICK_START);
    bot.button(IDELabel.Button.NEXT).click();
    bot.sleep(1000L);
    bot.button(IDELabel.Button.NEXT).click();
    bot.button(IDELabel.Button.FINISH).click();
    bot.sleep(1500);

    SWTBot v = eclipse.showView(ViewType.PACKAGE_EXPLORER);
    SWTBotTree tree = v.tree();
    tree.setFocus();
    assertTrue(
        "Project " + StrutsAllBotTests.STRUTS_PROJECT_NAME + " was not created properly.",
        SWTEclipseExt.treeContainsItemWithLabel(tree, StrutsAllBotTests.STRUTS_PROJECT_NAME));
  }
  @Test
  public void shouldListFileDeletedChange() throws Exception {
    // given
    resetRepositoryToCreateInitialTag();
    deleteFileAndCommit(PROJ1);

    // when
    launchSynchronization(HEAD, INITIAL_TAG, true);

    // then
    SWTBotTree syncViewTree = bot.viewByTitle("Synchronize").bot().tree();
    assertEquals(1, syncViewTree.getAllItems().length);

    SWTBotTreeItem projectTree = waitForNodeWithText(syncViewTree, PROJ1);
    assertEquals(1, projectTree.getItems().length);

    SWTBotTreeItem folderTree = waitForNodeWithText(projectTree, FOLDER);
    assertEquals(1, folderTree.getItems().length);

    SWTBotTreeItem fileTree = folderTree.getItems()[0];
    assertEquals("test.txt", fileTree.getText());
  }
Beispiel #28
0
 /**
  * Select the given element in the given editor.
  *
  * @param editor the editor where the bot must process
  * @param element the element to select
  * @return the selected node
  */
 public SWTBotTreeItem selectNode(SWTBotTree tree, EObject element) {
   assertNotNull("The model has not been initialized.", testModelResource);
   final List<Object> expansionPath = EEFModelHelper.getExpansionPath(element);
   final Iterator<Object> iterator = expansionPath.iterator();
   Object next = null;
   SWTBotTreeItem node2 = tree.getTreeItem(testModelResource.getURI().toString());
   while (iterator.hasNext()) {
     node2.expand();
     next = iterator.next();
     node2 = selectSubNode(node2, next);
   }
   return node2;
 }
Beispiel #29
0
  private void selectProjectFiles(SWTBotTree tree, String project, String[] files) {
    for (SWTBotTreeItem item : tree.getAllItems()) while (item.isChecked()) item.uncheck();

    for (String file : files) {
      String[] nodes = file.split("/|\\\\");
      List<String> regex = new ArrayList<String>(nodes.length + 1);
      regex.add(Pattern.quote(project));

      for (String node : nodes) regex.add(Pattern.quote(node));

      WidgetUtil.getTreeItemWithRegex(tree, regex.toArray(new String[0])).check();
    }
  }
  /**
   * Choose Run On Server menu for specified project
   *
   * @param bot
   * @param projectName
   */
  public static void runProjectOnServer(SWTWorkbenchBot bot, String projectName) {

    SWTBotTree packageExplorerTree = eclipse.showView(ViewType.PACKAGE_EXPLORER).tree();

    packageExplorerTree.setFocus();
    SWTBotTreeItem packageExplorerTreeItem = packageExplorerTree.getTreeItem(projectName);

    packageExplorerTreeItem.select();
    packageExplorerTreeItem.click();
    // Search for Menu Item with Run on Server substring within label
    final SWTBotMenu menuRunAs = bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.RUN_AS);
    final MenuItem menuItem =
        UIThreadRunnable.syncExec(
            new WidgetResult<MenuItem>() {
              public MenuItem run() {
                int menuItemIndex = 0;
                MenuItem menuItem = null;
                final MenuItem[] menuItems = menuRunAs.widget.getMenu().getItems();
                while (menuItem == null && menuItemIndex < menuItems.length) {
                  if (menuItems[menuItemIndex].getText().indexOf("Run on Server") > -1) {
                    menuItem = menuItems[menuItemIndex];
                  } else {
                    menuItemIndex++;
                  }
                }
                return menuItem;
              }
            });
    if (menuItem != null) {
      new SWTBotMenu(menuItem).click();
      bot.shell(IDELabel.Shell.RUN_ON_SERVER).activate();
      bot.button(IDELabel.Button.FINISH).click();
      SWTUtilExt swtUtil = new SWTUtilExt(bot);
      swtUtil.waitForAll(10 * 1000L);
    } else {
      throw new WidgetNotFoundException("Unable to find Menu Item with Label 'Run on Server'");
    }
  }