Esempio n. 1
0
  @Test
  public void testDeleteMultipleBranches() throws Exception {
    // expand first level
    SWTBotTree tree = getOrOpenView().bot().tree();
    refreshAndWait();
    // open a branch (checkout)
    SWTBotTreeItem localBranchesItem =
        myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).expand();
    SWTBotTreeItem masterNode = localBranchesItem.getNode("master");
    // create first branch (abc)
    masterNode.select();
    ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
    SWTBotShell createBranchShell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
    createBranchShell.bot().textWithId("BranchName").setText("abc");
    createBranchShell.bot().checkBox(UIText.CreateBranchPage_CheckoutButton).deselect();
    createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
    // create second branch (123)
    ContextMenuHelper.clickContextMenu(tree, "Create Branch...");
    createBranchShell = bot.shell(UIText.CreateBranchWizard_NewBranchTitle);
    createBranchShell.bot().textWithId("BranchName").setText("123");
    createBranchShell.bot().checkBox(UIText.CreateBranchPage_CheckoutButton).deselect();
    createBranchShell.bot().button(IDialogConstants.FINISH_LABEL).click();
    refreshAndWait();
    localBranchesItem = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).expand();
    // delete both
    localBranchesItem.select("abc", "123");
    ContextMenuHelper.clickContextMenuSync(
        tree, myUtil.getPluginLocalizedValue("RepoViewDeleteBranch.label"));
    refreshAndWait();

    SWTBotTreeItem[] items = myRepoViewUtil.getLocalBranchesItem(tree, repositoryFile).getItems();
    assertEquals("Wrong number of branches", 2, items.length);
    assertEquals("master", items[0].getText());
    assertEquals("stable", items[1].getText());
  }
  /**
   * 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;
  }
Esempio n. 3
0
 /**
  * Select the object <code>next</code> as a subnode of the <code>currentNode</code>.
  *
  * @param currentNode the currentNode
  * @param next the subnode to select
  * @return the selected node
  */
 private SWTBotTreeItem selectSubNode(SWTBotTreeItem currentNode, Object next) {
   final AdapterFactory adapterFactory = EEFRuntimePlugin.getDefault().getAdapterFactory();
   final IItemLabelProvider labelProvider =
       (IItemLabelProvider) adapterFactory.adapt(next, IItemLabelProvider.class);
   final String text = labelProvider.getText(next);
   final SWTBotTreeItem node2 = currentNode.getNode(text);
   node2.select();
   return node2;
 }
Esempio n. 4
0
 /**
  * Show properties
  *
  * @throws Exception
  */
 @Test
 public void testShowProperties() throws Exception {
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   item.select();
   ContextMenuHelper.clickContextMenuSync(
       tree, myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
   SWTBotView propertieView = bot.viewById(IPageLayout.ID_PROP_SHEET);
   assertTrue(propertieView.isActive());
 }
Esempio n. 5
0
 /**
  * Import wizard golden path test
  *
  * @throws Exception
  */
 @Test
 public void testImportWizard() throws Exception {
   deleteAllProjects();
   assertProjectExistence(PROJ1, false);
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   String wizardTitle =
       NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile.getPath());
   // start wizard from root item
   item.select();
   ContextMenuHelper.clickContextMenu(
       tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
   SWTBotShell shell = bot.shell(wizardTitle);
   bot.radio(UIText.GitSelectWizardPage_ImportExistingButton).click();
   TableCollection selected = shell.bot().tree().selection();
   String wizardNode = selected.get(0, 0);
   // wizard directory should be working dir
   assertEquals(myRepoViewUtil.getWorkdirItem(tree, repositoryFile).getText(), wizardNode);
   shell.close();
   // start wizard from .git
   myRepoViewUtil
       .getWorkdirItem(tree, repositoryFile)
       .expand()
       .getNode(Constants.DOT_GIT)
       .select();
   ContextMenuHelper.clickContextMenu(
       tree, myUtil.getPluginLocalizedValue("ImportProjectsCommand"));
   shell = bot.shell(wizardTitle);
   selected = shell.bot().tree().selection();
   wizardNode = selected.get(0, 0);
   // wizard directory should be .git
   assertEquals(Constants.DOT_GIT, wizardNode);
   shell.bot().button(IDialogConstants.NEXT_LABEL).click();
   shell.bot().label("Import Projects"); // wait for import projects page
   assertEquals(0, shell.bot().tree().getAllItems().length);
   shell.bot().button(IDialogConstants.BACK_LABEL).click();
   // go to project with .project
   shell.bot().tree().getAllItems()[0].getNode(PROJ1).select();
   // next is 1
   shell.bot().button(IDialogConstants.NEXT_LABEL).click();
   bot.button(UIText.WizardProjectsImportPage_deselectAll).click();
   assertEquals(1, shell.bot().tree().getAllItems().length);
   assertTrue(!shell.bot().button(IDialogConstants.FINISH_LABEL).isEnabled());
   shell.bot().button(UIText.WizardProjectsImportPage_selectAll).click();
   assertTrue(shell.bot().button(IDialogConstants.FINISH_LABEL).isEnabled());
   shell.bot().button(IDialogConstants.FINISH_LABEL).click();
   bot.waitUntil(Conditions.shellCloses(shell));
   assertProjectExistence(PROJ1, true);
   assertProjectIsShared(PROJ1, true);
 }
  @Test
  public void connectDBTest() {

    openPerspective("Hibernate");

    bot.viewByTitle("Hibernate Configurations").setFocus();
    bot.viewByTitle("Hibernate Configurations").show();

    SWTBot viewBot = bot.viewByTitle("Hibernate Configurations").bot();
    SWTBotTreeItem item =
        TreeHelper.expandNode(
            viewBot, Properties.SEAM_PROJECT_NAME, "Database", "ModeShape.ModeShape");
    item.select();
    assertTrue("Could not find node with text:" + item.getText(), item.isVisible());
  }
Esempio n. 7
0
 /**
  * Checks is some context menus are available, should be replaced with real tests
  *
  * @throws Exception
  */
 @Test
 public void testContextMenuRepository() throws Exception {
   // We just check if the dialogs open, the actual commit and import projects
   // is tested elsewhere
   SWTBotTree tree = getOrOpenView().bot().tree();
   SWTBotTreeItem item = myRepoViewUtil.getRootItem(tree, repositoryFile);
   item.select();
   assertClickOpens(
       tree,
       myUtil.getPluginLocalizedValue("RepoViewCommit.label"),
       UIText.CommitDialog_CommitChanges);
   assertClickOpens(
       tree,
       myUtil.getPluginLocalizedValue("RepoViewImportProjects.label"),
       NLS.bind(UIText.GitCreateProjectViaWizardWizard_WizardTitle, repositoryFile));
 }
  private void select(final SWTBotTreeItem entry) {
    if (!bot.tree().isEnabled()) {
      bot.waitUntil(
          new DefaultCondition() {

            public boolean test() throws Exception {
              return bot.tree().isEnabled();
            }

            public String getFailureMessage() {
              return "Entry " + entry + " is not enabled!";
            }
          });
    }
    // JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__init_entries_title_attonly );
    entry.click();
    entry.select();
    // watcher.waitUntilDone();
  }
  @Test
  public void testDeleteTag() throws Exception {
    SWTBotTree tree = getOrOpenView().bot().tree();
    int initialCount = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand().rowCount();

    createTag("Delete1", "The first tag");
    refreshAndWait();
    SWTBotTreeItem tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    SWTBotTreeItem[] items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount + 1, items.length);
    tagsItem.select("Delete1");
    ContextMenuHelper.clickContextMenu(
        tree, myUtil.getPluginLocalizedValue("DeleteTagCommand.name"));
    bot.shell(UIText.DeleteTagCommand_titleConfirm).bot().button(IDialogConstants.OK_LABEL).click();
    TestUtil.joinJobs(JobFamilies.TAG);
    refreshAndWait();
    tagsItem = myRepoViewUtil.getTagsItem(tree, repositoryFile).expand();
    items = tagsItem.getItems();
    assertEquals("Wrong number of tags", initialCount, items.length);
  }
  /**
   * Creates Drools Rule and checks result
   *
   * @param droolsRuletName
   */
  private void createDroolsRule(String droolsRuleName) {

    packageExplorer.show();
    SWTBotTreeItem tiDroolsRules =
        packageExplorer.selectTreeItem(
            DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,
            new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME});

    tiDroolsRules.select();
    eclipse.createNew(EntityType.DROOLS_RULE);

    bot.textWithLabel(IDELabel.NewDroolsRuleDialog.FILE_NAME).setText(droolsRuleName);
    bot.textWithLabel(IDELabel.NewDroolsRuleDialog.RULE_PACKAGE_NAME)
        .setText(DroolsAllBotTests.COM_SAMPLE_TREE_NODE);
    bot.button(IDELabel.Button.FINISH).click();
    bot.sleep(Timing.time1S());
    tiDroolsRules.expand();
    // Test if new Drools Rule is within package tree view
    boolean isRuleCreated = true;
    try {
      tiDroolsRules.getNode(droolsRuleName);
    } catch (WidgetNotFoundException wnfe) {
      isRuleCreated = false;
    }
    assertTrue(
        "New Drools Rule was not created properly. It's not present within Package Explorer",
        isRuleCreated);
    // Test if new Drools Rule is opened in editor
    isRuleCreated = true;
    try {
      bot.editorByTitle(droolsRuleName);
    } catch (WidgetNotFoundException wnfe) {
      isRuleCreated = false;
    }
    assertTrue(
        "New Drools Rule was not created properly. File "
            + droolsRuleName
            + " is not opened in editor",
        isRuleCreated);
  }
  /**
   * 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'");
    }
  }
  @Test
  public void seamGenerateEntitiesTest() {

    bot.menu(IDELabel.Menu.FILE).menu(IDELabel.Menu.NEW).menu(IDELabel.Menu.OTHER).click();

    SWTBotShell shell = bot.shell("New");
    shell.activate();
    shell.bot().tree(0).expandNode("Seam").select("Seam Generate Entities");
    shell.bot().button(IDELabel.Button.NEXT).click();

    shell.bot().button("Browse...").click();
    shell = bot.shell("Seam Web Projects");
    shell.activate();
    shell.bot().table(0).getTableItem(Properties.SEAM_PROJECT_NAME).click();
    open.finish(shell.bot(), IDELabel.Button.OK);

    shell = bot.shell("Generate Seam Entities");
    shell.activate();
    shell
        .bot()
        .comboBoxWithLabel("Hibernate Console Configuration:")
        .setSelection(Properties.SEAM_PROJECT_NAME);
    shell.bot().radio("Reverse engineer from database").click();
    shell.bot().button(IDELabel.Button.NEXT).click();

    shell.bot().button("Refresh").click();
    shell.bot().sleep(TIME_5S);

    SWTBotTreeItem item = shell.bot().tree(0).getTreeItem("ModeShape");
    item.expand();
    shell.bot().sleep(TIME_5S);
    item = item.getNode("ModeShape");
    item.expand();
    shell.bot().sleep(TIME_5S);
    item = item.getNode("xmi_model");
    item.select();

    shell.bot().button("Include...").click();

    assertTrue(shell.bot().table(0).cell(0, "Catalog").equals("ModeShape"));
    assertTrue(shell.bot().table(0).cell(0, "Schema").equals("ModeShape"));
    assertTrue(shell.bot().table(0).cell(0, "Table").equals("xmi_model"));

    open.finish(shell.bot());

    assertTrue(
        SWTTestExt.projectExplorer.existsResource(
            Properties.SEAM_PROJECT_NAME,
            "src",
            "main",
            "org",
            "domain",
            Properties.SEAM_PROJECT_NAME,
            "entity",
            "XmiModel.java"));

    assertTrue(
        SWTTestExt.projectExplorer.existsResource(
            Properties.SEAM_PROJECT_NAME,
            "src",
            "main",
            "org",
            "domain",
            Properties.SEAM_PROJECT_NAME,
            "entity",
            "XmiModelId.java"));
  }
 public void selectChildrenOfEnty(String[] children, String ViewTitle, String... path)
     throws Exception {
   SWTBotTreeItem entry = getEntry(ViewTitle, path);
   entry.select(children);
 }
  @Test
  public void testServerBuild() {

    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor activeEditor = bot.activeEditor();
    final String editorTitle = activeEditor.getTitle();
    // System.out.println("editorTitle1 = "+editorTitle1);
    assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty());

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();
    new BotGefProcessDiagramEditor(bot).selectElement("Step1");
    new BotExecutionDiagramPropertiesView(bot).selectFormTab().selectLegacy();

    // get the GEF editor to activate tools
    final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle);

    // Create 2 Pools
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 500);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 800);

    new BotProcessDiagramPropertiesViewFolder(bot)
        .selectExecutionTab()
        .selectInstantiationFormTab()
        .selectLegacy();

    // Save Diagram
    bot.menu("Diagram").menu("Save").click();

    // System.out.println(editorTitle);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.menu("Server")));

    // Menu Server > Build...
    bot.menu("Server").menu("Build...").click();

    // shell 'Build'
    final SWTBotShell shell = bot.shell(Messages.buildTitle);
    bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle));

    // select and check created Diagram in the Tree
    final SWTBotTree tree = bot.treeWithLabel("Select processes to export");
    final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle);

    // check the diagram to export
    diagramTreeItem.select().check();
    diagramTreeItem.expand();

    // Number of pool in the diagram
    final int poolListSize = diagramTreeItem.getItems().length;
    // System.out.println("Diagram contains "+ poolListSize + " items");
    assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize);

    // unselect the first pool of the list

    diagramTreeItem.getNode(0).select();
    diagramTreeItem.getNode(0).uncheck();

    final Vector<String> poolTitleList = new Vector<String>(3);
    final int poolTitleListSize = poolTitleList.size();

    // check the selected pools
    for (int i = 1; i < poolTitleListSize; i++) {
      final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i);
      poolTitleList.set(i, poolTreeItem.getText());
      final String poolName = getItemName(poolTitleList.get(i));

      // test the good pool is checked
      assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked());
      assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i));
    }
    // create tmp directory to write diagrams
    final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar");
    tmpBarFolder.mkdirs();
    // set the path where files are saved
    final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath();
    bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath);
    //		String tmpBarFolderPath = bot.comboBoxWithLabel(Messages.destinationPath+" *").getText();
    //		System.out.println("tmpBarFolder = "+tmpBarFolderPath);

    // click 'Finish' button to close 'Build' shell
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    //  click 'OK' button to close 'Export' shell
    bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle));
    bot.button(IDialogConstants.OK_LABEL).click();

    // wait the shell to close before checking creation of files
    bot.waitUntil(Conditions.shellCloses(shell));

    // check pools files exist
    for (int i = 1; i < poolTitleListSize; i++) {
      final String tmpPoolTitle = poolTitleList.get(i);
      final String poolFileName =
          getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar";
      final File poolFile = new File(tmpBarFolderPath, poolFileName);

      assertTrue("Error: The Pool export must exist", poolFile.exists());
      assertTrue("Error: The Pool export must be a file", poolFile.isFile());
    }
  }