move DistributedDatabaseImportIT to new setup
package com.orientechnologies.orient.server.distributed;
-import static org.junit.Assert.assertTrue;
-
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseSession;
import com.orientechnologies.orient.core.db.ODatabaseType;
@@ -9,29 +7,38 @@ import com.orientechnologies.orient.core.db.OrientDB;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.db.tool.ODatabaseExport;
import com.orientechnologies.orient.core.db.tool.ODatabaseImport;
-import com.orientechnologies.orient.server.OServer;
-import java.io.File;
-import java.io.IOException;
+import com.orientechnologies.orient.setup.LocalTestSetup;
+import com.orientechnologies.orient.setup.SetupConfig;
+import com.orientechnologies.orient.setup.configs.SimpleDServerConfig;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.assertTrue;
+
public class DistributedDatabaseImportIT {
- private OServer server0;
- private OServer server1;
- private OServer server2;
+ // Relies on direct access to OServer to import DB and can run only on local setup.
+ private LocalTestSetup setup;
+ private SetupConfig config;
+ private String server0, server1, server2;
@Before
public void before() throws Exception {
- server0 = OServer.startFromClasspathConfig("orientdb-simple-dserver-config-0.xml");
- server1 = OServer.startFromClasspathConfig("orientdb-simple-dserver-config-1.xml");
- server2 = OServer.startFromClasspathConfig("orientdb-simple-dserver-config-2.xml");
+ config = new SimpleDServerConfig();
+ server0 = SimpleDServerConfig.SERVER0;
+ server1 = SimpleDServerConfig.SERVER1;
+ server2 = SimpleDServerConfig.SERVER2;
+ setup = new LocalTestSetup(config);
+ setup.setup();
}
@Test
public void test() throws IOException {
- final OrientDB ctx1 = server0.getContext();
+ final OrientDB ctx1 = setup.getServer(server0).getServerInstance().getContext();
ctx1.create("import-test", ODatabaseType.PLOCAL);
final ODatabaseSession session = ctx1.open("import-test", "admin", "admin");
session.createClass("testa");
@@ -51,7 +58,7 @@ public class DistributedDatabaseImportIT {
imp.close();
session1.close();
- final OrientDB ctx2 = server1.getContext();
+ final OrientDB ctx2 = setup.getServer(server1).getServerInstance().getContext();
final ODatabaseSession session2 = ctx2.open("imported-test", "admin", "admin");
assertTrue(session2.getMetadata().getSchema().existsClass("testa"));
session2.close();
@@ -59,11 +66,9 @@ public class DistributedDatabaseImportIT {
@After
public void after() throws InterruptedException {
- server0.dropDatabase("import-test");
- server0.dropDatabase("imported-test");
- server0.shutdown();
- server1.shutdown();
- server2.shutdown();
+ setup.getServer(server0).getServerInstance().dropDatabase("import-test");
+ setup.getServer(server0).getServerInstance().dropDatabase("imported-test");
+ setup.teardown();
File file = new File("target/export.tar.gz");
if (file.exists()) file.delete();
ODatabaseDocumentTx.closeAll();
