Beispiel #1
0
 @Test
 public void should_load_database_configuration() throws IOException {
   JpaConfiguration configuration = read(fixture("database.yml"), JpaConfiguration.class);
   assertThat(
       configuration.getDatabase(),
       is(
           database()
               .with(
                   H2.driver,
                   H2.compatible("ORACLE"),
                   H2.privateMemoryDB,
                   Hibernate.dialect("Oracle"))
               .user("sa")
               .password("")
               .migration()
               .auto(false)
               .locations("db/migration")
               .placeholder("user", "real_user")
               .end()
               .build()));
 }
Beispiel #2
0
  private Engine createEngine(
      final DataStoreType database, final String fileName, final int port, final char[] password) {

    Properties properties =
        JpaConfiguration.getClientProperties(database, fileName, "localhost", port, password);

    Logger.getLogger(JpaNetworkServer.class.getName())
        .log(
            Level.INFO,
            "Local connection url is: {0}",
            properties.getProperty(JpaConfiguration.JAVAX_PERSISTENCE_JDBC_URL));

    Engine engine = null;

    try {
      factory = Persistence.createEntityManagerFactory("jgnash", properties);

      em = factory.createEntityManager();

      distributedLockManager = new DistributedLockManager("localhost", port + 2);
      distributedLockManager.connectToServer(password);

      distributedAttachmentManager = new DistributedAttachmentManager("localhost", port + 3);
      distributedAttachmentManager.connectToServer(password);

      Logger.getLogger(JpaNetworkServer.class.getName())
          .info("Created local JPA container and engine");
      engine =
          new Engine(
              new JpaEngineDAO(em, true),
              distributedLockManager,
              distributedAttachmentManager,
              SERVER_ENGINE); // treat as a remote engine
    } catch (final Exception e) {
      Logger.getLogger(JpaNetworkServer.class.getName()).log(Level.SEVERE, e.toString(), e);
    }

    return engine;
  }