ch.vorburger.exec.ManagedProcessException Java Examples

The following examples show how to use ch.vorburger.exec.ManagedProcessException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractEmbeddedDataSourceHelper.java    From freeacs with MIT License 8 votes vote down vote up
public static void setUpBeforeClass() throws ManagedProcessException {
    randomFolder = "./db/" + UUID.randomUUID();
    DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder();
    configBuilder.setPort(3307);
    configBuilder.setDataDir(randomFolder);
    db = DB.newEmbeddedDB(configBuilder.build());
    db.start();
    db.createDB("acs", "acs", "acs");
    db.source("install.sql", "acs", "acs", "acs");
    String url = configBuilder.getURL("acs");
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDataSourceClassName("org.mariadb.jdbc.MariaDbDataSource");
    hikariConfig.addDataSourceProperty("url", url);
    hikariConfig.addDataSourceProperty("user", "acs");
    hikariConfig.addDataSourceProperty("password", "acs");
    dataSource = new HikariDataSource(hikariConfig);
}
 
Example #2
Source File: MySQLTestCore.java    From rmlmapper-java with MIT License 6 votes vote down vote up
protected static void stopDBs(DB mysqlDB) throws ManagedProcessException {
    if (mysqlDB != null) {
        mysqlDB.stop();
    }

    // Make sure all tempFiles are removed
    int counter = 0;
    while (!tempFiles.isEmpty()) {
        for (Iterator<String> i = tempFiles.iterator(); i.hasNext(); ) {
            try {
                if (new File(i.next()).delete()) {
                    i.remove();
                }
            } catch (Exception ex) {
                counter++;
                ex.printStackTrace();
                // Prevent infinity loops
                if (counter > 100) {
                    throw new Error("Could not remove all temp mapping files.");
                }
            }
        }
    }
}
 
Example #3
Source File: BaseDBITest.java    From freeacs with MIT License 5 votes vote down vote up
@Before
public void init() throws SQLException, ManagedProcessException {
  AbstractEmbeddedDataSourceHelper.setUpBeforeClass();
  Users users = new Users(dataSource);
  User admin = users.getUnprotected("admin");
  Identity identity = new Identity(SyslogConstants.EVENT_DEFAULT, "test", admin);
  syslog = new Syslog(dataSource, identity);
  acs = new ACS(dataSource, syslog);
}
 
Example #4
Source File: MariaDBHook.java    From pandaria with MIT License 5 votes vote down vote up
@Before("@multi_db")
public void start() throws ManagedProcessException {
    foo = foo();
    bar = bar();

    foo.start();
    bar.start();

    foo.getDB().createDB("pandaria");
    bar.getDB().createDB("pandaria");
}
 
Example #5
Source File: DatabaseRule.java    From CodeDefenders with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void after() {
    try {
        db.stop();
    } catch (ManagedProcessException e) {
        // quiet
    }
}
 
Example #6
Source File: App.java    From hawkular-apm with Apache License 2.0 5 votes vote down vote up
private DB createDatabase() throws ManagedProcessException {

        DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder();
        configBuilder.setPort(3306);
        configBuilder.setDataDir("target/mariaDB");
        configBuilder.setBaseDir("target/mariaDB");
        DB database = DB.newEmbeddedDB(configBuilder.build());
        database.start();

        return database;
    }
 
Example #7
Source File: TestDatabase.java    From BungeeChat2 with GNU General Public License v3.0 5 votes vote down vote up
@SneakyThrows({ManagedProcessException.class})
public static void stopDatabase() {
  databaseInstance.stop();

  try {
    Thread.sleep(500);

    FileUtils.deleteDirectory(new File(databaseInstance.getConfiguration().getBaseDir()));
  } catch (IOException | InterruptedException e) {
    // Ignore
  }
}
 
Example #8
Source File: MariaDBHook.java    From pandaria with MIT License 5 votes vote down vote up
private MariaDB4jService mariaDb(String name, int port) throws ManagedProcessException {
    MariaDB4jService db = new MariaDB4jService();
    db.getConfiguration().setPort(port);
    db.getConfiguration().setDataDir(String.format("%s/%s/data", JAVA_IO_TMPDIR, name));
    db.getConfiguration().setBaseDir(String.format("%s/%s/base", JAVA_IO_TMPDIR, name));
    db.getConfiguration().addArg("--user=root");
    return db;
}
 
Example #9
Source File: TestDatabase.java    From BungeeChat2 with GNU General Public License v3.0 5 votes vote down vote up
@SneakyThrows(ManagedProcessException.class)
@SuppressFBWarnings( // TODO: Remove when fixed in SpotBugs
    value = "RV_RETURN_VALUE_IGNORED",
    justification = "Return values can be safely ignored as they are for chaining only.")
public static void startDatabase() {
  final int limit = 100;
  int count = 0;
  String actualBaseDir;
  String actualDataDir;

  do {
    actualBaseDir = baseDir + count;
  } while ((++count < limit) && (new File(actualBaseDir)).exists());

  Preconditions.checkElementIndex(count, limit, "count must be less than " + limit);

  actualDataDir = actualBaseDir + "/data";
  final DBConfiguration config =
      DBConfigurationBuilder.newBuilder()
          .setPort(0)
          .setSocket(localhost)
          .setBaseDir(actualBaseDir)
          .setDataDir(actualDataDir)
          .build();
  databaseInstance = DB.newEmbeddedDB(config);
  databaseInstance.start();

  port = databaseInstance.getConfiguration().getPort();
  host = localhost + ':' + port;

  databaseInstance.createDB("test");
}
 
Example #10
Source File: MySQLTestCore.java    From rmlmapper-java with MIT License 5 votes vote down vote up
protected static DB setUpMySQLDBInstance(int portNumber) throws ManagedProcessException {
    DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder();
    configBuilder.setPort(portNumber);
    configBuilder.addArg("--user=root");
    configBuilder.addArg("--sql-mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES");
    DB mysqlDB = DB.newEmbeddedDB(configBuilder.build());
    mysqlDB.start();

    return mysqlDB;
}
 
Example #11
Source File: MariaDB_IT_Base.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private static DB testDBStop() throws ManagedProcessException {
    if (TEST_DATABASE != null) {
        TEST_DATABASE.stop();
    }
    return null;
}
 
Example #12
Source File: Mapper_MySQL_Test.java    From rmlmapper-java with MIT License 4 votes vote down vote up
@AfterClass
public static void after() throws ManagedProcessException {
    stopDBs(mysqlDB);
}
 
Example #13
Source File: Arguments_Test_MySQL.java    From rmlmapper-java with MIT License 4 votes vote down vote up
@AfterClass
public static void after() throws ManagedProcessException {
    stopDBs(mysqlDB);
}
 
Example #14
Source File: MariaDBHook.java    From pandaria with MIT License 4 votes vote down vote up
private MariaDB4jService bar() throws ManagedProcessException {
    return mariaDb("bar", 3318);
}
 
Example #15
Source File: MariaDBHook.java    From pandaria with MIT License 4 votes vote down vote up
private MariaDB4jService foo() throws ManagedProcessException {
    return mariaDb("foo", 3317);
}
 
Example #16
Source File: MariaDBHook.java    From pandaria with MIT License 4 votes vote down vote up
@After("@multi_db")
public void stop() throws ManagedProcessException {
    foo.stop();
    bar.stop();
}
 
Example #17
Source File: AbstractEmbeddedDataSourceClassTest.java    From freeacs with MIT License 4 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws ManagedProcessException {
    AbstractEmbeddedDataSourceHelper.setUpBeforeClass();
}