Пример #1
0
 public void restart() {
   log.info("Restarting server " + getLabel().getName());
   if (!getLabel().getState().isRunningState()) {
     throw new ServersViewException("Cannot restart server because it is not running");
   }
   operateServerState("Restart", ServerState.STARTED);
 }
Пример #2
0
 public void debug() {
   log.info("Starting server in debug" + getLabel().getName());
   if (!ServerState.STOPPED.equals(getLabel().getState())) {
     throw new ServersViewException("Cannot debug server because it is not stopped");
   }
   operateServerState("Debug", ServerState.DEBUGGING);
 }
Пример #3
0
 public void profile() {
   log.info("Starting server in profiling mode" + getLabel().getName());
   if (!ServerState.STOPPED.equals(getLabel().getState())) {
     throw new ServersViewException("Cannot profile server because it is not stopped");
   }
   operateServerState("Profile", ServerState.PROFILING);
 }
Пример #4
0
 public void start() {
   log.info("Starting server " + getLabel().getName());
   if (!ServerState.STOPPED.equals(getLabel().getState())) {
     throw new ServersViewException("Cannot start server because it is not stopped");
   }
   operateServerState("Start", ServerState.STARTED);
 }
/**
 * Simple tests verifies only presence of JBoss Fuse Tooling plugins
 *
 * @author tsedmik
 */
public class SmokeTest extends RedDeerTest {

  private static final String PROJECT_ARCHETYPE = "camel-archetype-spring";
  private static final String PROJECT_NAME = "camel-spring";

  private static Logger log = Logger.getLogger(SmokeTest.class);

  @Test
  public void testCreateFuseProject() {

    log.info("Create a new Fuse project (" + PROJECT_ARCHETYPE + ")");
    ProjectFactory.createProject(PROJECT_ARCHETYPE);
    try {
      new ProjectExplorer().getProject(PROJECT_NAME);
    } catch (EclipseLayerException ex) {
      fail("Created project is not present in Project Explorer");
    }
  }

  @Test
  public void testOpenViews() {

    new FuseJMXNavigator().open();
    new FabricExplorer().open();
  }

  @Test
  public void testOpenPerspectives() {

    AbstractPerspective perspective = new FuseIntegrationPerspective();
    perspective.open();
    assertTrue(perspective.isOpened());
  }
}
Пример #6
0
/**
 * Test for Browser implementations
 *
 * @author Jiri Peterka
 */
@Ignore // https://github.com/jboss-reddeer/reddeer/issues/219
public class BrowserTest extends RedDeerTest {

  protected final Logger log = Logger.getLogger(this.getClass());

  @Override
  public void setUp() {
    super.setUp();
    // Open Internal Web Browser
    // TODO: should be replaced with Internal Web Browses view once it's implemented
    new DefaultShell();
    RegexMatchers m = new RegexMatchers("Window.*", "Show View.*", "Other...*");
    Menu menu = new ShellMenu(m.getMatchers());
    menu.select();
    new DefaultShell("Show View");
    new DefaultTreeItem("General", "Internal Web Browser").select();
    new PushButton("OK").click();
  }

  @Test
  public void testInternalBrowser() {
    try {
      Browser b = new InternalBrowser();
      b.setURL("http://www.google.com");
      final int limit = 100; // 100 cycles maximum
      int counter = 0;
      while (!b.isPageLoaded() && counter < limit) {
        counter++;
        AbstractWait.sleep(100);
      }
    } catch (SWTLayerException e) {
      fail("Browser should be available");
    }
  }
}
Пример #7
0
  /** Click the next button in wizard dialog. */
  public void next() {
    log.info("Go to next wizard page");

    Button button = new PushButton("Next >");
    button.click();
    currentPage++;
  }
Пример #8
0
 public void restartInProfile() {
   log.info("Restarting server in profile" + getLabel().getName());
   if (!getLabel().getState().isRunningState()) {
     throw new ServersViewException("Cannot restart server in profile because it is not running");
   }
   operateServerState("Restart in Profile", ServerState.PROFILING);
 }
Пример #9
0
 public void restartInDebug() {
   log.info("Restarting server in debug" + getLabel().getName());
   if (!getLabel().getState().isRunningState()) {
     throw new ServersViewException("Cannot restart server in debug because it is not running");
   }
   operateServerState("Restart in Debug", ServerState.DEBUGGING);
 }
Пример #10
0
 public void stop() {
   log.info("Stopping server " + getLabel().getName());
   ServerState state = getLabel().getState();
   if (!ServerState.STARTING.equals(state) && !state.isRunningState()) {
     throw new ServersViewException("Cannot stop server because it not running");
   }
   operateServerState("Stop", ServerState.STOPPED);
 }
Пример #11
0
 public void clean() {
   log.info("Cleaning server " + getLabel().getName());
   select();
   new ContextMenu("Clean...").select();
   new DefaultShell("Server");
   new PushButton("OK").click();
   waitForPublish();
 }
Пример #12
0
/**
 * WorkbenchShell is Shell implementation for WorkbenchShell
 *
 * @author Jiri Peterka
 */
public class WorkbenchShell extends AbstractShell {

  private Logger log = Logger.getLogger(WorkbenchShell.class);

  /** Default Constructor for a WorkbenchShell */
  public WorkbenchShell() {

    Display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            swtShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            WidgetHandler.getInstance().setFocus(swtShell);
          }
        });

    log.info("Workbench shell has title '" + getText() + "'");
  }

  /** Maximize window */
  public void maximize() {
    Display.syncExec(
        new Runnable() {

          public void run() {
            swtShell.setMaximized(true);
          }
        });
  }

  /** Restore window */
  public void restore() {
    Display.syncExec(
        new Runnable() {

          public void run() {
            swtShell.setMaximized(false);
          }
        });
  }

  /**
   * Return true if window is maximized, false otherwise
   *
   * @return true if window is maximized
   */
  public boolean isMaximized() {
    return Display.syncExec(
        new ResultRunnable<Boolean>() {

          public Boolean run() {
            return swtShell.getMaximized();
          }
        });
  }
}
Пример #13
0
 /**
  * Returns a current wizard page
  *
  * @return current wizard page
  * @deprecated use getCurrentWizardPage() instead
  */
 public WizardPage getWizardPage() {
   for (WizardPage wizardPage : wizardPageMap.keySet()) {
     Matcher<WizardDialog> matcher = wizardPageMap.get(wizardPage);
     if (matcher.matches(this)) {
       return wizardPage;
     }
   }
   log.warn("No wizard page found in page index '" + currentPage + "'");
   return null;
 }
Пример #14
0
  /** Click the cancel button in wizard dialog. */
  public void cancel() {
    log.info("Cancel wizard");

    String shellText = new DefaultShell().getText();
    new WaitWhile(new JobIsRunning());
    new PushButton("Cancel").click();

    new WaitWhile(new ShellWithTextIsActive(shellText));
    new WaitWhile(new JobIsRunning());
  }
Пример #15
0
  /** Click the finish button in wizard dialog. */
  public void finish() {
    log.info("Finish wizard");

    String shellText = new DefaultShell().getText();
    Button button = new PushButton("Finish");
    new WaitWhile(new JobIsRunning());
    button.click();

    new WaitWhile(new ShellWithTextIsActive(shellText), TimePeriod.LONG);
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
  }
  @Test
  public void testCreateFuseProject() {

    log.info("Create a new Fuse project (" + PROJECT_ARCHETYPE + ")");
    ProjectFactory.createProject(PROJECT_ARCHETYPE);
    try {
      new ProjectExplorer().getProject(PROJECT_NAME);
    } catch (EclipseLayerException ex) {
      fail("Created project is not present in Project Explorer");
    }
  }
Пример #17
0
 private static org.eclipse.swt.widgets.TreeItem findTreeItem(
     ReferencedComposite referencedComposite, int treeIndex, String... treeItemPath) {
   org.eclipse.swt.widgets.TreeItem result = null;
   Tree tree = new DefaultTree(referencedComposite, treeIndex);
   new WaitUntil(new TreeHasChildren(tree));
   List<TreeItem> items = tree.getItems();
   int index = 0;
   while (index < treeItemPath.length) {
     String pathItem = treeItemPath[index];
     logger.debug("Searching for tree item with label: " + pathItem);
     TreeItem tiItem = null;
     boolean isFound = false;
     Iterator<TreeItem> itTreeItem = items.iterator();
     while (itTreeItem.hasNext() && (!isFound)) {
       tiItem = itTreeItem.next();
       if (tiItem.getText().equals(pathItem)) {
         isFound = true;
       }
     }
     if (isFound) {
       // It's not last item of Tree Item Path
       if (index < (treeItemPath.length - 1)) {
         new WaitUntil(new TreeItemHasMinChildren(tiItem, 1), TimePeriod.NORMAL, false);
         items = tiItem.getItems();
       } else {
         result = tiItem.getSWTWidget();
       }
     } else {
       SWTLayerException exception = new SWTLayerException("No matching tree item found");
       exception.addMessageDetail("Tree Index: " + treeIndex);
       StringBuffer sbPath = new StringBuffer("");
       for (String treeItem : treeItemPath) {
         if (sbPath.length() > 0) {
           sbPath.append(" > ");
         }
         sbPath.append(treeItem);
       }
       exception.addMessageDetail("Tree Item Path: " + sbPath.toString());
       exception.addMessageDetail("Unalbe to find path item with text: " + pathItem);
       exception.addMessageDetail(
           "These Tree Items have been found at level where path item "
               + pathItem
               + " was expected:");
       for (TreeItem treeItem : items) {
         exception.addMessageDetail("  " + treeItem.getText());
       }
       throw exception;
     }
     index++;
   }
   return result;
 }
Пример #18
0
  /** Default Constructor for a WorkbenchShell */
  public WorkbenchShell() {

    Display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            swtShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            WidgetHandler.getInstance().setFocus(swtShell);
          }
        });

    log.info("Workbench shell has title '" + getText() + "'");
  }
Пример #19
0
  public void delete(boolean stopFirst) {
    final String name = getLabel().getName();
    log.info("Deleting server " + name + ". Stopping server first: " + stopFirst);
    select();
    ServerState state = getLabel().getState();

    new ContextMenu("Delete").select();
    new WaitUntil(new ShellWithTextIsActive("Delete Server"), TimePeriod.NORMAL);
    if (!ServerState.STOPPED.equals(state) && !ServerState.NONE.equals(state)) {
      new CheckBox().toggle(stopFirst);
    }
    new PushButton("OK").click();
    new WaitWhile(new ServerExists(name), TIMEOUT);
    new WaitWhile(new JobIsRunning(), TIMEOUT);
  }
Пример #20
0
 private static org.eclipse.swt.widgets.TreeItem findTreeItem(
     ReferencedComposite referencedComposite, int treeIndex, int treeItemIndex) {
   Tree tree = new DefaultTree(referencedComposite, treeIndex);
   new WaitUntil(new TreeHasChildren(tree));
   logger.debug("Searching for tree item with index: " + treeIndex);
   List<TreeItem> items = tree.getItems();
   if (items.size() < treeItemIndex + 1) {
     SWTLayerException exception = new SWTLayerException("No matching tree item found");
     exception.addMessageDetail("Tree Index: " + treeIndex);
     exception.addMessageDetail("Tree Item Index: " + treeItemIndex);
     exception.addMessageDetail("Tree has these " + items.size() + " Tree Items:");
     for (TreeItem treeItem : items) {
       exception.addMessageDetail("  " + treeItem.getText());
     }
     throw exception;
   } else {
     return tree.getItems().get(treeItemIndex).getSWTWidget();
   }
 }
/** @author apodhrad */
@CleanWorkspace
@OpenPerspective(JavaEEPerspective.class)
@RunWith(RedDeerSuite.class)
public class NewESBFileTest {

  public static final String PROJECT_NAME = "esb-file";
  public static final String ESB_FILE = "jboss-esb.xml";
  public static final String NAME_SUFFIX = "-name";

  public Logger log = Logger.getLogger(NewESBFileTest.class);

  @BeforeClass
  public static void createProject() {
    new WorkbenchShell().maximize();
  }

  @After
  public void deleteProject() {
    new ProjectExplorer().getProject(PROJECT_NAME).delete(true);
    ProjectExplorer projectExplorer = new ProjectExplorer();
    projectExplorer.open();
    for (Project project : projectExplorer.getProjects()) {
      project.delete(true);
    }
  }

  @Test
  public void createEsbFileTest() {
    new ESBProjectWizard().openWizard().setName(PROJECT_NAME).finish();

    new ProjectExplorer().getProject(PROJECT_NAME).select();
    new ESBFileWizard().openWizard().setName("another-esb-config").finish();

    ProblemsView problemsView = new ProblemsView();
    problemsView.open();
    assertTrue("ESB Editor opened problems", problemsView.getAllErrors().isEmpty());
  }
}
Пример #22
0
public class AbstractTableItem implements TableItem {
  protected final Logger log = Logger.getLogger(this.getClass());
  protected org.eclipse.swt.widgets.TableItem tableItem;

  protected AbstractTableItem(org.eclipse.swt.widgets.TableItem swtTableItem) {
    if (swtTableItem != null) {
      this.tableItem = swtTableItem;
    } else {
      throw new SWTLayerException("SWT Table item passed to constructor is null");
    }
  }

  /** See {@link TreeItem} */
  @Override
  public void setChecked(final boolean check) {
    log.info((check ? "Check" : "Uncheck") + "Table Item " + getText() + ":");
    WidgetHandler.getInstance().setChecked(tableItem, check);
  }

  @Override
  public boolean isChecked() {
    return WidgetHandler.getInstance().isChecked(tableItem);
  }

  @Override
  public String getText() {
    return WidgetHandler.getInstance().getText(tableItem);
  }

  @Override
  public String getText(int cellIndex) {
    return WidgetHandler.getInstance().getText(tableItem, cellIndex);
  }

  @Override
  public boolean isSelected() {
    return WidgetHandler.getInstance().isSelected(tableItem);
  }

  @Override
  public void select() {
    WidgetHandler.getInstance().select(tableItem);
  }

  @Override
  public boolean isGrayed() {
    return TableHandler.getInstance().isGrayed(tableItem);
  }

  @Override
  public Image getImage(int imageIndex) {
    return TableHandler.getInstance().getItemImage(tableItem, imageIndex);
  }

  @Override
  public Table getParent() {
    return (Table) WidgetHandler.getInstance().getParent(tableItem);
  }

  @Override
  public void doubleClick() {
    TableHandler.getInstance().doubleClick(tableItem, 0);
  }

  @Override
  public void doubleClick(int column) {
    TableHandler.getInstance().doubleClick(tableItem, column);
  }

  @Override
  public org.eclipse.swt.widgets.TableItem getSWTWidget() {
    return tableItem;
  }
}
Пример #23
0
 /** Click the back button in wizard dialog. */
 public void back() {
   log.info("Go to previous wizard page");
   Button button = new PushButton("< Back");
   button.click();
   currentPage--;
 }
Пример #24
0
/**
 * A dialog where are wizard pages displayed. It can operate Next, Back, Cancel and Finish buttons.
 *
 * @author Lucia Jelinkova
 * @author apodhrad
 * @since 0.5
 */
public class WizardDialog {

  protected final Logger log = Logger.getLogger(this.getClass());

  protected int currentPage;
  protected Properties properties;
  protected Map<WizardPage, Matcher<WizardDialog>> wizardPageMap;

  public WizardDialog() {
    properties = new Properties();
    wizardPageMap = new HashMap<WizardPage, Matcher<WizardDialog>>();
  }

  public void setProperty(Object key, Object value) {
    properties.put(key, value);
  }

  public Object getProperty(Object key) {
    return properties.get(key);
  }

  /**
   * Returns the first wizard page
   *
   * @return first wizard page
   * @deprecated Use getWizardPage
   * @see issue#359
   */
  public WizardPage getFirstPage() {
    return getWizardPage();
  }

  /**
   * Returns a current wizard page
   *
   * @return current wizard page or null when there is not any wizard page
   */
  public WizardPage getCurrentWizardPage() {
    for (WizardPage wizardPage : wizardPageMap.keySet()) {
      Matcher<WizardDialog> matcher = wizardPageMap.get(wizardPage);
      if (matcher.matches(this)) {
        return wizardPage;
      }
    }
    log.warn("No wizard page found in page index '" + currentPage + "'");
    return null;
  }

  /**
   * Returns a current wizard page
   *
   * @return current wizard page
   * @deprecated use getCurrentWizardPage() instead
   */
  public WizardPage getWizardPage() {
    for (WizardPage wizardPage : wizardPageMap.keySet()) {
      Matcher<WizardDialog> matcher = wizardPageMap.get(wizardPage);
      if (matcher.matches(this)) {
        return wizardPage;
      }
    }
    log.warn("No wizard page found in page index '" + currentPage + "'");
    return null;
  }

  /**
   * Automatically lists to desired wizard page and returns it.
   *
   * @param page index of desired wizard page
   * @return instance of desired WizardPage
   */
  public WizardPage getWizardPage(int pageIndex) {
    selectPage(pageIndex);
    return getCurrentWizardPage();
  }

  /**
   * Adds a new wizard page
   *
   * @param page wizard page
   * @param pageIndex wizard page index
   */
  public void addWizardPage(WizardPage page, int pageIndex) {
    page.setWizardDialog(this);
    wizardPageMap.put(page, new WizardPageIndex(pageIndex));
  }

  /**
   * Adds a new wizard page
   *
   * @param page wizard page
   * @param pageIndex wizard page index
   * @param matcher matcher when the wizard page will be displayed
   */
  public void addWizardPage(WizardPage page, int pageIndex, Matcher<WizardDialog> matcher) {
    page.setWizardDialog(this);
    wizardPageMap.put(page, allOf(new WizardPageIndex(pageIndex), matcher));
  }

  /** Click the finish button in wizard dialog. */
  public void finish() {
    log.info("Finish wizard");

    String shellText = new DefaultShell().getText();
    Button button = new PushButton("Finish");
    new WaitWhile(new JobIsRunning());
    button.click();

    new WaitWhile(new ShellWithTextIsActive(shellText), TimePeriod.LONG);
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
  }

  /** Click the cancel button in wizard dialog. */
  public void cancel() {
    log.info("Cancel wizard");

    String shellText = new DefaultShell().getText();
    new WaitWhile(new JobIsRunning());
    new PushButton("Cancel").click();

    new WaitWhile(new ShellWithTextIsActive(shellText));
    new WaitWhile(new JobIsRunning());
  }

  /** Click the next button in wizard dialog. */
  public void next() {
    log.info("Go to next wizard page");

    Button button = new PushButton("Next >");
    button.click();
    currentPage++;
  }

  /** Click the back button in wizard dialog. */
  public void back() {
    log.info("Go to previous wizard page");
    Button button = new PushButton("< Back");
    button.click();
    currentPage--;
  }

  /**
   * Go to the specific page of wizard dialog. First wizard dialog page has index 0.
   *
   * @param pageIndex of desired wizard page
   */
  public void selectPage(int pageIndex) {
    if (pageIndex != currentPage) {
      boolean goBack = pageIndex < currentPage;
      while (pageIndex != currentPage) {
        if (goBack) {
          back();
        } else {
          next();
        }
      }
    }
  }

  /**
   * Get page index of current wizard page.
   *
   * @return current wizard page index
   */
  public int getPageIndex() {
    return currentPage;
  }
}
Пример #25
0
/**
 * Represents a server on {@link ServersView}. Contains both, the server data (name, state, status)
 * and operations that can be invoked on server (Start, Stop, Delete etc.). For operations that can
 * be invoked on project added to server see {@link ServerModule}
 *
 * @author Lucia Jelinkova
 */
public class Server {

  private static final TimePeriod TIMEOUT = TimePeriod.VERY_LONG;

  private static final String ADD_AND_REMOVE = "Add and Remove...";

  private static final Logger log = Logger.getLogger(Server.class);

  protected TreeItem treeItem;

  public Server(TreeItem treeItem) {
    this.treeItem = treeItem;
  }

  public ServerLabel getLabel() {
    return new ServerLabel(treeItem);
  }

  public List<ServerModule> getModules() {
    final List<ServerModule> modules = new ArrayList<ServerModule>();

    Display.syncExec(
        new Runnable() {

          @Override
          public void run() {
            for (TreeItem item : treeItem.getItems()) {
              org.eclipse.swt.widgets.TreeItem swtItem = item.getSWTWidget();
              Object data = swtItem.getData();
              if (data instanceof IModule || data instanceof IServerModule) {
                modules.add(createServerModule(item));
              }
            }
          }
        });

    return modules;
  }

  public ServerModule getModule(String name) {
    for (ServerModule module : getModules()) {
      if (module.getLabel().getName().equals(name)) {
        return module;
      }
    }
    throw new EclipseLayerException(
        "There is no module with name " + name + " on server " + getLabel().getName());
  }

  public ModifyModulesDialog addAndRemoveModules() {
    select();
    new ContextMenu(ADD_AND_REMOVE).select();
    return new ModifyModulesDialog();
  }

  public ServerEditor open() {
    select();
    new ContextMenu("Open").select();
    return createServerEditor(getLabel().getName());
  }

  public void start() {
    log.info("Starting server " + getLabel().getName());
    if (!ServerState.STOPPED.equals(getLabel().getState())) {
      throw new ServersViewException("Cannot start server because it is not stopped");
    }
    operateServerState("Start", ServerState.STARTED);
  }

  public void debug() {
    log.info("Starting server in debug" + getLabel().getName());
    if (!ServerState.STOPPED.equals(getLabel().getState())) {
      throw new ServersViewException("Cannot debug server because it is not stopped");
    }
    operateServerState("Debug", ServerState.DEBUGGING);
  }

  public void profile() {
    log.info("Starting server in profiling mode" + getLabel().getName());
    if (!ServerState.STOPPED.equals(getLabel().getState())) {
      throw new ServersViewException("Cannot profile server because it is not stopped");
    }
    operateServerState("Profile", ServerState.PROFILING);
  }

  public void restart() {
    log.info("Restarting server " + getLabel().getName());
    if (!getLabel().getState().isRunningState()) {
      throw new ServersViewException("Cannot restart server because it is not running");
    }
    operateServerState("Restart", ServerState.STARTED);
  }

  public void restartInDebug() {
    log.info("Restarting server in debug" + getLabel().getName());
    if (!getLabel().getState().isRunningState()) {
      throw new ServersViewException("Cannot restart server in debug because it is not running");
    }
    operateServerState("Restart in Debug", ServerState.DEBUGGING);
  }

  public void restartInProfile() {
    log.info("Restarting server in profile" + getLabel().getName());
    if (!getLabel().getState().isRunningState()) {
      throw new ServersViewException("Cannot restart server in profile because it is not running");
    }
    operateServerState("Restart in Profile", ServerState.PROFILING);
  }

  public void stop() {
    log.info("Stopping server " + getLabel().getName());
    ServerState state = getLabel().getState();
    if (!ServerState.STARTING.equals(state) && !state.isRunningState()) {
      throw new ServersViewException("Cannot stop server because it not running");
    }
    operateServerState("Stop", ServerState.STOPPED);
  }

  public void publish() {
    log.info("Publishing server " + getLabel().getName());
    select();
    new ContextMenu("Publish").select();
    waitForPublish();
  }

  public void clean() {
    log.info("Cleaning server " + getLabel().getName());
    select();
    new ContextMenu("Clean...").select();
    new DefaultShell("Server");
    new PushButton("OK").click();
    waitForPublish();
  }

  public void delete() {
    delete(false);
  }

  public void delete(boolean stopFirst) {
    final String name = getLabel().getName();
    log.info("Deleting server " + name + ". Stopping server first: " + stopFirst);
    select();
    ServerState state = getLabel().getState();

    new ContextMenu("Delete").select();
    new WaitUntil(new ShellWithTextIsActive("Delete Server"), TimePeriod.NORMAL);
    if (!ServerState.STOPPED.equals(state) && !ServerState.NONE.equals(state)) {
      new CheckBox().toggle(stopFirst);
    }
    new PushButton("OK").click();
    new WaitWhile(new ServerExists(name), TIMEOUT);
    new WaitWhile(new JobIsRunning(), TIMEOUT);
  }

  protected void select() {
    treeItem.select();
  }

  protected void operateServerState(String menuItem, ServerState resultState) {
    select();
    new ContextMenu(menuItem).select();
    new WaitUntil(new JobIsRunning(), TIMEOUT);
    new WaitUntil(new ServerStateCondition(resultState), TIMEOUT);
    new WaitWhile(new JobIsRunning(), TIMEOUT);

    // check if the server has expected state after jobs are done
    new WaitUntil(new ServerStateCondition(resultState), TIMEOUT);
  }

  protected void waitForPublish() {
    new WaitUntil(new JobIsRunning(), TIMEOUT);
    new WaitWhile(new ServerPublishStateCondition(ServerPublishState.PUBLISHING), TIMEOUT);
    new WaitUntil(new ServerPublishStateCondition(ServerPublishState.SYNCHRONIZED), TIMEOUT);
  }

  protected ServerModule createServerModule(TreeItem item) {
    return new ServerModule(item);
  }

  protected ServerEditor createServerEditor(String title) {
    return new ServerEditor(title);
  }

  private class ServerStateCondition implements WaitCondition {

    private ServerState expectedState;

    private ServerStateCondition(ServerState expectedState) {
      this.expectedState = expectedState;
    }

    @Override
    public boolean test() {
      return expectedState.equals(getLabel().getState());
    }

    @Override
    public String description() {
      return "server's state is: " + expectedState.getText();
    }
  }

  private class ServerPublishStateCondition implements WaitCondition {

    private ServerPublishState expectedState;

    private ServerPublishStateCondition(ServerPublishState expectedState) {
      this.expectedState = expectedState;
    }

    @Override
    public boolean test() {
      return expectedState.equals(getLabel().getPublishState());
    }

    @Override
    public String description() {
      return "server's publish state is " + expectedState.getText();
    }
  }
}
Пример #26
0
/**
 * Default tree item implementation
 *
 * @author jjankovi
 */
public class DefaultTreeItem extends AbstractTreeItem {

  protected static final Logger logger = Logger.getLogger(DefaultTreeItem.class);

  /** Default parameter-less constructor */
  public DefaultTreeItem() {
    this(null, 0);
  }

  /**
   * TreeItem inside given composite
   *
   * @param
   */
  public DefaultTreeItem(ReferencedComposite referencedComposite) {
    this(referencedComposite, 0);
  }

  /**
   * Tree item with specified path will be constructed
   *
   * @param treeItemPath
   */
  public DefaultTreeItem(String... treeItemPath) {
    this(null, 0, treeItemPath);
  }

  /**
   * Tree item with specified path inside given composite will be constructed
   *
   * @param referencedComposite
   * @param treeItemPath
   */
  public DefaultTreeItem(ReferencedComposite referencedComposite, String... treeItemPath) {
    this(referencedComposite, 0, treeItemPath);
  }

  /**
   * Tree item with specified tree index and path will be constructed
   *
   * @param treeIndex
   * @param treeItemPath
   */
  public DefaultTreeItem(int treeIndex, String... treeItemPath) {
    super(findTreeItem(null, treeIndex, treeItemPath));
  }

  /**
   * Tree item with specified tree index and path inside given composite will be constructed
   *
   * @param referencedComposite
   * @param treeIndex
   * @param treeItemPath
   */
  public DefaultTreeItem(
      ReferencedComposite referencedComposite, int treeIndex, String... treeItemPath) {
    super(findTreeItem(referencedComposite, treeIndex, treeItemPath));
  }

  /**
   * Tree item with specified tree item index will be constructed
   *
   * @param treeItemIndex
   */
  public DefaultTreeItem(int treeItemIndex) {
    this(null, 0, treeItemIndex);
  }

  /**
   * Tree item with specified tree item index inside given composite will be constructed
   *
   * @param referencedComposite
   * @param treeItemIndex
   */
  public DefaultTreeItem(ReferencedComposite referencedComposite, int treeItemIndex) {
    this(referencedComposite, 0, treeItemIndex);
  }

  /**
   * Tree item with specified tree and tree item index will be constructed
   *
   * @param treeIndex
   * @param treeItemIndex
   */
  public DefaultTreeItem(int treeIndex, int treeItemIndex) {
    super(findTreeItem(null, treeIndex, treeItemIndex));
  }

  /**
   * Tree item with specified tree and tree item index inside given composite will be constructed
   *
   * @param referencedComposite
   * @param treeIndex
   * @param treeItemIndex
   */
  public DefaultTreeItem(
      ReferencedComposite referencedComposite, int treeIndex, int treeItemIndex) {
    super(findTreeItem(referencedComposite, treeIndex, treeItemIndex));
  }

  /** Return swt widget of Tree Item */
  public org.eclipse.swt.widgets.TreeItem getSWTWidget() {
    return swtTreeItem;
  }

  private static org.eclipse.swt.widgets.TreeItem findTreeItem(
      ReferencedComposite referencedComposite, int treeIndex, int treeItemIndex) {
    Tree tree = new DefaultTree(referencedComposite, treeIndex);
    new WaitUntil(new TreeHasChildren(tree));
    logger.debug("Searching for tree item with index: " + treeIndex);
    List<TreeItem> items = tree.getItems();
    if (items.size() < treeItemIndex + 1) {
      SWTLayerException exception = new SWTLayerException("No matching tree item found");
      exception.addMessageDetail("Tree Index: " + treeIndex);
      exception.addMessageDetail("Tree Item Index: " + treeItemIndex);
      exception.addMessageDetail("Tree has these " + items.size() + " Tree Items:");
      for (TreeItem treeItem : items) {
        exception.addMessageDetail("  " + treeItem.getText());
      }
      throw exception;
    } else {
      return tree.getItems().get(treeItemIndex).getSWTWidget();
    }
  }

  private static org.eclipse.swt.widgets.TreeItem findTreeItem(
      ReferencedComposite referencedComposite, int treeIndex, String... treeItemPath) {
    org.eclipse.swt.widgets.TreeItem result = null;
    Tree tree = new DefaultTree(referencedComposite, treeIndex);
    new WaitUntil(new TreeHasChildren(tree));
    List<TreeItem> items = tree.getItems();
    int index = 0;
    while (index < treeItemPath.length) {
      String pathItem = treeItemPath[index];
      logger.debug("Searching for tree item with label: " + pathItem);
      TreeItem tiItem = null;
      boolean isFound = false;
      Iterator<TreeItem> itTreeItem = items.iterator();
      while (itTreeItem.hasNext() && (!isFound)) {
        tiItem = itTreeItem.next();
        if (tiItem.getText().equals(pathItem)) {
          isFound = true;
        }
      }
      if (isFound) {
        // It's not last item of Tree Item Path
        if (index < (treeItemPath.length - 1)) {
          new WaitUntil(new TreeItemHasMinChildren(tiItem, 1), TimePeriod.NORMAL, false);
          items = tiItem.getItems();
        } else {
          result = tiItem.getSWTWidget();
        }
      } else {
        SWTLayerException exception = new SWTLayerException("No matching tree item found");
        exception.addMessageDetail("Tree Index: " + treeIndex);
        StringBuffer sbPath = new StringBuffer("");
        for (String treeItem : treeItemPath) {
          if (sbPath.length() > 0) {
            sbPath.append(" > ");
          }
          sbPath.append(treeItem);
        }
        exception.addMessageDetail("Tree Item Path: " + sbPath.toString());
        exception.addMessageDetail("Unalbe to find path item with text: " + pathItem);
        exception.addMessageDetail(
            "These Tree Items have been found at level where path item "
                + pathItem
                + " was expected:");
        for (TreeItem treeItem : items) {
          exception.addMessageDetail("  " + treeItem.getText());
        }
        throw exception;
      }
      index++;
    }
    return result;
  }
}
Пример #27
0
 public void publish() {
   log.info("Publishing server " + getLabel().getName());
   select();
   new ContextMenu("Publish").select();
   waitForPublish();
 }
Пример #28
0
 /** See {@link TreeItem} */
 @Override
 public void setChecked(final boolean check) {
   log.info((check ? "Check" : "Uncheck") + "Table Item " + getText() + ":");
   WidgetHandler.getInstance().setChecked(tableItem, check);
 }