/**
   * 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;
  }
  /**
   * 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;
  }
 @Test
 // (Test Cases for 1.8) test case 3
 public void testDisableCaching() throws Exception {
   Utility.createProject(Messages.projCache);
   SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1);
   // check
   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");
   Utility.selEndPtPage();
   Boolean endPtPresent =
       wabot
               .table()
               .cell(1, 0)
               .equals(String.format("%s%s", Messages.cachEndPtName, Messages.dfltCachName))
           && wabot.table().cell(1, 1).equals(Messages.typeIntrnl)
           && wabot.table().cell(1, 3).equals("11211");
   Utility.selLclStrPage(Messages.role1);
   Boolean LclStrPresent =
       wabot.table().cell(0, 0).equals(Messages.cachLclStr)
           && wabot.table().cell(0, 1).equals("20000");
   Utility.selCachePage(Messages.role1);
   // un-check
   wabot.checkBox().click();
   Boolean isDisabled =
       !wabot.checkBox().isChecked()
           && !wabot.label(Messages.cachScaleLbl).isEnabled()
           && !wabot.label(Messages.hostLbl).isEnabled()
           && !wabot.button(Messages.roleAddBtn).isEnabled()
           && !wabot.button(Messages.roleEditBtn).isEnabled()
           && !wabot.label(Messages.keyLbl).isEnabled()
           && !wabot.label(Messages.nameLbl).isEnabled()
           && !wabot.table().isEnabled()
           && !wabot.textWithLabel(Messages.cachScaleLbl).isEnabled()
           && !wabot.scale().isEnabled();
   // Once caching disabled, no storage account warning
   Utility.selEndPtPage();
   Boolean endPtRmv =
       !wabot
           .table()
           .containsItem(String.format("%s%s", Messages.cachEndPtName, Messages.dfltCachName));
   propShell = Utility.selLclStrPage(Messages.role1);
   Boolean lclStrRmv = !wabot.table().containsItem(Messages.cachLclStr);
   assertTrue(
       "testDisableCaching", endPtPresent && LclStrPresent && isDisabled && endPtRmv && lclStrRmv);
   propShell.close();
 }
示例#5
0
 public SDKPreferenceBot(SWTWorkbenchBot workbench) {
   this.workbench = workbench;
   sdks = workbench.table();
 }
 @Test
 // (Test Cases for 1.8) test case 2
 public void testEnableCaching() throws Exception {
   Utility.createProject(Messages.projCache);
   SWTBotShell propShell = Utility.selCacheUsingCnxtMenu(Messages.projCache, Messages.role1);
   wabot.checkBox().select();
   Boolean isEnabled =
       wabot.checkBox().isChecked()
           && wabot.label(Messages.cachScaleLbl).isEnabled()
           && wabot.label(Messages.hostLbl).isEnabled()
           && wabot.button(Messages.roleAddBtn).isEnabled()
           && !wabot.button(Messages.roleEditBtn).isEnabled()
           && wabot.label(Messages.keyLbl).isEnabled()
           && wabot.label(Messages.nameLbl).isEnabled()
           && wabot.table().isEnabled();
   Boolean cacheSizeVal =
       wabot.textWithLabel(Messages.cachScaleLbl).getText().equals(Messages.dfltSizeVal)
           && (wabot.scale().getValue() == 30);
   Boolean dfltCacheVal =
       wabot.table().containsItem(Messages.dfltCachName)
           && wabot.table().cell(0, 1).equals(Messages.cachBckNo)
           && wabot.table().cell(0, 2).equals(Messages.expPolAbs)
           && wabot.table().cell(0, 3).equals("10")
           && wabot.table().cell(0, 4).equals("11211");
   Boolean hostNmVal =
       wabot
           .textWithLabel(Messages.hostLbl)
           .getText()
           .equals(String.format("%s%s", Messages.hostNm, Messages.role1.toLowerCase()));
   Boolean StorageVal =
       wabot.textWithLabel(Messages.keyLbl).getText().equals("")
           && wabot.textWithLabel(Messages.nameLbl).getText().equals("");
   /*
    * To avoid missing storage account error,
    * set some value
    */
   wabot.textWithLabel(Messages.keyLbl).setText("a");
   wabot.textWithLabel(Messages.nameLbl).setText("a");
   Utility.selEndPtPage();
   Boolean endPtPresent =
       wabot
               .table()
               .cell(1, 0)
               .equals(String.format("%s%s", Messages.cachEndPtName, Messages.dfltCachName))
           && wabot.table().cell(1, 1).equals(Messages.typeIntrnl)
           && wabot.table().cell(1, 3).equals("11211");
   propShell = Utility.selLclStrPage(Messages.role1);
   Boolean LclStrPresent =
       wabot.table().cell(0, 0).equals(Messages.cachLclStr)
           && wabot.table().cell(0, 1).equals("20000");
   assertTrue(
       "testEnableCaching",
       isEnabled
           && cacheSizeVal
           && dfltCacheVal
           && hostNmVal
           && StorageVal
           && endPtPresent
           && LclStrPresent);
   propShell.close();
 }