コード例 #1
0
 @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 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);
  }