@Test
  public void testCreateRevengFile() {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.selectProjects(PROJECT_NAME);

    log.step("Create hibernate reverese engineering via reveng wizard");
    NewReverseEngineeringFileWizard wizard = new NewReverseEngineeringFileWizard();
    wizard.open();
    wizard.next();
    TableFilterWizardPage page = new TableFilterWizardPage();
    page.setConsoleConfiguration(PROJECT_NAME);
    page.refreshDatabaseSchema();
    page.pressInclude();
    log.step("Finish wizard to create a file");
    wizard.finish();

    EditorHandler.getInstance().closeAll(false);
    pe.open();
    new DefaultTreeItem(PROJECT_NAME, "hibernate.reveng.xml").doubleClick();
    new DefaultEditor("Hibernate Reverse Engineering Editor").activate();

    RevengEditor re = new RevengEditor();
    re.activateDesignTab();
    re.activateOverviewTab();
    re.activateSourceTab();
    re.activateTableFiltersTab();
    re.activateTypeMappingsTab();
  }
  @Test
  public void testJPADetailView() {

    log.step("Open entity");
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    try {
      pe.getProject(PRJ)
          .getProjectItem("Java Resources", "src/main/java", "org.gen", "Actor.java")
          .open();
    } catch (RedDeerException e) {
      fail("Entities not generated, possible cause https://issues.jboss.org/browse/JBIDE-19175");
    }
    TextEditor textEditor = new TextEditor("Actor.java");
    textEditor.setCursorPosition(20, 1);

    log.step("Open JPA view and check content");
    JPADetailsView jpaDetailsView = new JPADetailsView();
    jpaDetailsView.open();

    try {
      new DefaultStyledText("Type 'Actor' is mapped as entity.");
    } catch (RedDeerException e) {
      fail(
          "JPA details should be available - known issue - https://issues.jboss.org/browse/JBIDE-17940");
    }
  }
Esempio n. 3
0
 @Test
 public void logTest() {
   log.debug("debug");
   log.error("error");
   log.fatal("fatal");
   log.warn("info");
   log.info("info");
 }
 @Before
 public void testConnectionProfile() {
   log.step("Import test project");
   importMavenProject(PRJ);
   DatabaseConfiguration cfg = dbRequirement.getConfiguration();
   log.step("Create database driver definition");
   DriverDefinitionFactory.createDatabaseDriverDefinition(cfg);
   log.step("Create database connection profile");
   ConnectionProfileFactory.createConnectionProfile(cfg);
   // log.step("Convert project to faceted form");
   // ProjectConfigurationFactory.convertProjectToFacetsForm(PRJ);
   log.step("Set project facet for JPA");
   ProjectConfigurationFactory.setProjectFacetForDB(PRJ, cfg);
 }
 private void clearAllDriverLibraries() {
   if (new DefaultList().getListItems().length > 0) {
     new PushButton("Clear All").click();
   } else {
     log.info("No drivers to clean, skipped");
   }
 }
/**
 * Internal Progress Listener of Browser
 *
 * @author Vlado Pakan
 */
public class BrowserProgressListener implements ProgressListener {
  private final Browser browser;
  private boolean done = true;
  private int numCalledIsDoneWithNoChange = 0;
  private static final Logger log = Logger.getLogger(BrowserProgressListener.class);

  public BrowserProgressListener(Browser browser) {
    this.browser = browser;
  }
  // returns true in case page is loaded completely or
  // there is no change after calling this method more then 20 times
  // because on MS Windows method completed is not called properly
  public synchronized boolean isDone() {
    log.debug("Calling isDone()");
    numCalledIsDoneWithNoChange++;
    return done || numCalledIsDoneWithNoChange > 20;
  }

  public synchronized void setDone(boolean done) {
    this.done = done;
  }

  public synchronized void changed(ProgressEvent event) {
    log.debug("Calling chanded()");
    numCalledIsDoneWithNoChange = 0;
  }

  public void completed(ProgressEvent event) {
    setDone(true);
    browser.getSWTWidget().removeProgressListener(this);
  }
}
  @After
  public void cleanUp() {
    OpenShiftExplorerView explorer = new OpenShiftExplorerView();
    explorer.open();

    OpenShift3Connection connection = null;
    try {
      connection = explorer.getOpenShift3Connection();
    } catch (JFaceLayerException ex) {
      // There is no connection with such username, nothing happens
    }

    if (connection != null) {
      connection.select();
      connection.expand();

      new WaitWhile(new JobIsRunning(), TimePeriod.LONG);

      List<OpenShiftProject> projects = connection.getAllProjects();
      if (!projects.isEmpty()) {
        for (OpenShiftProject project : projects) {
          log.info("Removing OpenShift project");
          project.delete();
          connection.refresh();
        }
      }
    }
  }
Esempio n. 8
0
/**
 * Condition is fulfilled when tree has children.
 *
 * @author Jaroslav Jankovic
 * @author Jiri Peterka
 */
public class TreeHasChildren extends AbstractWaitCondition {
  private Logger log = Logger.getLogger(TreeHasChildren.class);
  private Tree tree;

  /**
   * Construct tree has children condition.
   *
   * @param tree given tree
   */
  public TreeHasChildren(Tree tree) {
    super();
    this.tree = tree;
  }

  @Override
  public boolean test() {
    int count = tree.getItems().size();
    log.trace("Count of found tree items:" + count);
    if (count > 0) {
      return true;
    }
    return false;
  }

  @Override
  public String description() {
    return "tree has children";
  }
}
 @Override
 public void finish() {
   log.info("Finishing '" + title + "' Dialog");
   new OkButton().click();
   new WaitWhile(new ShellWithTextIsActive(title), TimePeriod.NORMAL);
   AbstractWait.sleep(TimePeriod.SHORT);
 }
Esempio n. 10
0
/**
 * Wait condition for shells checking whether some shell is active (empty constructor) or using
 * Shell.equals (parameterized constructor).
 *
 * @author rhopp, [email protected]
 */
public class ShellIsActive extends AbstractWaitCondition {

  private Shell shell;
  private static final Logger log = Logger.getLogger(ShellIsActive.class);

  /**
   * Fulfilled, when active shell is equal to given shell.
   *
   * @param shell Shell to compare to.
   */
  public ShellIsActive(Shell shell) {
    InstanceValidator.checkNotNull(shell, "shell");
    this.shell = shell;
  }

  @Override
  public boolean test() {
    if (shell == null) {
      return ShellLookup.getInstance().getCurrentActiveShell() != null;
    } else {
      org.eclipse.swt.widgets.Shell currentActiveShell =
          ShellLookup.getInstance().getCurrentActiveShell();
      if (currentActiveShell == null) {
        log.debug("Current active shell is null");
        return false;
      }
      return currentActiveShell.equals(shell.getSWTWidget());
    }
  }

  @Override
  public String description() {
    return "shell is active";
  }
}
 public CreateDriverDialog setDriverClass(String driverClass) {
   log.info("Set driver class to: '" + driverClass + "'");
   new DefaultTabItem("Properties").activate();
   new DefaultTreeItem(new DefaultTree(0), "General", "Driver Class").doubleClick();
   new DefaultText().setText(driverClass);
   activate();
   return this;
 }
 private void deployProject(String deployableProject, ProjectExplorer explorer) {
   log.info("DEPLOYING " + deployableProject);
   explorer.activate();
   Project project = explorer.getProject(deployableProject);
   project.select();
   new ContextMenu("Run As", "1 Run on Server").select();
   new WizardDialog().finish();
 }
 public CreateDriverDialog setConnectionUrl(String connectionUrl) {
   log.info("Set driver connection url to: '" + connectionUrl + "'");
   new DefaultTabItem("Properties").activate();
   new DefaultTreeItem(new DefaultTree(0), "General", "Connection URL").doubleClick();
   new DefaultText().setText(connectionUrl);
   activate();
   return this;
 }
 public CreateDriverDialog setDatabaseName(String databaseName) {
   log.info("Set driver database name to: '" + databaseName + "'");
   new DefaultTabItem("Properties").activate();
   new DefaultTreeItem(new DefaultTree(0), "General", "Database Name").doubleClick();
   new DefaultText().setText(databaseName);
   activate();
   return this;
 }
/**
 * Tests JPA Details view
 *
 * @author Jiri Peterka
 */
@RunWith(RedDeerSuite.class)
@Database(name = "testdb")
public class JPADetailsViewTest extends HibernateRedDeerTest {

  private final String PRJ = "mvn-hibernate50-ent";
  @InjectRequirement private DatabaseRequirement dbRequirement;

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

  @Before
  public void testConnectionProfile() {
    log.step("Import test project");
    importMavenProject(PRJ);
    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    log.step("Create database driver definition");
    DriverDefinitionFactory.createDatabaseDriverDefinition(cfg);
    log.step("Create database connection profile");
    ConnectionProfileFactory.createConnectionProfile(cfg);
    // log.step("Convert project to faceted form");
    // ProjectConfigurationFactory.convertProjectToFacetsForm(PRJ);
    log.step("Set project facet for JPA");
    ProjectConfigurationFactory.setProjectFacetForDB(PRJ, cfg);
  }

  @After
  public void cleanUp() {
    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    ConnectionProfileFactory.deleteConnectionProfile(cfg.getProfileName());
  }

  @Test
  public void testJPADetailView() {

    log.step("Open entity");
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    try {
      pe.getProject(PRJ)
          .getProjectItem("Java Resources", "src/main/java", "org.gen", "Actor.java")
          .open();
    } catch (RedDeerException e) {
      fail("Entities not generated, possible cause https://issues.jboss.org/browse/JBIDE-19175");
    }
    TextEditor textEditor = new TextEditor("Actor.java");
    textEditor.setCursorPosition(20, 1);

    log.step("Open JPA view and check content");
    JPADetailsView jpaDetailsView = new JPADetailsView();
    jpaDetailsView.open();

    try {
      new DefaultStyledText("Type 'Actor' is mapped as entity.");
    } catch (RedDeerException e) {
      fail(
          "JPA details should be available - known issue - https://issues.jboss.org/browse/JBIDE-17940");
    }
  }
}
Esempio n. 16
0
 @Override
 public boolean test() {
   int count = tree.getItems().size();
   log.trace("Count of found tree items:" + count);
   if (count > 0) {
     return true;
   }
   return false;
 }
Esempio n. 17
0
 public DefaultShell() {
   super(ShellLookup.getInstance().getActiveShell());
   try {
     setFocus();
     log.debug("Active shell with title '" + getText() + "' found");
   } catch (Exception e) {
     throw new SWTLayerException("No active shell is available at the moment", e);
   }
 }
Esempio n. 18
0
 public DefaultShell(String title) {
   super(ShellLookup.getInstance().getShell(title));
   try {
     setFocus();
     log.debug("Shell with title '" + title + "' found");
   } catch (Exception e) {
     throw new SWTLayerException("No shell with title '" + title + "' is available", e);
   }
 }
Esempio n. 19
0
 @Test
 public void menuWithMnemonicTest() {
   log.info("menu with mnemonic test");
   new DefaultShell();
   Menu m = new ShellMenu("File", "New", "Other...");
   m.select();
   Shell s = new DefaultShell("New");
   s.close();
 }
 public CreateDriverDialog addDriver(String path) {
   log.info("Set driver path to: '" + path + "'");
   new DefaultTabItem("JAR List").activate();
   clearAllDriverLibraries();
   addItem(path);
   addItem(path);
   removeDriverLibrary(path);
   return this;
 }
Esempio n. 21
0
 @Test
 public void preferencesMenuTest() {
   log.info("Preferences menu test");
   new DefaultShell();
   Menu m = new ShellMenu("Window", "Preferences");
   m.select();
   Shell s = new DefaultShell("Preferences");
   s.close();
 }
Esempio n. 22
0
 /**
  * Creates a new DefaultShell matching specified matcher. First found shell with specified matcher
  * is created. Beware, there is no strict (deterministic) order of shells.
  *
  * @param matcher matcher to match title of a shell
  */
 public DefaultShell(Matcher<String> matcher) {
   super(ShellLookup.getInstance().getShell(matcher));
   try {
     setFocus();
     log.debug("Shell matching specified matcher is found and focused");
   } catch (Exception e) {
     throw new SWTLayerException(
         "Shell matching specified matcher was not focused successfully.", e);
   }
 }
 public ViewDialog chceckSupportUpdateIsSystemTable(boolean supportTable, boolean isSystemTable) {
   log.info("Setting checkboxes to ");
   new DefaultTabItem("Properties").activate();
   if (!new CheckBox("Supports Update").isChecked() && supportTable) {
     new CheckBox("Supports Update").click();
   }
   if (!new CheckBox("Is System Table").isChecked() && isSystemTable) {
     new CheckBox("Is System Table").click();
   }
   return this;
 }
 public CreateDriverDialog setDriverClassGeneric(String driverClass) {
   log.info("Set driver class to: '" + driverClass + "'");
   new DefaultTabItem("Properties").activate();
   new DefaultTreeItem(new DefaultTree(0), "General", "Driver Class").doubleClick();
   new PushButton("...").click();
   new DefaultShell("Available Classes from Jar List");
   new DefaultText().setText(driverClass);
   new PushButton("OK").click();
   activate();
   return this;
 }
Esempio n. 25
0
 @Test
 public void aboutMenuTest() {
   log.info("About menu test");
   new DefaultShell();
   @SuppressWarnings("unchecked")
   Menu m =
       new ShellMenu(
           new WithMnemonicTextMatcher("Help"), new WithTextMatcher(new RegexMatcher("About.*")));
   m.select();
   Shell s = new DefaultShell();
   s.close();
 }
Esempio n. 26
0
  @Test
  public void regexMenuTest() {

    log.info("regex menu test");
    try {
      RegexMatcher[] regexMatchers = {new RegexMatcher("Win.*"), new RegexMatcher("Pref.*")};
      WithTextMatchers m = new WithTextMatchers(regexMatchers);
      new ShellMenu(m.getMatchers());
    } catch (SWTLayerException e) {
      fail("there should be no exception");
    }
  }
Esempio n. 27
0
  @Test
  public void unavailableMenuTest() {
    log.info("unavailable regex menu test");
    try {
      RegexMatcher[] regexMatchers = {new RegexMatcher("Win.*"), new RegexMatcher("Prefz.*")};
      WithTextMatchers m = new WithTextMatchers(regexMatchers);
      new ShellMenu(m.getMatchers());
      fail("exception should be thrown");
    } catch (SWTLayerException e) { // do nothing

    }
  }
  private void createConfigurationFileFromDatasource(String hbVersion) {
    // Create datasource
    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    log.step("Create database driver definition");
    DriverDefinitionFactory.createDatabaseDriverDefinition(cfg);
    log.step("Create database connection profile");
    ConnectionProfileFactory.createConnectionProfile(cfg);

    log.step("Create Hibernate configuration file");
    NewHibernateConfigurationWizard wizard = new NewHibernateConfigurationWizard();
    wizard.open();

    NewConfigurationLocationPage p1 = new NewConfigurationLocationPage();
    p1.setLocation(PROJECT_NAME, "src");
    wizard.next();

    // Get values from connection
    log.step("Use created database connection profile for database details");
    Link link = new DefaultLink("Get values from Connection");
    link.click();
    new WaitUntil(new ShellWithTextIsActive("Select Connection Profile"));
    new DefaultCombo().setSelection(cfg.getProfileName());
    new OkButton().click();
    new WaitWhile(new ShellWithTextIsActive("Select Connection Profile"));

    new DefaultShell("");

    // Check values
    NewConfigurationSettingPage p2 = new NewConfigurationSettingPage();
    p2.setHibernateVersion(hbVersion);
    assertTrue("jdbc must match", p2.getConnectionURL().equals(cfg.getJdbcString()));
    assertTrue("driver must match", p2.getDriveClass().equals(cfg.getDriverClass()));
    assertTrue("username must match", p2.getUsername().equals(cfg.getUsername()));

    log.step("Finish the wizard");
    wizard.finish();

    checkFile(false);
  }
 public void ok() {
   new PushButton("Apply").click();
   try {
     new DefaultShell("Update project required");
     new PushButton("Yes").click();
     new DefaultShell("Preferences");
   } catch (SWTLayerException ex) {
     log.info("Update project required shell was not found.");
   } finally {
     new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG);
     new WorkbenchPreferenceDialog().ok();
   }
 }
  public void testCreateConfigurationFile(String hbVersion, boolean generateConsole) {

    log.step("Create Hibernate configuration file");
    NewHibernateConfigurationWizard wizard = new NewHibernateConfigurationWizard();
    wizard.open();
    NewConfigurationLocationPage p1 = new NewConfigurationLocationPage();
    p1.setLocation(PROJECT_NAME, "src");
    wizard.next();

    DatabaseConfiguration cfg = dbRequirement.getConfiguration();
    NewConfigurationSettingPage p2 = new NewConfigurationSettingPage();
    p2.setHibernateVersion(hbVersion);
    p2.setConnectionURL(cfg.getJdbcString());
    p2.setUsername(cfg.getUsername());

    if (generateConsole) {
      p2.setCreateConsoleConfiguration(generateConsole);
    }
    log.step("Finish the wizard");
    wizard.finish();

    checkFile(generateConsole);
  }