-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: removed used of some deprecated API, generalized server tes…
…ts setup/teardown
- Loading branch information
Showing
14 changed files
with
452 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
server/src/test/java/com/orientechnologies/orient/server/BaseMemoryInternalDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.orientechnologies.orient.server; | ||
|
||
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; | ||
import com.orientechnologies.orient.core.db.OrientDB; | ||
import com.orientechnologies.orient.core.db.OrientDBConfig; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.rules.TestName; | ||
|
||
public class BaseMemoryInternalDatabase { | ||
|
||
protected ODatabaseDocumentInternal db; | ||
protected OrientDB context; | ||
@Rule public TestName name = new TestName(); | ||
|
||
@Before | ||
public void beforeTest() { | ||
context = new OrientDB("embedded:", OrientDBConfig.defaultConfig()); | ||
context | ||
.execute( | ||
"create database " | ||
+ name.getMethodName() | ||
+ " memory users(admin identified by 'adminpwd' role admin) ") | ||
.close(); | ||
db = (ODatabaseDocumentInternal) context.open(name.getMethodName(), "admin", "adminpwd"); | ||
} | ||
|
||
@After | ||
public void afterTest() { | ||
db.close(); | ||
context.drop(name.getMethodName()); | ||
context.close(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
server/src/test/java/com/orientechnologies/orient/server/BaseServerMemoryDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.orientechnologies.orient.server; | ||
|
||
import com.orientechnologies.common.io.OFileUtils; | ||
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; | ||
import com.orientechnologies.orient.core.db.OrientDB; | ||
import com.orientechnologies.orient.core.db.OrientDBConfig; | ||
import java.io.File; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.rules.TestName; | ||
|
||
public class BaseServerMemoryDatabase { | ||
|
||
protected ODatabaseDocumentInternal db; | ||
protected OrientDB context; | ||
@Rule public TestName name = new TestName(); | ||
protected OServer server; | ||
|
||
@Before | ||
public void beforeTest() { | ||
server = new OServer(false); | ||
try { | ||
server.startup(getClass().getResourceAsStream("orientdb-server-config.xml")); | ||
server.activate(); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
context = new OrientDB("remote:localhost", "root", "root", OrientDBConfig.defaultConfig()); | ||
context | ||
.execute( | ||
"create database " | ||
+ name.getMethodName() | ||
+ " memory users(admin identified by 'adminpwd' role admin) ") | ||
.close(); | ||
db = (ODatabaseDocumentInternal) context.open(name.getMethodName(), "admin", "adminpwd"); | ||
} | ||
|
||
@After | ||
public void afterTest() { | ||
db.close(); | ||
context.drop(name.getMethodName()); | ||
context.close(); | ||
String directory = server.getDatabaseDirectory(); | ||
server.shutdown(); | ||
OFileUtils.deleteRecursively(new File(directory)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.