/**
   * Returns string representing version of defined Server Runtime on rowIndex position in Defined
   * Server Runtime table
   *
   * @param bot
   * @param rowIndex
   * @return null when no server runtime is specified, "unknown when not possible to determine
   *     server runtime version" or server runtime version
   */
  public static String getDefinedServerRuntimeVersion(SWTWorkbenchBot bot, int rowIndex) {

    String result = null;

    bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click();
    bot.shell(IDELabel.Shell.PREFERENCES).activate();
    bot.tree()
        .expandNode(IDELabel.PreferencesDialog.SERVER_GROUP)
        .select(PreferencesDialog.RUNTIME_ENVIRONMENTS);

    SWTBotTable serverRuntimesTable = bot.table();
    if (serverRuntimesTable.rowCount() > rowIndex) {
      String[] splitServerRuntimeType = serverRuntimesTable.cell(rowIndex, 1).split(" ");
      int index = 0;
      while (index < splitServerRuntimeType.length && result == null) {
        if (splitServerRuntimeType[index].length() > 0
            && splitServerRuntimeType[index].charAt(0) >= '0'
            && splitServerRuntimeType[index].charAt(0) <= '9') {
          result = splitServerRuntimeType[index].trim();
        } else {
          index++;
        }
      }
    }

    bot.button(IDELabel.Button.OK).click();

    return result;
  }
  /**
   * Returns true if runtimeName Server Runtime is defined
   *
   * @param bot
   * @param runtimeName
   * @return
   */
  public static boolean isServerRuntimeDefined(SWTWorkbenchBot bot, String runtimeName) {

    boolean serverRuntimeNotDefined = true;

    bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click();
    bot.shell(IDELabel.Shell.PREFERENCES).activate();
    bot.tree()
        .expandNode(IDELabel.PreferencesDialog.SERVER_GROUP)
        .select(PreferencesDialog.RUNTIME_ENVIRONMENTS);

    SWTBotTable tbRuntimeEnvironments = bot.table();
    int numRows = tbRuntimeEnvironments.rowCount();
    if (numRows > 0) {
      int currentRow = 0;
      while (serverRuntimeNotDefined && currentRow < numRows) {
        if (tbRuntimeEnvironments.cell(currentRow, 0).equalsIgnoreCase(runtimeName)) {
          serverRuntimeNotDefined = false;
        } else {
          currentRow++;
        }
      }
    }

    bot.button(IDELabel.Button.OK).click();

    return !serverRuntimeNotDefined;
  }
 /**
  * Creates new Server within Server View when Wizard for new Project is called
  *
  * @param bot
  * @param serverGroup
  * @param serverType
  */
 public static void addServerToServerViewOnWizardPage(
     SWTWorkbenchBot bot, String serverGroup, String serverType) {
   // Check if there is defined Application Server if not create one
   if (!SWTJBTExt.isServerDefinedInWebWizardPage(bot)) {
     // Specify Application Server for Deployment
     bot.button(IDELabel.Button.NEW, 1).click();
     bot.shell(IDELabel.Shell.NEW_SERVER).activate();
     bot.tree().select(serverGroup);
     bot.tree().expandNode(serverGroup).select(serverType);
     bot.button(IDELabel.Button.FINISH).click();
   }
 }
  /**
   * Returns true if any Server Runtime is defined
   *
   * @param bot
   * @return
   */
  public static boolean isServerRuntimeDefined(SWTWorkbenchBot bot) {

    bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click();
    bot.shell(IDELabel.Shell.PREFERENCES).activate();
    bot.tree()
        .expandNode(IDELabel.PreferencesDialog.SERVER_GROUP)
        .select(PreferencesDialog.RUNTIME_ENVIRONMENTS);
    boolean isServerRuntimeDefined = bot.table().rowCount() > 0;

    bot.button(IDELabel.Button.OK).click();

    return isServerRuntimeDefined;
  }
Exemplo n.º 5
0
  @Test
  public void createProject() throws Exception {
    String projectName = "prjBot-001";

    bot.menu("File").menu("New").click();
    SWTBotShell shell = bot.shell("New");
    shell.activate();
    // From menu open File > New dialog, verify whether the dialog has been opened.

    bot.tree().select("Project");
    SWTBotAssert.assertEnabled(bot.button("Next >"));
    // After selecting Project, the Next button should be enabled.

    bot.button("Next >").click();
    bot.textWithLabel("Project name:").setText(projectName);
    SWTBotAssert.assertEnabled(bot.button("Finish"));
    // Enter the Project Name, then Finish button should be enabled.

    bot.button("Finish").click();
    SWTBotAssert.assertVisible(bot.tree().select(projectName));
    // Click Finish button and verify whether the project's been successfully created.
  }
Exemplo n.º 6
0
  public void create(String projectId) {
    bot.menu().menu("File").menu("New").menu("Project...").click();
    SWTBotShell shell = bot.shell("New Project");
    shell.activate();

    bot.tree().expandNode("SWTBot", "SWTBot Test Plug-in").select();
    bot.button("Next >").click();

    bot.textWithLabel("Plug-in Name:").setText(projectId);
    bot.textWithLabel("Plug-in id:").setText(projectId);
    bot.textWithLabel("Provider:").setText("ACME Corp.");
    bot.button("Finish").click();
    bot.waitUntil(shellCloses(shell));
  }
  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();
  }
 SWTBotTree getTree() {
   return bot.tree();
 }
 private void selectFolder(String... treePath) {
   SWTBotTree tree = fBot.tree();
   fBot.waitUntil(Conditions.widgetIsEnabled(tree));
   SWTBotTreeItem folderNode = SWTBotUtils.getTreeItem(fBot, tree, treePath);
   folderNode.check();
 }
  /**
   * test opening a trace, importing
   *
   * @throws IOException won't happen
   */
  @Test
  public void test() throws IOException {
    File f = File.createTempFile("temp", ".xml").getCanonicalFile();
    try (FileWriter fw = new FileWriter(f)) {
      fw.write(TRACE_CONTENT);
    }
    File exportPackage = new File(EXPORT_LOCATION);
    if (exportPackage.exists()) {
      exportPackage.delete();
    }
    assertFalse(
        "File: " + EXPORT_LOCATION + " already present, aborting test", exportPackage.exists());
    assertTrue("Trace :" + f.getAbsolutePath() + " does not exist, aborting test", f.exists());
    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotUtils.openTrace(PROJECT_NAME, f.getAbsolutePath(), XMLSTUB_ID);
    WaitUtils.waitForJobs();
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(trace);
    assertEquals(
        "Incorrect opened trace!",
        f.getAbsolutePath(),
        (new File(trace.getPath())).getAbsolutePath());
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    assertNotNull("Cannot find " + PROJECT_EXPLORER, projectExplorerBot);
    projectExplorerBot.show();
    SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);

    treeItem.contextMenu(EXPORT_TRACE_PACKAGE).click();
    fBot.waitUntil(Conditions.shellIsActive(EXPORT_TRACE_PACKAGE_TITLE));
    SWTBot shellBot = fBot.activeShell().bot();
    shellBot.button(DESELECT_ALL).click();
    SWTBotTreeItem[] items = fBot.tree().getAllItems();
    for (SWTBotTreeItem item : items) {
      assertEquals(item.isChecked(), false);
    }
    shellBot.button(SELECT_ALL).click();
    for (SWTBotTreeItem item : items) {
      assertEquals(item.isChecked(), true);
    }
    shellBot.radio(SAVE_IN_TAR_FORMAT).click();
    shellBot.radio(SAVE_IN_ZIP_FORMAT).click();

    shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click();
    shellBot.checkBox(COMPRESS_THE_CONTENTS_OF_THE_FILE).click();
    shellBot.comboBox().setText(EXPORT_LOCATION);
    SWTBotShell shell = fBot.activeShell();
    shellBot.button(FINISH).click();
    // finished exporting
    WaitUtils.waitForJobs();
    fBot.waitUntil(Conditions.shellCloses(shell));
    fBot = new SWTWorkbenchBot();
    exportPackage = new File(EXPORT_LOCATION);
    assertTrue("Exported package", exportPackage.exists());
    // Fixme: determine why exportPackageSize is different on different machines
    // assertEquals("Exported package size check", PACKAGE_SIZE, exportPackage.length());

    // import
    treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    treeItem.contextMenu(IMPORT_TRACE_PACKAGE).click();
    fBot.waitUntil(Conditions.shellIsActive(IMPORT_TRACE_PACKAGE_TITLE));
    shellBot = fBot.activeShell().bot();
    shellBot.comboBox().setText(EXPORT_LOCATION);
    shellBot.comboBox().typeText("\n");

    shellBot.button(SELECT_ALL).click();
    shell = fBot.activeShell();
    shellBot.button(FINISH).click();
    fBot.button("Yes To All").click();
    fBot.waitUntil(Conditions.shellCloses(shell));
    fBot = new SWTWorkbenchBot();
    SWTBotUtils.openEditor(fBot, PROJECT_NAME, new Path(f.getName()));
    trace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(trace);
    assertEquals("Test if import matches", f.getName(), trace.getName());
    assertFalse("Test if import files don't match", f.getAbsolutePath().equals(trace.getPath()));
    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
    WaitUtils.waitForJobs();
  }