package com.orientechnologies.orient.test.server;

import org.testng.annotations.Test;

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.core.db.ODatabase;
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
import com.orientechnologies.orient.server.OServer;
import com.orientechnologies.orient.server.OServerMain;

public class OServerTest {

  /**
   * Test for https://github.com/orientechnologies/orientdb/issues/1667
   */
  @Test
  public void testRestart() throws Exception {
    // set ORIENTDB_HOME
    System.setProperty("ORIENTDB_HOME", System.getProperty("java.io.tmpdir") + "/orientdb");
    OLogManager.instance().info(this, "ORIENTDB_HOME: " + System.getProperty("ORIENTDB_HOME"));

    // loop for start & stop server
    for(int i = 0; i < 5; i++) {
      OLogManager.instance().info(this, "Iteration " + i);
      OServer server = OServerMain.create().startup().activate();
      // create database if does not exist
      ODatabase database = new OObjectDatabaseTx("local:" + System.getProperty("ORIENTDB_HOME") + "/test-db");
      if(!database.exists()) database.create();
      database.close();
      server.shutdown();
    }
  }

}

@@ -989,24 +989,30 @@
 %0A      O
+Object
 Database
  databas
@@ -1003,16 +1003,18 @@
 Database
+Tx
  databas
@@ -1145,24 +1145,99 @@
 e.create();%0A
+      database.open(%22admin%22, %22admin%22);%0A      database.countClass(%22ouser%22);%0A
       databa

Test server restart